You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
588 B
JavaScript

const ticks_per_second = 47;
const current_color = [10, 100, 45];
const target_color = [255, 255, 0];
const how_long_fade_is = 1500; // ms
var how_many_ticks_it_takes = Math.floor(how_long_fade_is / ticks_per_second); // 32
var percent_amount = 1;
var tick_inc = 0;
while (tick_inc < how_many_ticks_it_takes) {
let color_out = [];
for (let j = 0; j < 3; j++) {
color_out.push((current_color[j] * percent_amount) + (target_color[j] * (1 - percent_amount)));
}
console.log(`${tick_inc}: ${color_out}`);
tick_inc++;
percent_amount -= (1 / how_many_ticks_it_takes);
}