8.16.0.4
|
class Canvas(): | implements View | constructor ( | data :: MaybeObs.of(Any), | draw :: Function.of_arity(2), | ~mouse: mouse :: Function.of_arity(2) = Function.pass, | ~key: key :: Function.of_arity(2) = Function.pass, | ~label: label :: MaybeObs.of(maybe(LabelString)) = "canvas", | ~is_enabled: is_enabled :: MaybeObs.of(Boolean) = #true, | ~styles: styles :: MaybeObs.of(List.of(Canvas.Style)) = [], | ~margin: margin :: MaybeObs.of(Margin) = [0, 0], | ~min_size: min_size :: MaybeObs.of(Size) = [#false, #false], | ~stretch: stretch :: MaybeObs.of(Stretch) = [#true, #true], | ~mixin: mix :: Function = values, | ) |
|
Creates a canvas view. When the view is rendered, the draw
function is called as
to draw the canvas’s content to a backing store dc ~var,
where data_val is the value of Obs.peek(data)
when data is an observable. The draw function
is called to update the canvas content when data is an
observable and its value changes.
When a mouse or key event is received by a rendered canvas, the
mouse or key function is called with a
MouseEvent or KeyEvent,
respectively, and a CanvasContext.
A canvas style symbol.
A
CanvasContext represents a canvas instance that
receives mouse or keyboard events so that properties of the instance can
be accessed, including its size.