State object attributes
We can treat the following attributes as if they are entity object attributes, though in fact they are stored and managed by State objects
fillStyle and strokeStyle - color, gradient or pattern used to outline or fill a entity. Can be:
- CSS format color String -
#fff, #ffffff, rgb(255 255 255), rgb(255 255 255 / 1), rgb(255,255,255), rgba(255,255,255,1), white, etc
- COLORNAME String
- GRADIENTNAME String
- RADIALGRADIENTNAME String
- PATTERNNAME String
globalAlpha - entity transparency - a value between 0 and 1, where 0 is completely transparent and 1 is completely opaque
globalCompositeOperation - compositing method for applying the entity to an existing Cell (<canvas>) display. Permitted values include
- ‘source-over’
- ‘source-atop’
- ‘source-in’
- ‘source-out’
- ‘destination-over’
- ‘destination-atop’
- ‘destination-in’
- ‘destination-out’
- ‘lighter’
- ‘darker’
- ‘copy’
- ‘xor’
- any other permitted value - be aware that different browsers may render these operations in different ways, and some options are not supported by all browsers.
lineWidth - Number (in pixels)
lineCap - how the ends of lines will display. Permitted values include:
lineJoin - how line joints will display. Permitted values include:
lineDash - an array of integer Numbers representing line and gap values (in pixels), for example [5,2,2,2] for a long-short dash pattern
lineDashOffset - distance along the entity’s outline at which to start the line dash. Changing this value can be used to create a ‘marching ants effect
miterLimit - affecting the ‘pointiness’ of the line join where two lines join at an acute angle
shadowOffsetX, shadowOffsetY - horizontal and vertical offsets for a entity’s shadow, in Number pixels
shadowBlur - the blur width for a entity’s shadow, in Number pixels
shadowColor - the color used for an entity’s shadow effect. Can be:
- CSS format color String -
#fff, #ffffff, rgb(255 255 255), rgb(255 255 255 / 1), rgb(255,255,255), rgba(255,255,255,1), white, etc
- COLORNAME String
font, textAlign, textBaseline - the Canvas API standards for using fonts on a canvas are near-useless, and often lead to a sub-par display of text. The Scrawl-canvas Label and EnhancedLabel entitys use these attributes internally, but have their own set of attributes for defining the font styling used by their text.
filter - the Canvas 2D engine supports the filter attribute on an experimental basis, thus it is not guaranteed to work in all browsers and devices. The filter attribute takes a String value (default: ‘none’) defining one or more filter functions to be applied to the entity as it is stamped on the canvas.
- Be aware that entitys can also take a
filters Array - this represents an array of Scrawl-canvas filters to be applied to the entity (or group or Cell). The two filter systems are completely separate - combine their effects at your own risk!
};
P.defs = mergeOver(P.defs, defaultAttributes);