Commit 443355bd by October

dos

parent 1f2f8095
...@@ -144,6 +144,7 @@ function Particle() { ...@@ -144,6 +144,7 @@ function Particle() {
this.x = xPoint - this.w / 2; this.x = xPoint - this.w / 2;
this.y = yPoint - this.h / 2; this.y = yPoint - this.h / 2;
this.childrens = [];
this.vx = (Math.random() - 0.5) * 10; this.vx = (Math.random() - 0.5) * 10;
this.vy = (Math.random() - 0.5) * 10; this.vy = (Math.random() - 0.5) * 10;
...@@ -155,6 +156,7 @@ function Particle() { ...@@ -155,6 +156,7 @@ function Particle() {
Particle.prototype = { Particle.prototype = {
gravity: 0.01, gravity: 0.01,
move: function () { move: function () {
this.childrens.push({x:this.x,y:this.y} );
this.x += this.vx; this.x += this.vx;
this.vy += this.gravity; this.vy += this.gravity;
this.y += this.vy; this.y += this.vy;
...@@ -167,6 +169,7 @@ Particle.prototype = { ...@@ -167,6 +169,7 @@ Particle.prototype = {
return true; return true;
}, },
draw: function (c) { draw: function (c) {
var step = 0.05;
c.save(); c.save();
c.beginPath(); c.beginPath();
...@@ -178,5 +181,26 @@ Particle.prototype = { ...@@ -178,5 +181,26 @@ Particle.prototype = {
c.closePath(); c.closePath();
c.fill(); c.fill();
c.restore(); c.restore();
var newChildrens = [];
var alpha = this.alpha;
alpha -= step;
//console.log(alpha );
while( this.childrens.length > 0 && alpha > 0 ){
alpha -= step;
var children = this.childrens.pop( this.childrens );
c.save();
c.beginPath();
c.translate(children.x + this.w / 2, children.y + this.h / 2);
c.arc(0, 0, this.w, 0, Math.PI * 2);
c.fillStyle = this.color;
c.globalAlpha = alpha;
c.closePath();
c.fill();
c.restore();
newChildrens.unshift( children );
}
this.childrens = newChildrens;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment