The Canvas fill() method paints the interior of the current path’s shapes using the context’s active fillStyle. Unlike stroke(), which draws only a border, fill() produces a solid shape. section 15.2.3
Use fill() in a short drawing sequence:
- Define a shape such as a rectangle with rect() or roundRect(). section 15.2.3
- Set context.fillStyle when the shape needs a color other than Canvas’s default black. section 15.2.3
- Call fill() to paint the current path; call beginPath() before a separate path when styles or geometry should not carry over. section 15.2.3
Filled rectangle
context.rect(346, 33, 160, 80); context.fillStyle = "#6ba5d7"; context.fill(); This draws a blue rectangle at the specified position and size.
Filled circles in a visualization
For each painting node, assign fillStyle from its subject, start a path, draw an arc, and use fill() before stroke() adds the medium-specific border. section 15.3
