ai21.net
语言

像素风巫师施法动画

演示视频

像素风巫师施法动画 — 1像素风巫师施法动画 — 2像素风巫师施法动画 — 3

提示词

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 at 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.

中文译文

创建一个单一的自包含 HTML 文件,使用原生 JavaScript 和 Canvas 2D 渲染一个正在施法的像素艺术巫师动画。不得使用外部资源、库或网络请求。

渲染
- 将所有内容绘制到固定逻辑分辨率为 128x96 的离屏 canvas,然后按适配窗口的最大整数倍缩放、居中 blit 到全屏显示 canvas,设置 imageSmoothingEnabled = false 和 CSS image-rendering: pixelated。
- 所有绘制都对齐到逻辑 canvas 上的整数坐标。不得有子像素位置、抗锯齿、渐变或 shadowBlur。
- 固定调色板约 24 种十六进制颜色:夜空的深蓝/紫色、温暖的袍子色调、3-4 种明亮的魔法颜色。每个像素都来自这个调色板。

角色
- 用填充矩形和像素段程序化构建巫师,约 24x32 逻辑像素:带弯折的尖顶帽、长胡子、带较深色描边的双色长袍、顶端镶有宝石的法杖。
- 将姿势参数化(法杖角度、手臂抬起、头部倾斜、长袍摆动)。平滑地动画化参数,然后每帧量化到像素网格,使动作呈现出 8-12 fps 像素动画的观感,即使循环以 60fps 运行。

动画
- 循环状态机:IDLE(2 帧上下浮动,胡子摆动)-> CHARGE(法杖抬起,宝石闪烁,火花向内螺旋)-> CAST(明亮爆发,投射物飞越场景,1-2 像素的屏幕震动)-> RECOVER(恢复稳定)。在关键帧之间缓动姿势参数。
- 池化、零分配的粒子系统:预分配并复用。CHARGE 期间火花环绕宝石旋转,CAST 时向外爆发,每个粒子在消失前将其调色板索引从白色逐级切换到魔法色再到暗色。绘制时将粒子位置对齐到网格。
- 固定 60hz 时间步更新,配合 rAF 渲染。循环内零对象分配。

场景
- 极简背景:暗色天空、几颗闪烁的 1px 星星、月亮、石头地面线。角色剪影必须清晰可辨。
- 宝石在巫师身上投下细微的 1px 轮廓光,在 CHARGE 和 CAST 期间变亮。

质量标准
- 任意窗口尺寸下像素清晰、无缝循环、稳定 60fps、剪影可读。应当看起来像精致的 16 位精灵动画,而不是缩小后的矢量形状。

溯源

原作者
zacxbt
发布日期
2026-09-22(由推文 ID 反解)
原始出处
查看原帖 ↗
收录来源
yihui-dev/awesome-opus5-5-videos · zacxbt-944604 · MIT
yihui-dev/awesome-opus5-5-videos · majidmanzarpour-927543 · MIT
zhuyansen/awesome-opus-5.5-video · 2102476258948927543 · 未声明许可
本条由 3 个来源合并去重得来