wip experiments (unused)

This commit is contained in:
Brooke Vibber 2023-03-24 21:30:10 -07:00
parent 50c0f59ce6
commit 7b194147ef

View file

@ -651,13 +651,23 @@ function decimate(input, palette, n) {
rgb = rgb.multiply(brightest / avg_luma).clamp();
}
// this also works pretty ok
// but i think keeping luma is better
//
/*
// 1) take the brightest luma
// 2) take the most saturated chroma
// 3) profit!
let lumas = bucket.map((rgb) => rgb.luma());
let luma = Math.max(...lumas);
let rgb = bucket[lumas.indexOf(luma)];
let brightest = Math.max(...lumas);
let saturations = bucket.map((rgb) => Math.max(rgb.r, rgb.g, rgb.b) - Math.min(rgb.r, rgb.g, rgb.b));
let saturation = Math.max(...saturations);
let saturatedIndex = saturations.indexOf(saturation);
let rgb = bucket[saturatedIndex];
let luma = rgb.luma();
if (luma > 0) {
rgb = rgb.multiply(brightest / luma).clamp();
}
*/
// pick the luma-brightest color in the bucket