The Canvas State
When we draw on the Canvas context, we can make use of a stack of so-called drawing states. Each of these states stores data about the Canvas context at any one time. Here is a list of the data stored in the stack for each state:
Transformation matrix information such as rotations or translations using the
context.rotate()
andcontext.setTransform()
methodsThe current clipping region
The current values for canvas attributes, such as (but not limited to):
globalAlpha
globalCompositeOperation
strokeStyle
textAlign
,textBaseline
lineCap
,lineJoin
,lineWidth
, andmiterLimit
fillStyle
font
shadowBlur
,shadowColor
,shadowOffsetX
, andshadowOffsetY
We will cover these states later in this chapter.
Get HTML5 Canvas, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.