Name
CanvasRenderingContext2D.fill( ): fill the path
Synopsis
void fill( )
Description
fill( ) fills the current
path with the color, gradient, or pattern specified by the fillStyle property. Each subpath of the
path is filled independently. Any subpaths that are not closed are
filled as if the closePath( )
method had been called on them. (Note, however, that this does not
actually cause those subpaths to become closed.)
The canvas uses the “non-zero winding rule” to determine which points are inside the path and which are outside. The details of this rule are beyond the scope of this book, but they typically matter only for complex paths that intersect themselves.
Filling a path does not clear the path. You may call stroke( ) after calling fill( ) without redefining the
path.
See Also
CanvasRenderingContext2D.fillRect(
)
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access