API Referenceeffect-motion
effect-motion
effect-motion — deterministic, frame-exact motion graphics in code.
effect-motion
effect-motion — deterministic, frame-exact motion graphics in code.
Remarks
Scenes are pure descriptions of animation: the same scene produces the same frames on every run and every machine, because time is counted in frames rather than read from a clock and randomness comes from a seed.
Where to start:
Scene— declare a scene, create entities, compose animations, run it.Motion— animate over a duration, with easing.Physics— animate with springs, whose length emerges from the sim.Entity— the shapes, andvec3for positions.Color,Timing— the palette and the easing curves.Camera— aiming, orbiting, and dollying the viewpoint.
Prefer deep per-actor imports over this barrel:
import * as Motion from "effect-motion/Motion";
import * as Scene from "effect-motion/Scene";Example
A complete scene.
import * as Color from "effect-motion/Color";
import * as Motion from "effect-motion/Motion";
import * as Scene from "effect-motion/Scene";
export const scene = Scene.make(
function* () {
const dot = yield* Scene.instantiate("Circle", {
radius: 24,
fillColor: Color.hex("#7f5af0"),
});
yield* dot.pipe(
Motion.moveTo({ x: 430 }, "1 second", "easeInOutCubic"),
Motion.fadeTo(0, "400 millis"),
);
},
{ width: 500, height: 300, backgroundColor: Color.rgba(22, 22, 29) },
);Namespaces
- Audio
- Camera
- Color
- Entity
- Font
- Image
- Instance
- Motion
- Particles
- Phaser
- Physics
- Resource
- Runner
- Scene
- Timing