Space is an abstract class that represents a general context for expressing Pts. It's extended through subclasses such as CanvasSpace
and SVGSpace
. You can also create your own extension of Space.
See Space guide for details.
Set a custom rendering function fn(graphics_context, canvas_space)
if needed.
The inner bounding box of the space, excluding its positions.
Add an IPlayer
object or a AnimateCallbackFn
callback function to handle events in this Space. An IPlayer is an object with the following callback functions:
animate: fn( time, ftime, space )
start: fn(bound, space)
resize: fn( size, event )
action: fn( type, x, y, event )
Subclasses of Space may define other callback functions.clear all contents in the space. To be implemented in subclasses.
Get a default form for drawing in this space. To be implemented in subclasses.
Set a minimum frame time
at least this amount of miniseconds must have elapsed before frame advances
Pause the animation.
a boolean value to set if this function call should be a toggle (between pause and resume)
Main play loop. This implements window.requestAnimationFrame
and calls it recursively.
You may override this play()
function to implement your own animation loop.
current time
Main animate function. This calls all the items to perform.
current time
Play animation loop once. Optionally set a duration
time to play for that specific duration.
a value in millisecond to specify a time period to play before stopping, or -1
to play forever
Set whether the rendering should be repainted on each frame.
a boolean value to set whether to repaint each frame
Remove a player from this Space.
an IPlayer that has an animateID
property
Replay the animation after Space.stop
. This resets the end-time counter.
You may also use Space.pause
and resume
for temporary pause.
Resize the space. To be implemented in subclasses.
a Bound representing the position and size of the space
event
Specify when the animation should stop: immediately, after a time period, or never stops.
a value in millisecond to specify a time period to play before stopping, or -1
to play forever, or 0
to end immediately. Default is 0 which will stop the animation immediately.