This commit is contained in:
jane 2021-05-25 23:57:35 -04:00
parent d636fc88d2
commit 9491782686

View file

@ -62,21 +62,21 @@ function fade(index) {
var current = int_to_rgb(pixels[index]); var current = int_to_rgb(pixels[index]);
var final = int_to_rgb(next_pattern[index]); var final = int_to_rgb(next_pattern[index]);
var diff_r = final.r - original.r; var diff_r = final.r - original.r;
var diff_cr = current.r - original.r;
var diff_g = final.g - original.g; var diff_g = final.g - original.g;
var diff_b = final.b - original.b; var diff_b = final.b - original.b;
var interval_r = diff_r / fade_ticks; var interval_r = diff_r / fade_ticks;
var interval_g = diff_g / fade_ticks; var interval_g = diff_g / fade_ticks;
var interval_b = diff_b / fade_ticks; var interval_b = diff_b / fade_ticks;
var current_tick = Math.floor((diff_cr / diff_r) * fade_ticks);
// console.log(`original: ${original.r} ${original.g} ${original.b}\n` + // console.log(`original: ${original.r} ${original.g} ${original.b}\n` +
// `current: ${current.r} ${current.g} ${current.b}\n` + // `current: ${current.r} ${current.g} ${current.b}\n` +
// `final: ${final.r} ${final.g} ${final.b}\n` + // `final: ${final.r} ${final.g} ${final.b}\n` +
// `interval: ${interval_r} ${interval_g} ${interval_b}\n`) // `interval: ${interval_r} ${interval_g} ${interval_b}\n`)
if (final.r - current.r < interval_r && if (current_tick + 1 >= fade_ticks) {
final.g - current.g < interval_g &&
final.b - current.b < interval_b
) {
console.log("FINISHED FADE FOR " + index); console.log("FINISHED FADE FOR " + index);
pixels[index] = next_pattern[index]; pixels[index] = next_pattern[index];
pixel_cache[index] = next_pattern[index]; pixel_cache[index] = next_pattern[index];