From 48e830fa70b248ce2f31a52d3cc7f7ae3278a630 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 20 Nov 2022 17:32:54 -0800 Subject: [PATCH] there we go, was doing that limit fitness worng --- dither4.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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(