HTML and CSS Reference
In-Depth Information
mycontext.stroke();
mycontext.
restore
(); // back to previous <canvas> state
mycontext.beginPath();
mycontext.moveTo(80, 10);
mycontext.lineTo(14, 50);
mycontext.stroke();
Figure 9-12. Coordinate system transformations and stack management of the canvas state
See Also
9.8 Placing Text on a <canvas>
Problem
You want to include text directly in your
canvas
drawing.
Solution
The
canvas
API provides two commands for rendering text in your drawing:
fill
Text(...)
and
strokeText(...)
. Both commands take the same parameters:
(
stringTo
Render
,
x
,
y
[,
maxWidth
])
. The only difference is whether the text is filled in or simply
outlined.