-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
64 lines (52 loc) · 1.74 KB
/
script.js
File metadata and controls
64 lines (52 loc) · 1.74 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
window.requestAnimFrame = (function(callback){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback){
window.setTimeout(callback, 1000 / 60);
};
})();
function animate(canvas, lastTime)
{
var g = Math.round(Math.random() * 255);
context.strokeStyle = "rgba(0, " + g + ", 0, 0.25)";
var d2 = Math.pow(2, Math.round(Math.random() * 8));
var r = Math.random() * Math.PI*2;
context.rotate(r);
context.beginPath();
context.moveTo(0,0);
context.lineTo(l,0);
context.stroke();
context.closePath();
// update
var date = new Date();
var time = date.getTime();
var timeDiff = time - lastTime;
//animate(canvas, balls, timeDiff, mousePos);
lastTime = time;
requestAnimFrame(function(){
animate(canvas, timeDiff);
});
}
window.onload = function()
{
var canvas = document.getElementById("radial");
var body = document.body,
html = document.documentElement;
var height = Math.max( body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight, html.offsetHeight );
var width = Math.max( body.scrollWidth, body.offsetWidth,
html.clientWidth, html.scrollWidth, html.offsetWidth );
canvas.width = width;
canvas.height = height;
x = Math.floor(canvas.width / 2);
y = Math.floor(canvas.height / 2);
l = Math.sqrt((Math.pow(x, 2) + Math.pow(y, 2)));
context = canvas.getContext("2d");
context.translate(x,y);
var date = new Date();
var time = date.getTime();
animate(canvas, time);
};