This commit is contained in:
Brooke Vibber 2022-11-20 19:35:24 -08:00
parent 48e830fa70
commit 3e266b4f33

View file

@ -397,12 +397,6 @@ 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;
@ -436,14 +430,14 @@ function decimate(input, palette, n) {
error.blue[x] += nextError.b / 2;
*/
if (x == 159) {
error.red[x] += error.right.r;
error.green[x] += error.right.g;
error.blue[x] += error.right.b;
} else {
error.right.r = nextError.r / 4;
error.right.g = nextError.g / 4;
error.right.b = nextError.b / 4;
if (x == 159) {
error.red[0] = error.right.r;
error.green[0] = error.right.g;
error.blue[0] = error.right.b;
}
error.red[x - 1] += nextError.r / 4;
error.green[x - 1] += nextError.g / 4;
@ -456,6 +450,7 @@ function decimate(input, palette, n) {
error.red[x + 1] += nextError.r / 4;
error.green[x + 1] += nextError.g / 4;
error.blue[x + 1] += nextError.b / 4;
}
/*
error.right.r = nextError.r / 4;
@ -538,16 +533,16 @@ function decimate(input, palette, n) {
if (i == 0) {
continue; // keep black always
}
if (decimated[i].r == 255 && decimated[i].g == 255 && decimated[i].b == 255) {
//continue; // keep white always
}
//let coolFactor = popularity[i];
let coolFactor = 0;
if (popularity[i]) {
for (let x = 0; x < line.length; x++) {
if (output[x] == i) {
coolFactor += (fitness[x] ** 2);
//coolFactor += (fitness[x] ** 2);
coolFactor += (fitness[x] ** 4);
}
}
}