Module cocos.custom_clocks

Custom clocks used by cocos to perform special tasks, like:

dev notes: There's code duplication here, but having separated codepaths would help to follow changes in pyglet 1.2dev. When released, we could refactor this with some confidence.

References to the classes defined here are discouraged in code outside this module because of possible changes.

The public interface should be

Classes

  ScreenReaderClock
Make frames happen every 1/framerate and takes screenshots
  ScreenReaderClock_12dev
Make frames happen every 1/framerate and takes screenshots
  AutotestClock
Make frames follow a test plan
  AutotestClock_12dev
Make frames follow a test plan

Functions

  get_recorder_clock(framerate, template, duration=0)
Returns a clock object suitable to be used as a pyglet app clock, which will provide a steady framerate, and saves a snapshot for each frame from time=0 to time=duration
  get_autotest_clock(sampler)
Returns a clock object suitable to be used as a pyglet app clock, which will follow a test plan to advance time and take snapshots.
  set_app_clock(clock)
Sets the cocos (or pyglet) app clock to a custom one

Variables

  __package__ = 'cocos'

Function Details

get_recorder_clock

get_recorder_clock(framerate, template, duration=0)

Returns a clock object suitable to be used as a pyglet app clock, which will provide a steady framerate, and saves a snapshot for each frame from time=0 to time=duration

The clock object class depends on the pyglet version, and is set automatically

Parameters:
framerate : int
the number of frames per second
template : str
snapshot filenames will be template%frame_number (ex: "s%d.png" -> s0.png, s1.png...)
duration : float
the amount of seconds to record, or 0 for infinite

get_autotest_clock

get_autotest_clock(sampler)

Returns a clock object suitable to be used as a pyglet app clock, which will follow a test plan to advance time and take snapshots.

The clock object class depends on the pyglet version, and is determined automatically.

Parameters:
sampler : obj
obj with interface sampler.next(last_app_time) -> next_app_time Drives the app trough the desired states, take snapshots and handles the app termination conditions.