neurotools.graphics.pygame module
Collected utilities for pygame
It is difficult to write pixels directly in python.
There’s some way to get a framebuffer back from Tk, but it is cumberosme.
The module pygame supports sending pixel buffers, which is wrapped for convneinece in this module.
example usage
import neurotools.graphics.pygame as npg import time import numpy as np import pygame K = 128 screen = npg.start(K,K,’Image data’) dt = 1/20 wait_til = time.time() + dt print(‘Animating..’) for i in neurotools.tools.progress_bar(range(100)):
t = time.time() if t<wait_til: time.sleep(wait_til-t) wait_til = t + dt npg.draw_array(screen, np.random.rand(K,K,3))
pygame.quit()