Declarativas API
Declarativas exposes three simple methods to get you going.
Methods
Mutating the Canvas Context 2d Api
The createMutator(fn)
method is a way to directly manipulate the canvas state. This is the building block to creating components.
Building Components
Render components to the canvas
Calling the render
method will draw whatever virtual canvas nodes you have created onto the canvas you specified. If you want to update the canvas, just call render again. There is no extra state/updating mechanism built in, but there is nothing stopping any developer from integrating declarativas into a state management library.
Built-in Components
DrawImage
FillRect/StrokeRect
Path - uses the beginPath, path elements, fill, and stroke to build a path
MoveTo
LineTo
Rect
RoundRect
Arc/ArcTo
CurveTo - bezier or quadratic curves
Ellipse
Text
ClearRect - clear portion of screen
ClearCanvas - clear entire canvas
Translate
Rotate
Scale
Transform
Stateful - wraps drawing in a save/restore for color and transform states
Property - write a single property to the context2d
Properties - write multiple properties to the context2d
ErrorBoundary - catch errors and render an error message
Group - work-around for JSX so you can have multiple "root" elements
Last updated