wip in progress

This commit is contained in:
Brooke Vibber 2023-03-19 18:29:06 -07:00
parent 9826a90e02
commit 89db2f3d1d

View file

@ -566,23 +566,36 @@ function decimate(input, palette, n, inputError, y) {
console.log('end', decimated); console.log('end', decimated);
*/ */
// popularity? not really working right // fitness
// first, dither to the total atari palette // first, dither to the total atari palette
/*
while (decimated.length > n) { while (decimated.length > n) {
//console.log(y); console.log(`y ${y}`);
let {popularity} = dither(decimated); let worstFitness = Infinity;
let a = decimated; let nextPalette = null;
// temporarily strip the reserved items for (let i = 0; i < decimated.length; i++) {
a = a.filter((color) => !keepers[color]); if (keepers[i]) {
a = a.sort((a, b) => popularity[b] - popularity[a]); continue;
a = reserved.concat(a); }
decimated = a.slice(0, n); let without = decimated.slice();
//console.log(decimated); without.splice(i, 1);
let {popularity, fitness} = dither(decimated);
let total = 0;
for (let n of fitness) {
total += n;
}
let avg = total / fitness.length;
if (avg < worstFitness) {
worstFitness = avg;
nextPalette = without;
}
}
decimated = nextPalette;
} }
//console.log('end', decimated); //console.log('end', decimated);
*/
// old algo
/*
while (decimated.length > n) { while (decimated.length > n) {
let {popularity, fitness, output} = dither(decimated); let {popularity, fitness, output} = dither(decimated);
@ -625,6 +638,7 @@ function decimate(input, palette, n, inputError, y) {
}); });
} }
} }
*/
// Palette fits // Palette fits
return dither(decimated); return dither(decimated);