代码生成视频 / 规格模板派

像素巫师施法:自包含 HTML 规格 Pixel-Art Wizard Casting a Spell

规格模板派10s · 1:1分享者:Majid Manzarpour (@majidmanzarpour)· 出处:X @majidmanzarpour(3 源核验一致:joeseesun、fluxaipro.art、claudevideo.org)

预览为我们用这条提示词自行生成(seek(t) 逐帧渲染),非原作者成片

▶ 在线运行

Original Prompt

Create a single self-contained HTML file that renders an animated pixel art wizard casting a spell, using vanilla JavaScript and Canvas 2D. No external assets, libraries, or network requests.

RENDERING
- Draw everything to an offscreen canvas at a fixed logical resolution of 128x96, then blit to a fullscreen display canvas scaled by the largest integer factor that fits the window, centered, with imageSmoothingEnabled = false and CSS image-rendering: pixelated.
- All drawing snaps to integer coordinates on the logical canvas. No sub-pixel positions, anti-aliasing, gradients, or shadowBlur.
- Fixed palette of ~24 hex colors: deep blues/purples for night sky, warm robe tones, 3-4 bright magic colors. Every pixel comes from this palette.

CHARACTER
- Build the wizard procedurally from filled rects and pixel runs, ~24x32 logical pixels: pointed hat with a bend, long beard, two-shade robe with darker outline, staff with a gem at the tip.
- Parameterize the pose (staff angle, arm raise, head tilt, robe sway). Animate parameters smoothly, then quantize to the pixel grid each frame so motion reads as an 8-12 fps pixel animation feel even though the loop runs at 60fps.

ANIMATION
- Looping state machine: IDLE (2-frame bob, beard sway) -> CHARGE (staff raises, gem flickers, sparks spiral inward) -> CAST (bright burst, projectile fires across the scene, 1-2 pixel screen shake) -> RECOVER (settle back). Ease pose parameters between keyframes.
- Pooled allocation-free particle system: preallocate and reuse. Sparks orbit the gem during CHARGE, explode outward on CAST, each particle stepping its palette index from white to magic color to dark before despawn. Snap particle positions to the grid when drawing.
- Fixed 60hz timestep update with rAF rendering. Zero object allocation inside the loop.

SCENE
- Minimal background: dark sky, a few twinkling 1px stars, moon, stone floor line. Character silhouette must read clearly.
- Subtle 1px rim light on the wizard from the gem, brightening during CHARGE and CAST.

QUALITY BAR
- Crisp pixels at any window size, seamless loop, stable 60fps, readable silhouette. Should look like a polished 16-bit sprite animation, not vector shapes scaled down.
copy original

中文对照

〔要点对照〕创建单个自包含 HTML 文件,用 vanilla JavaScript 和 Canvas 2D 渲染一个施法的像素艺术巫师动画,不用外部素材、库或网络请求。
渲染:一切画在固定逻辑分辨率 128x96 的离屏画布上,再以适配窗口的最大整数倍缩放 blit 到全屏显示画布,居中,imageSmoothingEnabled=false 且 CSS image-rendering: pixelated;所有绘制吸附整数坐标,禁子像素、抗锯齿、渐变、shadowBlur;固定约 24 色调色板(夜空深蓝紫、长袍暖色、3-4 个亮魔法色),每个像素都出自此调色板。
角色:用填充矩形与像素段程序化构建巫师(约 24x32 逻辑像素):带弯折的尖帽、长胡须、双色长袍加深色描边、顶端镶宝石的法杖;姿态参数化(杖角、抬臂、歪头、袍摆),参数平滑动画后每帧量化到像素网格,让动作有 8-12 fps 像素动画的观感(尽管循环跑 60fps)。
动画:循环状态机 IDLE(2 帧浮动、须摆)→ CHARGE(举杖、宝石闪烁、火花螺旋吸入)→ CAST(爆亮、弹体横穿、1-2 像素屏震)→ RECOVER(回落);池化零分配粒子系统,火花调色板索引自白→魔法色→暗再消亡;60hz 定步长更新,循环内零对象分配。
场景:极简背景(暗天空、1px 闪烁星、月亮、石地平线),剪影清晰可读;宝石给巫师一层微妙的 1px 轮廓光,CHARGE/CAST 时增亮。
质量标准:任意窗口尺寸像素锐利、无缝循环、稳定 60fps、剪影可读——像打磨过的 16-bit 精灵动画,而不是缩小的矢量。
复制对照

规格派(spec-style)的教科书。 不描述“感觉”,直接写验收标准:128×96 逻辑分辨率 + 整数倍缩放 + 禁用平滑,像素感就从根上锁死;8-12fps 量化 + 60fps 循环,是“16-bit 观感”与“流畅动画”的兼容术;零分配对象池把 GC 卡顿拒之门外。

四个段落就是四层架构:RENDERING(渲染管线)→ CHARACTER(资产构建:矩形和像素段拼角色,完全程序化,无图片)→ ANIMATION(行为:状态机 + 粒子池)→ SCENE + QUALITY BAR(氛围与验收线)。照这个骨架换题材,任何像素动画 brief 都能写出来。

最值钱的两条硬约束:quantize to the pixel grid each frame(每帧量化到像素网格——平滑参数算完后取整,才有“逐格跳动”的老动画手感);Zero object allocation inside the loop(循环内零分配——性能红线,专业味的隐形来源)。

#规格模板#像素艺术#状态机#零分配