pixelfx README

项目的 README,来自 github.com/patch-gg/pixelfx。合并为一个 markdown 文件:README.md。

A grid of pixel art effects playing at once: a campfire, a burning skull, a waterfall, a plasma ball, a portal, a tornado and more.

pixelfx.

244 pixel art effects and animations, every one a small piece of code. Fire, explosions, magic, weather, UI, pickups, critters and more. Play them live, recolor and mirror them, drop them into a browser game, or export sprite sheets for any engine. Plus a Claude Code skill that makes new ones the way a picky pixel artist would: draft, render, look, refine.

Every effect that involves a character is acted out: he winds up, lets go, freezes on contact and recovers, and a target takes the hit. Twelve whole moves chain the effects into attacks from wind-up to recovery.

It's also a block on Patch: play pixelfx on Patch, pick an effect and a palette, and start a browser game from it.

open the gallery · catalog · acting · the skill · make your own · publish it on patch · how it works

The method is Hugo Duprez's, from How to make (good) pixel art effects with Claude: code is clay, trust your eyes, feed your references. His open-source effects at Sprite Fusion set the bar, and src/core/sim.js and the effects that say so at the top adapt his code. This repo is our take on the idea at library scale, with a skill to keep going.

what's in it.

category effects some of them
moves 12 arrow shot, dash strike, earth stomp, fireball throw, ground pound, holy smite…
fire 12 brazier, campfire, candle, fire breath, fire ring, fire tornado…
explosions 12 barrel explosion, big explosion, cartoon pow, dirt explosion, firework burst, firework rocket…
water 12 bubbles, drip, fountain, geyser, rain splash, ripples…
ice 10 blizzard vortex, freeze, frost breath, frost nova, ice crystal, ice lance…
lightning 11 ball lightning, chain lightning, charge up, electrified, lightning strike, plasma ball…
sci-fi 12 emp blast, energy core, force field, glitch, hologram, jetpack…
melee 12 claw swipe, dagger flurry, double slash, hammer smash, heavy cleave, scythe reap…
impacts 11 blunt hit, bullet impact, critical hit, ground slam, heavy landing, hit flash…
projectiles 13 arrow, bullet tracer, cannon shot, energy disc, signal flare, homing missile…
spawn & death 10 coin drop, disintegrate, dissolve burn, egg hatch, poof, respawn beam…
arcane 12 arcane beam, arcane missiles, arcane orb, blink in, blink out, magic circle cast…
holy 10 blessing, divine shield, feather burst, halo, heal, healing ring…
shadow 12 black hole, curse, dark explosion, eclipse, grasping hands, hex sigil…
status 13 bleeding, burning, charmed, confused, cursed, frozen…
nature 13 acid splash, boulder, earth spike, healing bloom, leaf storm, poison cloud…
weather 12 aurora, blizzard, cherry blossoms, clouds, falling leaves, fireflies…
ui 12 achievement, coin collect, combo counter, confetti, countdown, crit number…
pickups 11 chest open, coin spin, collect burst, crystal shard, gem spin, heart pickup…
transitions 10 blinds, burn away, crt off, diamond wipe, glitch wipe, iris…
critters 12 bat, bird, butterfly, eyeball, fish school, flying skull…

Every effect is a file in src/fx/<category>/<name>.js. The catalog lists them all.

use one.

In a browser game (canvas, Phaser, PixiJS, Kaplay, three.js), use the code. No dependencies.

import { createFrame, clearFrame, createFx, composite } from "pixelfx";
import * as frostNova from "pixelfx/fx/ice/frost-nova";

const frame = createFrame(320, 180);                   // your game's pixel resolution
const img = new ImageData(320, 180);
const fx = createFx(frostNova, { x: 160, y: 140 });   // also: flip, angle, seed, palette, light...

function tick(dt) {
  fx.update(dt);
  clearFrame(frame);
  fx.draw(frame, "back");                              // behind characters
  drawCharacters();
  fx.draw(frame, "front");
  composite(frame, img.data, backgroundColor);         // color, then light added on top
  ctx.putImageData(img, 0, 0);                         // scale up with image-rendering: pixelated
}

Install from GitHub with npm i github:patch-gg/pixelfx, or copy src/core and the effects you want.

In any engine (Godot, Unity, GameMaker, Defold, LÖVE, Bevy), use sprite sheets:

node tools/render.mjs ice/frost-nova --sheet

That writes a transparent PNG of every frame in a grid and an Aseprite-style JSON (frame rects, durations, and meta.pixelfx with fps, loop, columns and the pivot). Phaser's atlas loader and the Aseprite importers for Godot and Unity read it. node tools/sheets.mjs exports the whole library to sheets/.

Any effect takes a palette (a dark-to-bright ramp of hex colors), so a fire can burn blue and a heal can glow pink without touching its code:

node tools/render.mjs fire/torch --gif --opts '{"palette": ["#102","#215","#43a","#8cf","#cff","#fff"]}'

acting.

A grey dummy fighting a straw target: a three-stroke sword combo, a hammer smash, a ground pound, a holy smite, a frost nova and a run with after-images, each with a wind-up, a freeze on contact and a recovery.

An effect on its own looks like a sticker. What sells a hit is the body around it: the wind-up that says something is coming, the freeze on contact, the target rocking back, the recovery. So the 61 effects with a character, and the 12 moves, say what the body does and when:

export const act = {
  target: { x: 58 },
  poses: [
    [-0.55, GUARD],            // he starts before the effect does (t = 0 is the effect's first frame)
    [-0.3, WIND_UP],
    [0, CUT, "snap"],          // "snap" holds the last pose and jumps on the key
    [0.06, FOLLOW_THROUGH, "snap"],
    [0.86, GUARD],
  ],
  hits: [{ t: 0.06, stop: 0.14, shake: 0.18, amp: 2, push: 2.8, straw: 18 }],   // freeze for 0.14 s on contact
};

Play the whole thing, character and target included, by swapping createFx for createAct:

import { createFrame, clearFrame, createAct, composite } from "pixelfx";
import * as slash from "pixelfx/fx/melee/sword-slash";

const act = createAct(slash, { x: 80, y: 140 });

function tick(dt) {
  act.update(dt);                                  // holds still by itself during a freeze
  clearFrame(frame);
  act.draw(frame);                                 // { body: false } and { target: false } leave them out
  composite(frame, img.data, backgroundColor);
  const [sx, sy] = act.shake;                      // throw the picture this far
  ctx.putImageData(img, sx, sy);
}

Got your own character? Effect ids haven't changed and a sprite sheet is still the effect alone, so existing games keep working. (Effects drawn on the body paint the stock dummy, so regenerate those if you ship them.) The timing is plain data: read slash.act, or meta.pixelfx.act in a sprite sheet's JSON (windup, recovery, hits with t and freeze, poses). Start your own wind-up animation that long before the effect, and stop updating everything for freeze seconds at each hit.

Effects drawn on the body (frost, poison, a scan line) are written against the standing character and follow him wherever he goes: each pixel of a pose knows which pixel of the standing body it came from. node tools/act.mjs <id> --sheet bakes a whole act, character included, into a sprite sheet.

The body is yours to use too: skeleton(pose) gives you every joint of a pose in 3D, to hang your own things on, and posedParts(pose) gives you each part drawn on its own.

the skill.

The pixelfx skill teaches Claude Code to find, use, export and make effects. Install it as a plugin:

/plugin marketplace add patch-gg/pixelfx
/plugin install pixelfx@pixelfx

or copy skills/pixelfx into ~/.claude/skills/. Then ask for what you want:

make your own.

node tools/new.mjs arcane/my-spell       # a working starting point (add --loop for a loop)
node tools/render.mjs arcane/my-spell    # records/arcane/my-spell/contact.png: look at it
node tools/check.mjs arcane/my-spell     # spills, seams, unseeded randomness, slow frames

Then go round: look at the contact sheet, fix the worst thing, render again. --gif and --mp4 show the motion, --all shows every frame. node tools/act.mjs arcane/my-spell shows an act as consecutive 12 fps steps, because motion bugs don't show in samples. docs/AUTHORING.md has the contract, the drawing API and the quality bar. node tools/serve.mjs runs the gallery locally with your effects in it.

publish it on patch.

Made a browser game with these? Put it on Patch, where people play and remix browser games and mods. Install pch, Patch's command line, then restart your coding agent and ask it to publish the game: the install gives every agent on your PC Patch's tools. Or run it yourself:

npm i -g @patchgg/cli      # or: curl -fsSL https://patch.gg/install.sh | sh
pch login
pch init                   # in your game's folder; it says what's next
pch publish

Publishing needs Patch Desktop open on a Windows PC: it plays your game once to test it before it goes live. The quickstart has the rest.

how it works.

license.

MIT, code and effects. Use them in anything, commercial included. Parts are adapted from Hugo Duprez's MIT effects and from Hollow Crown's MIT source, and the Patch Pixel font in gallery/fonts is Patch's own and not covered: see NOTICE.md.

Made by Patch.

pixelfx (patch-gg/pixelfx)

正在搜索数据库…

这是什么?pixelfx 是一个包含 232 种像素艺术特效和动画的库(火焰、爆炸、魔法、天气、界面、拾取物、小生物等),每种特效都以一小段 JavaScript 代码实现,而不是预先画好的图片。此外还提供一个用于创建新特效的 Claude Code 技能。
这是代码库还是图片素材包?这是一个 JavaScript 代码库:每种特效都以文件形式存放在 src/fx/ 中,通过 draw 或 step 函数在 Canvas 2D 上下文中自行渲染。也可以把输出烘焙成 PNG 精灵图,供非 JS 引擎使用。
我要怎样把这些特效加到我的游戏里?用 npm i github:patch-gg/pixelfx 安装,或者直接把 src/core 和你想要的特定特效文件复制到项目中。它可以直接配合 Canvas、Phaser、PixiJS、Kaplay 或 three.js 使用。
使用这个特效库必须要装 Claude Code 吗?不需要。核心库没有任何依赖,可以在任何基于 Canvas 的 JS 游戏中独立运行。只有可选的技能(用于帮你起草和优化新特效)才需要 Claude Code。
我能在 Godot、Unity 或 GameMaker 里用这些特效,而不是只能在浏览器里用吗?可以。运行 node tools/sheets.mjs,即可把每种特效导出为透明的 PNG 网格,并附带 Aseprite 风格的 JSON(帧矩形、时长、帧率、轴心点)。Phaser 的图集加载器以及 Godot 和 Unity 的 Aseprite 导入器都能读取这些文件。
纯特效和模拟特效有什么区别?纯特效导出 draw(p, t, o),只根据经过的时间进行渲染,因此循环可以无缝衔接。模拟特效导出 create(o),以 120 Hz 的频率模拟真实的粒子、碎片和光源,从而呈现基于物理的运动效果,比如弹跳的火花和翻滚的烟雾。
不改代码能换特效颜色吗?可以。每种特效都接受一个调色板(由暗到亮的十六进制颜色渐变),所以只需替换调色板,同一段火焰代码就能燃烧出蓝色火焰,治疗特效也能发出粉色光芒,无需改动任何代码。
Claude Code 技能到底能帮我做什么?它能让 Claude Code 根据白话描述的需求查找、使用、导出和创作 pixelfx 特效,比如给技能添加一个冰霜新星,生成几个版本的硬币闪光,或者让打击特效更有冲击力。
这些特效背后的技术来自哪里?该方法遵循 Hugo Duprez 在《How to make (good) pixel art effects with Claude》一文中介绍的思路,核心模拟代码(src/core/sim.js)改编自他的开源库 Sprite Fusion VFX。
作者
patch-gg
大小
24.8 MB
星标
8K
更新
提交Nov 12
时长
19天
提交 · 90 天