Sign inGet started

Docs / Motion, timing and sound

Motion, timing and sound

Motion you can change

Every way something moves is a named piece in a family, and you pick one per family:

"style": { "motion": { "title": "words", "enter": "grow", "cut": "slide", "click": "pulse", "spotlight": "outline", "exit": "drop" } }
Family Built in What it is
title rise, fade, words, slam How a title card comes in
caption fade, words How a caption comes in (words: one word after another)
enter, exit rise, fade, grow · fade, drop How the window arrives and leaves
cut fade, slide, none How one picture gives way to the next
cursor arc, line How the cursor travels
click ring, pulse, none What a click looks like
spotlight dim, outline How something is pointed at
effect pulse, shake Effects a scene asks for: await effect("pulse", target)
animate count, draw, rows, pulse, pop, lift What animate() does to an element of the app: define("animate", "spin", ({ el, at, dur }, kit) => { … })

To change one, or add your own, write it in .scenlit/motion.js (npx scenlit motion new writes the file with two examples). It runs in the film's page:

scenlitMotion((define, kit) => {
  // a new way for one picture to give way to the next: it wipes in from the left
  define("cut", "wipe", (layer, at, dur) => {
    kit.start(layer, "clipPath", "inset(0% 100% 0% 0%)");
    kit.to(layer, "opacity", at, 1, 1);
    kit.to(layer, "clipPath", at, Math.max(dur, 450), "inset(0% 0% 0% 0%)");
  });
});

A piece schedules changes on the film's one clock (kit.start, kit.to, kit.show, kit.hide) instead of animating by itself, which is why any moment of the film can be exported exactly. Defining a piece under a built-in name replaces it. npx scenlit motion list shows every family and the shape of a piece in it.

Staging a film like a launch video

A launch video rarely shows a whole screen. It shows pieces of the product, one at a time, on a set. These steps and settings do that; format: "launch" turns the settings on together.

What How
One piece of the app alone on the stage piece(target): a card, a message, a chart, as large as fits. { with: [other] } puts more beside it; { animate: "count" } moves it once it is there
A sentence as a scene words("But who is late right now?", { highlight: "late" }). { beside: true } keeps the app on screen, stepped to the right
Moving type motion: rise (word by word), letters, bounce (letters drop in, tilted), blur (letters come out of a blur), track (the line closes up from wide spacing), type. big: "painful" sets words larger; sweep: true lays a box of the accent behind the highlighted words; tag: "every month" stamps a tilted label on; stroke: true draws a line through them
Quick swaps words(["Your product ships weekly.", "Your demo", "is from March."], { motion: "letters", for: 800 }): the phrases replace each other in one place. Words after words keep the app away between them
Lines and fields stack: true: each phrase a line under the last, on a numbered grid, the newest lit by a band. field: "#ffd23f": a full-bleed colour cuts in behind the words, with poster type in the ink that reads on it
The scene's own code style: { source: true }: the scene file runs down the left of the frame and the app sits beside it. The line now playing is lit, and the band reaches across to what it does: the camera puts that thing at the band's height. Wide films only; the scene file goes into the film only with this on
Marks on the app mark("circle", { testid: "total" }), mark("underline", …), mark("box", …), mark("arrow", "Send reminder"): drawn in the accent, moving with the camera. mark("stroke") sweeps one across the stage
Text that is typed, or streams in animate(target, "type") (letter by letter, with a caret; a field's value is typed) and animate(target, "stream") (word by word, as an answer arrives)
A screen that builds itself animate({ selector: "main" }, "build"): its blocks arrive in reading order
A new state growing out of the click motion: { cut: "grow" }
The rest out of focus motion: { spotlight: "focus" }, for point()
A window turned in space, never quite still camera: { tilt: [4, -9], drift: 0.04, parallax: 0.05 }
A lit set finish: { light: true, grain: 0.05, vignette: 0.3 }
The logo landing at the end logo: "assets/logo.svg" with end: { sting: true }
Cards and the window on the music's beat music: { file: "pulse", cuts: true } (your own track: add bpm)
Captions in time with the voice motion: { caption: "words" }: with narration, each word comes as it is said (by its length, not by a transcript)
export default {
  format: "launch",
  style: { logo: "assets/ledgerly.svg", music: { file: "calm", cuts: true } },
  async run({ card, open, piece, words, animate, click }) {
    await card("Every month,", "someone forgets to pay.");
    await open("/reports");
    await piece({ testid: "revenue-card" }, { animate: "draw", say: "Revenue is up a third this year." });
    await words("But who is late right now?", { highlight: "late" });
    await piece({ testid: "question" }, { animate: "type" });
    await piece({ testid: "answer" }, { animate: "stream" });
    await words("Ledgerly already knows.", { beside: true, highlight: "knows" });
    await open("/");
    await animate({ selector: ".page" }, "build");
    await click("Send reminder", { say: "One click sends the reminder.", sound: "success" });
    await card("Ledgerly", "Get paid on time.");
  },
};

What this does not give you: live action, people, illustration, or a script. Those are still a person's work.

Speed and timing

What How
The whole film's pace pace in the style (a project, a format or one scene): above 1 gives every step and card more time
One step { pace: 0.5 } makes that step twice as brisk; { hold: 2000 } stays two seconds longer on what it did
A dull stretch await fast(async () => { … }): the steps inside play four times quicker ({ speed: 8 } for more), with a mark on screen
A film of a set length length: 20 on the scene, in seconds
A moment of nothing pause(1500)
The camera and the cursor camera.speed in the style
One animation animate(target, "count", { ms: 1800 })
await click("New invoice", { say: "Start a new invoice and fill it in." });
await fast(async () => {
  await select("Customer", "Halcyon Health");
  await fill("Amount", "6,800");
});
await click("Send invoice", { say: "Send. It is on its way.", hold: 800 });

A step sizes itself: it lasts as long as its caption takes to read, or its narration to be said. Words have no time inside fast, so put the caption on the step before or after. With length, the rests are stretched or shrunk first (to between 0.3 and 4 times the style's pace); if that is not enough, the whole film plays up to a half quicker or slower for the rest of the way. A film with narration is never sped up, so it may come out longer than asked.

Sound

Music and sound effects are part of the style, so a project, a format or one scene can set them. Both play in the page and are mixed into the exported MP4.

Music under one film is part of the style, so a format or a single scene can have its own:

style: { music: { file: "assets/bed.mp3", volume: 0.2, start: 12, fadeIn: 2, fadeOut: 1.5, duck: 0.45, loop: true } }
Setting What it does
file A track in your project, or a built-in bed: calm (slow chords) or pulse (the same chords with a soft beat). The beds are made in code: no file to ship, nothing to license
volume 0 to 1 (0.15 when left out)
start Where in the track to begin, in seconds
fadeIn, fadeOut Seconds to come in at the start and go out at the end (0: none)
duck How far the music sinks while narration is speaking: 0.45 is down to 45%
loop Start the track again when it ends (on by default)

The viewer has their own controls in the player: a sound button (or the M key) and a volume slider, remembered for next time. They act on everything: music, narration and effects.

Sound effects. Sixteen come built in, made in code, so there is no file to ship and nothing to license:

For Sounds
Hands tap (a click), key (typing), tick
Things arriving and leaving pop, swipe, whoosh, rise (a build-up), boom, thud
Results chime, success, error, ding, notify, sparkle, shutter

npx scenlit sounds lists them, and --save writes each as a .wav to listen to. Your own go in .scenlit/sounds/<name>.wav (or .mp3, .m4a, .ogg) and win over a built-in one of the same name.

There are four ways to say where a sound plays:

// 1. the style: one sound for each kind of moment (a project, a format or one scene)
style: { sounds: { click: "tap", type: "key", cut: "swipe", end: "thud", volume: 0.5 } },

// 2. a step: when what it did shows, or say when, how much later and how loud; a list plays several
await click("Pay", { sound: "success" });
await animate({ selector: "table" }, "rows", { sound: { name: "ding", at: "end", delay: 200, volume: 0.6 } });

// 3. a step of its own
await sound("notify");

// 4. a moment of the film itself: seconds from the start, from the end (negative), or "title", "app", "end"
cues: [{ name: "rise", at: "end", delay: -1200 }, { name: "notify", at: 2.5 }],

The kinds of moment a style can give a sound to: click, type (each key), caption, card (every card, unless title, chapter or end says otherwise), enter and exit (the window), cut (the page changes between two steps), zoom, point, label, animate, fast (a fast-forward begins). A step's at is result (the default), start or end. A film with sound waits for a click before it plays, as browsers require.

Narration

A step's say is its caption and, with a voice, what is spoken. When the spoken sentence should be longer than the caption: say: { text: "Paid.", voice: "And just like that, the order is paid." }.

Who speaks is a provider, set under voice:

Provider What
say The Mac's own voice: free, for drafts
elevenlabs, openai ELEVENLABS_API_KEY / OPENAI_API_KEY; cost credits, and only ever run from scenlit voice
command Any program: "command": "piper -m en.onnx -f {file}" (the line comes on standard input, or as {text})
./tools/voice.mjs Your own: export default async (text, { file, voice, model, lang }) => { /* write an mp3 to file */ }

You, in the corner. A scene can carry a recording of a person, shown in a round bubble and kept in step with the film; its sound is the narration:

presenter: "assets/me.mp4",
// or: presenter: { file: "assets/me.mp4", at: "bottom left", size: 0.24, round: true, start: 1.5, volume: 1 },

Record yourself while the film plays, so the two are the same length. The bubble is there from the title to the end card, music sinks under your voice, and the MP4 and the web export both carry the recording. Reading its length needs ffmpeg. The film does not yet follow what you say: the steps keep their own timing.

Your own recording. A step can play a file of yours as its narration, with no provider at all:

await click("Pay", { say: { text: "Paid.", file: "voice/paid.mp3" } });

text is still the caption (leave it out for none), and the step lasts as long as the recording. The file is a path in your project; reading its length needs ffmpeg. A translated film does not use it: it is in the language you spoke.

"says": { "Scenlit": "Seen lit" } fixes how a word is pronounced; "voices": { "de": { "voice": "Anna" } } sets a voice per language. A line is recorded once and reused until its words or its voice change.

From the README of Scenlit 0.1.0. Read it on GitHub