Draws a circle or ellipse.
Fill or line.
Fill or stroke color.
Center position.
Optionalprops: {Optional arc, center, and stroke properties. Center is true by default.
Draws an image.
Image handle from newImage.
Draw position.
Optionalprops: DrawPropsOptional rotation, scale, origin, or quad.
Draws connected line segments.
Stroke color.
Array of [x, y] positions.
Optionalprops: ShapePropsOptional stroke properties.
Loads an image from a path. Unlike fetch, this pretends to be synchronous.
Image file path.
ImageHandle for use with draw.
Draws individual pixels.
Fill color.
Array of [x, y] positions.
Optionalprops: TransformPropsDraws a polygon.
Fill or line.
Fill or stroke color.
Array of [x, y] vertices.
Optionalprops: ShapePropsOptional stroke and transform properties.
Restores canvas state.
Draws text at a position.
Keep in mind: if you set align without width in your props,
nothing will happen -- you'll get left-aligned text.
Align works browser-style: if you align center, your text draws to the left and right of its position. If you align right, your position becomes the upper-right corner of the text.
Fill color.
Text string.
Top-left position.
Optionalprops: PrintPropsPrintProps Optional font, text limit, or alignment.
Saves canvas state.
Draws a rectangle.
Fill or line.
Fill or stroke color.
Rectangle [x, y, w, h].
Optionalprops: ShapePropsOptional stroke properties.
Applies a rotation.
Rotation in radians.
The idiomatic way to render to an external canvas.
Within this scope, the target canvas has changed.
Outside, it stays the same.
The context to call when drawing.
Functions that will be called while drawing to the target.
For Expressive Purposes
A simple wrapper around push/pop (save/restore) that clearly allows a set of statements to have their own transform matrix.
In other words, any scale, translate, etc.
performed in this block does not affect the
outside world.
the drawing logic.
LIKE's way of drawing to the screen.
More specifically: a system for wrapping canvas draw calls conveniently.
setColor, etc. Everything is passed in.Examples
Draw a spinning symbol in the center of the screen using transforms.