-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbackground.js
More file actions
37 lines (26 loc) · 798 Bytes
/
Copy pathbackground.js
File metadata and controls
37 lines (26 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
let canvas = document.getElementById("background");
let ctx = canvas.getContext("2d");
let col = function(x, y, r, g, b) {
ctx.fillStyle = `rgb(${r}, ${g}, ${b})`;
ctx.fillRect(x, y, 1, 1);
}
let Red = function(x, y, t) {
return(Math.floor(192+64*Math.cos((x*y-y^y)/500+t)));
}
let Green = function(x, y, t) {
return(Math.floor(192+64*Math.sin((x*x*Math.cos(t/5)+y*y*Math.sin(t/3))/100)));
}
let Blue = function(x, y, t) {
return(Math.floor(192+64*Math.sin(5*Math.sin(t/9)+((x-200)*(x-200)+(y-200)*(y-200))/1500)));
}
let t = 0;
let run = function() {
for(x = 0; x <= 55; x++) {
for(y = 0; y <= 55; y++) {
col(x, y, Red(x, y, t), Green(x, y, t), Blue(x, y, t));
}
}
t = t+ 0.08;
window.requestAnimationFrame(run);
}
run();