bramwelldocs

Developers

Engine API

For tinkering by hand. A reel is one ES module; every frame is a pure function of time.

A scene

js
export const meta = { W: 1080, H: 1920, fps: 30, duration: 25 };              // always reel size
export const sound = { voice: 'audio/vo.mp3', voiceAt: 0.15, music: 'procedural', duck: 8 };
export async function init(env) { /* load words, the plan */ }
export function draw(ctx, t, env) { /* frame t; no state between frames */ }
export function cues() { return [{ t: 1.2, sfx: 'pop', gain: -12 }]; }

Rules: no Math.random() or Date.now() (use rng(seed)), anchor motion to spoken words with at(VO, 'phrase'), and keep things inside x 72–930, y 220–1540.

core.js

rng(seed) · hash(v) · clamp(x, a, b) · lerp · seg(t, start, dur) → 0..1 · win(t, a, b, fin, fout) · ease.{outCubic, inOutCubic, outBack, outExpo, ink, …} · boil(t) · squash(p) · wobbleOut(p)

ink.js

C (palette) · paper(ctx, W, H, color) · scrawl(ctx, pts, { w, color, seed, t, progress }) · line · ellipse · coil · fill · shadow

cast.js

makeCharacter(seed, spec) · makeCast(seed, n, overrides) · drawCharacter(ctx, spec, { x, y, s, t, pose, from, poseK, face, talk, walk, reveal, pop, look, tilt, flip }) · extendCast({ hairs, poses, accessories }) · HAIRS · POSES · ACCESSORY_NAMES

env.js

set(ctx, name, { W, H, ground, s, p, t, tone }) · prop(ctx, name, { x, y, s, p, t, tone, flip, seed }) · ground(ctx, o) · defineProp(name, fn) · defineSet(name, fn) · PROP_NAMES · SET_NAMES

openers.js

OPENERS[name] → { dur, overlap, draw(ctx, t, o), cues(at) } · OPENER_FOR[family] · defineOpener(name, def)

transitions.js

transition(ctx, name, t, at, o) · playPlan(ctx, t, plan, o) · TRANSITIONS · defineTransition(name, { dur, sfx, draw(ctx, p, o) })

director.js

direct(script, { words, tone, voiceAt, force }) → plan · beatAt(plan, t) · splitBeats · hookFamily · beatKind · pickSet · pickPose · stressWord · pickScribble · pickTransition

A plan looks like:

json
{
  "hook": { "text": "Still using stock clipart? Bold choice.", "family": "roast", "why": "…" },
  "opener": { "name": "scratchReveal", "why": "fits a roast hook" },
  "set": { "set": "blank", "why": "…" },
  "duration": 24.5,
  "beats": [{ "i": 1, "kind": "reveal", "start": 2.9, "end": 7.7, "pose": "wave",
              "stress": { "word": "twice.", "at": 7.1 }, "scribble": { "kind": "circle", "at": 7.05 },
              "transitionIn": { "name": "inkIris", "at": 2.72, "dur": 0.7, "why": "a reveal: open on the subject" } }],
  "cues": [{ "t": 2.37, "sfx": "splat", "gain": -11 }],
  "notes": []
}

scribbles.js

underline · circle · arrow · burst · squiggle · scratch · hatch · bubble · frame · spiral · check · heart · sparkle · splat · inkWipe. All take (ctx, { …, p, t, sw, color }).

type.js

FONT · font(ctx, o) · layout(ctx, lines, { x, y, size, align }) · words(ctx, L, t, { start, stagger, mode }) · find(L, text) · span(L, a, b) · captions(ctx, words, t, o) · label

brand.js

logo · mark · chrome · card · button · toast · guides

timeline.js

loadWords(url) · at(words, phrase, fallback, after) · until(words, phrase, fallback) · beats(list, start) · cueSheet() → { cue, list }

config.js

applyConfig(cfg, base): applied by the stage from bramwell.config.json; you rarely call it yourself.