# Recipes

> A cookbook of common motion-graphics patterns as complete, rendered vidmake projects, including lower thirds, kinetic titles, counters, charts, progress bars, Ken Burns, beat sync, logo reveals, typewriter code, vertical templates, captions, end cards and picture-in-picture.

Each recipe is a complete project you can copy, render and adapt. The demos are 1280×720 (one is 720×1280) and use
the assets in `assets/` (a test-pattern clip, a gradient photo, music and an SVG logo); swap in your own files and
text. Every demo passes `vidmake validate --all` without warnings.

To try one locally: copy the JSON into `project.json` next to an `assets/` folder with your media and a `fonts/`
folder with [Schibsted Grotesk](https://fonts.google.com/specimen/Schibsted+Grotesk) and
[JetBrains Mono](https://fonts.google.com/specimen/JetBrains+Mono) (or change `font` to an installed family from
`vidmake fonts`), then:

```bash
vidmake validate project.json
vidmake storyboard project.json -o sb.png
vidmake render project.json -o out/video.mp4
```

- [Lower third](https://vidmake.app/docs/recipes.md#lower-third) Name and role over footage, wiped in.
- [Kinetic title](https://vidmake.app/docs/recipes.md#kinetic-title) Words rise one by one.
- [Number counter](https://vidmake.app/docs/recipes.md#number-counter) A live number with thousands separators.
- [Bar chart](https://vidmake.app/docs/recipes.md#bar-chart) One repeated layer, heights from a list.
- [Progress bar](https://vidmake.app/docs/recipes.md#progress-bar) A tween and a percentage on the same curve.
- [Ken Burns](https://vidmake.app/docs/recipes.md#ken-burns-photo) Slow zoom and pan on a still.
- [Background video](https://vidmake.app/docs/recipes.md#background-video-darkened) Footage behind readable type.
- [Beat pulse](https://vidmake.app/docs/recipes.md#beat-pulse) Music drives scale, glow and color.
- [Logo reveal](https://vidmake.app/docs/recipes.md#logo-reveal-with-a-mask) An iris mask opens on a logo.
- [Typewriter code](https://vidmake.app/docs/recipes.md#typewriter-code-with-a-cursor) Syntax colors and a blinking cursor.
- [Captions](https://vidmake.app/docs/recipes.md#tiktok-style-captions) One big word at a time, plus karaoke.
- [Vertical 9:16](https://vidmake.app/docs/recipes.md#vertical-9-16-social-template) A templated social video.
- [End card](https://vidmake.app/docs/recipes.md#end-card) Stacked layout with a call to action.
- [Picture-in-picture](https://vidmake.app/docs/recipes.md#picture-in-picture) A framed inset video.
- [Slideshow](https://vidmake.app/docs/recipes.md#slideshow-with-transitions) Scenes in a series with transitions.

## Lower third

A red rule wipes down, the name wipes in from the left, the role fades up. Everything lives in one `group`
anchored at its top-left, so moving the whole lower third is one `x`/`y` change, and the `exit` on the group
takes all three out together. The name and role are [props](https://vidmake.app/docs/props.md), so the same file renders any person:
`vidmake render lt.json -p name="Grace Hopper" -p role="Rear admiral"`.

**Demo: Lower third: a red rule wipes in, then name and role slide up** (rendered video: https://vidmake.app/media/recipe-lower-third.mp4)

```json
{
  "fonts": [
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },
    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }
  ],
  "compositions": [{
    "id": "lowerThird", "description": "Lower third: a red rule wipes in, then name and role slide up",
    "width": 1280, "height": 720, "fps": 30, "duration": "4s",
    "background": { "type": "radial", "center": [0.7, 0.3], "radius": 1, "stops": ["#f4f1ea", "#e9e4d8"] },
    "props": { "name": "Ada Lovelace", "role": "First programmer" },
    "layers": [
      { "id": "footage", "type": "video", "src": "assets/clip.mp4", "width": "100%", "height": "100%", "muted": true,
        "saturation": 0, "opacity": 0.3, "blur": 10 },
      { "id": "lt", "type": "group", "x": 96, "y": 520, "width": 560, "height": 120, "anchor": "top-left",
        "exit": { "type": "fadeLeft", "duration": "0.4s" },
        "children": [
          { "id": "rule", "type": "rect", "x": 0, "y": 0, "width": 6, "height": 120, "anchor": "top-left", "fill": "#c92a26",
            "enter": { "type": "wipeDown", "duration": "0.4s" } },
          { "id": "name", "type": "text", "text": "{{name}}", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 64,
            "letterSpacing": -2.8, "fill": "#161412", "anchor": "top-left", "x": 32, "y": 2, "start": "0.25s",
            "enter": { "type": "wipeRight", "duration": "0.6s" } },
          { "id": "role", "type": "text", "text": "{{role}}", "font": "JetBrains Mono", "fontSize": 18, "letterSpacing": 3, "uppercase": true,
            "fill": "#4a4640", "anchor": "top-left", "x": 34, "y": 86, "start": "0.5s", "enter": "fadeUp" }
        ] }
    ]
  }]
}
```

- Children of a group are positioned and timed **relative to the group** (`x: 32` is 32 px from the group's
  left edge; `start: "0.25s"` is 0.25 s after the group starts).
- `wipeRight`/`wipeDown` reveal with a moving mask; they don't move the layer.
- The footage is the [background video recipe](https://vidmake.app/docs/recipes.md#background-video-darkened) turned the other way:
  grayscale and faded to 30% `opacity` over the light background instead of darkened, with extra blur.
- To reuse it across videos, move the group into its own composition and place it with a `use` layer: see
  [components](https://vidmake.app/docs/components.md).

## Kinetic title

Words that rise from behind their line with [`stagger`](https://vidmake.app/docs/text.md#stagger) and `rise`, a second line that lands with a spring and a
`blur` entrance, and a red rule that grows underneath. The letter spacing of the first line opens slowly from
tight to normal for the whole duration (`"=map(t, 0, 4, -6, 0)"`), which keeps a static title alive.

**Demo: Kinetic title: words rise one by one, the last one lands in a lighter italic** (rendered video: https://vidmake.app/media/recipe-kinetic-title.mp4)

```json
{
  "fonts": [
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk-Italic.ttf" }
  ],
  "compositions": [{
    "id": "kinetic", "description": "Kinetic title: words rise one by one, the last one lands in a lighter italic",
    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",
    "layers": [
      { "id": "line1", "type": "text", "text": "Make every frame", "font": "Schibsted Grotesk", "fontWeight": 860,
        "fontSize": 124, "fill": "#161412", "y": "40%", "letterSpacing": "=map(t, 0, 4, -6, 0)",
        "stagger": "word", "enter": "rise",
        "exit": { "type": "fadeUp", "duration": "0.4s" } },
      { "id": "line2", "type": "text", "text": "count.", "font": "Schibsted Grotesk", "italic": true, "fontWeight": 400,
        "fontSize": 150, "letterSpacing": -5, "fill": "#161412", "y": "61%", "start": "0.5s",
        "scale": { "from": 1.4, "to": 1, "duration": "0.8s", "spring": { "damping": 14 } },
        "enter": { "type": "blur", "duration": "0.6s" }, "exit": { "type": "fadeUp", "duration": "0.4s" } },
      { "id": "rule", "type": "rect", "y": "77%", "height": 3, "fill": "#c92a26", "start": "0.9s",
        "width": { "from": 0, "to": 280, "duration": "0.8s", "ease": "easeOutCubic" }, "exit": "fade" }
    ]
  }]
}
```

- `"stagger": "word"` plays the layer's `enter` once per word, all of them started within 0.6 s; `char` and `line`
  work the same way. For letters that blur into focus, use `"enter": { "from": { "opacity": 0, "y": "0.3em", "blur": "0.15em" } }`
  with `"stagger": "char"`.
- The italic face is a second entry in `fonts` with the same family name; `"italic": true` picks it.
- Combine presets with your own animation freely: `line2` has both an `enter` preset and a `scale` spring.

## Number counter

The text contains a `${...}` expression, evaluated every frame. `fmt()` adds thousands separators and
`easeOutCubic(clamp(t / 2.5, 0, 1))` makes the count decelerate into its final value at 2.5 s.

**Demo: Number counter: live text eased from 0 to 1.5 million, with thousands separators** (rendered video: https://vidmake.app/media/recipe-counter.mp4)

```json
{
  "fonts": [
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },
    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }
  ],
  "compositions": [{
    "id": "counter", "description": "Number counter: live text eased from 0 to 1.5 million, with thousands separators",
    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",
    "layers": [
      { "id": "count", "type": "text", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 180, "letterSpacing": -8,
        "fill": "#161412", "y": "44%", "text": "${fmt(round(1500000 * easeOutCubic(clamp(t / 2.5, 0, 1))))}" },
      { "id": "caption", "type": "text", "text": "videos rendered", "font": "JetBrains Mono", "fontSize": 18, "letterSpacing": 2.5,
        "uppercase": true, "fill": "#8a857a", "y": "62%", "enter": "fadeUp" },
      { "id": "spark", "type": "ellipse", "width": 14, "fill": "#c92a26", "x": "50%", "y": "70%", "start": "2.5s", "enter": "pop" }
    ]
  }]
}
```

```json
"text": "${fmt(round(1500000 * easeOutCubic(clamp(t / 2.5, 0, 1))))}"
```

- Use `fmt(x, '.', 2)` for European formatting with two decimals, `pad(x, 2)` for leading zeros, `round(x, 1)` for
  one decimal. See [expressions](https://vidmake.app/docs/expressions.md).
- A centered counter grows as digits are added. Anchor it `left` or `right` (or use a monospace font) if the
  jitter bothers you.
- Counters stay sharp under composition motion blur: text expressions are evaluated at the whole frame.

## Bar chart

One `rect` layer with [`repeat`](https://vidmake.app/docs/repeat.md) makes eight bars; `i` picks each bar's value from a list and
offsets its start by `delay`. The bars are anchored at the `bottom`, so animating `height` grows them upward
from the axis. A second repeated text layer with the same `spacing` labels them.

**Demo: Bar chart from one repeated layer: heights from a list, staggered spring-in** (rendered video: https://vidmake.app/media/recipe-bar-chart.mp4)

```json
{
  "fonts": [
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },
    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }
  ],
  "compositions": [{
    "id": "bars", "description": "Bar chart from one repeated layer: heights from a list, staggered spring-in",
    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",
    "layers": [
      { "id": "heading", "type": "text", "text": "Renders per week", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 64,
        "letterSpacing": -2.8, "fill": "#161412", "y": 110, "enter": "fadeUp" },
      { "id": "axis", "type": "rect", "x": "50%", "y": 582, "width": 900, "height": 2, "fill": "#161412" },
      { "id": "bar", "type": "rect", "width": 64, "anchor": "bottom", "x": "50%", "y": 580,
        "repeat": { "count": 8, "layout": "row", "spacing": 108, "delay": "0.08s" },
        "height": "=pick(i, [120, 190, 160, 250, 230, 310, 290, 370]) * easeOutBack(clamp(t / 0.7, 0, 1))",
        "fill": "=i == n - 1 ? '#c92a26' : '#4a4640'" },
      { "id": "week", "type": "text", "text": "W${i + 1}", "font": "JetBrains Mono", "fontSize": 16, "letterSpacing": 2, "fill": "#8a857a",
        "x": "50%", "y": 612, "repeat": { "count": 8, "layout": "row", "spacing": 108 } }
    ]
  }]
}
```

```json
"height": "=pick(i, [120, 190, 160, 250, 230, 310, 290, 370]) * easeOutBack(clamp(t / 0.7, 0, 1))",
"fill": "=i == n - 1 ? '#c92a26' : '#4a4640'"
```

- `t` is local to each copy, so `delay` staggers the growth without changing the expression.
- `easeOutBack` overshoots a little before settling; use `easeOutCubic` for a calmer chart.
- Pass the data as a prop (`"=pick(i, {{values}})"` with `"values": [120, 190, ...]`) to render charts from data.

## Progress bar

A track and a fill, both anchored `left` at the same point. The fill's `width` is a tween; the percentage
label uses the same easing function in an expression, so the number and the bar always agree.

**Demo: Progress bar: one tween drives the width, the percentage reads the same curve** (rendered video: https://vidmake.app/media/recipe-progress-bar.mp4)

```json
{
  "fonts": [
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },
    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }
  ],
  "compositions": [{
    "id": "progress", "description": "Progress bar: one tween drives the width, the percentage reads the same curve",
    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",
    "layers": [
      { "id": "label", "type": "text", "text": "Rendering", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 64,
        "letterSpacing": -2.8, "fill": "#161412", "anchor": "bottom-left", "x": 240, "y": 330 },
      { "id": "pct", "type": "text", "font": "JetBrains Mono", "fontSize": 28, "fill": "#161412", "anchor": "bottom-right", "x": 1040, "y": 322,
        "text": "${round(100 * easeInOutCubic(clamp(t / 3, 0, 1)))}%" },
      { "id": "track", "type": "rect", "anchor": "left", "x": 240, "y": 372, "width": 800, "height": 10, "fill": "#e9e4d8" },
      { "id": "fill", "type": "rect", "anchor": "left", "x": 240, "y": 372, "height": 10,
        "width": { "from": 0, "to": 800, "duration": "3s", "ease": "easeInOutCubic" },
        "fill": { "type": "linear", "angle": 90, "stops": ["#161412", "#c92a26"] } },
      { "id": "done", "type": "text", "text": "Done in 3.0 s", "font": "JetBrains Mono", "fontSize": 16, "letterSpacing": 2, "uppercase": true,
        "fill": "#8a857a", "anchor": "top-left", "x": 240, "y": 404, "start": "3s", "enter": "fadeUp" }
    ]
  }]
}
```

- A gradient `fill` is laid out over the layer's current box, so it stretches as the bar grows.
- For a circular version, animate an [`arc`](https://vidmake.app/docs/shapes.md)'s `endAngle` from 0 to 360.
- A progress bar spanning the whole video: `"width": "=w * p"` on a layer that lasts the whole composition
  (`p` is the layer's progress, 0 to 1).

## Ken Burns photo

A slow, linear zoom and pan on a still image. Anchoring the image off-center (`[0.3, 0.3]`) makes the zoom push
toward that point, and a linear `x` tween adds a drift. A gradient that fades to the background color keeps the
caption readable.

**Demo: Ken Burns: a slow linear zoom and drift on a still photo, under a paper-colored gradient** (rendered video: https://vidmake.app/media/recipe-ken-burns.mp4)

```json
{
  "fonts": [
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk-Italic.ttf" }
  ],
  "compositions": [{
    "id": "kenBurns", "description": "Ken Burns: a slow linear zoom and drift on a still photo, under a paper-colored gradient",
    "width": 1280, "height": 720, "fps": 30, "duration": "5s", "background": "#f4f1ea",
    "layers": [
      { "id": "photo", "type": "image", "src": "assets/photo.jpg", "width": "100%", "height": "100%",
        "anchor": [0.3, 0.3], "y": 216, "saturation": 0.6, "brightness": 1,
        "x": { "from": 384, "to": 300, "duration": "5s", "ease": "linear" },
        "scale": { "from": 1, "to": 1.4, "duration": "5s", "ease": "linear" } },
      { "id": "shade", "type": "rect", "fill": { "type": "linear", "angle": 180, "stops": [[0.3, "#f4f1ea00"], [1, "#f4f1eaf2"]] } },
      { "id": "place", "type": "text", "text": ["Somewhere ", { "text": "warm", "italic": true, "fontWeight": 400 }], "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 96,
        "letterSpacing": -4.5, "fill": "#161412", "anchor": "bottom-left", "x": 80, "y": 640, "start": "0.4s",
        "enter": { "type": "fadeUp", "duration": "1s" }, "exit": "fade" }
    ]
  }]
}
```

- Use `"ease": "linear"`: eased Ken Burns moves look like they start and stop.
- Make the image at least as large as the frame for the whole move. Scaling up from 100% (as here) never shows
  an edge; panning more than the zoom allows does.
- The scale happens around the `anchor`; `x`/`y` place that anchor. To zoom into a face at 70%/40% of the photo,
  set `"anchor": [0.7, 0.4]` and `x`/`y` to the same point of the canvas.

## Background video, darkened

Full-frame footage, muted, desaturated and darkened with `brightness`, plus a gradient scrim on the side where
the text sits. Two cheap adjustments that make any footage work behind type.

**Demo: Background video, darkened and desaturated so the headline reads** (rendered video: https://vidmake.app/media/recipe-background-video.mp4)

```json
{
  "fonts": [
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },
    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }
  ],
  "compositions": [{
    "id": "bgVideo", "description": "Background video, darkened and desaturated so the headline reads",
    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#131210",
    "layers": [
      { "id": "bg", "type": "video", "src": "assets/clip.mp4", "width": "100%", "height": "100%", "muted": true,
        "brightness": 0.45, "saturation": 0.25, "blur": 3 },
      { "id": "scrim", "type": "rect", "fill": { "type": "linear", "angle": 90, "stops": [[0, "#131210ee"], [0.65, "#13121066"], [1, "#13121000"]] } },
      { "id": "kicker", "type": "text", "text": "Chapter one", "font": "JetBrains Mono", "fontSize": 18, "letterSpacing": 2.5, "uppercase": true,
        "fill": "#f05a4e", "anchor": "left", "x": 96, "y": 290, "enter": "fadeRight" },
      { "id": "headline", "type": "text", "text": "Footage behind,\nwords in front.", "font": "Schibsted Grotesk", "fontWeight": 860,
        "fontSize": 84, "letterSpacing": -3.5, "fill": "#efebe2", "align": "left", "anchor": "top-left", "x": 96, "y": 320, "lineHeight": 0.98,
        "stagger": { "by": "line", "type": "fadeUp", "each": "150ms" } }
    ]
  }]
}
```

- `brightness` below 1 darkens, `saturation` 0 is grayscale; both are animatable (fade footage to gray at the end
  of a scene).
- `blur` softens detail without losing motion. Keep it small on full-frame layers; large blurs are slow to render.
- `muted: true` drops the clip's sound from the mix. Without it, the video's audio plays. See [video](https://vidmake.app/docs/video.md).

## Beat pulse

[Audio-reactive](https://vidmake.app/docs/audio-reactive.md) variables come from all the sound in the composition: `beat` jumps to 1
on each detected beat and decays, `bass` follows the low end, and `beats` counts beats so far. Here the word
scales and glows on each beat, the ring of dots pops and cycles colors, and the halo breathes with the bass.

**Demo: Beat pulse: amp, bass and beat from the music drive scale, glow and color** (rendered video: https://vidmake.app/media/recipe-beat-pulse.mp4)

```json
{
  "fonts": [{ "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" }],
  "compositions": [{
    "id": "beat", "description": "Beat pulse: amp, bass and beat from the music drive scale, glow and color",
    "width": 1280, "height": 720, "fps": 30, "duration": "6s", "background": "#131210",
    "layers": [
      { "id": "music", "type": "audio", "src": "assets/music.mp3", "trimStart": "2s", "fadeIn": "0.3s", "fadeOut": "0.6s" },
      { "id": "halo", "type": "ellipse", "width": 420, "y": "46%", "scale": "=1 + 0.35 * bass",
        "fill": { "type": "radial", "stops": ["#efebe222", "#efebe200"] } },
      { "id": "dot", "type": "ellipse", "width": 14, "x": "50%", "y": "46%",
        "repeat": { "count": 24, "layout": "radial", "radius": 170 },
        "scale": "=1 + 1.2 * beat", "fill": "=pick(beats + i, ['#f05a4e', '#6aa6e8', '#efebe2'])" },
      { "id": "core", "type": "text", "text": "beat", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 100, "letterSpacing": -4,
        "fill": "#efebe2", "y": "46%", "scale": "=1 + 0.18 * beat", "glow": { "radius": "=4 + 30 * beat", "color": "#f05a4e" } },
      { "id": "viz", "type": "waveform", "src": "assets/music.mp3", "trimStart": "2s", "mode": "line",
        "y": "88%", "width": "70%", "height": 90, "stroke": "#8f8a7f", "strokeWidth": 2 }
    ]
  }]
}
```

```json
"scale": "=1 + 0.18 * beat",
"glow": { "radius": "=4 + 30 * beat", "color": "#f05a4e" },
"fill": "=pick(beats + i, ['#f05a4e', '#6aa6e8', '#efebe2'])"
```

- The analysis follows the mix after `trimStart`, `volume` and fades, so the visuals line up with what plays.
- Run `vidmake analyze project.json` before choosing multipliers: it prints the beat times and how much of the
  track `amp` and `bass` spend at 1. A glow driven by a variable that sits at its ceiling just stays on; see
  [analyze](https://vidmake.app/docs/audio-reactive.md#check-the-soundtrack-with-analyze).
- A [`waveform`](https://vidmake.app/docs/waveform.md) in `line` mode draws the signal itself.
- Without any audio in the composition these variables stay 0, and `validate` says so.

## Logo reveal with a mask

The logo is revealed through an iris: its [`mask`](https://vidmake.app/docs/masks.md) is an ellipse that scales up from 0. A thin ring
draws on around it, then the wordmark wipes in.

**Demo: Logo reveal: an iris mask opens on the logo, a ring draws, the wordmark wipes in** (rendered video: https://vidmake.app/media/recipe-logo-reveal.mp4)

```json
{
  "fonts": [
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },
    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }
  ],
  "compositions": [{
    "id": "logoReveal", "description": "Logo reveal: an iris mask opens on the logo, a ring draws, the wordmark wipes in",
    "width": 1280, "height": 720, "fps": 30, "duration": "4s",
    "background": { "type": "radial", "center": [0.5, 0.45], "radius": 0.8, "stops": ["#f4f1ea", "#e9e4d8"] },
    "layers": [
      { "id": "ring", "type": "arc", "y": "40%", "width": 250, "stroke": "#161412", "strokeWidth": 2,
        "startAngle": "=-90 * easeInOutCubic(clamp(t / 1.2, 0, 1))",
        "endAngle": { "from": 0, "to": 360, "duration": "1.2s", "ease": "easeInOutCubic" } },
      { "id": "logo", "type": "image", "src": "assets/logo.svg", "width": 180, "y": "40%", "start": "0.3s",
        "mask": { "type": "ellipse", "width": 200, "y": "40%", "start": "0.3s",
          "scale": { "from": 0, "to": 1.05, "duration": "0.9s", "ease": "easeOutCubic" } },
        "rotation": { "from": -20, "to": 0, "duration": "1s", "ease": "easeOutBack" } },
      { "id": "wordmark", "type": "text", "text": "vidmake", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 88,
        "letterSpacing": -4, "fill": "#161412", "y": "70%", "start": "1s", "enter": { "type": "wipeRight", "duration": "0.8s", "ease": "easeInOutCubic" } },
      { "id": "tagline", "type": "text", "text": "Motion, written.", "font": "JetBrains Mono", "fontSize": 18, "letterSpacing": 3.5,
        "uppercase": true, "fill": "#8a857a", "y": "80%", "start": "1.5s", "enter": "fadeUp" }
    ]
  }]
}
```

```json
"mask": { "type": "ellipse", "width": 200, "y": "40%", "start": "0.3s",
  "scale": { "from": 0, "to": 1.05, "duration": "0.9s", "ease": "easeOutCubic" } }
```

> [!IMPORTANT]
> A mask is positioned and timed like a **sibling** of the masked layer, not like its child. Give it the same
> `x`/`y` and `start` as the layer it masks; here, without `"start": "0.3s"`, the iris would already be 30% open
> on the logo's first frame, and without `"y": "40%"` it would be centered on the canvas instead of the logo.

- `maskMode: "alphaInverted"` shows the layer everywhere *except* the mask, for a "punch-out" reveal.
- Any layer can be a mask: text for video-through-type, a `path` with `drawEnd` for a hand-drawn wipe.
- SVG logos are rasterized at their displayed size and stay sharp at any scale.

## Typewriter code with a cursor

A rich-text layer (an array of spans, each with its own `fill`, `fontWeight` or `italic`) in a monospace font
with `whiteSpace: "pre"` to keep the indentation. The `typewriter` preset reveals it character by character, and
a thin rect with [`attach`](https://vidmake.app/docs/attach.md) rides the last visible character.

**Demo: Typewriter code: rich-text spans typed out, with a blinking cursor attached to the last character** (rendered video: https://vidmake.app/media/recipe-typewriter-code.mp4)

```json
{
  "fonts": [
    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" },
    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono-Italic.ttf" }
  ],
  "compositions": [{
    "id": "code", "description": "Typewriter code: rich-text spans typed out, with a blinking cursor attached to the last character",
    "width": 1280, "height": 720, "fps": 30, "duration": "5s", "background": "#f4f1ea",
    "layers": [
      { "id": "panel", "type": "rect", "width": 860, "height": 340, "cornerRadius": 4, "fill": "#fbf9f4",
        "stroke": "#161412", "strokeWidth": 2 },
      { "id": "code", "type": "text", "font": "JetBrains Mono", "fontSize": 30, "align": "left", "whiteSpace": "pre",
        "anchor": "top-left", "x": 260, "y": 270, "lineHeight": 1.5, "fill": "#4a4640",
        "text": [
          { "text": "let", "fill": "#161412", "fontWeight": 800 }, " clip = ", { "text": "render", "fill": "#c92a26", "fontWeight": 700 }, "(project);\n",
          { "text": "if", "fill": "#161412", "fontWeight": 800 }, " clip.ok {\n",
          "    publish(clip, ", { "text": "\"1080p\"", "fill": "#161412", "fontWeight": 700 }, ");\n",
          "}", { "text": "  // every frame checked", "fill": "#8a857a", "italic": true }
        ],
        "enter": { "type": "typewriter", "duration": "3s", "ease": "linear" } },
      { "id": "cursor", "type": "rect", "width": 3, "height": 36, "fill": "#161412", "attach": "code", "x": 4,
        "opacity": "=t < 3 ? 1 : floor(t * 2.5) % 2" }
    ]
  }]
}
```

```json
{ "id": "cursor", "type": "rect", "width": 3, "height": 36, "fill": "#161412", "attach": "code", "x": 4,
  "opacity": "=t < 3 ? 1 : floor(t * 2.5) % 2" }
```

- The cursor stays solid while typing (the first 3 s) and blinks afterwards. A cursor that blinks the whole time
  is at opacity 0 on some frames, which may trigger an [`invisible`](https://vidmake.app/docs/lint.md) warning. If so, silence it with
  `"lint": { "ignore": ["invisible"] }`.
- `x: 4` on an attached layer is an offset from the attach point.
- For a constant typing speed, use `"ease": "linear"` on the preset, or animate `reveal` from 0 to 1 yourself.

## TikTok-style captions

Two [`captions`](https://vidmake.app/docs/captions.md) layers on the same text: one in `word` mode (one big word at a time, with a pop)
and one in line mode with a `highlight` color for the current word, karaoke-style. A thick `stroke` in the
opposite tone (here light around dark text) keeps the words readable on any footage.

**Demo: TikTok-style captions: one big word at a time with a pop, outlined for contrast** (rendered video: https://vidmake.app/media/recipe-captions-tiktok.mp4)

```json
{
  "fonts": [{ "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" }],
  "compositions": [{
    "id": "captions", "description": "TikTok-style captions: one big word at a time with a pop, outlined for contrast",
    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",
    "layers": [
      { "id": "bg", "type": "video", "src": "assets/clip.mp4", "width": "100%", "height": "100%", "muted": true,
        "saturation": 0, "opacity": 0.3, "blur": 6 },
      { "id": "subs", "type": "captions", "mode": "word", "font": "Schibsted Grotesk", "fontSize": 110, "fontWeight": 900,
        "letterSpacing": -3, "uppercase": true, "fill": "#161412", "stroke": "#f4f1ea", "strokeWidth": 14, "y": "55%",
        "items": [
          { "text": "Write the JSON,", "start": "0.2s", "end": "1.4s" },
          { "text": "look at every frame,", "start": "1.5s", "end": "2.8s" },
          { "text": "then render.", "start": "2.9s", "end": "3.9s" }
        ] },
      { "id": "line", "type": "captions", "font": "Schibsted Grotesk", "fontSize": 30, "fontWeight": 600, "fill": "#4a4640",
        "highlight": "#c92a26", "y": "84%",
        "items": [
          { "text": "Write the JSON, look at every frame, then render.", "start": "0.2s", "end": "3.9s" }
        ] }
    ]
  }]
}
```

- Word timing is spread over each caption by word length unless you give `words` with exact times. Use real
  timings from a transcript: `src` accepts `.srt`, `.vtt` and Whisper-style `.json` (times in seconds).
- Inline `items` use frames for bare numbers, like everywhere else; write `"1.5s"` for seconds.
- `uppercase`, `fontWeight: 900` and a stroke are the usual short-form look; `y: "55%"` keeps words clear of the
  platform UI at the bottom.

## Vertical 9:16 social template

A 720×1280 composition where the hook text and handle are props, so one file renders a series of posts:
`vidmake render vertical.json -p hook="Why every frame is a function of time" -o out/post-2.mp4`.
The clip sits in a square frame, captions overlap its lower edge, and a progress bar runs along the bottom.

**Demo: Vertical 9:16 template: props for the hook and handle, framed clip, captions, progress bar** (rendered video: https://vidmake.app/media/recipe-vertical.mp4)

```json
{
  "fonts": [
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },
    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }
  ],
  "compositions": [{
    "id": "vertical", "description": "Vertical 9:16 template: props for the hook and handle, framed clip, captions, progress bar",
    "width": 720, "height": 1280, "fps": 30, "duration": "5s", "background": "#f4f1ea",
    "props": { "hook": "Three things nobody tells you about video", "handle": "@vidmake" },
    "layers": [
      { "id": "hook", "type": "text", "text": "{{hook}}", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 64, "letterSpacing": -2.8,
        "fill": "#161412", "maxWidth": 600, "lineHeight": 0.96, "anchor": "top", "y": 120, "stagger": { "by": "word", "type": "fadeUp", "each": "60ms" } },
      { "id": "frame", "type": "video", "src": "assets/clip.mp4", "width": 600, "height": 600, "fit": "cover", "y": 680,
        "cornerRadius": 6, "muted": true, "saturation": 0.15, "brightness": 0.4, "start": "0.3s", "enter": "fadeUp" },
      { "id": "subs", "type": "captions", "font": "Schibsted Grotesk", "fontSize": 38, "fontWeight": 800, "fill": "#fbf9f4",
        "highlight": "#c92a26", "stroke": "#161412", "strokeWidth": 8, "y": 900, "maxWidth": 440,
        "items": [
          { "text": "Every frame is a function of time.", "start": "0.6s", "end": "2.6s" },
          { "text": "So you can check any of them.", "start": "2.8s", "end": "4.8s" }
        ] },
      { "id": "handle", "type": "text", "text": "{{handle}}", "font": "JetBrains Mono", "fontSize": 22, "letterSpacing": 2, "fill": "#8a857a", "y": 1120 },
      { "id": "progress", "type": "rect", "anchor": "left", "x": 0, "y": 1276, "height": 8, "fill": "#161412",
        "width": { "from": 0, "to": 720, "duration": "5s", "ease": "linear" } }
    ]
  }]
}
```

- `maxWidth` wraps the hook; the `top` anchor makes it grow downward when it wraps to more lines.
- `fit: "cover"` crops the landscape clip into the square frame; `cornerRadius` rounds video layers too.
- Keep important content inside the platform's safe area (roughly the middle 80% vertically).
- Use even dimensions (720×1280, 1080×1920) for MP4.

## End card

A column [layout group](https://vidmake.app/docs/groups.md) stacks the heading, a row of two tiles and a call-to-action button with
fixed gaps, so nothing needs hand-computed `y` values. The tiles are one repeated `group` whose children read
`i` to pick their label.

**Demo: End card: a stack layout with a thank-you, two next-up tiles and a call to action** (rendered video: https://vidmake.app/media/recipe-end-card.mp4)

```json
{
  "fonts": [
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },
    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }
  ],
  "compositions": [{
    "id": "endCard", "description": "End card: a stack layout with a thank-you, two next-up tiles and a call to action",
    "width": 1280, "height": 720, "fps": 30, "duration": "5s",
    "background": { "type": "radial", "center": [0.5, 0.3], "radius": 1, "stops": ["#f4f1ea", "#e9e4d8"] },
    "layers": [
      { "id": "stack", "type": "group", "layout": { "direction": "column", "gap": 36 }, "exit": "fade",
        "children": [
          { "id": "thanks", "type": "text", "text": "Thanks for watching", "font": "Schibsted Grotesk", "fontWeight": 860,
            "fontSize": 76, "letterSpacing": -3.5, "fill": "#161412", "enter": "fadeUp" },
          { "id": "tiles", "type": "group", "width": 1000, "height": 230, "layout": { "direction": "row", "gap": 32 },
            "children": [
              { "id": "tile", "type": "group", "width": 400, "height": 225, "repeat": { "count": 2, "delay": "0.15s" },
                "start": "0.3s", "enter": { "type": "fadeUp", "distance": 30 },
                "children": [
                  { "id": "card", "type": "rect", "cornerRadius": 4, "fill": "=pick(i, ['#fbf9f4', '#e9e4d8'])",
                    "stroke": "#161412", "strokeWidth": 2 },
                  { "id": "play", "type": "polygon", "sides": 3, "width": 44, "rotation": 90, "y": "42%", "fill": "#161412" },
                  { "id": "next", "type": "text", "text": "${pick(i, ['Up next: captions', 'Up next: recipes'])}",
                    "font": "JetBrains Mono", "fontSize": 15, "letterSpacing": 1.8, "uppercase": true, "fill": "#4a4640", "y": "75%" }
                ] }
            ] },
          { "id": "cta", "type": "text", "text": "Subscribe for more", "font": "Schibsted Grotesk", "fontSize": 26, "fontWeight": 700,
            "fill": "#fbf9f4", "background": "#c92a26", "padding": 18, "cornerRadius": 2, "start": "0.8s", "enter": "pop" }
        ] }
    ]
  }]
}
```

- A text layer with `background`, `padding` and `cornerRadius` makes a button or a chip.
- Inside a layout, `x`/`y` become offsets from the slot; presets and `scale` don't push other items around.
- Children of a repeated group see the copy's `i` and `n`.

## Picture-in-picture

A second video in a group that holds an off-white border like a print's, the video, and a "LIVE" tag. The group
is anchored at its bottom-right corner, so it scales up from the corner with a spring. The same clip plays in both
places from different points (`trimStart: "3s"` on the inset).

**Demo: Picture-in-picture: a second video in a print-bordered, shadowed frame that springs into the corner** (rendered video: https://vidmake.app/media/recipe-pip.mp4)

```json
{
  "fonts": [{ "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }],
  "compositions": [{
    "id": "pip", "description": "Picture-in-picture: a second video in a print-bordered, shadowed frame that springs into the corner",
    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#131210",
    "layers": [
      { "id": "main", "type": "video", "src": "assets/clip.mp4", "width": "100%", "height": "100%", "muted": true,
        "saturation": 0.2, "brightness": 0.4 },
      { "id": "inset", "type": "group", "width": 384, "height": 216, "anchor": "bottom-right", "x": 1232, "y": 672,
        "start": "0.4s", "scale": { "from": 0.6, "to": 1, "spring": { "damping": 13 } },
        "enter": { "type": "fade", "duration": "0.3s" }, "shadow": { "color": "#000a", "blur": 30, "y": 12 },
        "children": [
          { "id": "border", "type": "rect", "width": 400, "height": 232, "cornerRadius": 4, "fill": "#efebe2" },
          { "id": "cam", "type": "video", "src": "assets/clip.mp4", "trimStart": "3s", "width": 384, "height": 216,
            "cornerRadius": 2, "muted": true, "saturation": 0.4, "brightness": 0.85 },
          { "id": "tag", "type": "text", "text": "LIVE", "font": "JetBrains Mono", "fontSize": 14, "fontWeight": 700, "letterSpacing": 2,
            "fill": "#efebe2", "background": "#f05a4e", "padding": 8, "cornerRadius": 2, "anchor": "top-left", "x": 14, "y": 14 }
        ] }
    ]
  }]
}
```

- `shadow` on the group shadows its whole contents at once.
- Both videos are `muted`; to hear the inset (a webcam, a speaker), drop `muted` there and lower the main track's
  `volume`.
- For a round webcam bubble, give the inset video an `ellipse` [mask](https://vidmake.app/docs/masks.md) or a large `cornerRadius`.

## Slideshow with transitions

A group with `"series": true` plays its children one after another; each child's `transition` overlaps it with
the next one (here a push, then a fade). The composition `duration` is left out, so it's computed from the series:
three 1.6 s slides minus two 0.5 s overlaps is 3.8 s.

**Demo: Slideshow: a series group plays three slides back to back with push and fade transitions** (rendered video: https://vidmake.app/media/recipe-slideshow.mp4)

```json
{
  "fonts": [
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },
    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }
  ],
  "compositions": [{
    "id": "slides", "description": "Slideshow: a series group plays three slides back to back with push and fade transitions",
    "width": 1280, "height": 720, "fps": 30, "background": "#f4f1ea",
    "layers": [
      { "id": "deck", "type": "group", "series": true, "children": [
        { "id": "s1", "type": "group", "duration": "1.6s", "transition": { "type": "slideLeft", "duration": "0.5s" }, "children": [
          { "id": "s1-bg", "type": "rect", "fill": "#f4f1ea" },
          { "id": "s1-t", "type": "text", "text": "One", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 200, "letterSpacing": -9, "fill": "#161412" } ] },
        { "id": "s2", "type": "group", "duration": "1.6s", "transition": "fade", "children": [
          { "id": "s2-bg", "type": "rect", "fill": "#161412" },
          { "id": "s2-t", "type": "text", "text": "Two", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 200, "letterSpacing": -9, "fill": "#f4f1ea" } ] },
        { "id": "s3", "type": "group", "duration": "1.6s", "children": [
          { "id": "s3-bg", "type": "rect", "fill": "#e9e4d8" },
          { "id": "s3-t", "type": "text", "text": "Three", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 200, "letterSpacing": -9, "fill": "#c92a26" } ] }
      ] },
      { "id": "count", "type": "text", "text": "${pad(min(floor(gt / 1.1) + 1, 3), 2)} / 03", "font": "JetBrains Mono", "fontSize": 16,
        "letterSpacing": 2, "fill": "#8a857a", "anchor": "bottom-right", "x": 1216, "y": 676 }
    ]
  }]
}
```

```output
deck       group        0.00s    3.80s    3.80s  "3 children"
  s1       group        0.00s    1.60s    1.60s  exit:transition "2 children"
  s2       group        1.10s    2.70s    1.60s  enter:transition exit:transition "2 children"
  s3       group        2.20s    3.80s    1.60s  enter:transition "2 children"
```

`vidmake timeline` shows the overlaps (excerpt above). The page counter uses the global time `gt` because it lives
outside the series. See [series and transitions](https://vidmake.app/docs/series.md).

## More patterns

These are short enough to read without a demo. All of them are checked with `vidmake validate`.

### Staggered list

A column layout with one repeated text layer. The group's `stagger` starts the copies' entrances in turn (and
runs their exits in reverse); `align: "start"` left-aligns them.

```json
{ "id": "list", "type": "group", "x": 400, "width": 600, "height": 400, "anchor": "left", "start": "0.3s",
  "layout": { "direction": "column", "gap": 20, "align": "start" }, "stagger": true,
  "children": [
    { "id": "item", "type": "text", "repeat": 4, "enter": "fadeLeft",
      "text": "${pick(i, ['Write the JSON', 'Validate', 'Look at a storyboard', 'Render'])}", "fontSize": 40 }
  ] }
```

Or one text layer with `\n` between items, `"stagger": "line"` and `"enter": "fadeLeft"`.

### Countdown

```json
{ "id": "countdown", "type": "text", "font": "JetBrains Mono", "fontSize": 64,
  "text": "00:${pad(ceil(max(0, 10 - gt)), 2)}" }
```

`gt` is the global time, so the countdown is independent of the layer's `start`. A monospace font keeps the digits
from shifting.

### Corner logo (watermark)

```json
{ "id": "bug", "type": "image", "src": "assets/logo.svg", "width": 56, "anchor": "top-right", "x": "=w - 32", "y": 32, "opacity": 0.6 }
```

Put it last in `layers` so it's on top. `w` is the composition width, so the margin holds at any size.

### Music ducking under speech

Lower the music while a voice clip plays with `volume` keyframes (gain multipliers, linear between keys):

```json
{ "id": "music", "type": "audio", "src": "assets/music.mp3", "fadeOut": "1s",
  "volume": [[0, 0], ["1s", 0.8], ["2s", 0.8], ["2.5s", 0.25], ["4.5s", 0.25], ["5s", 0.8]] },
{ "id": "voice", "type": "video", "src": "assets/clip.mp4", "start": "2.5s", "duration": "2s", "width": 320, "height": 180 }
```

`vidmake timeline` lists both clips under `Audio:`; render once with `--frames` around the dip to check it by ear.
If anything in the project reacts to the music, `vidmake analyze project.json` shows what the dip does to `amp` and
to the detected beats (quiet beats under a duck stop counting). See [audio](https://vidmake.app/docs/audio.md).

### Handwritten word

Write each letter as its own sub-path (`M ...`) in reading order, then draw them one after another with
[`drawMode: "total"`](https://vidmake.app/docs/paths.md#several-strokes-drawmode) and a pen dot riding the tip:

```json
{ "id": "word", "type": "path", "drawMode": "total", "fill": null, "stroke": "#4a4640", "strokeWidth": 9,
  "d": "M20 80 L60 180 L100 80 M135 80 L135 180 M135 42 L135 44 ...",
  "drawEnd": { "from": 0, "to": 1, "duration": "3s", "ease": "easeInOutSine" } },
{ "id": "pen", "type": "ellipse", "width": 18, "fill": "#c92a26", "attach": "word" }
```

Without `drawMode: "total"` every letter starts at once. The [paths page](https://vidmake.app/docs/paths.md#several-strokes-drawmode)
has both versions side by side.

## Related

- The [demo gallery](https://vidmake.app/demos/) has every demo on this site in one place.
- [Coming from Remotion](https://vidmake.app/docs/remotion.md) maps these patterns to their React equivalents.
- [Inspecting](https://vidmake.app/docs/inspecting.md) and [lint](https://vidmake.app/docs/lint.md) for checking your own versions before rendering.
