Node / Canvas · guide
Patterns & film noise
Current Apexify.js 6.0.0 documentation for Patterns & film noise.
Use await painter.createCanvas(config) with fields on CanvasConfig (apexify.js). Patterns and noise are not separate ApexPainter methods — they are pure config: either top-level patternBg / noiseBg, or entries inside bgLayers[].
Paint order (what goes on top)
Inside CanvasCreator, after clipping and optional zoom, backgrounds are painted in this fixed order:
- Exactly one primary fill —
videoBg, orcustomBg, orgradientBg, orcolorBg, ortransparentBase: true(no automatic fill), or default opaque#000if you set none of those. bgLayers[]— each layer in array order (bottom → top). Supportscolor,gradient,image,pattern(tiled bitmap),presetPattern(proceduralPatternOptions), andnoise.patternBg— full-canvas procedural pattern (PatternOptions). Runs after everybgLayersrow.noiseBg— film grain overlay (applyNoise). Runs last among background paints (still before canvasshadow/stroke).
So: patternBg is never “between” two bgLayers — if you need a pattern sandwiched between colors, model it as bgLayers (presetPattern / pattern) or reorder bgLayers + skip patternBg.
See also Paint order for the full pipeline.
Three pattern mechanisms (do not mix them up)
| Mechanism | Where | What it draws | Blend default |
|---|---|---|---|
patternBg | Top-level CanvasConfig | Procedural mesh from PatternOptions (EnhancedPatternRenderer) | If pattern.blendMode is omitted → overlay |
bgLayers[] presetPattern | Layer stack | Same procedural renderer as patternBg, but scoped like any other layer | stackedInLayer: true → missing blendMode does not force overlay; uses normal source-over unless you set pattern.blendMode or layer.blendMode |
bgLayers[] pattern | Layer stack | createPattern over a loaded image (source path/URL); tiled (repeat) | Standard layer opacity / blendMode |
Summary
- Want a dots / grid / stripes overlay drawn after all
bgLayers? →patternBg. - Want that between an image wash and a vignette? →
bgLayerswithpresetPattern(and optionalblendModeper layer). - Want your own seamless PNG/JPG tiled? →
bgLayerstype: "pattern"withsource+repeat.
patternBg — procedural overlay after bgLayers
Type: PatternOptions (see catalog below). Typical use: subtle texture on top of colorBg or stacked bgLayers.
If you omit blendMode on patternBg, the renderer defaults to overlay so light textures sit on photographs or gradients without repainting the whole canvas math yourself.
bgLayers — presetPattern vs pattern
presetPattern (vector-style presets)
Same PatternOptions as patternBg, but honours stack order and per-layer opacity / blendMode.
pattern (tiled bitmap)
Loads source as an image (path / URL resolved like other backgrounds), builds a CanvasPattern, fills the canvas.
PatternOptions — type catalogue
Common fields across types (defaults vary per type): color, secondaryColor, opacity, size, spacing, rotation, offsetX, offsetY, blendMode, gradient. custom additionally uses customPatternImage, repeat, scale.
type | Role |
|---|---|
grid | Line grid (size ≈ cell feel; spacing gap between lines). |
dots | Filled dots on a lattice. |
diagonal | Diagonal hatch lines. |
stripes | Horizontal stripes alternating color / secondaryColor. |
waves | Sinusoidal strokes. |
crosses | Cross / plus motifs. |
hexagons | Hex lattice outline fill. |
checkerboard | Checker squares. |
diamonds | Diamond tessellation. |
triangles | Triangle motif tiling. |
stars | Star shapes on a grid. |
polka | Larger “polka” dots variant. |
custom | Tile customPatternImage manually (scale, repeat like repeat-x). |
Import typings from apexify.js / apexify.js/types — PatternOptions ships with the package.
Noise — noiseBg vs bgLayers noise
Both call the same applyNoise helper: random grayscale pixels drawn into a scratch bitmap, then drawImage onto the canvas; intensity scales alpha (255 * intensity per pixel).
| Location | Default intensity if omitted |
|---|---|
noiseBg | 0.05 |
bgLayers { type: "noise" } | 0.08 |
Top-level noiseBg runs after patternBg. A noise inside bgLayers runs where that layer sits in the stack — use it for grain between washes without affecting layers above.
Transparent canvases
With transparentBase: true, there is no automatic colorBg fill — compose visibility only via bgLayers, patternBg, and noiseBg. See Transparent base.
Types reference
PatternOptions— procedural / custom tiled presets.BackgroundLayer— union forbgLayers(color,gradient,image,pattern,presetPattern,noise).CanvasConfig—patternBg,noiseBg,bgLayers.