/*! snowmachine v0.1.0 */ var snowmachine=snowmachine||{};snowmachine.CanvasBackend=function(a){this.canvas=a.element,this.context=this.canvas.getContext("2d")},snowmachine.CanvasBackend.prototype.render=function(a){var b=this.context;b.clearRect(0,0,this.getWidth(),this.getHeight()),b.fillStyle="rgba(255, 255, 255, 0.5)",a.forEach(function(a){b.beginPath(),b.arc(a.x,a.y,a.radius,0,2*Math.PI,!1),b.fill()})},snowmachine.CanvasBackend.prototype.getWidth=function(){return this.canvas.width},snowmachine.CanvasBackend.prototype.getHeight=function(){return this.canvas.height},snowmachine=snowmachine||{},snowmachine.DEFAULT_COUNT=150,snowmachine.DEFAULT_FPS=25,snowmachine.DEFAULT_ANGLE=45,snowmachine.Engine=function(a){var b,c,d,e;for(this.backend=a.backend,this.count=a.count||snowmachine.DEFAULT_COUNT,this.fps=a.fps||snowmachine.DEFAULT_FPS,this.snowflakes=[],b=0;this.count>b;b++)c=Math.random()*this.backend.getWidth(),d=Math.random()*this.backend.getHeight(),e=5*Math.random()+1,this.snowflakes[b]=new snowmachine.Snowflake(c,d,e);this.last=new Date},snowmachine.Engine.prototype.loop=function(){var a=new Date;this.timedelta=(a-this.last)/1e3,this.last=a},snowmachine.Engine.prototype.start=function(){setInterval(this.loop.bind(this),1e3/this.fps)},snowmachine.SimpleEngine=function(a){snowmachine.Engine.call(this,a),this.angle=a.angle||snowmachine.DEFAULT_ANGLE},snowmachine.SimpleEngine.prototype=Object.create(snowmachine.Engine.prototype),snowmachine.SimpleEngine.prototype.loop=function(){snowmachine.Engine.prototype.loop.call(this),this.snowflakes.forEach(function(a){a.x+=this.timedelta*a.getHorizontalSpeed()*this.angle/45,a.y+=this.timedelta*a.getVerticalSpeed()*(90-this.angle)/45,a.x>this.backend.getWidth()+a.radius&&(a.x=-a.radius,a.y=Math.random()*this.backend.getHeight()),a.y>this.backend.getHeight()+a.radius&&(a.x=Math.random()*this.backend.getWidth(),a.y=-a.radius)},this),this.backend.render(this.snowflakes)},snowmachine=snowmachine||{},snowmachine.Snowflake=function(a,b,c){this.x=a,this.y=b,this.radius=c},snowmachine.Snowflake.prototype.getVerticalSpeed=function(){return 5*this.radius},snowmachine.Snowflake.prototype.getHorizontalSpeed=function(){return 5*this.radius};