The Essential Guide to HTML5

(Greg DeLong) #1

CHAPTER 2


Smile





Your browser doesn't support the HTML5 element canvas.



Black is the default color.


Figure 2-9. Filling in the half circle using ctx.fill()


If you want a shape to be filled and have a distinct outline, you use both the fill and the stroke
commands and specify different colors using the fillStyle and strokeStyle properties. The color
scheme is based on the same red/green/blue codes introduced in Chapter 1. You can experiment or use a
tool such as Photoshop or Paint Shop Pro to get the colors you want. Here is the complete code:




Smile