Java Reference
In-Depth Information
context.arc(200, 200, 30, 0, Math.PI * 2, false);
context.strokeStyle = "#ff0";
context.lineWidth = 4;
context.stroke();
The fillText() method is used to write text onto the canvas. The first parameter is the
text to be displayed, while the next two parameters are the x and y coordinates respect-
ively. The font property can be used to set the font style used, otherwise the style is in-
herited from the canvas element's CSS setting (note that it needs to be changed before
the fillText() method is used to draw the text). The following example will draw the
text “Hello” in green at coordinates (20,50), as shown in Figure 14.5 .
context.fillStyle = "#0c0"; // a blue fill color
context.font = "bold 26px sans-serif";
context.fillText("Hello", 20, 200);
Search WWH ::




Custom Search