effect-motion
Learn

Timing

Durations are exact frame counts; easings shape the path between start and target

Every duration-based animator takes a duration and an optional easing.

Durations are frame counts

"1 second", "600 millis", "2 seconds" — any Effect duration works. At the scene's frame rate a duration is an exact number of frames, and the final frame lands exactly on the target value. There is no drift to accumulate: a chain of hundred tweens ends precisely where the math says.

Easings shape the in-between

An easing maps normalized time to normalized progress. Pass one by name:

Motion.moveTo(dot, { x: 780 }, "2 seconds", "easeOutExpo");

The named curves are the standard families — easeIn/easeOut/easeInOut crossed with Sine, Quad, Cubic, Quart, Quint, Expo, Circ, Back, Elastic, Bounce — plus linear (the default). An unknown name fails loudly with a defect naming the offender, not a silent fallback.

You can also pass a function (t: number) => number directly, for a custom curve.

Springy looks without physics: easeOutElastic and easeOutBounce give overshoot and bounce within a fixed duration. When you want real physics — where the settling time emerges from the simulation instead of being chosen — that's springs, the next page.

The race

Same distance, same two seconds, four different curves — the only thing that differs is when each dot covers which part of the distance. They all land on the same frame:

0:00
import * as Color from "effect-motion/Color";import * as Entity from "effect-motion/Entity";import * as Motion from "effect-motion/Motion";import * as Scene from "effect-motion/Scene";// Same distance, same duration — only the pacing differs. Every easing is a// pure curve over the same frame count, so all four land on the same frame.const RACERS: ReadonlyArray<{	label: string;	easing?: "easeInOutCubic" | "easeOutExpo" | "easeOutBounce";	color: string;}> = [	{ label: "linear", color: "#7f5af0" },	{ label: "easeInOutCubic", easing: "easeInOutCubic", color: "#2cb67d" },	{ label: "easeOutExpo", easing: "easeOutExpo", color: "#ff8906" },	{ label: "easeOutBounce", easing: "easeOutBounce", color: "#e53170" },];export const scene = Scene.make(	"easing race",	function* () {		const motions = [];		for (const [i, racer] of RACERS.entries()) {			const y = 270 - i * 180;			yield* Scene.instantiate("Text", {				position: Entity.vec3({ x: -780, y: y + 80 }),				text: racer.label,				fontSize: 36,				fillColor: Color.hex("#94a3b8"),			});			const dot = yield* Scene.instantiate("Circle", {				position: Entity.vec3({ x: -780, y }),				radius: 44,				fillColor: Color.hex(racer.color),			});			motions.push(				racer.easing					? Motion.moveTo(dot, { x: 780 }, "2 seconds", racer.easing)					: Motion.moveTo(dot, { x: 780 }, "2 seconds"),			);		}		yield* Scene.all(motions);		yield* Motion.wait("600 millis");	},	{ width: 1920, height: 1080, backgroundColor: Color.rgba(22, 22, 29) },);

Next: Physics.

On this page