request animation framne

This commit is contained in:
Sander Hautvast 2020-12-02 14:21:10 +01:00
parent 57498704b7
commit bce4ff7a92
2 changed files with 9 additions and 13 deletions

View file

@ -1,3 +1 @@
__Gradients are pretty magic!__
Lets you stare at passing clouds.
__Lets you stare at passing clouds.__

18
sky.js
View file

@ -11,16 +11,14 @@
canvas.height = window.innerHeight;
};
let i = 0, di = 1,
step = function () {
if ((i < 1000 && di > 0) || (i > 0 && di < 0)) {
i += di;
canvas.style.background = 'linear-gradient(' + i + 'deg, white , rgb(20,56,200))';
} else {
di = -di;
}
setTimeout(step, 150);
let start_timestamp = 0, angle = 0,
step = function (timestamp) {
angle = ((timestamp - start_timestamp) / 100) % 360;
canvas.style.background = 'linear-gradient(' + angle + 'deg, white , rgb(20,56,200))';
requestAnimationFrame(step);
};
step();
requestAnimationFrame(step);
})()