On this page:
Canvas
Canvas.Style  Symbol
Canvas  Context
Canvas  Context.client_  size
8.12

6 Canvases🔗ℹ

class

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,

    ~style: style :: MaybeObs.of(List.of(Canvas.StyleSymbol)) = [],

    ~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

draw(dc :: DC, data_val)

to draw the canvas’s content to a backing store dc ~var, where draw_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 funciton is called with a MouseEvent or KeyEvent, respectively, and a CanvasContext.

Satisfied by the following symbols:

A CanvasContext represents a canvas instance that receives mouse or keyboard events so that properties of the instance can be accessed, including its size.