Masks and layer blending
Use a vector to reveal earlier layers inside a group. The mask remains editable, but contributes coverage instead of visible artwork.
@version 6
imagine group
imagine artwork
shape: rectangle
size: (240, 160)
fill: "#ff6b35"
imagine reveal
shape: circle
size: (120, 120)
fill: "#ffffff"
maskMode: alpha
animate position.x from -80 to 80 over 2s
create group
create artwork
create revealMask scope
A mask affects everything already painted inside its immediate parent, including the parent's own fill. Later siblings remain unaffected. A second mask multiplies the result accumulated before it. Root masks also affect the scene background. Grouping limits the affected content.
“Earlier” follows rendered depth and sibling order. Changing depth, reordering, or reparenting a mask changes what it covers. Ordinary groups remain open to the enclosing backdrop. A group with direct mask children, effects, clipping, or its own non-normal blend isolates its content against a transparent backdrop.
| Property | Values | Default |
|---|---|---|
maskMode |
none, alpha, luminance |
none |
maskInvert |
false, true |
false |
Alpha uses the source's rendered alpha. Luminance uses linear RGB luminance times alpha. Source effects apply before coverage is extracted; inversion applies last, including outside the source geometry. The source's blend mode is inactive while it acts as a mask. Removing its mask role restores ordinary artwork.
Shapes and SVGs without authored child layers can be mask sources. Both fill and painted stroke contribute, including open strokes. Images, text, and groups can be masked content. Text and containers are not mask sources yet. Vertex-specific stroke cuts and feathering are not part of this implementation.
Source opacity controls coverage independently of shared ancestor opacity. A hidden mask does nothing. A zero-opacity or entirely offscreen alpha mask erases earlier content, unless inverted. Animate transforms or opacity to reveal artwork; mask and blend selectors are static. Invalid selector values or selector animations produce validation errors.
Layer blending
Set blendMode on artwork or a group. It combines the layer's completed image,
including its effects, with earlier content in the current scope. A group's own
blend applies once after its children have composed. Parent effects apply after
its child masks; place another mask outside the group to clip those effects too.
The current registry contains 19 distinct modes:
| Family | Modes |
|---|---|
| Basic | normal, add, subtract, divide |
| Darken | darken, multiply, color-burn |
| Lighten | lighten, screen, color-dodge |
| Contrast | overlay, hard-light, soft-light |
| Difference | difference, exclusion |
| Color | hue, saturation, color, luminosity |
Default is normal. Underscores are accepted instead of hyphens. Quote mode names
when writing the DSL, for example blendMode: "soft-light". These controls are
independent of animation blend and grain's effect-local blendMode.
Blending operates in linear RGB with premultiplied alpha. The standard modes use the W3C source-over blending equations. Add clamps the overlap color sum to one; subtract clamps backdrop minus source to zero; divide clamps backdrop/source to one, with zero/zero defined as zero. These three also use source-over alpha. Color-space blend inputs are bounded to [0,1]. The renderer converts to display color only at output.
Editor
Blend appears in the appearance properties. Active masks expose Mask and Invert. A selected vector's layer-row action and the command palette offer Use as mask and Disable mask. Mask layers have a distinct icon and keep their selection bounds and transform controls.
Blend, Mask, and Invert accept static variable bindings. Each selected layer must resolve the variable to a supported value in its own scope. The editor keeps the binding, including through save and reload, and rejects invalid or computed values before changing any selected layers.
Select adjacent flat 2D layers, with a vector on top, and choose Mask selection. The editor inserts a group at their existing position and makes that top vector the mask. Local transforms and compatible animation tracks remain unchanged. Parent-relative values, including named constants from the immediate parent in properties, effect parameters, or animation keys, require explicit group authoring instead. Local and global constants remain usable. Containers and ambiguous depth motion also require explicit grouping. Children created by a blueprint template must be grouped inside that template; the selection command rejects moving only their instantiated copies, which would duplicate artwork on reopening. Mixed-selection mask edits validate every target before applying any changes. Ungroup refuses to move active masks into another scope; disable or move them first. All composition edits participate in undo/redo.
Preview, player playback, and exports share the compositor. Named-camera masks use the content's projection and preserve surviving opaque depth. Composition boundaries retain the same depth limitations as effect groups; they do not offer general 3D interleaving across groups.
Compatibility
Format 6 activates previously ignored layer mask/blend properties and fixes transparent color conversion in FXAA/SMAA output. Earlier files migrate in memory and disclose the rendering change. Older runtimes cannot open format 6 files. Keep a copy of the original file if you need to open it in an older editor.