Parent: #129. Depends on the sampled grid from the previous F14.1 child.
Scope
Convert sampled grid pixels into a deterministic generated palette and a one-based numbered guide buffer.
Implementation
- Add a pure palette-reduction module under
src/services/paint-by-number/.
- Accept sampled
ImageData plus a maximum generated color count.
- Use a deterministic bounded quantization strategy suitable for small grids.
- Map transparent cells to index 0.
- Map opaque cells to palette indices
1..N using one consistent perceptual color-distance function.
- Return
{ palette, target, width, height } with a compact typed target buffer.
- Do not reuse
extractColorsFromDrawing as if it were already a bounded quantizer; share only genuinely reusable color helpers.
Acceptance
- The palette never exceeds the requested color count.
- Every nonzero target index resolves to an existing palette entry.
- Transparent cells remain 0.
- Fixed fixtures produce stable palette and target hashes.
- No project state or UI is introduced.
Verification
- Targeted Vitest coverage
npm run lint
git diff --check
Parent: #129. Depends on the sampled grid from the previous F14.1 child.
Scope
Convert sampled grid pixels into a deterministic generated palette and a one-based numbered guide buffer.
Implementation
src/services/paint-by-number/.ImageDataplus a maximum generated color count.1..Nusing one consistent perceptual color-distance function.{ palette, target, width, height }with a compact typed target buffer.extractColorsFromDrawingas if it were already a bounded quantizer; share only genuinely reusable color helpers.Acceptance
Verification
npm run lintgit diff --check