DICE GAME
in the frown example, will “finish off” the arc. The complete code is
This produces the screen show in Figure 2-8.
Figure 2-8. The frown becomes a half-circle by adding ctx.closePath(); before ctx.stroke();
The closePath command is not always necessary, but its good practice to include it. Experiment here
and also look ahead to the drawing of the slingshot in Chapter 5 and the drawing of the hangman figure in
Chapter 9. If you want the path filled in, you use ctx.fill() in place of ctx.stroke(), which produces a
black, filled-in shape as shown in Figure 2-9. The complete code is