(r, g, b, labPalette)
| 35 | } |
| 36 | |
| 37 | function nearestLabColor(r, g, b, labPalette) { |
| 38 | const srcLab = rgbToLab(r, g, b); |
| 39 | let minD = Infinity, best = labPalette[0]; |
| 40 | for (const entry of labPalette) { |
| 41 | const d = labDistanceSq(srcLab, entry.lab); |
| 42 | if (d < minD) { minD = d; best = entry; } |
| 43 | } |
| 44 | return best.rgb; |
| 45 | } |
| 46 | |
| 47 | // ============================================================ |
| 48 | // Palette Generation (returns palette without modifying imageData) |
no test coverage detected