Commit 474f1e19 by doszhang

dos

parent cc8f6b80
...@@ -47,7 +47,7 @@ window.requestAnimationFrame = ...@@ -47,7 +47,7 @@ window.requestAnimationFrame =
window.setTimeout(callback, 1000 / 60); window.setTimeout(callback, 1000 / 60);
}; };
var canvas, ctx, w, h, particles = [], var fireworkCanvas, fireworkCtx, w, h, particles = [],
probability = 0.04, probability = 0.04,
xPoint, yPoint; xPoint, yPoint;
...@@ -261,7 +261,7 @@ function update() { ...@@ -261,7 +261,7 @@ function update() {
function paint() { function paint() {
fireworkCtx.globalCompositeOperation = 'lighter'; fireworkCtx.globalCompositeOperation = 'lighter';
for (var i = 0; i < particles.length; i++) { for (var i = 0; i < particles.length; i++) {
particles[i].draw(ctx); particles[i].draw(fireworkCtx);
for (k in particles[i].children) { for (k in particles[i].children) {
particles[i].children[k].w -= 0.205 particles[i].children[k].w -= 0.205
particles[i].children[k].draw(fireworkCtx) particles[i].children[k].draw(fireworkCtx)
...@@ -309,8 +309,8 @@ Particle.prototype = { ...@@ -309,8 +309,8 @@ Particle.prototype = {
this.vy += this.gravity; this.vy += this.gravity;
this.y += this.vy; this.y += this.vy;
this.alpha -= 0.01; this.alpha -= 0.01;
if (this.x <= -this.w || this.x >= canvas.width || if (this.x <= -this.w || this.x >= fireworkCanvas.width ||
this.y >= canvas.height || this.y >= fireworkCanvas.height ||
this.alpha <= 0) { this.alpha <= 0) {
this.alpha = 0 this.alpha = 0
return false; return false;
......
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