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 個來源合併去重而來