vidmake v0.2.1
Download

Docs/MotionPage 23 / 45

Animation

Every numeric field and every color can be a constant, keyframes, a tween, a spring or an expression. This page covers the first four, with exact timing and easing rules.

View .md Ask Claude Ask ChatGPT

vidmake has no separate "animation" section in a project. Instead, almost every property of a layer accepts either a plain value or a description of how that value changes over time. The same five forms work on x, opacity, fontSize, strokeWidth, blur, fill and the rest:

formlooks likeuse it for
constant100, "25%", "#4a4640"values that don't move
keyframes[[0, 100], ["1s", 500]]several stops, each with its own ease
tween{ "from": 0, "to": 1, "duration": "1s" }one move from A to B
spring{ "from": 0, "to": 1, "spring": true }physical, overshooting motion
expression"=sin(t * 2) * 50"anything computed from time, index or audio

All five evaluate to a single number (or color) at each frame, so you can mix them freely: one layer can have keyframed x, a tween on opacity, a spring on scale and an expression on rotation. Presets (enter/exit) are applied on top of all of them.

Important

Animation times are local to the layer: 0 is the moment the layer starts, not the start of the video. A layer with "start": "2s" and a keyframe at "1s" reaches that keyframe 3 seconds into the composition. See Time for the time syntax and how groups nest.

#Constants

A constant is a number, a percentage string, or (for paints) a color:

json
"x": 640"x": "50%""rotation": "45deg""fill": "#4a4640"

Percentages are relative to the parent: the parent's width for x and width, its height for y, height and fontSize. Numeric strings may end in px or deg, which are ignored ("12px" is 12). true and false count as 1 and 0.

#Keyframes

Keyframes are a list of stops. Between two stops the value is interpolated; before the first stop it holds the first value, after the last stop it holds the last value. Keyframes are sorted by time, so the order you write them in doesn't matter.

There are three ways to write them.

Arrays: [time, value] or [time, value, ease]. This is the most compact form.

json
"x": [[0, 240], ["0.8s", 640, "easeOutBack"], ["1.6s", 1040, "easeInOutCubic"]]

Objects: { "t": time, "v": value, "ease": name }. The same thing with names, which some generators find easier to produce. time/at are accepted for t, and value for v.

json
"x": [{ "t": 0, "v": 240 }, { "t": "0.8s", "v": 640, "ease": "easeOutBack" }]

A keys object: { "keys": [...], "ease": ..., "repeat": ... }. Use it when you want a default ease for every segment, or when the keyframes should repeat. keyframes is accepted as an alias for keys on numeric fields.

json
"x": { "keys": [[0, 240], ["1s", 1040]], "ease": "easeInOutSine", "repeat": "pingpong" }

Times are frames when they are numbers and time strings like "1.5s", "500ms" or "45f" otherwise. Values can be numbers or percentages ([[0, "0%"], ["1s", "100%"]]).

#Ease shapes the segment arriving at a keyframe

This is the one rule to remember: the ease written on a keyframe controls the motion from the previous keyframe to this one. The first keyframe's ease is never used. A keyframe with no ease is linear, unless a keys object sets a default ease.

00:00.0 · f 000
One keyframe list: each ease shapes the segment arriving at its keyframeDownload
anim-keyframes.jsonjson
{  "fonts": [{ "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }],  "compositions": [{    "id": "keyframes", "description": "One keyframe list: each ease shapes the segment arriving at its keyframe",    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",    "layers": [      { "id": "track", "type": "line", "points": [[0, 0], [800, 0]], "x": 640, "y": 380, "stroke": "#d8d1c1", "strokeWidth": 2 },      { "id": "stop", "type": "ellipse", "width": 12, "x": 640, "y": 380, "fill": "#161412",        "repeat": { "count": 3, "layout": "row", "spacing": 400 } },      { "id": "ease1", "type": "text", "text": "easeOutBack", "font": "JetBrains Mono", "fontSize": 20, "fill": "#4a4640", "x": 440, "y": 450 },      { "id": "ease2", "type": "text", "text": "easeInOutCubic", "font": "JetBrains Mono", "fontSize": 20, "fill": "#4a4640", "x": 840, "y": 450 },      { "id": "ease3", "type": "text", "text": "← easeInOutQuint", "font": "JetBrains Mono", "fontSize": 20, "fill": "#4a4640", "x": 640, "y": 300 },      { "id": "ball", "type": "ellipse", "width": 56, "y": 380, "fill": "#c92a26",        "x": [[0, 240], ["0.8s", 640, "easeOutBack"], ["1.6s", 1040, "easeInOutCubic"], ["2.2s", 1040], ["3.4s", 240, "easeInOutQuint"]] },      { "id": "label", "type": "text", "text": "\"x\": [[t, value, ease], …]", "font": "JetBrains Mono", "fontSize": 36, "fill": "#161412", "y": 150 }    ]  }]}

In that demo, easeOutBack is on the 0.8s keyframe, so the ball overshoots as it arrives at 640. The return trip has its ease on the last keyframe. vidmake trace shows the actual values; note x overshooting to about 675 around frame 12 and settling on 640 exactly at the keyframe (frame 24):

vidmake trace anim-keyframes.json -l ball --every 6 --to 2.4s
$ vidmake trace anim-keyframes.json -l ball --every 6 --to 2.4s
 FRAME    TIME        X        Y       W       H    ROT  SCALE  OPAC  NOTES
     0   0.00s    240.0    380.0    56.0    56.0    0.0   1.00  1.00  
     6   0.20s    567.0    380.0    56.0    56.0    0.0   1.00  1.00  
    12   0.40s    675.1    380.0    56.0    56.0    0.0   1.00  1.00  
    18   0.60s    665.7    380.0    56.0    56.0    0.0   1.00  1.00  
    24   0.80s    640.0    380.0    56.0    56.0    0.0   1.00  1.00  
    30   1.00s    665.0    380.0    56.0    56.0    0.0   1.00  1.00  
    36   1.20s    840.0    380.0    56.0    56.0    0.0   1.00  1.00  
    42   1.40s   1015.0    380.0    56.0    56.0    0.0   1.00  1.00  
    48   1.60s   1040.0    380.0    56.0    56.0    0.0   1.00  1.00  
    54   1.80s   1040.0    380.0    56.0    56.0    0.0   1.00  1.00  
    60   2.00s   1040.0    380.0    56.0    56.0    0.0   1.00  1.00  
    66   2.20s   1040.0    380.0    56.0    56.0    0.0   1.00  1.00  
    72   2.40s   1038.4    380.0    56.0    56.0    0.0   1.00  1.00

A segment with the same value at both ends is a hold: ["1.6s", 1040], ["2.2s", 1040] keeps the ball still for 0.6 s. The hold ease does the same thing in one keyframe: the value jumps at the keyframe's time instead of moving towards it. See Easing for every curve.

#Repeating keyframes

A keys object with repeat replays its keyframes forever, measured from the first keyframe:

repeatbehavior
"loop" or truejump back to the first keyframe and play again
"pingpong" (alias "yoyo")play forwards, then backwards, then forwards...
false or absentplay once and hold the last value

The period is the time from the first to the last keyframe. loop is also accepted as the field name ("loop": true).

00:00.0 · f 000
Keyframes and tweens that repeat: pingpong, loop, and a looping tweenDownload
anim-repeat.jsonjson
{  "fonts": [{ "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }],  "compositions": [{    "id": "repeat", "description": "Keyframes and tweens that repeat: pingpong, loop, and a looping tween",    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",    "layers": [      { "id": "lane", "type": "rect", "x": 700, "y": 360, "width": 760, "height": 2, "fill": "#d8d1c1",        "repeat": { "count": 3, "layout": "column", "spacing": 170 } },      { "id": "name", "type": "text", "text": "${pick(i, ['pingpong', 'loop', 'tween loop'])}", "font": "JetBrains Mono", "uppercase": true,        "fontSize": 20, "letterSpacing": 2, "fill": "#4a4640", "anchor": "right", "x": 270, "y": 360, "repeat": { "count": 3, "layout": "column", "spacing": 170 } },      { "id": "pingpong", "type": "ellipse", "width": 48, "y": 190, "fill": "#161412",        "x": { "keys": [[0, 340], ["1s", 1060]], "ease": "easeInOutSine", "repeat": "pingpong" } },      { "id": "loop", "type": "ellipse", "width": 48, "y": 360, "fill": "#161412",        "x": { "keys": [[0, 340], ["1s", 1060, "easeOutCubic"]], "repeat": "loop" } },      { "id": "spinner", "type": "arc", "width": 80, "x": 700, "y": 530, "stroke": "#c92a26", "strokeWidth": 8, "endAngle": 270,        "rotation": { "from": 0, "to": 360, "duration": "1s", "ease": "linear", "repeat": true } }    ]  }]}

The third row is a tween with "repeat": true: tweens repeat the same way.

Tip

For a loop that should survive any change to the composition length, a pingpong or loop repeat is simpler than writing out every cycle. For motion that must line up exactly with the end of the video, keyframes with explicit times are easier to reason about.

#Tweens

A tween animates from one value to another once. It's the shortest way to say "fade in over half a second":

json
"opacity": { "from": 0, "to": 1, "start": "0.5s", "duration": "0.5s", "ease": "easeOutCubic" }
fielddefaultnotes
fromrequiredstart value (number, percentage or, on color fields, a color)
torequiredend value
start (alias delay)0when the tween begins, in layer-local time
durationlength of the tween
endabsolute (layer-local) end time; wins over duration if both are set
easeeaseInOutany easing name, cubic-bezier(...), [x1, y1, x2, y2], steps(n) or spring(bounce)
motiona motion ("snap", "house", { "spring": 0.2, "duration": "0.5s" }): brings its curve and its duration. duration and ease override it
springtrue or { "damping", "stiffness", "mass" }: use a spring instead of ease
repeat (alias loop)nonetrue/"loop" or "pingpong", as for keyframes

A tween needs duration or end, unless it is a spring or its motion has a duration. Before start the value is from; after the end it is to. On numeric fields unknown tween fields are rejected, so a typo like "durration" fails validation instead of silently doing nothing.

00:00.0 · f 000
Tweens: from, to, start, duration and ease on four properties of one cardDownload
anim-tween.jsonjson
{  "fonts": [{ "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" }],  "compositions": [{    "id": "tween", "description": "Tweens: from, to, start, duration and ease on four properties of one card",    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",    "layers": [      { "id": "card", "type": "group", "width": 640, "height": 220, "x": 640, "y": { "from": 470, "to": 360, "duration": "0.9s", "ease": "easeOutCubic" },        "opacity": { "from": 0, "to": 1, "duration": "0.6s", "ease": "linear" }, "exit": "fadeDown",        "children": [          { "id": "panel", "type": "rect", "cornerRadius": 4, "fill": "#fbf9f4", "stroke": "#161412", "strokeWidth": 2 },          { "id": "title", "type": "text", "text": "Rendering video.mp4", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 40, "fill": "#161412",            "anchor": "left", "x": 48, "y": 80, "letterSpacing": { "from": 12, "to": -2, "duration": "1.2s", "ease": "easeOutQuart" } },          { "id": "bar-bg", "type": "rect", "anchor": "left", "x": 48, "y": 150, "width": 544, "height": 8, "fill": "#e9e4d8" },          { "id": "bar", "type": "rect", "anchor": "left", "x": 48, "y": 150, "height": 8, "fill": "#c92a26",            "width": { "from": 0, "to": 544, "start": "0.6s", "end": "3.2s", "ease": "easeInOutSine" } }        ] }    ]  }]}

With motion the tween takes its timing from a name, so every move in a video can share one feel:

json
"x": { "from": 160, "to": 1120, "start": "0.3s", "motion": "bouncy" }"y": { "from": 40, "to": 0, "motion": "house" }

The easing page shows the built-in motions side by side.

The card in that demo uses four tweens with different timings: y and opacity start at 0, letterSpacing runs longer, and the bar's width uses start and end to fill between 0.6 s and 3.2 s.

Note

The default ease of a tween is easeInOut (cubic), but keyframes default to linear. If a keyframed motion looks mechanical, add an ease to its keyframes.

#Springs

The quickest spring is an ease: "ease": "spring(0.3)" (bounce 0..1) on any tween or keyframe, or a motion such as "motion": "snap". Both settle exactly at the end of their duration.

A spring tween replaces the easing curve with a damped spring simulation, the same model as Remotion's spring(). It starts at from, moves towards to, may overshoot, and settles.

json
"scale": { "from": 0, "to": 1, "spring": true }"y": { "from": 800, "to": 540, "delay": 15, "spring": { "damping": 12, "stiffness": 180 } }
spring fielddefaulteffect
damping10friction. Lower values bounce more; 20 (with the default stiffness and mass) is critically damped: the fastest settle with no overshoot. Higher values creep in slowly
stiffness100spring strength. Higher is faster and snappier
mass1heavier is slower, with more overshoot

"spring": true uses all three defaults. Those settle (within 0.1% of to) after about 1.3 s, with a peak overshoot of about 16%.

#Stretching a spring with duration

A spring has its own natural length, which depends on the three parameters. Add duration (or end) to stretch or squeeze it so it settles exactly when the duration is over, keeping the shape of the motion:

json
"scale": { "from": 0, "to": 1, "delay": "0.3s", "duration": "0.4s", "spring": true }
00:00.0 · f 000
Scale springs: damping 4, the default 10, damping 26, and the default stretched to 0.4sDownload
anim-spring.jsonjson
{  "fonts": [{ "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }],  "compositions": [{    "id": "spring", "description": "Scale springs: damping 4, the default 10, damping 26, and the default stretched to 0.4s",    "width": 1280, "height": 720, "fps": 30, "duration": "3s", "background": "#f4f1ea",    "layers": [      { "id": "ring", "type": "ellipse", "width": 160, "x": 640, "y": 330, "fill": null, "stroke": "#8a857a", "strokeWidth": 1.5, "dash": [6, 6],        "repeat": { "count": 4, "layout": "row", "spacing": 280 } },      { "id": "label", "type": "text", "text": "${pick(i, ['damping 4', 'spring: true', 'damping 26', 'duration 0.4s'])}", "font": "JetBrains Mono",        "fontSize": 22, "fill": "#4a4640", "x": 640, "y": 480, "repeat": { "count": 4, "layout": "row", "spacing": 280 } },      { "id": "soft", "type": "ellipse", "width": 160, "x": 220, "y": 330, "fill": "#161412",        "scale": { "from": 0, "to": 1, "delay": "0.3s", "spring": { "damping": 4 } } },      { "id": "default", "type": "ellipse", "width": 160, "x": 500, "y": 330, "fill": "#c92a26",        "scale": { "from": 0, "to": 1, "delay": "0.3s", "spring": true } },      { "id": "stiff", "type": "ellipse", "width": 160, "x": 780, "y": 330, "fill": "#161412",        "scale": { "from": 0, "to": 1, "delay": "0.3s", "spring": { "damping": 26 } } },      { "id": "fast", "type": "ellipse", "width": 160, "x": 1060, "y": 330, "fill": "#161412",        "scale": { "from": 0, "to": 1, "delay": "0.3s", "duration": "0.4s", "spring": true } }    ]  }]}

The trace of the default spring in that demo shows the overshoot past 1.0 and the settle:

vidmake trace anim-spring.json -l default --every 3 --from 0.3s --to 1.8s
$ vidmake trace anim-spring.json -l default --every 3 --from 0.3s --to 1.8s
 FRAME    TIME        X        Y       W       H    ROT  SCALE  OPAC  NOTES
     9   0.30s    500.0    330.0   160.0   160.0    0.0   0.00  1.00  
    12   0.40s    500.0    330.0   160.0   160.0    0.0   0.34  1.00  
    15   0.50s    500.0    330.0   160.0   160.0    0.0   0.85  1.00  
    18   0.60s    500.0    330.0   160.0   160.0    0.0   1.12  1.00  
    21   0.70s    500.0    330.0   160.0   160.0    0.0   1.15  1.00  
    24   0.80s    500.0    330.0   160.0   160.0    0.0   1.07  1.00  
    27   0.90s    500.0    330.0   160.0   160.0    0.0   1.00  1.00  
    30   1.00s    500.0    330.0   160.0   160.0    0.0   0.97  1.00  
    33   1.10s    500.0    330.0   160.0   160.0    0.0   0.98  1.00  
    36   1.20s    500.0    330.0   160.0   160.0    0.0   0.99  1.00  
    39   1.30s    500.0    330.0   160.0   160.0    0.0   1.00  1.00  
    42   1.40s    500.0    330.0   160.0   160.0    0.0   1.00  1.00  
    45   1.50s    500.0    330.0   160.0   160.0    0.0   1.00  1.00  
    48   1.60s    500.0    330.0   160.0   160.0    0.0   1.00  1.00  
    51   1.70s    500.0    330.0   160.0   160.0    0.0   1.00  1.00  
    54   1.80s    500.0    330.0   160.0   160.0    0.0   1.00  1.00

A spring ignores ease and repeat. For a spring inside an expression, use the spring(frame) function, which takes a frame count: "scale": "=spring(f - 10, 12, 180)".

#Animating colors

Color fields (fill, stroke, shadow.color, glow.color, text background, rich-text span fills) take keyframes and tweens just like numbers. The colors are blended channel by channel, including alpha.

json
"fill": [[0, "#161412"], ["1.3s", "#c92a26", "easeInOut"], ["2.6s", "#1f5fb0", "easeInOut"]]"stroke": { "from": "#d8d1c1", "to": "#161412", "duration": "2s", "repeat": "pingpong" }

Inside a gradient, the angle of a linear gradient is animatable; stops are fixed. See Colors.

00:00.0 · f 000
Colors animate like numbers: keyframes on a fill, a tween on a stroke, an animated gradient angleDownload
anim-color.jsonjson
{  "fonts": [{ "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }],  "compositions": [{    "id": "color", "description": "Colors animate like numbers: keyframes on a fill, a tween on a stroke, an animated gradient angle",    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",    "layers": [      { "id": "keys", "type": "rect", "x": 340, "width": 220, "height": 220,        "fill": [[0, "#161412"], ["1.3s", "#c92a26", "easeInOut"], ["2.6s", "#1f5fb0", "easeInOut"], ["4s", "#161412", "easeInOut"]] },      { "id": "tween", "type": "ellipse", "x": 640, "width": 220, "fill": "#fbf9f4", "strokeWidth": 14,        "stroke": { "from": "#d8d1c1", "to": "#161412", "duration": "2s", "repeat": "pingpong" } },      { "id": "grad", "type": "star", "x": 940, "width": 240, "innerRadius": 0.5,        "fill": { "type": "linear", "angle": { "from": 0, "to": 360, "duration": "4s", "ease": "linear" }, "stops": ["#1f5fb0", "#c92a26"] } },      { "id": "cap", "type": "text", "text": "${pick(i, ['keyframes', 'tween', 'gradient angle'])}", "font": "JetBrains Mono", "uppercase": true,        "fontSize": 18, "letterSpacing": 2, "fill": "#8a857a", "y": 540, "repeat": { "count": 3, "layout": "row", "spacing": 300 } }    ]  }]}

Colors can also come from an expression: "=hsl(t * 90, 60, 70)", "=pick(i, ['#c92a26', '#1f5fb0'])" or "=lerp('#161412', '#c92a26', p)".

Warning

Color keyframes support the array forms and { "keys": [...], "ease": ... }, but not repeat (it is ignored on colors) and not the keyframes alias. For a repeating color cycle, use a tween with "repeat", or an expression such as "=lerp('#d8d1c1', '#161412', pingpong(t, 1))".

#Combining with presets

Presets (enter, exit, and series transitions) don't replace your animation; they are applied on top of it. A fade preset multiplies your opacity, a slide adds an offset to your x/y, a scale preset multiplies your scale. So a layer can float with an expression, rock with a tween and still pop in and zoom out:

00:00.0 · f 000
A pop-in preset, a floating expression and a slow spin, all on one layerDownload
anim-combine.jsonjson
{  "fonts": [{ "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" }],  "compositions": [{    "id": "combine", "description": "A pop-in preset, a floating expression and a slow spin, all on one layer",    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": { "type": "radial", "center": [0.5, 0.45], "radius": 0.8, "stops": ["#f4f1ea", "#e9e4d8"] },    "layers": [      { "id": "logo", "type": "image", "src": "assets/logo.svg", "width": 220, "x": 640,        "y": "=330 + sin(t * 2.4) * 14", "rotation": { "from": -8, "to": 8, "duration": "2s", "repeat": "pingpong" },        "shadow": { "color": "#16141233", "blur": 30, "y": 18 }, "enter": "pop", "exit": { "type": "zoom", "duration": "0.4s" } },      { "id": "title", "type": "text", "text": "Presets add to your own animation", "font": "Schibsted Grotesk", "fontWeight": 860,        "fontSize": 48, "letterSpacing": -2, "fill": "#161412", "y": 560, "start": "0.4s", "enter": "fadeUp", "exit": "fade" }    ]  }]}

The logo layer's y is an expression, its rotation a pingpong tween, and enter: "pop" scales the result from 0 with a spring. vidmake trace lists the active preset in its notes column, which is handy when an entrance and your own animation seem to fight:

vidmake trace anim-combine.json -l logo --every 4 --to 0.7s
$ vidmake trace anim-combine.json -l logo --every 4 --to 0.7s
 FRAME    TIME        X        Y       W       H    ROT  SCALE  OPAC  NOTES
     0   0.00s    640.0    330.0   220.0   220.0   -8.0   0.00  1.00  enter:pop
     4   0.13s    640.0    334.4   220.0   220.0   -8.0   0.61  1.00  enter:pop
     8   0.27s    640.0    338.4   220.0   220.0   -7.8   1.09  1.00  enter:pop
    12   0.40s    640.0    341.5   220.0   220.0   -7.5   1.10  1.00  enter:pop
    16   0.53s    640.0    343.4   220.0   220.0   -6.8   1.01  1.00  enter:pop
    20   0.67s    640.0    344.0   220.0   220.0   -5.6   0.99  1.00  enter:pop

#Which fields animate

Every field below accepts all five forms (constant, keyframes, tween, spring, expression):

groupfields
transformx, y, width, height, rotation, scale, scaleX, scaleY, opacity
3DrotateX, rotateY, perspective
stylestrokeWidth, cornerRadius
effectsblur, brightness, saturation, grain, chromaticAberration, glow (radius, or radius/strength in the object form), shadow.blur, shadow.x, shadow.y
textfontSize, letterSpacing, maxWidth, reveal, padding
shapes and pathsinnerRadius (star), startAngle/endAngle (arc), drawStart/drawEnd (path, line)
mediavolume (audio and video)
otherattach.progress, a group layout's gap, a linear gradient's angle

Color fields (fill, stroke, shadow.color, glow.color, text background, span fill) accept constants, keyframes, tweens and expressions.

These are not animatable: anchor, start/duration/end, lineHeight, fontWeight, dash, sides, closed, playbackRate, trimStart, blendMode, maskMode, gradient stops and radial center/radius, repeat options, particle emitter fields, and preset options. Text content isn't a field animation either, but ${...} in text is re-evaluated every frame (see live text).

Warning

Ellipses, polygons, stars and arcs become square when only width (or only height) is set. That missing side is computed once, from the value at frame 0. If you animate only width, the height stays at its frame-0 value. Animate scale instead, or animate both width and height.

#Checking animation

For agents

Don't guess whether a curve looks right: vidmake trace project.json -l <id> --every 3 prints x, y, size, rotation, scale and opacity at every sampled frame, plus active presets and the current text. Narrow it with --from and --to. For a whole-frame view use vidmake storyboard with --at times placed just before, during and after the motion.

See Inspecting for trace, inspect and storyboard in depth.