Design Mode
Compositor
How the layer compositor renders and blends design layers over algorithm output.
The compositor is the rendering engine for design mode. It takes the algorithm's canvas output and overlays the design layer stack on top, producing the final composite image.
Rendering Pipeline
- Algorithm render — The sketch algorithm draws to the base canvas
- Layer iteration — Layers are processed bottom-to-top (index 0 first)
- Visibility check — Hidden layers are skipped
- Plugin render — Each layer's plugin renders it to an offscreen canvas
- Transform apply — Position, scale, rotation, and anchor are applied
- Blend composite — The layer is composited onto the output using its blend mode and opacity
- Final output — The composited result is the visible sketch
Implementation
The compositor runs inside the sketch iframe. It uses the Canvas 2D globalCompositeOperation for blend modes and standard 2D transforms for positioning.
Algorithm Canvas → [Layer 0] → [Layer 1] → ... → [Layer N] → Final Output
↑ ↑ ↑
Plugin Plugin Plugin
Render Render RenderPerformance
- Only visible layers are rendered
- Layers use offscreen canvases to avoid re-rendering unchanged layers
- The compositor is triggered by layer changes, not on every frame
- For animated sketches, the compositor runs after each algorithm frame
Accessing Layer Data
Algorithms can read (but not write) layer data via __genart_design:
// Inside a sketch algorithm
const layers = window.__genart_design?.layers;
if (layers) {
// React to layer positions, colors, etc.
}This enables algorithms to respond to design layer changes dynamically.