RSSAmplifier

Karthik Karanth · Feb 29, 2020

Drawing numpy arrays with pygame

0
Sign in to vote or save

This page cannot be shown here. You can still read it on the original site — the toolbar below keeps your place in the directory.

While building GPU accelerated cellular automata, I needed a quick way to dump a numpy array of pixels onto the screen. This is pretty simple to do with pygame’s surfarray API. You run this in the main drawing loop: 
 # Z is a numpy array 
 surf = pygame . surfarray . make_surface ( Z ) 
 self . display . blit ( surf , ( 0 , 0 )) 
 
 pygame . display . update () 
…

Read on /blog/drawing-pixels-with-python/

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.