canon_learn
Define or update named sprite regions by sampling colors from image points, with optional protection, so repaint stays consistent and verification checks integrity.
Instructions
Define or update a named region in the canon (e.g. skin, hair, outfit, outline). Give a few [x,y] points on sample images; the sampled colours (optionally expanded by absorb) become the region. The region's luminance range is recorded — repaint uses that FIXED range so the same source colour always maps to the same output colour in every frame and direction. Mark regions like face/eyes/outline as protected: repaint will never touch them and verify will fail if anything else does. Instead of points you may pass explicit colors, or an HSL rule (hue/sat/light ranges) for anti-aliased art — an HSL-only region additionally needs lumRange if you ever want to repaint it. Updates MERGE additively into an existing region; pass replace=true to redefine it from scratch (the only way to remove a mis-sampled colour).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hue | No | HSL rule: hue range in degrees | |
| sat | No | HSL rule: saturation range 0..1 | |
| cellH | No | spritesheet cell height (PNG sheets only) | |
| cellW | No | spritesheet cell width (PNG sheets only) | |
| light | No | HSL rule: lightness range 0..1 | |
| absorb | No | also absorb colours within this per-channel distance of sampled ones (default 0) | |
| colors | No | explicit hex colours instead of samples | |
| region | Yes | region name, e.g. 'skin' / 'outline' / 'cloak' | |
| replace | No | redefine the region from scratch instead of merging (default false) | |
| samples | No | ||
| lumRange | No | fixed luminance range (0-255) for repainting — required for HSL-only regions, auto-computed for colour lists | |
| canonPath | No | path to sprite-canon.json (default: search upward from the target file) | |
| protected | No | mark as protected (never repainted, verified untouched) |