Commit ff433304 by October

Merge branch 'master' of git.izhida.cn:php/pingan-maruko

parents 443355bd 583616e4
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<meta name="format-detection" content="telephone=no"> <meta name="format-detection" content="telephone=no">
{:assign var=projectId value=0} {:assign var=projectId value=0}
{:assign var=rem value=false} {:assign var=rem value=false}
{:assign var=version value='6.1.0'} {:assign var=version value='1.0.0'}
{:block name='projectx'}{:/block} {:block name='projectx'}{:/block}
{:if $rem == true} {:if $rem == true}
<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1, user-scalable=no"> <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1, user-scalable=no">
......
...@@ -67,6 +67,22 @@ $(document).ready(function () { ...@@ -67,6 +67,22 @@ $(document).ready(function () {
}); });
function deepClone(obj) {
var objClone = new Particle
if (obj && typeof obj === 'object') {
for (key in obj) {
if (key !== 'children') {
objClone[key] = obj[key]
}
}
}
return objClone
}
function init() { function init() {
inited = true; inited = true;
$('.page1').show(); $('.page1').show();
...@@ -99,32 +115,39 @@ function updateWorld() { ...@@ -99,32 +115,39 @@ function updateWorld() {
} }
function update() { function update() {
if (particles.length < 500 && Math.random() < probability) { if (particles.length < 200 && Math.random() < probability) {
createFirework(); createFirework();
} }
var alive = []; var alive = [];
for (var i = 0; i < particles.length; i++) { for (var i = 0; i < particles.length; i++) {
oldParticle = deepClone(particles[i])
if (particles[i].move()) { if (particles[i].move()) {
alive.push(particles[i]); alive.push(particles[i]);
particles[i].children.push(oldParticle)
if (particles[i].children.length > 5) {
particles[i].children.splice(0, 1)
}
} }
} }
particles = alive; particles = alive;
} }
function paint() { function paint() {
// ctx.globalCompositeOperation = 'source-over';
// // ctx.fillStyle = "rgba(0,0,0,0.1)";
// ctx.fillRect(0, 0, w, h);
ctx.globalCompositeOperation = 'lighter'; ctx.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(ctx);
for (k in particles[i].children) {
particles[i].children[k].w -= 0.205
particles[i].children[k].draw(ctx)
}
} }
} }
function createFirework() { function createFirework() {
xPoint = Math.random() * (w - 200) + 100; xPoint = Math.random() * (w - 200) + 100;
yPoint = Math.random() * (h - 500) + 100; yPoint = Math.random() * (h - 200) + 100;
var nFire = Math.random() * 50 + 100; var nFire = Math.random() * 50 + 100;
// var nFire = 1;
var c = "rgb(" + (~~(Math.random() * 200 + 55)) + "," + var c = "rgb(" + (~~(Math.random() * 200 + 55)) + "," +
(~~(Math.random() * 200 + 55)) + "," + (~~(Math.random() * 200 + 55)) + ")"; (~~(Math.random() * 200 + 55)) + "," + (~~(Math.random() * 200 + 55)) + ")";
for (var i = 0; i < nFire; i++) { for (var i = 0; i < nFire; i++) {
...@@ -139,7 +162,7 @@ function createFirework() { ...@@ -139,7 +162,7 @@ function createFirework() {
} }
function Particle() { function Particle() {
this.w = this.h = Math.random() * 4 + 1; this.w = this.h = 2;
this.x = xPoint - this.w / 2; this.x = xPoint - this.w / 2;
this.y = yPoint - this.h / 2; this.y = yPoint - this.h / 2;
...@@ -151,19 +174,21 @@ function Particle() { ...@@ -151,19 +174,21 @@ function Particle() {
this.alpha = Math.random() * .5 + .5; this.alpha = Math.random() * .5 + .5;
this.color; this.color;
this.children = [];
} }
Particle.prototype = { Particle.prototype = {
gravity: 0.01, gravity: 0.05,
move: function () { move: function () {
this.childrens.push({x:this.x,y:this.y} ); 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;
this.alpha -= 0.01; this.alpha -= 0.01;
if (this.x <= -this.w || this.x >= canvas.width || if (this.x <= -this.w || this.x >= screen.width ||
this.y >= canvas.height || this.y >= screen.height ||
this.alpha <= 0) { this.alpha <= 0) {
this.alpha = 0
return false; return false;
} }
return true; return true;
...@@ -172,7 +197,7 @@ Particle.prototype = { ...@@ -172,7 +197,7 @@ Particle.prototype = {
var step = 0.05; var step = 0.05;
c.save(); c.save();
c.beginPath(); c.beginPath();
this.w = this.w >= 0 ? this.w : 0.09
c.translate(this.x + this.w / 2, this.y + this.h / 2); c.translate(this.x + this.w / 2, this.y + this.h / 2);
c.arc(0, 0, this.w, 0, Math.PI * 2); c.arc(0, 0, this.w, 0, Math.PI * 2);
c.fillStyle = this.color; c.fillStyle = this.color;
......
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