【烟花代码】,情人节,情侣生日礼物代码适用
老规矩,先上效果图
图片做了加速处理,放樱花的位置,速度完全由点击控制。
1初始化粒子系统
var Particle = function(x, y, hue){
this.x = x;
this.y = y;
this.coordLast = [
{
x: x, y: y},
{
x: x, y: y},
{
x: x, y: y}
];
this.angle = rand(0, 360);
this.speed = rand(((self.partSpeed - self.partSpeedVariance) <= 0) ? 1 : self.partSpeed - self.partSpeedVariance, (self.partSpeed + self.partSpeedVariance));
this.friction = 1 - self.partFriction/100;
this.gravity = self.partGravity/2;
this.hue = rand(hue-self.hueVariance, hue+self.hueVariance);
this.brightness = rand(50, 80);
this.alpha = rand(40,100)/100;
this.decay = rand(10, 50)/1000;
this.wind = (rand(0, self.partWind) - (self.partWind/2))/25;
this.lineWidth = self.lineWidth