The Essential Guide to HTML5

(Greg DeLong) #1

CHAPTER 2


Now, lets go on with other variations. Do take each one and experiment with it. Changing the las t
parameter of the arc method to true:


ctx.arc(200,200,50,0,Math.PI,true);


makes the arc go in a counterclockwise direction. The complete code is:




Frown





Your browser doesn't support the HTML5 element canvas.



Notice that I also changed the title. This code produces the screen shown in Figure 2-7.


Figure 2-7. The “frown” produced by the expression ctx.arc(200,200,50,0,Math.PI, true);


Putting in the statement to close the path before the stroke:


ctx.closePath();
ctx.stroke();

Free download pdf