HTML and CSS Reference
In-Depth Information
The Canvas State
WhenwedrawontheCanvascontext,wecanmakeuseofastackofso-calleddrawing
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
con-
text.rotate()
and
context.setTransform()
methods
▪ The current clipping region
▪ The current values for canvas attributes, such as (but not limited to):
—
globalAlpha
—
globalCompositeOperation
—
strokeStyle
—
textAlign
,
textBaseline
—
lineCap
,
lineJoin
,
lineWidth
, and
miterLimit
—
fillStyle
—
font
—
shadowBlur
,
shadowColor
,
shadowOffsetX
, and
shadowOffsetY
We will cover these states later in this chapter.