A declarative pixel art generation engine. Describe weapons and items in natural language, and produce PNG pixel art via a configuration-driven engine.
- Declarative Configuration — Define pixel art via simple JS config objects (body segments, decorations, palettes)
- Template Mode — Separate geometry from coloring. Use pre-made weapon silhouettes from
base_shapes/and fill them with color gradients - Classic Mode — Define geometry and coloring inline for fully custom shapes
- Symmetry Support — Diagonal, vertical, and horizontal symmetry strategies
- Multiple Fill Types — Solid, gradient, linear, and dual fills
- Decorations — Add asymmetric elements like vines, leaves, particles, and rectangles
- PNG Output — Generates transparent-background PNG images
const { PixelEngine } = require("./lib");
new PixelEngine({
size: 64,
scale: 8,
palette: {
dark: "#0a1e3d",
mid: "#1a4a8a",
light: "#7ab8ff",
white: "#ffffff",
},
symmetry: "diagonal",
template: "base_shapes/orb_staff_circle.png",
body: [
{ range: [0, 6], fill: { type: "gradient", colors: ["dark", "mid"] } },
{ range: [7, 27], fill: { type: "gradient", colors: ["dark", "mid", "light"] } },
{ range: [28, 34], fill: { type: "gradient", colors: ["mid", "light"] } },
{ range: [35, 40], fill: { type: "solid", color: "light" } },
{ range: [41, 60], fill: { type: "gradient", colors: ["white", "light", "mid", "dark"] } },
],
}).render().savePNG("output.png");pixel-art/
├── lib/ # Modular core engine
│ ├── index.js # Entry point
│ ├── engine.js # PixelEngine class
│ ├── color.js # Color utilities
│ ├── png.js # PNG encode/decode
│ ├── image.js # Image loading
│ ├── symmetry.js # Symmetry strategies
│ └── fills.js # Fill strategies
├── base_shapes/ # Pre-made weapon contour templates (PNG)
├── tools/
│ └── add_template.js # External image to template converter
├── cache/ # Auto-generated scripts (auto-cleaned after 7 days)
├── pixel_engine.js # Backward-compatible re-export bridge
├── SKILL.md # OpenCode skill definition
└── AGENTS.md # Agent behavior constraints
| Field | Type | Default | Description |
|---|---|---|---|
size |
number | 128 | Canvas size (32/64/128) |
scale |
number | 8 | Output pixel size multiplier |
palette |
object | {} |
Color names → hex values |
symmetry |
string | "diagonal" | "diagonal" / "vertical" / "horizontal" |
body |
Segment[] | [] |
Symmetric colored segments |
decorations |
Decoration[] | [] |
Asymmetric decorative elements |
template |
string | null | Path to base shape PNG |
center |
number | auto | Symmetry axis position |
postProcess |
object | null | Auto-shade / outline / quantize |
Origin is at the bottom-left (0, 0). X-axis points right, Y-axis points up. PNG output flips Y automatically.
Templates are pre-drawn weapon silhouettes in base_shapes/. Template mode separates geometry from coloring:
- Select a template (e.g.,
"base_shapes/broadsword.png") - Define body segments with colors only (no
widthparameter) - The engine fills template pixels with your colors
Create new templates using classic mode with black fill, then reference them in any generation script.
Generated examples (PNG) are available in the project root:
colorful_staff.pngcruciform_lava_sword.pngfire_bone_staff.pngfire_ice_orb_staff.pngfire_ice_staff.pngice_storm_staff.pnglava_broadsword.pngnightglow_64.pngthunder_staff.pngvortex_staff.png
MIT