Gesso.Application.Behavior
- Package
- purescript-gesso
- Repository
- smilack/purescript-gesso
#FixedUpdate Source
type FixedUpdate state = { function :: UpdateFunction state, interval :: Interval }
An update function that occurs at a fixed, regular interval, rather than on every animation frame.
#InputReceiver Source
type InputReceiver state input = input -> UpdateFunction state
An input receiver is a variant of an update function that can receive information from the component's parent and produce an update function in response.
#RenderFunction Source
type RenderFunction state = Context2D -> Delta -> Scalers -> States state -> Effect Unit
A function that draws on the component. It knows the following:
Context2D
is the drawing context of the canvas elementDelta
is a record containing current and previous timestamps and the time elapsed since the previous frame.Scalers
is a record containing scaling information for transforming coordinates between the drawing and the canvas.state
is the state of the application, withStates
containing the two most recent states and the time progress between them (on the interval[0, 1]
).
The render function may run any operations in Effect
, not just functions
related to drawing on the canvas.
#TimestampedUpdate Source
type TimestampedUpdate state = Scalers -> state -> Effect (Maybe state)
A partially applied UpdateFunction
that already has the Delta
record.
#UpdateFunction Source
type UpdateFunction state = Delta -> TimestampedUpdate state
An function that may update the application state. It runs on every frame, before the render function. It knows the following:
Delta
is a record containing current and previous timestamps and the time elapsed since the previous frame.Scalers
is a record containing scaling information for transforming coordinates between the drawing and the canvas.state
is the state of the application
The update function may return a new state if changes are necessary (or
Nothing
if not).
This type is also used by Interaction handlers and when receiving input from a host application.