Patterns
The createPattern()
method returns a canvas pattern object, which can be used as a fill or stroke style for any drawing.
Referencing an Image Element
You can also use an image DOM element as the value for the source
property.
Creating a pattern using a function
As of version 5.3, anything that can be drawn on the canvas can also be used as a pattern.
To do so, use a function as the value of the source
property. In your function, you may draw using jCanvas methods, or utilize the given canvas context. Also ensure you give the pattern a width
and a height
.
Finally, if you would rather use a existing canvas element, feel free to do so using the source
property.
Notes
By default, the pattern repeats on both the X- and Y-axis