Animaku — Code-Driven Canvas Animation Studio
Create polished short-form animated videos from code using the Animaku HTML5 Canvas 2D engine, edge-tts neural narration, and headless Playwright + FFmpeg rendering.
Workflow
1. Plan Storyboard & Narration (script.json)
Create a project folder under projects/<slug>/ (or examples/<slug>/) with script.json:
- Choose a voice from presets.md (e.g.,
id-ID-ArdiNeural,id-ID-GadisNeural,en-US-GuyNeural). - Wrap emphasis keywords in
*asterisks*so kinetic subtitles automatically highlight them in yellow (e.g.,"Nahan *fantasi* liar"). - Add
pauseAfter(seconds) for dramatic beats between lines.
{
"voice": "id-ID-ArdiNeural",
"rate": "+6%",
"cues": [
{ "id": "c1", "text": "Nahan *fantasi* liar", "pauseAfter": 0.25 },
{ "id": "c2", "text": "Padahal masih *ngecat* tembok!", "pauseAfter": 0.3 }
]
}
2. Generate Narrator Audio & Exact Timestamps
Run narrator.py to synthesize narrator.mp3 and timing.json:
python .agents/skills/animaku/scripts/narrator.py --script projects/<slug>/script.json --out-dir projects/<slug>
3. Code the Animated Canvas Scene (scene.js)
Write projects/<slug>/scene.js importing helpers from ../../engine/animaku.js (see canvas-api.md):
- Export
meta(width,height,fps) matching the requested aspect ratio (1080x1920portrait by default). - Export
init({ width, height, timing, duration })to pre-build deterministic particle systems or background props. - Export
render(ctx, { width, height, t, duration, timing, state }):- Background: Use
VFX.drawBlurredLayer(...)for depth-of-field rooms, doorways, or gradients. - Camera: Wrap world-space elements in
cam.begin(ctx, width, height, t)...cam.end(ctx)with smooth pan/zoom and impacttraumashake. - Characters & Props: Use
drawCharacter(ctx, cfg, state, t)with'flat-glow'or'stickman-toon'style, rim-light glow, andVFX.drawMotionLines(...)/VFX.drawSweatDrop(...). - VFX & Post-Processing: Add
VFX.drawParticles(...)andVFX.drawPostProcess(ctx, width, height, { vignette, lightLeak, grain, t }). - Kinetic Subtitles: Call
drawKineticSubtitles(ctx, width, height, timing.cues, t)outside the camera transform so captions stay crisp and centered.
- Background: Use
4. Render to MP4
Run render.mjs to capture deterministic frames via headless Edge/Chrome and encode with FFmpeg:
node .agents/skills/animaku/scripts/render.mjs --scene projects/<slug>/scene.js --timing projects/<slug>/timing.json --audio projects/<slug>/narrator.mp3 --out projects/<slug>/output.mp4 --w 1080 --h 1920 --fps 30
Optional: pass --bgm path/to/music.mp3 to mix background music at 18% volume under the narrator.
5. Verify Output
Confirm the rendered video has valid video and audio streams and non-zero duration:
ffprobe -v error -show_entries format=duration -show_entries stream=codec_type,width,height -of default=noprint_wrappers=1 projects/<slug>/output.mp4