-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcircle.js
57 lines (48 loc) · 1.25 KB
/
circle.js
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
//Color options stored in an array
var colors = [
'#FFFFFF',
'#84DCC6',
'#A5FFD6',
'#FFA69E',
'#FF686B',
]
var blurArr = [ 0, 10, 20, 30];
var pickColor = function(){
return colors[Math.floor(Math.random()*colors.length)];
}
//Constructor for circle object
function Circle(x,y,radius,color){
this.x = x;
this.y = y;
// this.x = Math.floor(Math.random()*window.innerWidth);
// this.y = Math.floor(Math.random()*window.innerWidth);
// this.dx = dx;
// this.dy = dy;
this.radius = radius;
this.color = color;
this.blur = 30;
this.reappear = function () {
// //change x and y coordinates
// this.x = Math.floor(Math.random()*window.innerWidth);
// this.y = Math.floor(Math.random()*window.innerHeight);
//change color
this.color = pickColor();
this.blur = blurArr[Math.floor(Math.random()*blurArr.length)];
this.draw();
}
this.draw = function(){
c.beginPath();
//context.arc(x,y,r,sAngle,eAngle,counterclockwise)
c.arc(this.x,this.y,this.radius,0, Math.PI * 2, false )
c.fillStyle = this.color;
c.shadowBlur = 30;
c.shadowColor = "white";
c.fill();
}
this.move = function() {
while (this.x - this.radius < window.innerWidth){
this.x += 0.5;
this.draw();
}
}
}