diff --git a/dither4.js b/dither4.js index ab21a23..9721a30 100644 --- a/dither4.js +++ b/dither4.js @@ -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(