replace_colors
Replace colors in an Aseprite layer using multiple color mappings at once, with tolerance matching and optional transparency swaps across frames or regions.
Instructions
Replace colours in a layer, all mappings at once (A->B with B->A swaps them).
A pixel matches a mapping when each of r, g, b and alpha is within tolerance of
from; fully transparent pixels count as 'transparent' whatever their colour. The
first matching mapping wins. to='transparent' erases, except on a background layer,
which ignores alpha and gets opaque black. On indexed sprites pixels are matched by
their palette colour and get the palette entry nearest to to (exactly to when
the palette has it); the palette is not changed. On grayscale sprites pixels compare
as (v, v, v), so a coloured from only matches within tolerance, and to is
stored as its gray value.
Frames without a cel are skipped. Linked cels change once; one also linked to
frames outside the list gets its own copy, only when some of its pixels change.
replaced counts the pixels that matched.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"path": "<path>",
"layer": "<layer>",
"mappings": "<mappings>"
},
"name": "replace_colors"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Sprite file. Relative paths resolve against the server root. | |
| layer | Yes | Layer name, or a 'group/child' path for nested layers | |
| frames | No | Frames: a number, "1-4", "1-4,7" or "all" (1-based) | |
| region | No | Only change pixels inside this canvas rectangle; default the whole cel | |
| mappings | Yes | [{"from": colour, "to": colour}] | |
| tolerance | No | Largest difference per channel (r, g, b, a) that matches |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||