This commit is contained in:
jane 2021-05-26 12:23:55 -04:00
parent a123db11ec
commit f77f2654c3

View file

@ -82,29 +82,32 @@ function fade(index) {
var diff_cg = current.g - original.g;
var diff_b = final.b - original.b;
var diff_cb = current.b - original.b;
var interval_r = Math.ceil(diff_r / fade_ticks);
var interval_g = Math.ceil(diff_g / fade_ticks);
var interval_b = Math.ceil(diff_b / fade_ticks);
var sign_r = diff_r == Math.abs(diff_r) ? 1 : -1;
var sign_g = diff_g == Math.abs(diff_g) ? 1 : -1;
var sign_b = diff_b == Math.abs(diff_b) ? 1 : -1;
var interval_r = sign_r * Math.ceil(Math.abs(diff_r / fade_ticks));
var interval_g = sign_g * Math.ceil(Math.abs(diff_g / fade_ticks));
var interval_b = sign_b * Math.ceil(Math.abs(diff_b / fade_ticks));
var current_tick_r = Math.abs(Math.floor((diff_cr / diff_r) * fade_ticks));
var current_tick_g = Math.abs(Math.floor((diff_cg / diff_g) * fade_ticks));
var current_tick_b = Math.abs(Math.floor((diff_cb / diff_b) * fade_ticks));
if (diff_r == 0 ||
Math.abs(current.r + interval_r) >= Math.abs(final.r) ||
current.r + interval_r >= final.r ||
current_tick_r + 1 >= fade_ticks) {
current.r = final.r;
interval_r = 0;
current_tick_r = fade_ticks;
}
if (diff_g == 0 ||
Math.abs(current.g + interval_g) >= Math.abs(final.g) ||
current.g + interval_g >= final.g ||
current_tick_g + 1 >= fade_ticks) {
current.g = final.g;
interval_g = 0;
current_tick_g = fade_ticks;
}
if (diff_b == 0 ||
Math.abs(current.b + interval_b) >= Math.abs(final.b) ||
current.b + interval_b >= final.b ||
current_tick_b + 1 >= fade_ticks) {
current.b = final.b;
interval_b = 0;