Skip to content

Commit

Permalink
Cosmetic changes
Browse files Browse the repository at this point in the history
Conflicts:
	www/static/js/snow.js
  • Loading branch information
jakearchibald committed Dec 19, 2012
1 parent 5325cb0 commit 27aab34
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions www/static/js/snow.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,23 @@
Snowflake.prototype.tick = function() {
var sidePhase = this.sidePhase += this.sideVel;
this.y += this.vel;
this.x = this.midX + Math.sin(sidePhase) * this.sideAmp;
this.x += this.sideVel;
};
Snowflake.prototype.reset = function(maxX) {
var rand = Math.random();
var sizeRand;
var chanceOfLargeSnowflake = 0.15;

if (Math.random() < chanceOfLargeSnowflake) {
sizeRand = Math.random() * 0.9 + 0.1;
}
else {
sizeRand = Math.random() * 0.1;
}

this.size = sizeRand * 20 + 2.5;
this.vel = sizeRand * 4 + 1;
this.alpha = (1 - sizeRand * 0.9);
this.size = 2 + Math.random() * 5;
this.vel = 3 + Math.random() * 3;
this.alpha = 0.5 + Math.random() * 0.8;

// random x position
this.midX = Math.random() * maxX;
this.x = Math.random() * maxX;
this.y = -this.size;

// side-to-side movement
this.sidePhase = 0;
this.sideAmp = sizeRand * 40;
this.sideVel = Math.random() * 0.05;
this.sideVel = (0.5 - Math.random()) * this.vel;

this.x = 0;

return this;
};
Expand All @@ -53,7 +42,7 @@
var settleCanvasStyle = settleCanvas.style;
var windowResized;
var activeFlakes = [];
var snowflakesPerPixelPerSecond = 0.02;
var snowflakesPerPixelPerSecond = 0.05;
var PIx2 = Math.PI*2;
var assumedFps = 60;
var settlePoint;
Expand All @@ -75,7 +64,7 @@
range += xStart;
xStart = 0;
}
else if (xStart + range > settlePoint.length) {
if (xStart + range > settlePoint.length) {
range -= xStart + range - settlePoint.length;
}

Expand Down Expand Up @@ -109,7 +98,7 @@
activeFlakes.push( new Snowflake(canvas.width) );
}
}

var i = activeFlakes.length;
var flake;

Expand Down

0 comments on commit 27aab34

Please sign in to comment.