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(
)
Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.