/** * particleground.js v1.0.0 (https://github.com/barrior/particleground.js) * copyright 2016 barrior * licensed under the mit (https://opensource.org/licenses/mit-license.php) particle , wave , snow */ !function(t){"object"==typeof module&&module.exports?module.exports=t():t()}(function(){"use strict";function t(t){return parseint(t,10)}function e(t){return t.replace(t,"")}function i(){return"#"+c().tostring(16).slice(-6)}function n(t,e){return c()*(t-e)+e}function o(){var t,e,i=arguments,n=i[0]||{},s=!1,r=i.length,c=1;for("boolean"==typeof n&&(s=n,n=i[1]||{},c++);c0&&t<1?e*t:t}function m(t){var e=!!p(t)&&t.length,n=function(){return t[b(c()*e)]};return"string"!=typeof t?e?n:i:function(){return t}}function v(t,e){t.set&&!t.paused&&(r(e)&&e.call(t,"pause"),t.paused=!0)}function g(t,e){t.set&&t.paused&&(r(e)&&e.call(t,"open"),t.paused=!1,t.draw())}function y(t,e){t.set.resize&&u(w,"resize",function(){var i=t.cw,n=t.ch;t.cw=t.c.width=f(t.container,"width"),t.ch=t.c.height=f(t.container,"height");var o=t.cw/i,s=t.ch/n;p(t.dots)&&t.dots.foreach(function(t){a(t)&&(t.x*=o,t.y*=s)}),r(e)&&e.call(t,o,s),t.paused&&t.draw()})}function x(t,i,n){e(i).split(",").foreach(function(e){t[e]=function(){z[e](this,n)}})}var w=window,e=document,c=math.random,b=math.floor,p=array.isarray,a=!!e.createelement("canvas").getcontext,t=/\s/g,k=/^\d+(\.\d+)?[a-z]+$/i;w.requestanimationframe=function(t){return t.requestanimationframe||t.webkitrequestanimationframe||t.mozrequestanimationframe||function(e){t.settimeout(e,1e3/60)}}(w);var z={pint:t,trimall:e,randomcolor:i,limitrandom:n,extend:o,typechecking:s,isfunction:r,isplainobject:a,iselem:c,getcss:f,offset:h,createcanvas:p,scalevalue:d,setcolor:m,pause:v,open:g,resize:y,modifyprototype:x},l={version:"1.0.0",canvassupport:a,commonconfig:{opacity:1,color:[],resize:!0},util:z,inherit:{requestanimationframe:function(){!this.paused&&w.requestanimationframe(this.draw.bind(this))},pause:function(){v(this)},open:function(){g(this)},resize:function(){y(this)}},event:{on:u,off:l},extend:function(t){return o(t,this.inherit),this}};return w.particleground=l,"function"==typeof define&&define.amd&&define(function(){return l}),l}),+function(t){"use strict";function e(t,e,i){for(var n=o.getcss;t=t.offsetparent;)if(n(t,e)===i)return!0;return!1}function i(t,e){o.createcanvas(this,i,t,e)}function n(t){var e=this,i=e.set;i.num>0&&i.range>0&&(t="pause"===t?"off":"on",s[t](i.eventelem,"mousemove",e.movehandler),s[t](i.eventelem,"touchmove",e.movehandler))}var o=t.util,s=t.event,r=math.random,a=math.abs,c=2*math.pi;i.defaultconfig={speed:1,num:.12,max:2.4,min:.6,dis:130,linewidth:.2,range:160,eventelem:null};var f=i.prototype={version:"1.0.0",init:function(){this.set.num>0&&(this.set.range>0&&(o.iselem(this.set.eventelem)||this.set.eventelem===document||(this.set.eventelem=this.c),this.posx=r()*this.cw,this.posy=r()*this.ch,this.event()),this.createdots(),this.draw(),this.resize())},createdots:function(){for(var t,e=this.cw,i=this.ch,n=this.set,s=this.color,r=o.limitrandom,a=n.speed,c=n.max,f=n.min,h=o.pint(o.scalevalue(n.num,e)),u=[];h--;)t=r(c,f),u.push({x:r(e-t,t),y:r(i-t,t),r:t,vx:r(a,.5*-a)||a,vy:r(a,.5*-a)||a,color:s()});this.dots=u},draw:function(){var t=this.set;if(!(t.num<=0)){var e=this.cw,i=this.ch,n=this.cxt,o=this.paused;n.clearrect(0,0,e,i),n.linewidth=t.linewidth,n.globalalpha=t.opacity,this.dots.foreach(function(t){var s=t.r;if(n.save(),n.beginpath(),n.arc(t.x,t.y,s,0,c),n.fillstyle=t.color,n.fill(),n.restore(),!o){t.x+=t.vx,t.y+=t.vy;var r=t.x,a=t.y;(r+s>=e||r-s<=0)&&(t.vx*=-1),(a+s>=i||a-s<=0)&&(t.vy*=-1)}}),t.range>0&&this.connectdots(),this.requestanimationframe()}},connectdots:function(){var t=this.cxt,e=this.set,i=e.dis,n=this.posx,o=this.posy,s=e.range,r=this.dots,c=r.length;r.foreach(function(e,f){for(var h=e.x,u=e.y,l=e.color;++f0&&this.set.range>0&&(this.posx*=t,this.posy*=e,this.getelemoffset())}),t.particle=f.constructor=i}(particleground),+function(t){"use strict";function e(t,n){i.createcanvas(this,e,t,n)}var i=t.util,n=math.random,o=2*math.pi;e.defaultconfig={color:"#fff",max:6.5,min:.4,speed:.4};var s=e.prototype={version:"1.0.0",init:function(){this.dots=[],this.createdots(),this.draw(),this.resize()},snowshape:function(){var t=this.color,e=this.cw,o=this.set,s=o.speed,r=i.limitrandom(o.max,o.min);return{x:n()*e,y:-r,r:r,vx:n()||.4,vy:r*s,color:t()}},createdots:function(){for(var t=i.pint(6*n()),e=this.dots;t--;)e.push(this.snowshape())},draw:function(){var t=this,e=t.set,i=t.cxt,s=t.cw,r=t.ch,a=t.paused;i.clearrect(0,0,s,r),i.globalalpha=e.opacity,t.dots.foreach(function(e,c,f){var h=e.x,u=e.y,l=e.r;i.save(),i.beginpath(),i.arc(h,u,l,0,o),i.fillstyle=e.color,i.fill(),i.restore(),a||(e.x+=e.vx,e.y+=e.vy,n()>.99&&n()>.5&&(e.vx*=-1),h<0||h-l>s?f.splice(c,1,t.snowshape()):u-l>=r&&f.splice(c,1))}),!a&&n()>.9&&t.createdots(),t.requestanimationframe()}};t.extend(s),t.snow=s.constructor=e}(particleground),+function(t){"use strict";function e(t,n){i.createcanvas(this,e,t,n)}var i=t.util,n=i.limitrandom,o=i.randomcolor,s=i.scalevalue,r=math.random,a=math.sin,c=2*math.pi,f="undefined",h=array.isarray;e.defaultconfig={num:3,fillcolor:[],linecolor:[],linewidth:[],offsetleft:[],offsettop:[],crestheight:[],ripplenum:[],speed:[],fill:!1,stroke:!0};var u=e.prototype={version:"1.0.0",init:function(){this.set.num>0&&(this.ripplelength=[],this.attrnormalize(),this.createdots(),this.draw(),this.resize())},attrnormalize:function(){["fillcolor","linecolor","linewidth","offsetleft","offsettop","crestheight","ripplenum","speed","fill","stroke"].foreach(function(t){this.attrprocessor(t)}.bind(this))},attrprocessor:function(t){var e=this.set.num,i=this.set[t],n=i,o="offsetleft"===t?this.cw:this.ch;for(h(i)||(n=this.set[t]=[]);e--;){var s=h(i)?i[e]:i;n[e]=typeof s===f?this.generateattrval(t):this.scalevalue(t,s,o),"ripplenum"===t&&(this.ripplelength[e]=this.cw/n[e])}},scalevalue:function(t,e,i){return"offsettop"===t||"offsetleft"===t||"crestheight"===t?s(e,i):e},generateattrval:function(t){var e=this.cw,i=this.ch;switch(t){case"linecolor":case"fillcolor":t=o();break;case"linewidth":t=n(2,.2);break;case"offsetleft":t=r()*e;break;case"offsettop":case"crestheight":t=r()*i;break;case"ripplenum":t=n(e/2,1);break;case"speed":t=n(.4,.1);break;case"fill":t=!1;break;case"stroke":t=!0}return t},setoffsettop:function(t){this.set.num>0&&(!h(t)&&t>0&&t<1&&(t*=this.ch),this.set.offsettop.foreach(function(e,i,n){n[i]=h(t)?t[i]||e:t}))},createdots:function(){for(var t=this.dots=[],e=this.ripplelength,i=this.cw,n=this.set.num;n--;){for(var o=[],s=c/e[n],r=0;r0&&this.dots.foreach(function(i){i.foreach(function(i){i.x*=t,i.y*=e})})}),t.wave=u.constructor=e}(particleground);