实例教程 HTML5 Canvas 超炫酷烟花绽放动画实现代码

2019-01-28 16:48:10丽君
  •         } if(this.hitX && this.hitY){ var randExplosion = rand(0, 9);                self.createParticles(this.targetX, this.targetY, this.hue);   
  •             self.fireworks.splice(index, 1);                                }   
  •     };      
  •     Firework.prototype.draw = function(){            self.ctx.lineWidth = this.lineWidth; var coordRand = (rand(1,3)-1);                       
  •         self.ctx.beginPath();                                        self.ctx.moveTo(Math.round(this.coordLast[coordRand].x), Math.round(this.coordLast[coordRand].y));   
  •         self.ctx.lineTo(Math.round(this.x), Math.round(this.y));            self.ctx.closePath();   
  •         self.ctx.strokeStyle = 'hsla('+this.hue+', 100%, '+this.brightness+'%, '+this.alpha+')';            self.ctx.stroke(); if(self.showTarget){   
  •             self.ctx.save();                self.ctx.beginPath();   
  •             self.ctx.arc(Math.round(this.targetX), Math.round(this.targetY), this.targetRadius, 0, Math.PI*2, false)                self.ctx.closePath();   
  •             self.ctx.lineWidth = 1;                self.ctx.stroke();   
  •             self.ctx.restore();            } if(self.showShockwave){