(function() {

  var Flake = function() {
    this.reset();
    this.y = Math.random() * window.innerHeight;
  };

  Flake.prototype.reset = function() {
    this.x = Math.random() * window.innerWidth;
    this.y = -10;
    this.angle = Math.random() * 0.3 + Math.PI / 2 - 0.1;
    this.speed = Math.random() * 2 + 1;
    this.radius = Math.random() * 3 + 1;
  };

  Flake.prototype.tick = function(ctx) {
    this.x += this.speed * Math.cos(this.angle);
    this.y += this.speed * Math.sin(this.angle);
    this.angle += 0.01 - Math.random() * 0.02;

    //console.log(this.x, this.y);

    if (this.y > window.innerHeight + this.radius) {
      this.reset();
    }

    if (this.x > -this.radius && this.x < window.innerWidth + this.radius) {
      ctx.beginPath();
      ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
      ctx.fill();
    }
  };

  var canvas = document.getElementById("snow-canvas");
  var ctx = canvas.getContext("2d");

  var flakes = [];
  for (var i = 0; i < 512; i++) {
    flakes.push(new Flake());
  }

  var resetCanvas = function() {
    ctx.fillStyle = "rgb(255, 255, 255)";
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
  };

  var redraw = function() {
    ctx.clearRect(0, 0, canvas.width, canvas.height);

    ctx.fillStyle = "rgb(255, 255, 255)";
    for (var i = flakes.length - 1; i >= 0; i--) {
      flakes[i].tick(ctx);
    }

    requestAnimationFrame(redraw);
  };

  window.addEventListener("resize", resetCanvas);

  resetCanvas();
  redraw();

}());

@@ -49,232 +49,269 @@
 is.r
-eset();%0A    this.y = Math.random() * window.innerHeight;%0A  %7D;%0A%0A  Flake.prototype.reset = function() %7B%0A    this.x = Math.random() * window.innerWidth;%0A    this.y = -10;%0A    this.angle = Math.random() * 0.3 + Math.PI / 2 - 0.1
+adius = Math.random() * 3 + 1;%0A%0A    this.pos = %7B%0A      x: Math.random() * window.innerWidth,%0A      y: Math.random() * window.innerHeight,%0A    %7D;%0A%0A    this.velocity = %7B x: 0, y: 0 %7D;%0A  %7D;%0A%0A  Flake.prototype.wrapValues = function() %7B%0A    var v = this.radius * 0.9
 ;%0A  
@@ -321,176 +321,240 @@
 his.
-speed = Math.random() * 2 + 1;%0A    this.radius = Math.random() * 3 + 1;%0A  %7D;%0A%0A  Flake.prototype.tick = function(ctx) %7B%0A    this.x += this.speed * Math.cos(this.angle);%0A
+velocity.y = Math.min(this.velocity.y, v);%0A    this.velocity.x = Math.min(Math.max(this.velocity.x, -v / 5), v / 5);%0A%0A    var height = window.innerHeight + this.radius * 2;%0A    if (this.pos.y %3E window.innerHeight + this.radius) %7B%0A  
     
@@ -562,130 +562,154 @@
 his.
+pos.
 y 
-+= this.speed * Math.sin(this.angle)
+-= height;%0A    %7D%0A%0A    var width = window.innerWidth + this.radius * 2
 ;%0A    
+if (
 this.
-angle += 0.01 - Math.random() * 0.02;%0A%0A    //console.log(this.x, this.y);
+pos.x %3C -this.radius) %7B%0A      this.pos.x += width;%0A    %7D
 %0A%0A  
@@ -719,17 +719,21 @@
 f (this.
-y
+pos.x
  %3E windo
@@ -731,38 +731,37 @@
 x %3E window.inner
-Height
+Width
  + this.radius) 
@@ -777,23 +777,30 @@
 his.
-reset()
+pos.x -= width
 ;%0A    %7D%0A
 %0A   
@@ -799,88 +799,251 @@
   %7D%0A
-%0A
   
-  if (this.x %3E -this.radius && this.x %3C window.innerWidth +
+%7D;%0A%0A  Flake.prototype.tick = function(ctx) %7B%0A    this.velocity.y += 0.4 - 0.5 * Math.random();%0A    this.velocity.x += 0.05 - 0.1 * Math.random();%0A    this.pos.x += this.velocity.x;%0A    this.pos.y += this.velocity.y;%0A%0A   
  this.
+w
 ra
-dius) %7B%0A  
+pValues();%0A%0A
     
@@ -1059,26 +1059,24 @@
 Path();%0A    
-  
 ctx.arc(this
@@ -1080,16 +1080,20 @@
 his.
+pos.
 x, this.
 y, t
@@ -1088,16 +1088,20 @@
 x, this.
+pos.
 y, this.
@@ -1129,18 +1129,16 @@
 2);%0A    
-  
 ctx.fill
@@ -1141,22 +1141,16 @@
 fill();%0A
-    %7D%0A
   %7D;%0A%0A  

Improve quality of snow