Skip to main content
Glama
README.md
# PixelPad

A tiny pixel-art editor that AI agents and people draw in together, like the Blender MCP but for sprites.
Connect Claude Code, Codex or any MCP client; whatever the AI draws appears live in the app window, and you can edit the same canvas by hand.

- Zero dependencies: plain Node.js (18+) and one HTML page. Opens instantly, no login, no start screen, nothing saved between runs.
- Built for AI: draw with text rows, look with a ruler-and-grid `view`, shade along palette ramps, compare with a reference image, animate frame by frame.

<p>
  <img src="examples/knight@8x.png" height="200" alt="48x48 knight">
  <img src="examples/dragon@4x.png" height="200" alt="256x256 dragon">
  <img src="examples/campfire.gif" height="200" alt="animated campfire">
  <img src="examples/knight-run.gif" height="120" alt="8-direction run cycle">
</p>

*All examples were drawn by Claude through the MCP.*

## Connect an AI

**Claude Code**

```
claude mcp add --scope user pixelpad -- npx -y pixelpad-mcp
```

**Codex** – add to `~/.codex/config.toml`:

```toml
[mcp_servers.pixelpad]
command = "npx"
args = ["-y", "pixelpad-mcp"]
```

**Claude Desktop / other MCP clients** – add to the client's MCP config:

```json
{ "mcpServers": { "pixelpad": { "command": "npx", "args": ["-y", "pixelpad-mcp"] } } }
```

The first tool call starts the app and opens its window (Edge, Chrome, Brave or Vivaldi app window, else your default browser).
Then just ask: *"make a 48x48 knight sprite"*, *"animate a campfire"*, *"recreate this image"*.

## Run it yourself

```
npx -p pixelpad-mcp pixelpad          # open the app
npx -p pixelpad-mcp pixelpad --stop   # quit it
```

Or clone this repo and run `node pixelpad.js` (Windows: double-click `PixelPad.cmd`). The app keeps running in the background until you stop it.

## AI tools

| Group | Tools |
|---|---|
| Canvas | `new_canvas`, `resize_canvas`, `set_palette` (32 slots + ramps), `undo`, `redo`, `save`, `open` |
| Drawing | **`draw`** (text rows), `set_pixels`, `shape`, `fill`, `replace_color`, `erase` |
| Detail | `auto_shade` (light direction), `shade` (ramp steps), `outline` (selective, auto color), `dither` (checker/bayer/gradient), `scatter` (texture), `flip` / mirror, `copy` / move |
| Layers | `layer` (list, add, set, delete, move, merge) |
| Reference | `reference` (open/fit/clear any image), `get_reference`, `palette_from_reference` |
| Animation | `frame` (list, add copy/blank, set, delete, move, fps), `frame` option on every drawing tool, `split_sheet`, `export_gif`, `save` with `sheet: true` |
| Looking | `view` (PNG with numbered rulers + grid, zoom by region, `mode: compare` side by side with the reference, `mode: frames` all frames in a grid), `get_canvas` |

`draw` takes one text row per pixel row:

```
rows: ["..00..",
       ".0110.",
       "011110"]      0-9 a-v = palette slot, "." = skip, "_" = erase
```

Colors anywhere can be a palette slot (`0`-`31` or one char `"0"`-`"v"`), `"#rrggbb"`, or `null` for transparent.
The palette is 32 slots grouped into ramps (dark → light); shading tools step along the ramps.
The MCP tells the AI to work in passes: reference → palette/ramps → layers → big shapes → flats → light → outline → details, looking with `view` after each pass.

## Animation

Every layer has one picture per frame. The timeline at the bottom shows a thumbnail per frame:
click to select, **+ Copy** duplicates the current frame, **+ Blank** adds an empty one, ◀ ▶ reorder.
**Play** (or Space) plays it at the fps you set; **Onion** shows the previous frame faintly while you draw.
**Sheet** saves all frames as one sprite sheet, **GIF** saves an animated GIF (both use the export scale).

## Keys

B pencil · E eraser · G fill · I pick color · L line · R rectangle · O ellipse · X replace color
0-9 pick a swatch · , / . previous / next frame · Space play · H grid · +/- zoom · Ctrl+Z / Ctrl+Y undo/redo · Ctrl+S save · Ctrl+O open
Right-click erases. Ctrl+wheel zooms. Drop a PNG to open it; drop any other image to import it into the active layer.
The side panel has the palette (each row is a ramp), layers (click to select, double-click to rename, checkbox to hide) and a reference image you can trace over (opacity slider).

## Files

- `pixelpad.js` – server, canvas state, PNG read/write, launcher
- `index.html` – the editor
- `raster.js` – line/rect/ellipse shapes (shared)
- `mcp.js` – MCP bridge (stdio)

Port 7777. Set `PIXELPAD_PORT` to change it.