def main(): "main function called when the script is run" #first we just init pygame and create some empty arrays to work with pygame.init() screen = pygame.display.set_mode(RES, 0, 8) print screen.get_flags() setpalette(screen) flame = zeros(RES/2 + (0,3)) doubleflame = zeros(RES) randomflamebase(flame) #the mainloop is pretty simple, the work is done in these funcs frame_timer = FrameTimer() quit_now = 0 while not quit_now: for event in pygame.event.get(): if event.type in (QUIT,KEYDOWN,MOUSEBUTTONDOWN): quit_now = 1 modifyflamebase(flame) processflame(flame) blitdouble(screen, flame, doubleflame) pygame.display.flip() frame_timer.tick() frame_timer.log_histogram()
def test_FrameTimer(): ft = FrameTimer() ft.tick() ft.tick() result = ft.get_longest_frame_duration_sec()
ll = int(lowerlefts[i + 1]) width = int(lowerlefts[i] - ll) projection = SimplePerspectiveProjection(fov_x=fov_x, aspect_ratio=aspect_ratio) projection.look_at(eye, camera_look_at, camera_up) viewport = Viewport(screen=screen, projection=projection, stimuli=[stimulus], anchor='lowerleft', position=(ll, 0), size=(width, height)) viewports.append(viewport) # list of viewports, drawn in order, so overlay viewport goes last viewports.append(overlay_viewport) frame_timer = FrameTimer() quit_now = False while not quit_now: for event in pygame.event.get(): if event.type in (QUIT, KEYDOWN, MOUSEBUTTONDOWN): quit_now = True screen.clear() for v in viewports: v.draw() swap_buffers() frame_timer.tick() frame_timer.log_histogram() im = screen.get_framebuffer_as_image(buffer='front') im.save('project_linear_grating_on_cylinder.png')