Commit 11afe7fa by doszhang

dos

parent 120167b1
...@@ -215,24 +215,24 @@ function init() { ...@@ -215,24 +215,24 @@ function init() {
} }
function onLoad() { function onLoad() {
$('.canvas-block').html('<canvas id="canvas"></canvas>'); $('.canvas-block').html('<canvas id="fireworkCanvas"></canvas>');
canvas = document.getElementById("canvas"); fireworkCanvas = document.getElementById("fireworkCanvas");
ctx = canvas.getContext("2d"); fireworkCtx = canvas.getContext("2d");
resizeCanvas(); resizeCanvas();
window.requestAnimationFrame(updateWorld); window.requestAnimationFrame(updateWorld);
} }
function resizeCanvas() { function resizeCanvas() {
if (!!canvas) { if (!!fireworkCanvas) {
w = canvas.width = 640; w = fireworkCanvas.width = 640;
h = canvas.height = 1400; h = fireworkCanvas.height = 1400;
} }
} }
function updateWorld() { function updateWorld() {
canvas.width = 641; fireworkCanvas.width = 641;
canvas.width = 640; fireworkCanvas.width = 640;
update(); update();
paint(); paint();
if (!fireworkLock) { if (!fireworkLock) {
...@@ -259,12 +259,12 @@ function update() { ...@@ -259,12 +259,12 @@ function update() {
} }
function paint() { function paint() {
ctx.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(ctx);
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(ctx) particles[i].children[k].draw(fireworkCtx)
} }
} }
} }
......
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