vidmake v0.2.1
Download

Docs/LayersPage 11 / 45

Layer basics

The fields every layer shares — id, timing, position, anchor, size, transforms, paint, shadow, filters, blend modes, 3D tilt and presets — and how percentages and draw order work.

View .md Ask Claude Ask ChatGPT

A composition is a stack of layers. Every layer is a JSON object with a type and, ideally, an id; everything else is optional and has a sensible default. This page covers the fields that every layer type shares. The pages that follow cover what each type adds.

the smallest useful layersjson
{ "id": "bg",    "type": "rect", "fill": "#f4f1ea" }{ "id": "title", "type": "text", "text": "Hello", "fontSize": 96 }

With no position, both land in the center of their parent. With no size, the rect fills its parent and the text is measured from its content. With no timing, both last as long as their parent.

#Layer types

typewhat it drawspage
rect, ellipse, polygon, star, arcbuilt-in shapesShapes
path, lineSVG path data or a polyline, with draw-on trimmingPaths
texta text block: fonts, wrapping, rich spans, staggerText
imagepng, jpg, webp, bmp, gif (first frame) or svgImages
videoany file ffmpeg can read, with its soundVideo
audiosound only, nothing on screenAudio
groupother layers in their own coordinate spaceGroups
useanother composition, with props (a component)Components
captionssubtitles from srt/vtt/json or inline itemsCaptions
waveforma spectrum or oscilloscope of an audio trackWaveform
particlesa deterministic particle emitterParticles

A field that does not apply to a type is an error, not a silent no-op, and a misspelled field gets a suggestion:

output
✗ main: layer `box` (main > layers[0]): field(s) fontSize do not apply to `rect` layers✗ main: composition `main`: unknown field `fontsize` — did you mean `fontSize`?

#Identity and bookkeeping

fielddefaultnotes
idtype#indexEvery CLI command addresses layers by id (inspect -l, trace -l, set title.fontSize). Give every layer one.
typerequiredOne of the types above.
visibletruefalse removes the layer completely: it is not drawn, takes no space in a layout, and its sound is not mixed. Handy for switching variants on and off.
commentFree text for humans and agents. Ignored by the renderer.
lintfalse, or { "ignore": ["offCanvas", "invisible"] }, silences validate warnings for this layer and its children.
motionBlurtruefalse renders this layer at the exact frame when the composition has motion blur.

Auto-generated ids (rect#0, text#3) change whenever layers are reordered, so they are fine for a quick look but not something to script against.

#Timing

fielddefaultnotes
start0When the layer appears, relative to its parent's start.
durationrest of the parentHow long it stays. Media layers default to their media length.
endAlternative to duration: the time it disappears, on the same clock as start. duration wins if both are set.

Numbers are frames; strings can be seconds ("1.5s"), milliseconds ("500ms"), frames ("45f") or m:ss ("1:02.5"). Every animation time inside a layer is local to that layer, so a keyframe at 0 fires when the layer appears, not when the video starts. Time values covers this in depth, and series plays layers one after another without adding up start times by hand.

#Position and size

fielddefaultnotes
x, y"50%" (center of the parent)Where the layer's anchor point sits, in parent coordinates.
width, heightdepends on the typeSee the table below.
anchor[0.5, 0.5]Which point of the layer's own box is placed at x/y.

Coordinates are pixels with 0,0 at the parent's top-left corner, y growing downward. At the top level the parent is the composition; inside a group or component it is that layer's box.

#Default sizes

typesize when width/height are not set
rectthe full parent size. If only one of the two is set, the other is 100.
ellipse, polygon, star, arc100×100. One of width/height makes it square.
text, captionsmeasured from the content, plus padding (captions are 80% of the parent wide)
image, videothe media's native size. One of width/height keeps the aspect ratio.
path, linethe bounds of the points, from 0,0 to the largest x and y
groupthe parent size
usethe referenced composition's size
waveform80% of the parent width × 200
particlesa point (1×1): the area particles are born in
audiono box at all

#Anchor

The anchor is a fraction of the layer's own box: [0, 0] is its top-left corner, [1, 1] the bottom-right, [0.5, 0.5] (the default) the center. Rotation and scale happen around it too. Names work as well: center, top-left, top, top-right, left, right, bottom-left, bottom, bottom-right (camelCase like topLeft is accepted). Values outside 0..1 are allowed and put the pivot outside the box, which is useful with attach.

The anchor is the easiest way to align things without arithmetic. To pin a watermark to the top-right corner 40 px from the edges, anchor its top-right corner and place that:

json
{ "id": "mark", "type": "text", "text": "vidmake", "anchor": "top-right", "x": "=w - 40", "y": 40 }

Left-aligned blocks (lower thirds, bullet lists) usually want "anchor": "left" and an explicit x.

00:00.0 · f 000
The same rotation around three different anchor pointsDownload
layers-anchor.jsonjson
{  "fonts": [{ "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }],  "compositions": [{    "id": "anchor", "description": "The same rotation around three different anchor points",    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",    "layers": [      { "id": "guide", "type": "rect", "y": 330, "width": 1100, "height": 1, "fill": "#8a857a" },      { "id": "card-tl", "type": "rect", "x": 260, "y": 330, "width": 180, "height": 110, "cornerRadius": 4,        "anchor": "top-left", "fill": "#161412", "rotation": "=t * 90" },      { "id": "card-c", "type": "rect", "x": 640, "y": 330, "width": 180, "height": 110, "cornerRadius": 4,        "fill": "#161412", "rotation": "=t * 90" },      { "id": "card-br", "type": "rect", "x": 1020, "y": 330, "width": 180, "height": 110, "cornerRadius": 4,        "anchor": "bottom-right", "fill": "#161412", "rotation": "=t * 90" },      { "id": "pin", "type": "ellipse", "width": 22, "y": 330, "fill": "#c92a26", "stroke": "#f4f1ea", "strokeWidth": 4,        "x": "=pick(i, [260, 640, 1020])", "repeat": 3 },      { "id": "label", "type": "text", "y": 630, "font": "JetBrains Mono", "fontSize": 22, "fill": "#8a857a",        "text": "${pick(i, ['\"top-left\"', '\"center\"', '\"bottom-right\"'])}", "x": "=pick(i, [260, 640, 1020])", "repeat": 3 }    ]  }]}

#Percentages

Any numeric field accepts a percentage string. What it is a percentage of depends on the field:

field"50%" means
x, width, maxWidthhalf the parent's width
y, heighthalf the parent's height
fontSizehalf the parent's height
cornerRadiushalf the shorter side of the layer (so "50%" is a pill or a circle)

Inside a group, the parent is the group's box, so "width": "100%" on a child fills the group, not the canvas. In expressions, w/h are the composition size and pw/ph the parent size: "x": "=pw - 40" hugs the right edge of whatever contains the layer.

#Transforms

fielddefaultnotes
rotation0Degrees, clockwise, around the anchor.
skewX, skewY0Shear in degrees around the anchor, animatable. skewX: -12 leans the top to the right, like italic type.
scale1Uniform scale around the anchor. Multiplies scaleX/scaleY.
scaleX, scaleY1Per-axis scale. Negative values mirror.
opacity10..1, multiplied with every ancestor's opacity.
rotateX, rotateY03D tilt in degrees around the anchor: positive rotateX tips the top edge away, positive rotateY the right edge.
perspective1000Camera distance in px for the tilt. Smaller is more dramatic.

The layer is placed in this order: move the anchor to x/y, rotate, skew, scale, then draw the box offset by the anchor. Transforms never change the layer's measured width/height (what layouts use); they only change where pixels land, which vidmake inspect reports as the BBOX column.

vidmake inspect layers-anchor.json -t 1s -l card-tl
$ vidmake inspect layers-anchor.json -t 1s -l card-tl
Frame 30 (1.00s) of `anchor` (1280x720), 1 visible layer(s), drawn bottom→top:

ID                       TYPE            X        Y       W       H    ROT  SCALE  OPAC  BBOX [x0,y0,x1,y1]          NOTES
card-tl                  rect        260.0    330.0   180.0   110.0   90.0   1.00  1.00  [150,330,260,510]

rotateX/rotateY render the finished layer flat, then project it in perspective, so they work on any layer, including a whole group:

00:00.0 · f 000
rotateX and rotateY tilt a flat card in perspectiveDownload
layers-tilt.jsonjson
{  "fonts": [    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }  ],  "compositions": [{    "id": "tilt", "description": "rotateX and rotateY tilt a flat card in perspective",    "width": 1280, "height": 720, "fps": 30, "duration": "4s",    "background": { "type": "radial", "center": [0.5, 0.45], "radius": 0.8, "stops": ["#f4f1ea", "#e9e4d8"] },    "layers": [      { "id": "card", "type": "group", "width": 520, "height": 320, "perspective": 900,        "rotateY": "=28 * sin(t * pi / 2)", "rotateX": "=12 * cos(t * pi / 2)",        "shadow": { "color": "#16141244", "blur": 30, "y": 24 },        "children": [          { "id": "face", "type": "rect", "cornerRadius": 6, "fill": { "type": "linear", "angle": 135, "stops": ["#4a4640", "#161412"] } },          { "id": "title", "type": "text", "text": "Perspective", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 72,            "letterSpacing": -3, "fill": "#f4f1ea", "y": "44%" },          { "id": "sub", "type": "text", "text": "rotateX · rotateY", "font": "JetBrains Mono", "fontSize": 20, "letterSpacing": 2.4,            "uppercase": true, "fill": "#8a857a", "y": "68%" }        ] }    ]  }]}

#Fill and stroke

fielddefaultnotes
fillwhiteA color or gradient (paints). null turns it off.
strokenoneOutline paint. On text the outline is drawn behind the fill.
strokeWidth2 (8 for line and open arc)In px, animatable. The stroke is centered on the outline, so half of it lies outside the box.
dashsolidDash pattern in px, e.g. [20, 10].
lineCaproundround, butt or square: the ends of open strokes and dashes.
cornerRadius0Rounds rect, image, video, a text background and waveform bars.

Shapes, text and particles get a white fill when you set neither fill nor stroke. A line and an open arc are strokes by nature: if you give them only a fill, that paint becomes the stroke. Gradient coordinates are relative to the layer's box, so a gradient follows the layer as it moves.

#Shadow and filters

fielddefaultnotes
shadownone{ "color": "#0008", "blur": 20, "x": 0, "y": 8 }. Defaults: color rgba(0,0,0,0.5), blur 10, x 0, y 4. Every part is animatable.
blur0Gaussian blur radius in px.
brightness1Multiplies the color: 0.5 darkens, 1.3 brightens.
saturation10 is grayscale, above 1 boosts color.
blendModenormalHow the layer combines with what is under it, see below.

The shadow is cast by the layer's actual pixels (text glyphs, a star's points, the visible part of an image), not by its box. Filters apply to the finished layer, so blurring a group blurs everything in it.

00:00.0 · f 000
Stroke and dash, shadow, saturation and blur on four layersDownload
layers-style.jsonjson
{  "fonts": [{ "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }],  "compositions": [{    "id": "style", "description": "Stroke and dash, shadow, saturation and blur on four layers",    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",    "layers": [      { "id": "dashed", "type": "rect", "x": 200, "y": 330, "width": 200, "height": 200, "cornerRadius": 6, "fill": null,        "stroke": "#161412", "strokeWidth": 6, "dash": [26, 14], "lineCap": "butt", "rotation": "=t * 22.5" },      { "id": "lifted", "type": "rect", "x": 493, "y": "=330 - 14 * sin(t * pi / 2)", "width": 200, "height": 200,        "cornerRadius": 6, "fill": "#fbf9f4", "stroke": "#d8d1c1", "strokeWidth": 1.5,        "shadow": { "color": "#16141255", "blur": "=12 + 18 * max(0, sin(t * pi / 2))", "y": "=8 + 22 * max(0, sin(t * pi / 2))" } },      { "id": "logo", "type": "image", "src": "assets/logo.svg", "x": 786, "y": 330, "width": 220,        "saturation": [[0, 0], ["2s", 1.4, "easeInOutSine"], ["4s", 0, "easeInOutSine"]] },      { "id": "blurred", "type": "star", "x": 1080, "y": 330, "width": 200, "fill": "#161412",        "blur": [[0, 0], ["2s", 14, "easeInOutSine"], ["4s", 0, "easeInOutSine"]] },      { "id": "label", "type": "text", "y": 520, "font": "JetBrains Mono", "fontSize": 20, "letterSpacing": 2.4, "uppercase": true,        "fill": "#8a857a", "x": "=pick(i, [200, 493, 786, 1080])", "repeat": 4,        "text": "${pick(i, ['dash', 'shadow', 'saturation', 'blur'])}" }    ]  }]}

blendMode takes normal, multiply, screen, overlay, darken, lighten, color-dodge, color-burn, hard-light, soft-light, difference, exclusion and add (camelCase spellings and plus are accepted too). screen and add are the usual choices for light leaks and glows over video; multiply for shadows and paper textures.

Glow, film grain, chromatic aberration and masks are covered in Effects and Masks.

#Presets and transitions

fieldnotes
enterAnimation played when the layer appears: "fadeUp", "pop", { "type": "wipeRight", "duration": "0.4s" }...
exitAnimation played as the layer ends.
transitionOnly on children of a series group: how this child hands over to the next one.

Presets combine with your own animation, so a layer can pop in while its y also floats. See Presets and Series and transitions. Two more fields reshape a layer rather than style it: repeat stamps out copies, and attach pins a layer to a path's tip or after a text's last character.

#Animating any field

Every numeric field on this page (and every color) accepts a constant, keyframes, a tween, a spring or an expression:

json
"x": [[0, 100], ["1s", 500, "easeOutCubic"]],"opacity": { "from": 0, "to": 1, "duration": "0.5s" },"rotation": "=t * 90","fill": [[0, "#c92a26"], ["2s", "#1f5fb0"]]

See Animation for the forms and Expressions for the = language. A few fields are plain values that cannot animate: dash, lineCap, blendMode, anchor, visible, and type-specific switches like sides, lineHeight or playbackRate; each page says which.

#Draw order

Layers draw in array order: the first one is at the bottom, the last one on top. There is no zIndex; to bring a layer forward, move it later in the array (vidmake add --index n inserts at a position). A group draws all of its children at the group's place in its parent's order, so everything inside a group sits above the layers before the group and below the layers after it.

vidmake inspect lists visible layers bottom to top, indented by depth, which makes the stacking easy to check:

vidmake inspect groups-card.json -t 2s
$ vidmake inspect groups-card.json -t 2s
Frame 60 (2.00s) of `card` (1280x720), 6 visible layer(s), drawn bottom→top:

ID                       TYPE            X        Y       W       H    ROT  SCALE  OPAC  BBOX [x0,y0,x1,y1]          NOTES
card                     group       640.0    360.0   560.0   300.0    0.0   1.00  1.00  [360,210,920,510]           
  bg                     rect        280.0    150.0   560.0   300.0    0.0   1.00  1.00  [360,210,920,510]           
  dot                    ellipse      64.0     64.0    40.0    40.0    0.0   1.00  1.00  [404,254,444,294]           
  title                  text         48.0    150.0   285.9   115.2    0.0   1.00  1.00  [408,302,694,418]           "Group"
  sub                    text         50.0    228.0   265.8    28.8    0.0   1.00  1.00  [410,424,676,452]           "0,0 is the card's top-left"
  shine                  rect        645.1    150.0    90.0   600.0   20.0   1.00  0.06  [860,63,1150,657]

For agents

When something is missing from a frame, run vidmake inspect project.json -t <time> before changing anything: a layer that is not listed is outside its time window (or visible: false), a layer with OPAC near 0 is faded out, and a BBOX outside 0..width/0..height is off-canvas. vidmake validate flags the last two as invisible and offCanvas.