javascript-animation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseJavaScript Animation (every frame drawn in code)
JavaScript动画(每一帧都用代码绘制)
Make short animated films where every pixel is computed: no images, no fonts to load, no libraries. One HTML file holds the whole piece; a headless browser seeks it frame by frame into an MP4.
制作每像素都被计算的短动画电影:没有图片,没有加载字体,没有库。一个HTML文件包含全部内容;一个无头浏览器逐帧查找并生成MP4。
Model
模型
Built and tested with Claude Opus 5.5; drawing quality depends heavily on the model. The self-check below needs image input: if the current model can't see images, say so to the user and treat visual verification as not done. Other models are untested; if the result looks crude, say that a stronger model is likely to help rather than claim it's the best possible.
使用Claude Opus 5.5构建和测试;绘图质量很大程度上取决于模型。下面的自检需要图像输入:如果当前模型无法看到图像,请告知用户并将视觉验证视为未完成。其他模型未经过测试;如果结果看起来粗糙,请说明更强的模型可能会有帮助,而不要声称这是最好的。
Default flow: don't stop to ask
默认流程:不要停下来询问
Run straight through. Pick sensible defaults and mention alternatives at delivery. Ask before starting only if there is no subject at all (e.g. "make an animation", nothing else).
- Read the brief. Infer the form (story, explainer, poem, loop, interactive page), length (default 30-45 s) and aspect (default 1080x1080) from what the user said. On-screen text is in the language the user wrote the brief in; make it bilingual only if they ask or the audience clearly is. has a short structure for each form.
references/forms.md - Write a look and sound brief from the subject and the audience. Decide each of these explicitly, with one line of why: style (ingredients in ), palette (3-5 colours with one lead), line (outlined or not,
references/techniques.md), ground (LOOK.wobble), boil, type (LOOK.ground,LOOK.font), framing, pace; and for sound: template (LOOK.labelStyleorgroove), kit, harmony, tempo. The starter's values are placeholders, not a house style. Never reuse the look or sound of a previous piece by default: two different subjects should not come out looking or sounding alike. If the user points at someone else's piece ("like that viral one"), borrow its techniques, never its characters, story or compositions.score - Beat grid, storyboard and blocking, as data (). Tempo and sections first; then a shot list with a pace that fits the form (pace table in
references/storyboard.md; each shot with framing, camera move, action, the beat it lands on, its sound, its transition); then the blocking tracks of one continuous world. These go into the page asreferences/storyboard.md,BPM,SECTIONS,SHOTS: the scenes, camera and soundtrack all read them, so picture and sound line up by construction. Check the story logic: every beat caused by the one before, the metaphor visible in the picture.EVENTS - Build from . It is already storyboard-driven: one world drawn in world coordinates,
templates/starter.htmlper shot,withCamerafor every piece of text and every key object. Replace the placeholder palette and the demo world. Keep the contract:claim()is a pure function of the frame number. Usedraw(frame)/rng(seed), neverhash2()orMath.random.Date - Self-check, then render (next section). Fix and re-check until clean.
- Deliver: the MP4 and the HTML (it plays live in a browser; clicking starts the sound). Then, in one or two lines, offer what can change: another look, AI music instead of synthesized, different length.
For music, use the skill (default: synthesized in the page with Web Audio, no key needed).
soundtrack直接执行。选择合理的默认值,并在交付时提及替代方案。仅当完全没有主题时才在开始前询问(例如“制作一个动画”,没有其他内容)。
- 阅读简报。 从用户所说的内容推断形式(故事、说明、诗歌、循环、交互页面)、长度(默认30-45秒)和宽高比(默认1080x1080)。屏幕文字使用用户编写简报的语言;仅当用户要求或观众明显是双语时才使其成为双语。对每种形式都有简短的结构。
references/forms.md - 根据主题和受众编写视觉和声音简报。 明确决定以下每一项,并附一行原因:风格(中的成分)、调色板(3-5种颜色,带一个主色)、线条(是否描边,
references/techniques.md)、地面(LOOK.wobble)、沸腾、字体(LOOK.ground,LOOK.font)、取景、节奏;以及声音:模板(LOOK.labelStyle或groove)、套件、和声、速度。起始值是占位符,不是标准风格。默认情况下永远不要重复使用以前作品的视觉或声音:两个不同的主题不应该看起来或听起来相同。如果用户指向别人的作品(“像那个病毒视频一样”),借用其技术,但绝不借用其角色、故事或构图。score - 拍子网格、故事板和分镜作为数据()。先确定速度和章节;然后是一个符合形式节奏的镜头列表(
references/storyboard.md中的节奏表;每个镜头带取景、相机移动、动作、落在哪个拍子上、声音、转场);然后是一个连续世界的分镜轨道。这些以references/storyboard.md、BPM、SECTIONS、SHOTS的形式进入页面:场景、相机和配乐都读取它们,因此画面和声音按构造对齐。检查故事逻辑:每个拍子由前一个引起,隐喻在画面中可见。EVENTS - 从构建。 它已经是故事板驱动的:一个在世界坐标中绘制的世界,每个镜头
templates/starter.html,每段文本和每个关键对象都用withCamera。替换占位调色板和演示世界。保持契约:claim()是帧号的纯函数。使用draw(frame)/rng(seed),绝不要使用hash2()或Math.random。Date - 自检,然后渲染(下一节)。修复并重新检查直到干净。
- 交付: MP4和HTML(它在浏览器中实时播放;点击开始声音)。然后,用一两句话提供可以更改的内容:另一种外观、AI音乐代替合成声音、不同的长度。
对于音乐,使用技能(默认:在页面中使用Web Audio合成,无需密钥)。
soundtrackSelf-check (the agent does this; the user never sees it)
自检(代理执行;用户永远看不到)
bash
node scripts/render.mjs piece.html sheet.jpg --sheet 1 # one frame per second, stepping off cuts
node scripts/render.mjs piece.html shot --stills 90,300,610 # specific moments
node scripts/render.mjs piece.html piece.mp4 # full render (+ soundtrack if the page has one)
node scripts/asset-audit.mjs piece.html # proves zero-asset: exit 1 if anything is loaded or embedded
node scripts/layout-check.mjs piece.html # text colliding with text, or straddling a claimed object
node ../soundtrack/scripts/sync-check.mjs piece.mp4 --cues-file piece.cues.json # cuts on the beat, no startleThen two passes by eye, both in :
references/qc.md- Storyboard conformance: a still at the action beat of every shot, read against its row (is the actor where the blocking says, doing what the row says?).
- Director pass: the contact sheet at 2 frames per second (), scored for pace against the form, framing variety, dead frames, whether every action has its sound, and whether the look fits the audience. Do at least two rounds. Render stills of the frames you change instead of re-rendering the whole film each time.
--sheet .5
bash
node scripts/render.mjs piece.html sheet.jpg --sheet 1 # one frame per second, stepping off cuts
node scripts/render.mjs piece.html shot --stills 90,300,610 # specific moments
node scripts/render.mjs piece.html piece.mp4 # full render (+ soundtrack if the page has one)
node scripts/asset-audit.mjs piece.html # proves zero-asset: exit 1 if anything is loaded or embedded
node scripts/layout-check.mjs piece.html # text colliding with text, or straddling a claimed object
node ../soundtrack/scripts/sync-check.mjs piece.mp4 --cues-file piece.cues.json # cuts on the beat, no startle然后通过目视检查两遍,都在中:
references/qc.md- 故事板一致性:每个镜头的动作拍子处的一个静止画面,与行对比阅读(演员是否在分镜所说的地方,执行行所说的动作?)。
- 导演检查:以每秒2帧的预览图(),按形式、取景多样性、死帧、每个动作是否有声音以及外观是否适合受众来评分。至少做两轮。渲染你改变的帧的静止画面,而不是每次都重新渲染整部电影。
--sheet .5
Only if triggered
仅当触发时
| When | Do |
|---|---|
| A character appears in more than one scene | Before the scenes, render the character alone (expressions + poses) and check it yourself against |
| The user supplied photos of real people, pets or places | Build the character from the photos with the extraction method in |
| It's a real-person piece and the user is present | At delivery (not before), offer to use photos of key props or people to make it more theirs. |
| Text or a speech bubble follows a moving character | Place it with |
| On-screen text is not Latin (Chinese, Japanese...) | Use a CJK font stack; check every glyph renders (monospace fonts silently swap missing glyphs, e.g. |
| The page will be published as a web page | Deliver the HTML; keep the live preview loop and the click-to-play audio. |
| 当 | 做 |
|---|---|
| 一个角色出现超过一个场景 | 在场景之前,单独渲染角色(表情+姿势)并你自己根据 |
| 用户提供了真人、宠物或地点的照片 | 使用 |
| 这是一个真人作品且用户在场 | 在交付时(不是之前),提供使用关键道具或人物的照片来使其更具个人色彩。 |
| 文本或气泡跟随移动角色 | 使用 |
| 屏幕文本不是拉丁文字(中文、日文...) | 使用CJK字体栈;检查每个字形是否渲染(等宽字体静默替换缺失字形,例如 |
| 页面将作为网页发布 | 交付HTML;保留实时预览循环和点击播放音频。 |
Rules that prevent the common failures
阻止常见失败的规则
- Pure function of time. No state, no CSS animations, no accumulated physics: compute each frame from
requestAnimationFramealone, or the render and the preview disagree.t - Boil, don't jitter. Change the wobble seed every 4 frames (), not every frame. Every frame reads as noise; ~7.5 changes a second reads as hand-drawn.
BOIL - Rounded forms for bodies. Build figures from ellipses and rounded rectangles. Raw polygons with few points read as signs (a pentagon hand, a box torso).
- Pick the angle that makes the pose read. A long body with stubby limbs from the side reads as a caterpillar; the same pose from the front (foreshortened) reads as a baby on its tummy.
- Draw back to front, explicitly. Back hair, then body, then neck, then face, then front hair. Most "something covers the face" bugs are draw order.
- Hit points on cuts and actions. Every cut and every visible action is in /
EVENTS; the soundtrack lands on them (seeCUES).soundtrack - Text never collides. Claim every text box and key object; must print CLEAN. A caption overlapping a monitor edge or a face looks careless, and eyes on a contact sheet miss it.
layout-check
- 时间的纯函数。 没有状态,没有CSS动画,没有累积物理:仅从
requestAnimationFrame计算每个帧,否则渲染和预览不一致。t - 沸腾,而不是抖动。 每4帧改变抖动种子(),而不是每帧。每帧变化会被视为噪声;每秒大约7.5次变化会被视为手绘。
BOIL - 身体使用圆角形状。 用椭圆和圆角矩形构建图形。少点的原始多边形看起来像标志(五边形手、盒子躯干)。
- 选择使姿势清晰的角度。 从侧面看,长身体和短肢看起来像毛毛虫;同样的姿势从正面(透视缩短)看起来像趴着的婴儿。
- 从后到前明确绘制。 后发,然后身体,然后脖子,然后脸,然后前发。大多数“某物遮住脸”的bug是绘制顺序。
- 在剪辑和动作上击中节点。 每个剪辑和可见动作都在/
EVENTS中;配乐落在它们上面(见CUES)。soundtrack - 文本永不碰撞。 声明每个文本框和关键对象;必须打印CLEAN。字幕与显示器边缘或人脸重叠看起来草率,而预览图上的眼睛会漏掉它。
layout-check
Files
文件
- : drawing library (ink, illustration, flat/blueprint primitives, labels, paper, filtered layers),
templates/starter.html,withCamera/claim, and a storyboard-driven two-shot skeleton.placeFree - : MP4 / stills / contact sheet.
scripts/render.mjsandwindow.CUESare optional: on a full render it writeswindow.SCOREand muxes the SCORE soundtrack (no SCORE = silent MP4). Needs an even canvas size.<out>.cues.json - : static scan + live network check for anything loaded or embedded.
scripts/asset-audit.mjs - : reads
scripts/layout-check.mjsover the whole film and lists text collisions with their times.window.LAYOUT - : beat grid, shot list, blocking, continuity and story logic.
references/storyboard.md - : tested drawing techniques (ink, spot-color print, single-line engraving, words as shapes, marker fills, illustration shapes).
references/techniques.md - : structure notes per form.
references/forms.md - : only when there's a character.
references/character.md - : the self-check list.
references/qc.md
Requirements: Node 18+, ffmpeg, Chrome (or ), and in the folder you run the scripts from (your project, not the skill folder).
npx playwright install chromiumnpm i playwright-core- :绘图库(墨水、插图、平面/蓝图图元、标签、纸张、滤镜层),
templates/starter.html,withCamera/claim,以及一个故事板驱动的双镜头骨架。placeFree - :MP4 / 静止画面 / 预览图。
scripts/render.mjs和window.CUES是可选的:在完整渲染时写入window.SCORE并混合SCORE配乐(无SCORE = 静音MP4)。需要偶数画布尺寸。<out>.cues.json - :静态扫描 + 实时网络检查任何加载或嵌入的内容。
scripts/asset-audit.mjs - :读取整个影片的
scripts/layout-check.mjs并列出文本碰撞及其时间。window.LAYOUT - :拍子网格、镜头列表、分镜、连续性和故事逻辑。
references/storyboard.md - :经过测试的绘图技术(墨水、专色印刷、单线雕刻、文字作为形状、标记填充、插图形状)。
references/techniques.md - :每种形式的结构说明。
references/forms.md - :仅当有角色时。
references/character.md - :自检清单。
references/qc.md
要求:Node 18+、ffmpeg、Chrome(或),以及在你运行脚本的文件夹中(你的项目文件夹,不是技能文件夹)。
npx playwright install chromiumnpm i playwright-core