force white also
this leaves us with only two new colors per row but gives more dither possibilities
This commit is contained in:
parent
e5a9c68d05
commit
ed9538ecc5
1 changed files with 8 additions and 3 deletions
11
dither4.js
11
dither4.js
|
@ -398,6 +398,12 @@ function decimate(input, palette, n) {
|
|||
let least = Infinity;
|
||||
let pick = -1;
|
||||
for (let i = 1; i < decimated.length; i++) {
|
||||
if (i == 0) {
|
||||
continue; // keep black always
|
||||
}
|
||||
if (decimated[i].r == 255 && decimated[i].g == 255 && decimated[i].b == 255) {
|
||||
continue; // keep white always
|
||||
}
|
||||
if (popularity[i] < least) {
|
||||
pick = i;
|
||||
least = popularity[i];
|
||||
|
@ -405,9 +411,6 @@ function decimate(input, palette, n) {
|
|||
}
|
||||
let old = decimated.length;
|
||||
decimated = decimated.filter((rgb, i) => {
|
||||
if (i == 0) {
|
||||
return true; // keep black always
|
||||
}
|
||||
if (i == pick) {
|
||||
return false;
|
||||
}
|
||||
|
@ -417,6 +420,8 @@ function decimate(input, palette, n) {
|
|||
return true;
|
||||
});
|
||||
if (decimated.length >= old) {
|
||||
console.log(decimated);
|
||||
debugger;
|
||||
throw new Error('logic error');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue