-
Notifications
You must be signed in to change notification settings - Fork 1
/
ParticleView.js
63 lines (47 loc) · 1.2 KB
/
ParticleView.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
58
59
60
61
62
/**
* Particle View
*/
typedef ('Humble.Gravity.Particle.view', function () {
var view = function (context) {
// Members
this.context = context;
// Construct
this.constructor();
};
// Methods
view.prototype = {
constructor : function () {
},
/**
* Draw a particle
*
* @param Particle particle
*/
draw : function (particle) {
var context = this.context;
var r, g;
r = Math.floor(Math.random(0)*256);
g = Math.floor(Math.random(0)*256);
if (r < g) {
swap = r;
r = g;
g = r;
}
r = r.toString(16);
if (r.length == 1) {
r = '0'+r;
};
g = g.toString(16);
if (g.length == 1) {
g = '0'+g;
};
context.fillStyle = '#'+r+g+'00';
//context.fillStyle = '#ffffff';
context.beginPath();
context.arc(particle.x, particle.y, particle.r, 0, 360, 1);
context.fill();
context.closePath();
}
};
return view;
});