there we go, was doing that limit fitness worng

This commit is contained in:
Brooke Vibber 2022-11-20 17:32:54 -08:00
parent b023e2a73e
commit 48e830fa70

View file

@ -397,10 +397,12 @@ function decimate(input, palette, n) {
for (let i = 0; i < palette.length; i++) {
let diff = rgb.difference(palette[i]);
let dist = diff.magnitude();
/*
let darker = Math.min(diff.r, diff.g, diff.b) < 0;
if (darker) {
dist **= 2;
}
*/
if (dist < shortest) {
nextError = diff;
shortest = dist;
@ -476,7 +478,7 @@ function decimate(input, palette, n) {
// 442 is the 3d distance across the rgb cube
//fitness[x] = 442 - (nextError.magnitude());
//fitness[x] = 442 / (442 - nextError.magnitude());
fitness[x] = 255 / (256 - Math.max(nextError.r, nextError.g, nextError.b));
fitness[x] = 255 / (256 - Math.max(0, nextError.r, nextError.g, nextError.b));
/*
fitness[x] = Math.max(