A repeating pattern drawn from a path, used as a fill or stroke style.
Unlike CanvasPattern, which tiles a bitmap, a texture redraws its path at each grid position, so it stays sharp at any scale.
Reachable either way: CanvasRenderingContext2D.createTexture and this constructor are the same call.
ctx.fillStyle = new CanvasTexture(8, { color: "red", line: 2 }) Copy
ctx.fillStyle = new CanvasTexture(8, { color: "red", line: 2 })
🧪 Not in the HTML Canvas standard.
grid pitch, either [x, y] or one number for both
[x, y]
Optional
what to draw at each grid position; parallel lines if no path is given
path
A repeating pattern drawn from a path, used as a fill or stroke style.
Unlike CanvasPattern, which tiles a bitmap, a texture redraws its path at each grid position, so it stays sharp at any scale.
Reachable either way: CanvasRenderingContext2D.createTexture and this constructor are the same call.
🧪 Not in the HTML Canvas standard.