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