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 stateAn 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 UnitA function that draws on the component. It knows the following:
Context2Dis the drawing context of the canvas elementDeltais a record containing current and previous timestamps and the time elapsed since the previous frame.Scalersis a record containing scaling information for transforming coordinates between the drawing and the canvas.stateis the state of the application, withStatescontaining 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 stateAn function that may update the application state. It runs on every frame, before the render function. It knows the following:
Deltais a record containing current and previous timestamps and the time elapsed since the previous frame.Scalersis a record containing scaling information for transforming coordinates between the drawing and the canvas.stateis 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.