Skip to content

Documentation / @ripl/canvas / toCanvasPattern

Function: toCanvasPattern() ​

toCanvasPattern(ctx, value): CanvasPattern | null

Defined in: canvas/src/utilities.ts:180

Materializes a pattern(...) paint string as a repeating CanvasPattern, drawing the shared tile geometry into an offscreen canvas. Results (including parse failures) are cached per context and string, and released by releaseCanvasPaintCache.

Parameters ​

ParameterTypeDescription
ctxCanvasRenderingContext2DThe context the pattern will paint into.
valuestringThe pattern(...) paint string.

Returns ​

CanvasPattern | null

The repeating pattern, or null when the string or environment can't produce one.