Properties

Properties are how the canvas context2d api lets you set how functions draw their paths and shapes. Think of them in terms of css for the upcoming function calls. One a property is set, it persists until you set a different value, or load a previous canvas state.

Notes

Using a property

All properties are accessible using the following standard API:
import { c } from 'declarativas';
​
c('nameOfProperty', { value: appropriateValueHere });
The appropriateValueHere can be tricky, but refer to the MDN Documentation for information on valid values for different properties. Some are strings, others are numbers.

Resetting after properties

The only consistent mechanism I have found for resetting properties and general canvas state has been to use save and restore canvas functions, which are documented in the Functions section.

Properties

Where's property X?

You may have noticed that some properties are missing. Properties marked as experimental or deprecated on MDN have been skipped since they will not produce predictable results.

fillStyle

font

globalAlpha

globalCompositeOperation

imageSmoothingEnabled

lineCap

lineHashOffset

lineJoin

lineWidth

miterLimit

shadowBlur

shadowColor

shadowOffsetX

shadowOffsetY

strokeStyle

strokeStyle

textAlign

textBaseline

​