代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>particles.js</title>
<meta name="description" content="particles.js is a lightweight JavaScript library for creating particles.">
<meta name="author" content="Vincent Garreau" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
</head>
<body>
<div id="particles">
<canvas class="particles-js-canvas-el" style="width: 100%; height: 100%;"></canvas>
</div>
<script src="js/jquery-2.1.4.min.js"></script>
<script src="js/plugins.js"></script>
<script src="js/init-particles.js"></script>
<script src="js/main.js"></script>
</body>
</html>
plugin.js:
function hexToRgb(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;e=e.replace(t,function(e,t,a,i){return t+t+a+a+i+i});var a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return a?{r:parseInt(a[1],16),g:parseInt(a[2],16),b:parseInt(a[3],16)}:null}function clamp(e,t,a){return Math.min(Math.max(e,t),a)}function isInArray(e,t){return t.indexOf(e)>-1}!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):e(jQuery)}(function(e){"use strict";function t(e){if(e instanceof Date)return e;if(String(e).match(s))return String(e).match(/^[0-9]*$/)&&(e=Number(e)),String(e).match(/\-/)&&(e=String(e).replace(/\-/g,"/")),new Date(e);throw new Error("Couldn't cast `"+e+"` to a date object.")}function a(e){var t=e.toString().replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1");return new RegExp(t)}function i(e){return function(t){var i=t.match(/%(-|!)?[A-Z]{1}(:[^;]+;)?/gi);if(i)for(var r=0,s=i.length;s>r;++r){var o=i[r].match(/%(-|!)?([a-zA-Z]{1})(:[^;]+;)?/),l=a(o[0]),d=o[1]||"",p=o[3]||"",u=null;o=o[2],c.hasOwnProperty(o)&&(u=c[o],u=Number(e[u])),null!==u&&("!"===d&&(u=n(p,u)),""===d&&10>u&&(u="0"+u.toString()),t=t.replace(l,u.toString()))}return t=t.replace(/%%/,"%")}}function n(e,t){var a="s",i="";return e&&(e=e.replace(/(:|;|\s)/gi,"").split(/\,/),1===e.length?a=e[0]:(i=e[0],a=e[1])),1===Math.abs(t)?i:a}var r=[],s=[],o={precision:100,elapse:!1};s.push(/^[0-9]*$/.source),s.push(/([0-9]{1,2}\/){2}[0-9]{4}( [0-9]{1,2}(:[0-9]{2}){2})?/.source),s.push(/[0-9]{4}([\/\-][0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source),s=new RegExp(s.join("|"));var c={Y:"years",m:"months",n:"daysToMonth",w:"weeks",d:"daysToWeek",D:"totalDays",H:"hours",M:"minutes",S:"seconds"},l=function(t,a,i){this.el=t,this.$el=e(t),this.interval=null,this.offset={},this.options=e.extend({},o),this.instanceNumber=r.length,r.push(this),this.$el.data("countdown-instance",this.instanceNumber),i&&("function"==typeof i?(this.$el.on("update.countdown",i),this.$el.on("stoped.countdown",i),this.$el.on("finish.countdown",i)):this.options=e.extend({},o,i)),this.setFinalDate(a),this.start()};e.extend(l.prototype,{start:function(){null!==this.interval&&clearInterval(this.interval);var e=this;this.update(),this.interval=setInterval(function(){e.update.call(e)},this.options.precision)},stop:function(){clearInterval(this.interval),this.interval=null,this.dispatchEvent("stoped")},toggle:function(){this.interval?this.stop():this.start()},pause:function(){this.stop()},resume:function(){this.start()},remove:function(){this.stop.call(this),r[this.instanceNumber]=null,delete this.$el.data().countdownInstance},setFinalDate:function(e){this.finalDate=t(e)},update:function(){if(0===this.$el.closest("html").length)return void this.remove();var t,a=void 0!==e._data(this.el,"events"),i=new Date;t=this.finalDate.getTime()-i.getTime(),t=Math.ceil(t/1e3),t=!this.options.elapse&&0>t?0:Math.abs(t),this.totalSecsLeft!==t&&a&&(this.totalSecsLeft=t,this.elapsed=i>=this.finalDate,this.offset={seconds:this.totalSecsLeft%60,minutes:Math.floor(this.totalSecsLeft/60)%60,hours:Math.floor(this.totalSecsLeft/60/60)%24,days:Math.floor(this.totalSecsLeft/60/60/24)%7,daysToWeek:Math.floor(this.totalSecsLeft/60/60/24)%7,daysToMonth:Math.floor(this.totalSecsLeft/60/60/24%30.4368),totalDays:Math.floor(this.totalSecsLeft/60/60/24),weeks:Math.floor(this.totalSecsLeft/60/60/24/7),months:Math.floor(this.totalSecsLeft/60/60/24/30.4368),years:Math.abs(this.finalDate.getFullYear()-i.getFullYear())},this.options.elapse||0!==this.totalSecsLeft?this.dispatchEvent("update"):(this.stop(),this.dispatchEvent("finish")))},dispatchEvent:function(t){var a=e.Event(t+".countdown");a.finalDate=this.finalDate,a.elapsed=this.elapsed,a.offset=e.extend({},this.offset),a.strftime=i(this.offset),this.$el.trigger(a)}}),e.fn.countdown=function(){var t=Array.prototype.slice.call(arguments,0);return this.each(function(){var a=e(this).data("countdown-instance");if(void 0!==a){var i=r[a],n=t[0];l.prototype.hasOwnProperty(n)?i[n].apply(i,t.slice(1)):null===String(n).match(/^[$A-Z_][0-9A-Z_$]*$/i)?(i.setFinalDate.call(i,n),i.start()):e.error("Method %s does not exist on jQuery.countdown".replace(/\%s/gi,n))}else new l(this,t[0],t[1])})}}),!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports?require("jquery"):window.jQuery||window.Zepto)}(function(e){var t,a,i,n,r,s,o="Close",c="BeforeClose",l="AfterClose",d="BeforeAppend",p="MarkupParse",u="Open",m="Change",v="mfp",f="."+v,h="mfp-ready",y="mfp-removing",g="mfp-prevent-close",b=function(){},x=!!window.jQuery,w=e(window),_=function(e,a){t.ev.on(v+e+f,a)},k=function(t,a,i,n){var r=document.createElement("div");return r.className="mfp-"+t,i&&(r.innerHTML=i),n?a&&a.appendChild(r):(r=e(r),a&&r.appendTo(a)),r},C=function(a,i){t.ev.triggerHandler(v+a,i),t.st.callbacks&&(a=a.charAt(0).toLowerCase()+a.slice(1),t.st.callbacks[a]&&t.st.callbacks[a].apply(t,e.isArray(i)?i:[i]))},I=function(a){return a===s&&t.currTemplate.closeBtn||(t.currTemplate.closeBtn=e(t.st.closeMarkup.replace("%title%",t.st.tClose)),s=a),t.currTemplate.closeBtn},S=function(){e.magnificPopup.instance||(t=new b,t.init(),e.magnificPopup.instance=t)},M=function(){var e=document.createElement("p").style,t=["ms","O","Moz","Webkit"];if(void 0!==e.transition)return!0;for(;t.length;)if(t.pop()+"Transition"in e)return!0;return!1};b.prototype={constructor:b,init:function(){var a=navigator.appVersion;t.isLowIE=t.isIE8=document.all&&!document.addEventListener,t.isAndroid=/android/gi.test(a),t.isIOS=/iphone|ipad|ipod/gi.test(a),t.supportsTransition=M(),t.probablyMobile=t.isAndroid||t.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),i=e(document),t.popupsCache={}},open:function(a){var n;if(a.isObj===!1){t.items=a.items.toArray(),t.index=0;var s,o=a.items;for(n=0;n<o.length;n++)if(s=o[n],s.parsed&&(s=s.el[0]),s===a.el[0]){t.index=n;break}}else t.items=e.isArray(a.items)?a.items:[a.items],t.index=a.index||0;if(t.isOpen)return void t.updateItemHTML();t.types=[],r="",a.mainEl&&a.mainEl.length?t.ev=a.mainEl.eq(0):t.ev=i,a.key?(t.popupsCache[a.key]||(t.popupsCache[a.key]={}),t.currTemplate=t.popupsCache[a.key]):t.currTemplate={},t.st=e.extend(!0,{},e.magnificPopup.defaults,a),t.fixedContentPos="auto"===t.st.fixedContentPos?!t.probablyMobile:t.st.fixedContentPos,t.st.modal&&(t.st.closeOnContentClick=!1,t.st.closeOnBgClick=!1,t.st.showCloseBtn=!1,t.st.enableEscapeKey=!1),t.bgOverlay||(t.bgOverlay=k("bg").on("click"+f,function(){t.close()}),t.wrap=k("wrap").attr("tabindex",-1).on("click"+f,function(e){t._checkIfClose(e.target)&&t.close()}),t.container=k("container",t.wrap)),t.contentContainer=k("content"),t.st.preloader&&(t.preloader=k("preloader",t.container,t.st.tLoading));var c=e.magnificPopup.modules;for(n=0;n<c.length;n++){var l=c[n];l=l.charAt(0).toUpperCase()+l.slice(1),t["init"+l].call(t)}C("BeforeOpen"),t.st.showCloseBtn&&(t.st.closeBtnInside?(_(p,function(e,t,a,i){a.close_replaceWith=I(i.type)}),r+=" mfp-close-btn-in"):t.wrap.append(I())),t.st.alignTop&&(r+=" mfp-align-top"),t.fixedContentPos?t.wrap.css({overflow:t.st.overflowY,overflowX:"hidden",overflowY:t.st.overflowY}):t.wrap.css({top:w.scrollTop(),position:"absolute"}),(t.st.fixedBgPos===!1||"auto"===t.st.fixedBgPos&&!t.fixedContentPos)&&t.bgOverlay.css({height:i.height(),position:"absolute"}),t.st.enableEscapeKey&&i.on("keyup"+f,function(e){27===e.keyCode&&t.close()}),w.on("resize"+f,function(){t.updateSize()}),t.st.closeOnContentClick||(r+=" mfp-auto-cursor"),r&&t.wrap.addClass(r);var d=t.wH=w.height(),m={};if(t.fixedContentPos&&t._hasScrollBar(d)){var v=t._getScrollbarSize();v&&(m.marginRight=v)}t.fixedContentPos&&(t.isIE7?e("body, html").css("overflow","hidden"):m.overflow="hidden");var y=t.st.mainClass;return t.isIE7&&(y+=" mfp-ie7"),y&&t._addClassToMFP(y),t.updateItemHTML(),C("BuildControls"),e("html").css(m),t.bgOverlay.add(t.wrap).prependTo(t.st.prependTo||e(document.body)),t._lastFocusedEl=document.activeElement,setTimeout(function(){t.content?(t._addClassToMFP(h),t._setFocus()):t.bgOverlay.addClass(h),i.on("focusin"+f,t._onFocusIn)},16),t.isOpen=!0,t.updateSize(d),C(u),a},close:function(){t.isOpen&&(C(c),t.isOpen=!1,t.st.removalDelay&&!t.isLowIE&&t.supportsTransition?(t._addClassToMFP(y),setTimeout(function(){t._close()},t.st.removalDelay)):t._close())},_close:function(){C(o);var a=y+" "+h+" ";if(t.bgOverlay.detach(),t.wrap.detach(),t.container.empty(),t.st.mainClass&&(a+=t.st.mainClass+" "),t._removeClassFromMFP(a),t.fixedContentPos){var n={marginRight:""};t.isIE7?e("body, html").css("overflow",""):n.overflow="",e("html").css(n)}i.off("keyup"+f+" focusin"+f),t.ev.off(f),t.wrap.attr("class","mfp-wrap").removeAttr("style"),t.bgOverlay.attr("class","mfp-bg"),t.container.attr("class","mfp-container"),!t.st.showCloseBtn||t.st.closeBtnInside&&t.currTemplate[t.currItem.type]!==!0||t.currTemplate.closeBtn&&t.currTemplate.closeBtn.detach(),t.st.autoFocusLast&&t._lastFocusedEl&&e(t._lastFocusedEl).focus(),t.currItem=null,t.content=null,t.currTemplate=null,t.prevHeight=0,C(l)},updateSize:function(e){if(t.isIOS){var a=document.documentElement.clientWidth/window.innerWidth,i=window.innerHeight*a;t.wrap.css("height",i),t.wH=i}else t.wH=e||w.height();t.fixedContentPos||t.wrap.css("height",t.wH),C("Resize")},updateItemHTML:function(){var a=t.items[t.index];t.contentContainer.detach(),t.content&&t.content.detach(),a.parsed||(a=t.parseEl(t.index));var i=a.type;if(C("BeforeChange",[t.currItem?t.currItem.type:"",i]),t.currItem=a,!t.currTemplate[i]){var r=t.st[i]?t.st[i].markup:!1;C("FirstMarkupParse",r),r?t.currTemplate[i]=e(r):t.currTemplate[i]=!0}n&&n!==a.type&&t.container.removeClass("mfp-"+n+"-holder");var s=t["get"+i.charAt(0).toUpperCase()+i.slice(1)](a,t.currTemplate[i]);t.appendContent(s,i),a.preloaded=!0,C(m,a),n=a.type,t.container.prepend(t.contentContainer),C("AfterChange")},appendContent:function(e,a){t.content=e,e?t.st.showCloseBtn&&t.st.closeBtnInside&&t.currTemplate[a]===!0?t.content.find(".mfp-close").length||t.content.append(I()):t.content=e:t.content="",C(d),t.container.addClass("mfp-"+a+"-holder"),t.contentContainer.append(t.content)},parseEl:function(a){var i,n=t.items[a];if(n.tagName?n={el:e(n)}:(i=n.type,n={data:n,src:n.src}),n.el){for(var r=t.types,s=0;s<r.length;s++)if(n.el.hasClass("mfp-"+r[s])){i=r[s];break}n.src=n.el.attr("data-mfp-src"),n.src||(n.src=n.el.attr("href"))}return n.type=i||t.st.type||"inline",n.index=a,n.parsed=!0,t.items[a]=n,C("ElementParse",n),t.items[a]},addGroup:function(e,a){var i=function(i){i.mfpEl=this,t._openClick(i,e,a)};a||(a={});var n="click.magnificPopup";a.mainEl=e,a.items?(a.isObj=!0,e.off(n).on(n,i)):(a.isObj=!1,a.delegate?e.off(n).on(n,a.delegate,i):(a.items=e,e.off(n).on(n,i)))},_openClick:function(a,i,n){var r=void 0!==n.midClick?n.midClick:e.magnificPopup.defaults.midClick;if(r||!(2===a.which||a.ctrlKey||a.metaKey||a.altKey||a.shiftKey)){var s=void 0!==n.disableOn?n.disableOn:e.magnificPopup.defaults.disableOn;if(s)if(e.isFunction(s)){if(!s.call(t))return!0}else if(w.width()<s)return!0;a.type&&(a.preventDefault(),t.isOpen&&a.stopPropagation()),n.el=e(a.mfpEl),n.delegate&&(n.items=i.find(n.delegate)),t.open(n)}},updateStatus:function(e,i){if(t.preloader){a!==e&&t.container.removeClass("mfp-s-"+a),i||"loading"!==e||(i=t.st.tLoading);var n={status:e,text:i};C("UpdateStatus",n),e=n.status,i=n.text,t.preloader.html(i),t.preloader.find("a").on("click",function(e){e.stopImmediatePropagation()}),t.container.addClass("mfp-s-"+e),a=e}},_checkIfClose:function(a){if(!e(a).hasClass(g)){var i=t.st.closeOnContentClick,n=t.st.closeOnBgClick;if(i&&n)return!0;if(!t.content||e(a).hasClass("mfp-close")||t.preloader&&a===t.preloader[0])return!0;if(a===t.content[0]||e.contains(t.content[0],a)){if(i)return!0}else if(n&&e.contains(document,a))return!0;return!1}},_addClassToMFP:function(e){t.bgOverlay.addClass(e),t.wrap.addClass(e)},_removeClassFromMFP:function(e){this.bgOverlay.removeClass(e),t.wrap.removeClass(e)},_hasScrollBar:function(e){return(t.isIE7?i.height():document.body.scrollHeight)>(e||w.height())},_setFocus:function(){(t.st.focus?t.content.find(t.st.focus).eq(0):t.wrap).focus()},_onFocusIn:function(a){return a.target===t.wrap[0]||e.contains(t.wrap[0],a.target)?void 0:(t._setFocus(),!1)},_parseMarkup:function(t,a,i){var n;i.data&&(a=e.extend(i.data,a)),C(p,[t,a,i]),e.each(a,function(a,i){if(void 0===i||i===!1)return!0;if(n=a.split("_"),n.length>1){var r=t.find(f+"-"+n[0]);if(r.length>0){var s=n[1];"replaceWith"===s?r[0]!==i[0]&&r.replaceWith(i):"img"===s?r.is("img")?r.attr("src",i):r.replaceWith(e("<img>").attr("src",i).attr("class",r.attr("class"))):r.attr(n[1],i)}}else t.find(f+"-"+a).html(i)})},_getScrollbarSize:function(){if(void 0===t.scrollbarSize){var e=document.createElement("div");e.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(e),t.scrollbarSize=e.offsetWidth-e.clientWidth,document.body.removeChild(e)}return t.scrollbarSize}},e.magnificPopup={instance:null,proto:b.prototype,modules:[],open:function(t,a){return S(),t=t?e.extend(!0,{},t):{},t.isObj=!0,t.index=a||0,this.instance.open(t)},close:function(){return e.magnificPopup.instance&&e.magnificPopup.instance.close()},registerModule:function(t,a){a.options&&(e.magnificPopup.defaults[t]=a.options),e.extend(this.proto,a.proto),this.modules.push(t)},defaults:{disableOn:0,key:null,midClick:!1,mainClass:"",preloader:!0,focus:"",closeOnContentClick:!1,closeOnBgClick:!0,closeBtnInside:!0,showCloseBtn:!0,enableEscapeKey:!0,modal:!1,alignTop:!1,removalDelay:0,prependTo:null,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'<button title="%title%" type="button" class="mfp-close">×</button>',tClose:"Close (Esc)",tLoading:"Loading...",autoFocusLast:!0}},e.fn.magnificPopup=function(a){S();var i=e(this);if("string"==typeof a)if("open"===a){var n,r=x?i.data("magnificPopup"):i[0].magnificPopup,s=parseInt(arguments[1],10)||0;r.items?n=r.items[s]:(n=i,r.delegate&&(n=n.find(r.delegate)),n=n.eq(s)),t._openClick({mfpEl:n},i,r)}else t.isOpen&&t[a].apply(t,Array.prototype.slice.call(arguments,1));else a=e.extend(!0,{},a),x?i.data("magnificPopup",a):i[0].magnificPopup=a,t.addGroup(i,a);return i};var z,P,T,A="inline",E=function(){T&&(P.after(T.addClass(z)).detach(),T=null)};e.magnificPopup.registerModule(A,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){t.types.push(A),_(o+"."+A,function(){E()})},getInline:function(a,i){if(E(),a.src){var n=t.st.inline,r=e(a.src);if(r.length){var s=r[0].parentNode;s&&s.tagName&&(P||(z=n.hiddenClass,P=k(z),z="mfp-"+z),T=r.after(P).detach().removeClass(z)),t.updateStatus("ready")}else t.updateStatus("error",n.tNotFound),r=e("<div>");return a.inlineElement=r,r}return t.updateStatus("ready"),t._parseMarkup(i,{},a),i}}});var F,j="ajax",O=function(){F&&e(document.body).removeClass(F)},L=function(){O(),t.req&&t.req.abort()};e.magnificPopup.registerModule(j,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'<a href="%url%">The content</a> could not be loaded.'},proto:{initAjax:function(){t.types.push(j),F=t.st.ajax.cursor,_(o+"."+j,L),_("BeforeChange."+j,L)},getAjax:function(a){F&&e(document.body).addClass(F),t.updateStatus("loading");var i=e.extend({url:a.src,success:function(i,n,r){var s={data:i,xhr:r};C("ParseAjax",s),t.appendContent(e(s.data),j),a.finished=!0,O(),t._setFocus(),setTimeout(function(){t.wrap.addClass(h)},16),t.updateStatus("ready"),C("AjaxContentAdded")},error:function(){O(),a.finished=a.loadError=!0,t.updateStatus("error",t.st.ajax.tError.replace("%url%",a.src))}},t.st.ajax.settings);return t.req=e.ajax(i),""}}});var q,R=function(a){if(a.data&&void 0!==a.data.title)return a.data.title;var i=t.st.image.titleSrc;if(i){if(e.isFunction(i))return i.call(t,a);if(a.el)return a.el.attr(i)||""}return""};e.magnificPopup.registerModule("image",{options:{markup:'<div class="mfp-figure"><div class="mfp-close"></div><figure><div class="mfp-img"></div><figcaption><div class="mfp-bottom-bar"><div class="mfp-title"></div><div class="mfp-counter"></div></div></figcaption></figure></div>',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'<a href="%url%">The image</a> could not be loaded.'},proto:{initImage:function(){var a=t.st.image,i=".image";t.types.push("image"),_(u+i,function(){"image"===t.currItem.type&&a.cursor&&e(document.body).addClass(a.cursor)}),_(o+i,function(){a.cursor&&e(document.body).removeClass(a.cursor),w.off("resize"+f)}),_("Resize"+i,t.resizeImage),t.isLowIE&&_("AfterChange",t.resizeImage)},resizeImage:function(){var e=t.currItem;if(e&&e.img&&t.st.image.verticalFit){var a=0;t.isLowIE&&(a=parseInt(e.img.css("padding-top"),10)+parseInt(e.img.css("padding-bottom"),10)),e.img.css("max-height",t.wH-a)}},_onImageHasSize:function(e){e.img&&(e.hasSize=!0,q&&clearInterval(q),e.isCheckingImgSize=!1,C("ImageHasSize",e),e.imgHidden&&(t.content&&t.content.removeClass("mfp-loading"),e.imgHidden=!1))},findImageSize:function(e){var a=0,i=e.img[0],n=function(r){q&&clearInterval(q),q=setInterval(function(){return i.naturalWidth>0?void t._onImageHasSize(e):(a>200&&clearInterval(q),a++,void(3===a?n(10):40===a?n(50):100===a&&n(500)))},r)};n(1)},getImage:function(a,i){var n=0,r=function(){a&&(a.img[0].complete?(a.img.off(".mfploader"),a===t.currItem&&(t._onImageHasSize(a),t.updateStatus("ready")),a.hasSize=!0,a.loaded=!0,C("ImageLoadComplete")):(n++,200>n?setTimeout(r,100):s()))},s=function(){a&&(a.img.off(".mfploader"),a===t.currItem&&(t._onImageHasSize(a),t.updateStatus("error",o.tError.replace("%url%",a.src))),a.hasSize=!0,a.loaded=!0,a.loadError=!0)},o=t.st.image,c=i.find(".mfp-img");if(c.length){var l=document.createElement("img");l.className="mfp-img",a.el&&a.el.find("img").length&&(l.alt=a.el.find("img").attr("alt")),a.img=e(l).on("load.mfploader",r).on("error.mfploader",s),l.src=a.src,c.is("img")&&(a.img=a.img.clone()),l=a.img[0],l.naturalWidth>0?a.hasSize=!0:l.width||(a.hasSize=!1)}return t._parseMarkup(i,{title:R(a),img_replaceWith:a.img},a),t.resizeImage(),a.hasSize?(q&&clearInterval(q),a.loadError?(i.addClass("mfp-loading"),t.updateStatus("error",o.tError.replace("%url%",a.src))):(i.removeClass("mfp-loading"),t.updateStatus("ready")),i):(t.updateStatus("loading"),a.loading=!0,a.hasSize||(a.imgHidden=!0,i.addClass("mfp-loading"),t.findImageSize(a)),i)}}});var B,D=function(){return void 0===B&&(B=void 0!==document.createElement("p").style.MozTransform),B};e.magnificPopup.registerModule("zoom",{options:{enabled:!1,easing:"ease-in-out",duration:300,opener:function(e){return e.is("img")?e:e.find("img")}},proto:{initZoom:function(){var e,a=t.st.zoom,i=".zoom";if(a.enabled&&t.supportsTransition){var n,r,s=a.duration,l=function(e){var t=e.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"),i="all "+a.duration/1e3+"s "+a.easing,n={position:"fixed",zIndex:9999,left:0,top:0,"-webkit-backface-visibility":"hidden"},r="transition";return n["-webkit-"+r]=n["-moz-"+r]=n["-o-"+r]=n[r]=i,t.css(n),t},d=function(){t.content.css("visibility","visible")};_("BuildControls"+i,function(){if(t._allowZoom()){if(clearTimeout(n),t.content.css("visibility","hidden"),e=t._getItemToZoom(),!e)return void d();r=l(e),r.css(t._getOffset()),t.wrap.append(r),n=setTimeout(function(){r.css(t._getOffset(!0)),n=setTimeout(function(){d(),setTimeout(function(){r.remove(),e=r=null,C("ZoomAnimationEnded")},16)},s)},16)}}),_(c+i,function(){if(t._allowZoom()){if(clearTimeout(n),t.st.removalDelay=s,!e){if(e=t._getItemToZoom(),!e)return;r=l(e)}r.css(t._getOffset(!0)),t.wrap.append(r),t.content.css("visibility","hidden"),setTimeout(function(){r.css(t._getOffset())},16)}}),_(o+i,function(){t._allowZoom()&&(d(),r&&r.remove(),e=null)})}},_allowZoom:function(){return"image"===t.currItem.type},_getItemToZoom:function(){return t.currItem.hasSize?t.currItem.img:!1},_getOffset:function(a){var i;i=a?t.currItem.img:t.st.zoom.opener(t.currItem.el||t.currItem);var n=i.offset(),r=parseInt(i.css("padding-top"),10),s=parseInt(i.css("padding-bottom"),10);n.top-=e(window).scrollTop()-r;var o={width:i.width(),height:(x?i.innerHeight():i[0].offsetHeight)-s-r};return D()?o["-moz-transform"]=o.transform="translate("+n.left+"px,"+n.top+"px)":(o.left=n.left,o.top=n.top),o}}});var H="iframe",W="//about:blank",N=function(e){if(t.currTemplate[H]){var a=t.currTemplate[H].find("iframe");a.length&&(e||(a[0].src=W),t.isIE8&&a.css("display",e?"block":"none"))}};e.magnificPopup.registerModule(H,{options:{markup:'<div class="mfp-iframe-scaler"><div class="mfp-close"></div><iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe></div>',srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){t.types.push(H),_("BeforeChange",function(e,t,a){t!==a&&(t===H?N():a===H&&N(!0))}),_(o+"."+H,function(){N()})},getIframe:function(a,i){var n=a.src,r=t.st.iframe;e.each(r.patterns,function(){return n.indexOf(this.index)>-1?(this.id&&(n="string"==typeof this.id?n.substr(n.lastIndexOf(this.id)+this.id.length,n.length):this.id.call(this,n)),n=this.src.replace("%id%",n),!1):void 0});var s={};return r.srcAction&&(s[r.srcAction]=n),t._parseMarkup(i,s,a),t.updateStatus("ready"),i}}});var $=function(e){var a=t.items.length;return e>a-1?e-a:0>e?a+e:e},J=function(e,t,a){return e.replace(/%curr%/gi,t+1).replace(/%total%/gi,a)};e.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var a=t.st.gallery,n=".mfp-gallery";return t.direction=!0,a&&a.enabled?(r+=" mfp-gallery",_(u+n,function(){a.navigateByImgClick&&t.wrap.on("click"+n,".mfp-img",function(){return t.items.length>1?(t.next(),!1):void 0}),i.on("keydown"+n,function(e){37===e.keyCode?t.prev():39===e.keyCode&&t.next()})}),_("UpdateStatus"+n,function(e,a){a.text&&(a.text=J(a.text,t.currItem.index,t.items.length))}),_(p+n,function(e,i,n,r){var s=t.items.length;n.counter=s>1?J(a.tCounter,r.index,s):""}),_("BuildControls"+n,function(){if(t.items.length>1&&a.arrows&&!t.arrowLeft){var i=a.arrowMarkup,n=t.arrowLeft=e(i.replace(/%title%/gi,a.tPrev).replace(/%dir%/gi,"left")).addClass(g),r=t.arrowRight=e(i.replace(/%title%/gi,a.tNext).replace(/%dir%/gi,"right")).addClass(g);n.click(function(){t.prev()}),r.click(function(){t.next()}),t.container.append(n.add(r))}}),_(m+n,function(){t._preloadTimeout&&clearTimeout(t._preloadTimeout),t._preloadTimeout=setTimeout(function(){t.preloadNearbyImages(),t._preloadTimeout=null},16)}),void _(o+n,function(){i.off(n),t.wrap.off("click"+n),t.arrowRight=t.arrowLeft=null})):!1},next:function(){t.direction=!0,t.index=$(t.index+1),t.updateItemHTML()},prev:function(){t.direction=!1,t.index=$(t.index-1),t.updateItemHTML()},goTo:function(e){t.direction=e>=t.index,t.index=e,t.updateItemHTML()},preloadNearbyImages:function(){var e,a=t.st.gallery.preload,i=Math.min(a[0],t.items.length),n=Math.min(a[1],t.items.length);for(e=1;e<=(t.direction?n:i);e++)t._preloadItem(t.index+e);for(e=1;e<=(t.direction?i:n);e++)t._preloadItem(t.index-e)},_preloadItem:function(a){if(a=$(a),!t.items[a].preloaded){var i=t.items[a];i.parsed||(i=t.parseEl(a)),C("LazyLoad",i),"image"===i.type&&(i.img=e('<img class="mfp-img" />').on("load.mfploader",function(){i.hasSize=!0}).on("error.mfploader",function(){i.hasSize=!0,i.loadError=!0,C("LazyLoadError",i)}).attr("src",i.src)),i.preloaded=!0}}}});var Z="retina";e.magnificPopup.registerModule(Z,{options:{replaceSrc:function(e){return e.src.replace(/\.\w+$/,function(e){return"@2x"+e})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var e=t.st.retina,a=e.ratio;a=isNaN(a)?a():a,a>1&&(_("ImageHasSize."+Z,function(e,t){t.img.css({"max-width":t.img[0].naturalWidth/a,width:"100%"})}),_("ElementParse."+Z,function(t,i){i.src=e.replaceSrc(i,a)}))}}}}),S()}),function(e){"use strict";e.ajaxChimp={responses:{"We have sent you a confirmation email":0,"Please enter a value":1,"An email address must contain a single @":2,"The domain portion of the email address is invalid (the portion after the @: )":3,"The username portion of the email address is invalid (the portion before the @: )":4,"This email address looks fake or invalid. Please enter a real email address":5},translations:{en:null},init:function(t,a){e(t).ajaxChimp(a)}},e.fn.ajaxChimp=function(t){return e(this).each(function(a,i){var n=e(i),r=n.find("input[type=email]"),s=n.find("label[for="+r.attr("id")+"]"),o=e.extend({url:n.attr("action"),language:"en"},t),c=o.url.replace("/post?","/post-json?").concat("&c=?");n.attr("novalidate","true"),r.attr("name","EMAIL"),n.submit(function(){function t(t){if("success"===t.result)a="We have sent you a confirmation email",s.removeClass("error").addClass("valid"),r.removeClass("error").addClass("valid");else{r.removeClass("valid").addClass("error"),s.removeClass("valid").addClass("error");var i=-1;try{var n=t.msg.split(" - ",2);if(void 0===n[1])a=t.msg;else{var c=parseInt(n[0],10);c.toString()===n[0]?(i=n[0],a=n[1]):(i=-1,a=t.msg)}}catch(l){i=-1,a=t.msg}}"en"!==o.language&&void 0!==e.ajaxChimp.responses[a]&&e.ajaxChimp.translations&&e.ajaxChimp.translations[o.language]&&e.ajaxChimp.translations[o.language][e.ajaxChimp.responses[a]]&&(a=e.ajaxChimp.translations[o.language][e.ajaxChimp.responses[a]]),s.html(a),s.show(2e3),o.callback&&o.callback(t)}var a,i={},l=n.serializeArray();e.each(l,function(e,t){i[t.name]=t.value}),e.ajax({url:c,data:i,success:t,dataType:"jsonp",error:function(e,t){console.log("mailchimp ajax submit error: "+t)}});var d="Submitting...";return"en"!==o.language&&e.ajaxChimp.translations&&e.ajaxChimp.translations[o.language]&&e.ajaxChimp.translations[o.language].submit&&(d=e.ajaxChimp.translations[o.language].submit),s.html(d).show(2e3),!1})}),this}}(jQuery);var pJS=function(e,t){var a=document.querySelector("#"+e+" > .particles-js-canvas-el");this.pJS={canvas:{el:a,w:a.offsetWidth,h:a.offsetHeight},particles:{number:{value:400,density:{enable:!0,value_area:800}},color:{value:"#fff"},shape:{type:"circle",stroke:{width:0,color:"#ff0000"},polygon:{nb_sides:5},image:{src:"",width:100,height:100}},opacity:{value:1,random:!1,anim:{enable:!1,speed:2,opacity_min:0,sync:!1}},size:{value:20,random:!1,anim:{enable:!1,speed:20,size_min:0,sync:!1}},line_linked:{enable:!0,distance:100,color:"#fff",opacity:1,width:1},move:{enable:!0,speed:2,direction:"none",random:!1,straight:!1,out_mode:"out",bounce:!1,attract:{enable:!1,rotateX:3e3,rotateY:3e3}},array:[]},interactivity:{detect_on:"canvas",events:{onhover:{enable:!0,mode:"grab"},onclick:{enable:!0,mode:"push"},resize:!0},modes:{grab:{distance:100,line_linked:{opacity:1}},bubble:{distance:200,size:80,duration:.4},repulse:{distance:200,duration:.4},push:{particles_nb:4},remove:{particles_nb:2}},mouse:{}},retina_detect:!1,fn:{interact:{},modes:{},vendors:{}},tmp:{}};var i=this.pJS;t&&Object.deepExtend(i,t),i.tmp.obj={size_value:i.particles.size.value,size_anim_speed:i.particles.size.anim.speed,move_speed:i.particles.move.speed,line_linked_distance:i.particles.line_linked.distance,line_linked_width:i.particles.line_linked.width,mode_grab_distance:i.interactivity.modes.grab.distance,mode_bubble_distance:i.interactivity.modes.bubble.distance,mode_bubble_size:i.interactivity.modes.bubble.size,mode_repulse_distance:i.interactivity.modes.repulse.distance},i.fn.retinaInit=function(){i.retina_detect&&window.devicePixelRatio>1?(i.canvas.pxratio=window.devicePixelRatio,i.tmp.retina=!0):(i.canvas.pxratio=1,i.tmp.retina=!1),i.canvas.w=i.canvas.el.offsetWidth*i.canvas.pxratio,i.canvas.h=i.canvas.el.offsetHeight*i.canvas.pxratio,i.particles.size.value=i.tmp.obj.size_value*i.canvas.pxratio,i.particles.size.anim.speed=i.tmp.obj.size_anim_speed*i.canvas.pxratio,i.particles.move.speed=i.tmp.obj.move_speed*i.canvas.pxratio,i.particles.line_linked.distance=i.tmp.obj.line_linked_distance*i.canvas.pxratio,i.interactivity.modes.grab.distance=i.tmp.obj.mode_grab_distance*i.canvas.pxratio,i.interactivity.modes.bubble.distance=i.tmp.obj.mode_bubble_distance*i.canvas.pxratio,i.particles.line_linked.width=i.tmp.obj.line_linked_width*i.canvas.pxratio,i.interactivity.modes.bubble.size=i.tmp.obj.mode_bubble_size*i.canvas.pxratio,i.interactivity.modes.repulse.distance=i.tmp.obj.mode_repulse_distance*i.canvas.pxratio},i.fn.canvasInit=function(){i.canvas.ctx=i.canvas.el.getContext("2d")},i.fn.canvasSize=function(){i.canvas.el.width=i.canvas.w,i.canvas.el.height=i.canvas.h,i&&i.interactivity.events.resize&&window.addEventListener("resize",function(){i.canvas.w=i.canvas.el.offsetWidth,i.canvas.h=i.canvas.el.offsetHeight,i.tmp.retina&&(i.canvas.w*=i.canvas.pxratio,i.canvas.h*=i.canvas.pxratio),i.canvas.el.width=i.canvas.w,i.canvas.el.height=i.canvas.h,i.particles.move.enable||(i.fn.particlesEmpty(),i.fn.particlesCreate(),i.fn.particlesDraw(),i.fn.vendors.densityAutoParticles()),i.fn.vendors.densityAutoParticles()})},i.fn.canvasPaint=function(){i.canvas.ctx.fillRect(0,0,i.canvas.w,i.canvas.h)},i.fn.canvasClear=function(){i.canvas.ctx.clearRect(0,0,i.canvas.w,i.canvas.h)},i.fn.particle=function(e,t,a){if(this.radius=(i.particles.size.random?Math.random():1)*i.particles.size.value,i.particles.size.anim.enable&&(this.size_status=!1,this.vs=i.particles.size.anim.speed/100,i.particles.size.anim.sync||(this.vs=this.vs*Math.random())),this.x=a?a.x:Math.random()*i.canvas.w,this.y=a?a.y:Math.random()*i.canvas.h,this.x>i.canvas.w-2*this.radius?this.x=this.x-this.radius:this.x<2*this.radius&&(this.x=this.x+this.radius),this.y>i.canvas.h-2*this.radius?this.y=this.y-this.radius:this.y<2*this.radius&&(this.y=this.y+this.radius),i.particles.move.bounce&&i.fn.vendors.checkOverlap(this,a),this.color={},"object"==typeof e.value)if(e.value instanceof Array){var n=e.value[Math.floor(Math.random()*i.particles.color.value.length)];this.color.rgb=hexToRgb(n)}else void 0!=e.value.r&&void 0!=e.value.g&&void 0!=e.value.b&&(this.color.rgb={r:e.value.r,g:e.value.g,b:e.value.b}),void 0!=e.value.h&&void 0!=e.value.s&&void 0!=e.value.l&&(this.color.hsl={h:e.value.h,s:e.value.s,l:e.value.l});else"random"==e.value?this.color.rgb={r:Math.floor(256*Math.random())+0,g:Math.floor(256*Math.random())+0,b:Math.floor(256*Math.random())+0}:"string"==typeof e.value&&(this.color=e,this.color.rgb=hexToRgb(this.color.value));this.opacity=(i.particles.opacity.random?Math.random():1)*i.particles.opacity.value,i.particles.opacity.anim.enable&&(this.opacity_status=!1,this.vo=i.particles.opacity.anim.speed/100,i.particles.opacity.anim.sync||(this.vo=this.vo*Math.random()));var r={};switch(i.particles.move.direction){case"top":r={x:0,y:-1};break;case"top-right":r={x:.5,y:-.5};break;case"right":r={x:1,y:-0};break;case"bottom-right":r={x:.5,y:.5};break;case"bottom":r={x:0,y:1};break;case"bottom-left":r={x:-.5,y:1};break;case"left":r={x:-1,y:0};break;case"top-left":r={x:-.5,y:-.5};break;default:r={x:0,y:0}}i.particles.move.straight?(this.vx=r.x,this.vy=r.y,i.particles.move.random&&(this.vx=this.vx*Math.random(),this.vy=this.vy*Math.random())):(this.vx=r.x+Math.random()-.5,this.vy=r.y+Math.random()-.5),this.vx_i=this.vx,this.vy_i=this.vy;var s=i.particles.shape.type;if("object"==typeof s){if(s instanceof Array){var o=s[Math.floor(Math.random()*s.length)];this.shape=o}}else this.shape=s;if("image"==this.shape){var c=i.particles.shape;this.img={src:c.image.src,ratio:c.image.width/c.image.height},this.img.ratio||(this.img.ratio=1),"svg"==i.tmp.img_type&&void 0!=i.tmp.source_svg&&(i.fn.vendors.createSvgImg(this),i.tmp.pushing&&(this.img.loaded=!1))}},i.fn.particle.prototype.draw=function(){
function e(){i.canvas.ctx.drawImage(s,t.x-a,t.y-a,2*a,2*a/t.img.ratio)}var t=this;if(void 0!=t.radius_bubble)var a=t.radius_bubble;else var a=t.radius;if(void 0!=t.opacity_bubble)var n=t.opacity_bubble;else var n=t.opacity;if(t.color.rgb)var r="rgba("+t.color.rgb.r+","+t.color.rgb.g+","+t.color.rgb.b+","+n+")";else var r="hsla("+t.color.hsl.h+","+t.color.hsl.s+"%,"+t.color.hsl.l+"%,"+n+")";switch(i.canvas.ctx.fillStyle=r,i.canvas.ctx.beginPath(),t.shape){case"circle":i.canvas.ctx.arc(t.x,t.y,a,0,2*Math.PI,!1);break;case"edge":i.canvas.ctx.rect(t.x-a,t.y-a,2*a,2*a);break;case"triangle":i.fn.vendors.drawShape(i.canvas.ctx,t.x-a,t.y+a/1.66,2*a,3,2);break;case"polygon":i.fn.vendors.drawShape(i.canvas.ctx,t.x-a/(i.particles.shape.polygon.nb_sides/3.5),t.y-a/.76,2.66*a/(i.particles.shape.polygon.nb_sides/3),i.particles.shape.polygon.nb_sides,1);break;case"star":i.fn.vendors.drawShape(i.canvas.ctx,t.x-2*a/(i.particles.shape.polygon.nb_sides/4),t.y-a/1.52,2*a*2.66/(i.particles.shape.polygon.nb_sides/3),i.particles.shape.polygon.nb_sides,2);break;case"image":if("svg"==i.tmp.img_type)var s=t.img.obj;else var s=i.tmp.img_obj;s&&e()}i.canvas.ctx.closePath(),i.particles.shape.stroke.width>0&&(i.canvas.ctx.strokeStyle=i.particles.shape.stroke.color,i.canvas.ctx.lineWidth=i.particles.shape.stroke.width,i.canvas.ctx.stroke()),i.canvas.ctx.fill()},i.fn.particlesCreate=function(){for(var e=0;e<i.particles.number.value;e++)i.particles.array.push(new i.fn.particle(i.particles.color,i.particles.opacity.value))},i.fn.particlesUpdate=function(){for(var e=0;e<i.particles.array.length;e++){var t=i.particles.array[e];if(i.particles.move.enable){var a=i.particles.move.speed/2;t.x+=t.vx*a,t.y+=t.vy*a}if(i.particles.opacity.anim.enable&&(1==t.opacity_status?(t.opacity>=i.particles.opacity.value&&(t.opacity_status=!1),t.opacity+=t.vo):(t.opacity<=i.particles.opacity.anim.opacity_min&&(t.opacity_status=!0),t.opacity-=t.vo),t.opacity<0&&(t.opacity=0)),i.particles.size.anim.enable&&(1==t.size_status?(t.radius>=i.particles.size.value&&(t.size_status=!1),t.radius+=t.vs):(t.radius<=i.particles.size.anim.size_min&&(t.size_status=!0),t.radius-=t.vs),t.radius<0&&(t.radius=0)),"bounce"==i.particles.move.out_mode)var n={x_left:t.radius,x_right:i.canvas.w,y_top:t.radius,y_bottom:i.canvas.h};else var n={x_left:-t.radius,x_right:i.canvas.w+t.radius,y_top:-t.radius,y_bottom:i.canvas.h+t.radius};switch(t.x-t.radius>i.canvas.w?(t.x=n.x_left,t.y=Math.random()*i.canvas.h):t.x+t.radius<0&&(t.x=n.x_right,t.y=Math.random()*i.canvas.h),t.y-t.radius>i.canvas.h?(t.y=n.y_top,t.x=Math.random()*i.canvas.w):t.y+t.radius<0&&(t.y=n.y_bottom,t.x=Math.random()*i.canvas.w),i.particles.move.out_mode){case"bounce":t.x+t.radius>i.canvas.w?t.vx=-t.vx:t.x-t.radius<0&&(t.vx=-t.vx),t.y+t.radius>i.canvas.h?t.vy=-t.vy:t.y-t.radius<0&&(t.vy=-t.vy)}if(isInArray("grab",i.interactivity.events.onhover.mode)&&i.fn.modes.grabParticle(t),(isInArray("bubble",i.interactivity.events.onhover.mode)||isInArray("bubble",i.interactivity.events.onclick.mode))&&i.fn.modes.bubbleParticle(t),(isInArray("repulse",i.interactivity.events.onhover.mode)||isInArray("repulse",i.interactivity.events.onclick.mode))&&i.fn.modes.repulseParticle(t),i.particles.line_linked.enable||i.particles.move.attract.enable)for(var r=e+1;r<i.particles.array.length;r++){var s=i.particles.array[r];i.particles.line_linked.enable&&i.fn.interact.linkParticles(t,s),i.particles.move.attract.enable&&i.fn.interact.attractParticles(t,s),i.particles.move.bounce&&i.fn.interact.bounceParticles(t,s)}}},i.fn.particlesDraw=function(){i.canvas.ctx.clearRect(0,0,i.canvas.w,i.canvas.h),i.fn.particlesUpdate();for(var e=0;e<i.particles.array.length;e++){var t=i.particles.array[e];t.draw()}},i.fn.particlesEmpty=function(){i.particles.array=[]},i.fn.particlesRefresh=function(){cancelRequestAnimFrame(i.fn.checkAnimFrame),cancelRequestAnimFrame(i.fn.drawAnimFrame),i.tmp.source_svg=void 0,i.tmp.img_obj=void 0,i.tmp.count_svg=0,i.fn.particlesEmpty(),i.fn.canvasClear(),i.fn.vendors.start()},i.fn.interact.linkParticles=function(e,t){var a=e.x-t.x,n=e.y-t.y,r=Math.sqrt(a*a+n*n);if(r<=i.particles.line_linked.distance){var s=i.particles.line_linked.opacity-r/(1/i.particles.line_linked.opacity)/i.particles.line_linked.distance;if(s>0){var o=i.particles.line_linked.color_rgb_line;i.canvas.ctx.strokeStyle="rgba("+o.r+","+o.g+","+o.b+","+s+")",i.canvas.ctx.lineWidth=i.particles.line_linked.width,i.canvas.ctx.beginPath(),i.canvas.ctx.moveTo(e.x,e.y),i.canvas.ctx.lineTo(t.x,t.y),i.canvas.ctx.stroke(),i.canvas.ctx.closePath()}}},i.fn.interact.attractParticles=function(e,t){var a=e.x-t.x,n=e.y-t.y,r=Math.sqrt(a*a+n*n);if(r<=i.particles.line_linked.distance){var s=a/(1e3*i.particles.move.attract.rotateX),o=n/(1e3*i.particles.move.attract.rotateY);e.vx-=s,e.vy-=o,t.vx+=s,t.vy+=o}},i.fn.interact.bounceParticles=function(e,t){var a=e.x-t.x,i=e.y-t.y,n=Math.sqrt(a*a+i*i),r=e.radius+t.radius;r>=n&&(e.vx=-e.vx,e.vy=-e.vy,t.vx=-t.vx,t.vy=-t.vy)},i.fn.modes.pushParticles=function(e,t){i.tmp.pushing=!0;for(var a=0;e>a;a++)i.particles.array.push(new i.fn.particle(i.particles.color,i.particles.opacity.value,{x:t?t.pos_x:Math.random()*i.canvas.w,y:t?t.pos_y:Math.random()*i.canvas.h})),a==e-1&&(i.particles.move.enable||i.fn.particlesDraw(),i.tmp.pushing=!1)},i.fn.modes.removeParticles=function(e){i.particles.array.splice(0,e),i.particles.move.enable||i.fn.particlesDraw()},i.fn.modes.bubbleParticle=function(e){function t(){e.opacity_bubble=e.opacity,e.radius_bubble=e.radius}function a(t,a,n,r,o){if(t!=a)if(i.tmp.bubble_duration_end){if(void 0!=n){var c=r-p*(r-t)/i.interactivity.modes.bubble.duration,l=t-c;u=t+l,"size"==o&&(e.radius_bubble=u),"opacity"==o&&(e.opacity_bubble=u)}}else if(s<=i.interactivity.modes.bubble.distance){if(void 0!=n)var d=n;else var d=r;if(d!=t){var u=r-p*(r-t)/i.interactivity.modes.bubble.duration;"size"==o&&(e.radius_bubble=u),"opacity"==o&&(e.opacity_bubble=u)}}else"size"==o&&(e.radius_bubble=void 0),"opacity"==o&&(e.opacity_bubble=void 0)}if(i.interactivity.events.onhover.enable&&isInArray("bubble",i.interactivity.events.onhover.mode)){var n=e.x-i.interactivity.mouse.pos_x,r=e.y-i.interactivity.mouse.pos_y,s=Math.sqrt(n*n+r*r),o=1-s/i.interactivity.modes.bubble.distance;if(s<=i.interactivity.modes.bubble.distance){if(o>=0&&"mousemove"==i.interactivity.status){if(i.interactivity.modes.bubble.size!=i.particles.size.value)if(i.interactivity.modes.bubble.size>i.particles.size.value){var c=e.radius+i.interactivity.modes.bubble.size*o;c>=0&&(e.radius_bubble=c)}else{var l=e.radius-i.interactivity.modes.bubble.size,c=e.radius-l*o;c>0?e.radius_bubble=c:e.radius_bubble=0}if(i.interactivity.modes.bubble.opacity!=i.particles.opacity.value)if(i.interactivity.modes.bubble.opacity>i.particles.opacity.value){var d=i.interactivity.modes.bubble.opacity*o;d>e.opacity&&d<=i.interactivity.modes.bubble.opacity&&(e.opacity_bubble=d)}else{var d=e.opacity-(i.particles.opacity.value-i.interactivity.modes.bubble.opacity)*o;d<e.opacity&&d>=i.interactivity.modes.bubble.opacity&&(e.opacity_bubble=d)}}}else t();"mouseleave"==i.interactivity.status&&t()}else if(i.interactivity.events.onclick.enable&&isInArray("bubble",i.interactivity.events.onclick.mode)){if(i.tmp.bubble_clicking){var n=e.x-i.interactivity.mouse.click_pos_x,r=e.y-i.interactivity.mouse.click_pos_y,s=Math.sqrt(n*n+r*r),p=((new Date).getTime()-i.interactivity.mouse.click_time)/1e3;p>i.interactivity.modes.bubble.duration&&(i.tmp.bubble_duration_end=!0),p>2*i.interactivity.modes.bubble.duration&&(i.tmp.bubble_clicking=!1,i.tmp.bubble_duration_end=!1)}i.tmp.bubble_clicking&&(a(i.interactivity.modes.bubble.size,i.particles.size.value,e.radius_bubble,e.radius,"size"),a(i.interactivity.modes.bubble.opacity,i.particles.opacity.value,e.opacity_bubble,e.opacity,"opacity"))}},i.fn.modes.repulseParticle=function(e){function t(){var t=Math.atan2(u,p);if(e.vx=v*Math.cos(t),e.vy=v*Math.sin(t),"bounce"==i.particles.move.out_mode){var a={x:e.x+e.vx,y:e.y+e.vy};a.x+e.radius>i.canvas.w?e.vx=-e.vx:a.x-e.radius<0&&(e.vx=-e.vx),a.y+e.radius>i.canvas.h?e.vy=-e.vy:a.y-e.radius<0&&(e.vy=-e.vy)}}if(i.interactivity.events.onhover.enable&&isInArray("repulse",i.interactivity.events.onhover.mode)&&"mousemove"==i.interactivity.status){var a=e.x-i.interactivity.mouse.pos_x,n=e.y-i.interactivity.mouse.pos_y,r=Math.sqrt(a*a+n*n),s={x:a/r,y:n/r},o=i.interactivity.modes.repulse.distance,c=100,l=clamp(1/o*(-1*Math.pow(r/o,2)+1)*o*c,0,50),d={x:e.x+s.x*l,y:e.y+s.y*l};"bounce"==i.particles.move.out_mode?(d.x-e.radius>0&&d.x+e.radius<i.canvas.w&&(e.x=d.x),d.y-e.radius>0&&d.y+e.radius<i.canvas.h&&(e.y=d.y)):(e.x=d.x,e.y=d.y)}else if(i.interactivity.events.onclick.enable&&isInArray("repulse",i.interactivity.events.onclick.mode))if(i.tmp.repulse_finish||(i.tmp.repulse_count++,i.tmp.repulse_count==i.particles.array.length&&(i.tmp.repulse_finish=!0)),i.tmp.repulse_clicking){var o=Math.pow(i.interactivity.modes.repulse.distance/6,3),p=i.interactivity.mouse.click_pos_x-e.x,u=i.interactivity.mouse.click_pos_y-e.y,m=p*p+u*u,v=-o/m*1;o>=m&&t()}else 0==i.tmp.repulse_clicking&&(e.vx=e.vx_i,e.vy=e.vy_i)},i.fn.modes.grabParticle=function(e){if(i.interactivity.events.onhover.enable&&"mousemove"==i.interactivity.status){var t=e.x-i.interactivity.mouse.pos_x,a=e.y-i.interactivity.mouse.pos_y,n=Math.sqrt(t*t+a*a);if(n<=i.interactivity.modes.grab.distance){var r=i.interactivity.modes.grab.line_linked.opacity-n/(1/i.interactivity.modes.grab.line_linked.opacity)/i.interactivity.modes.grab.distance;if(r>0){var s=i.particles.line_linked.color_rgb_line;i.canvas.ctx.strokeStyle="rgba("+s.r+","+s.g+","+s.b+","+r+")",i.canvas.ctx.lineWidth=i.particles.line_linked.width,i.canvas.ctx.beginPath(),i.canvas.ctx.moveTo(e.x,e.y),i.canvas.ctx.lineTo(i.interactivity.mouse.pos_x,i.interactivity.mouse.pos_y),i.canvas.ctx.stroke(),i.canvas.ctx.closePath()}}}},i.fn.vendors.eventsListeners=function(){"window"==i.interactivity.detect_on?i.interactivity.el=window:i.interactivity.el=i.canvas.el,(i.interactivity.events.onhover.enable||i.interactivity.events.onclick.enable)&&(i.interactivity.el.addEventListener("mousemove",function(e){if(i.interactivity.el==window)var t=e.clientX,a=e.clientY;else var t=e.offsetX||e.clientX,a=e.offsetY||e.clientY;i.interactivity.mouse.pos_x=t,i.interactivity.mouse.pos_y=a,i.tmp.retina&&(i.interactivity.mouse.pos_x*=i.canvas.pxratio,i.interactivity.mouse.pos_y*=i.canvas.pxratio),i.interactivity.status="mousemove"}),i.interactivity.el.addEventListener("mouseleave",function(e){i.interactivity.mouse.pos_x=null,i.interactivity.mouse.pos_y=null,i.interactivity.status="mouseleave"})),i.interactivity.events.onclick.enable&&i.interactivity.el.addEventListener("click",function(){if(i.interactivity.mouse.click_pos_x=i.interactivity.mouse.pos_x,i.interactivity.mouse.click_pos_y=i.interactivity.mouse.pos_y,i.interactivity.mouse.click_time=(new Date).getTime(),i.interactivity.events.onclick.enable)switch(i.interactivity.events.onclick.mode){case"push":i.particles.move.enable?i.fn.modes.pushParticles(i.interactivity.modes.push.particles_nb,i.interactivity.mouse):1==i.interactivity.modes.push.particles_nb?i.fn.modes.pushParticles(i.interactivity.modes.push.particles_nb,i.interactivity.mouse):i.interactivity.modes.push.particles_nb>1&&i.fn.modes.pushParticles(i.interactivity.modes.push.particles_nb);break;case"remove":i.fn.modes.removeParticles(i.interactivity.modes.remove.particles_nb);break;case"bubble":i.tmp.bubble_clicking=!0;break;case"repulse":i.tmp.repulse_clicking=!0,i.tmp.repulse_count=0,i.tmp.repulse_finish=!1,setTimeout(function(){i.tmp.repulse_clicking=!1},1e3*i.interactivity.modes.repulse.duration)}})},i.fn.vendors.densityAutoParticles=function(){if(i.particles.number.density.enable){var e=i.canvas.el.width*i.canvas.el.height/1e3;i.tmp.retina&&(e/=2*i.canvas.pxratio);var t=e*i.particles.number.value/i.particles.number.density.value_area,a=i.particles.array.length-t;0>a?i.fn.modes.pushParticles(Math.abs(a)):i.fn.modes.removeParticles(a)}},i.fn.vendors.checkOverlap=function(e,t){for(var a=0;a<i.particles.array.length;a++){var n=i.particles.array[a],r=e.x-n.x,s=e.y-n.y,o=Math.sqrt(r*r+s*s);o<=e.radius+n.radius&&(e.x=t?t.x:Math.random()*i.canvas.w,e.y=t?t.y:Math.random()*i.canvas.h,i.fn.vendors.checkOverlap(e))}},i.fn.vendors.createSvgImg=function(e){var t=i.tmp.source_svg,a=/#([0-9A-F]{3,6})/gi,n=t.replace(a,function(t,a,i,n){if(e.color.rgb)var r="rgba("+e.color.rgb.r+","+e.color.rgb.g+","+e.color.rgb.b+","+e.opacity+")";else var r="hsla("+e.color.hsl.h+","+e.color.hsl.s+"%,"+e.color.hsl.l+"%,"+e.opacity+")";return r}),r=new Blob([n],{type:"image/svg+xml;charset=utf-8"}),s=window.URL||window.webkitURL||window,o=s.createObjectURL(r),c=new Image;c.addEventListener("load",function(){e.img.obj=c,e.img.loaded=!0,s.revokeObjectURL(o),i.tmp.count_svg++}),c.src=o},i.fn.vendors.destroypJS=function(){cancelAnimationFrame(i.fn.drawAnimFrame),a.remove(),pJSDom=null},i.fn.vendors.drawShape=function(e,t,a,i,n,r){var s=n*r,o=n/r,c=180*(o-2)/o,l=Math.PI-Math.PI*c/180;e.save(),e.beginPath(),e.translate(t,a),e.moveTo(0,0);for(var d=0;s>d;d++)e.lineTo(i,0),e.translate(i,0),e.rotate(l);e.fill(),e.restore()},i.fn.vendors.exportImg=function(){window.open(i.canvas.el.toDataURL("image/png"),"_blank")},i.fn.vendors.loadImg=function(e){if(i.tmp.img_error=void 0,""!=i.particles.shape.image.src)if("svg"==e){var t=new XMLHttpRequest;t.open("GET",i.particles.shape.image.src),t.onreadystatechange=function(e){4==t.readyState&&(200==t.status?(i.tmp.source_svg=e.currentTarget.response,i.fn.vendors.checkBeforeDraw()):(console.log("Error pJS - Image not found"),i.tmp.img_error=!0))},t.send()}else{var a=new Image;a.addEventListener("load",function(){i.tmp.img_obj=a,i.fn.vendors.checkBeforeDraw()}),a.src=i.particles.shape.image.src}else console.log("Error pJS - No image.src"),i.tmp.img_error=!0},i.fn.vendors.draw=function(){"image"==i.particles.shape.type?"svg"==i.tmp.img_type?i.tmp.count_svg>=i.particles.number.value?(i.fn.particlesDraw(),i.particles.move.enable?i.fn.drawAnimFrame=requestAnimFrame(i.fn.vendors.draw):cancelRequestAnimFrame(i.fn.drawAnimFrame)):i.tmp.img_error||(i.fn.drawAnimFrame=requestAnimFrame(i.fn.vendors.draw)):void 0!=i.tmp.img_obj?(i.fn.particlesDraw(),i.particles.move.enable?i.fn.drawAnimFrame=requestAnimFrame(i.fn.vendors.draw):cancelRequestAnimFrame(i.fn.drawAnimFrame)):i.tmp.img_error||(i.fn.drawAnimFrame=requestAnimFrame(i.fn.vendors.draw)):(i.fn.particlesDraw(),i.particles.move.enable?i.fn.drawAnimFrame=requestAnimFrame(i.fn.vendors.draw):cancelRequestAnimFrame(i.fn.drawAnimFrame))},i.fn.vendors.checkBeforeDraw=function(){"image"==i.particles.shape.type?"svg"==i.tmp.img_type&&void 0==i.tmp.source_svg?i.tmp.checkAnimFrame=requestAnimFrame(check):(cancelRequestAnimFrame(i.tmp.checkAnimFrame),i.tmp.img_error||(i.fn.vendors.init(),i.fn.vendors.draw())):(i.fn.vendors.init(),i.fn.vendors.draw())},i.fn.vendors.init=function(){i.fn.retinaInit(),i.fn.canvasInit(),i.fn.canvasSize(),i.fn.canvasPaint(),i.fn.particlesCreate(),i.fn.vendors.densityAutoParticles(),i.particles.line_linked.color_rgb_line=hexToRgb(i.particles.line_linked.color)},i.fn.vendors.start=function(){isInArray("image",i.particles.shape.type)?(i.tmp.img_type=i.particles.shape.image.src.substr(i.particles.shape.image.src.length-3),i.fn.vendors.loadImg(i.tmp.img_type)):i.fn.vendors.checkBeforeDraw()},i.fn.vendors.eventsListeners(),i.fn.vendors.start()};Object.deepExtend=function(e,t){for(var a in t)t[a]&&t[a].constructor&&t[a].constructor===Object?(e[a]=e[a]||{},arguments.callee(e[a],t[a])):e[a]=t[a];return e},window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(e,1e3/60)}}(),window.cancelRequestAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||clearTimeout}(),window.pJSDom=[],window.particlesJS=function(e,t){"string"!=typeof e&&(t=e,e="particles-js"),e||(e="particles-js");var a=document.getElementById(e),i="particles-js-canvas-el",n=a.getElementsByClassName(i);if(n.length)for(;n.length>0;)a.removeChild(n[0]);var r=document.createElement("canvas");r.className=i,r.style.width="100%",r.style.height="100%";var s=document.getElementById(e).appendChild(r);null!=s&&pJSDom.push(new pJS(e,t))},window.particlesJS.load=function(e,t,a){var i=new XMLHttpRequest;i.open("GET",t),i.onreadystatechange=function(t){if(4==i.readyState)if(200==i.status){var n=JSON.parse(t.currentTarget.response);window.particlesJS(e,n),a&&a()}else console.log("Error pJS - XMLHttpRequest status: "+i.status),console.log("Error pJS - File config not found")},i.send()};
init-particles.js:
particlesJS('particles',
{
"particles": {
"number": {
"value": 80,
"density": {
"enable": true,
"value_area": 800
}
},
"color": {
"value": "#333333"
},
"shape": {
"type": "circle",
"stroke": {
"width": 0,
"color": "#000000"
},
"polygon": {
"nb_sides": 5
},
"image": {
"src": "img/github.svg",
"width": 100,
"height": 100
}
},
"opacity": {
"value": 0.5,
"random": false,
"anim": {
"enable": false,
"speed": 1,
"opacity_min": 0.1,
"sync": false
}
},
"size": {
"value": 2,
"random": false,
"anim": {
"enable": false,
"speed": 40,
"size_min": 0.1,
"sync": false
}
},
"line_linked": {
"enable": true,
"distance": 192.40944730386272,
"color": "#333333",
"opacity": 0.3447335930860874,
"width": 0.6413648243462091
},
"move": {
"enable": true,
"speed": 6,
"direction": "none",
"random": true,
"straight": false,
"out_mode": "out",
"bounce": false,
"attract": {
"enable": false,
"rotateX": 600,
"rotateY": 1200
}
}
},
"interactivity": {
"detect_on": "canvas",
"events": {
"onhover": {
"enable": true,
"mode": "repulse"
},
"onclick": {
"enable": false,
"mode": "repulse"
},
"resize": true
},
"modes": {
"grab": {
"distance": 400,
"line_linked": {
"opacity": 1
}
},
"bubble": {
"distance": 400,
"size": 40,
"duration": 2,
"opacity": 8,
"speed": 3
},
"repulse": {
"distance": 200,
"duration": 0.4
},
"push": {
"particles_nb": 4
},
"remove": {
"particles_nb": 2
}
}
},
"retina_detect": false
}
);
main.js:
(function($){
"use strict"
/*------------------
Preloder
--------------------*/
$(window).on('load', function() {
$('#preloader').delay(550).fadeOut('slow');
});
/*------------------
Countdown
--------------------*/
$(".counter").countdown("2018/01/01", function(event) {
$(this).html(event.strftime("<div class='cd-item'>%D<span>days</span></div>" + "<div class='cd-item'>%H<span>hour</span></div>" + "<div class='cd-item'>%M<span>min</span></div>" + "<div class='cd-item'>%S<span>sec</span></div>"));
});
/*------------------
Subscribe Form
--------------------*/
$('#mc-form').ajaxChimp({
url: 'http://webdevhomes.us12.list-manage.com/subscribe/post?u=4d62424bdf73c15d3fa0f3578&id=9c6fab69f2',//Set Your Mailchamp URL
});
$('.popup').magnificPopup({
type:'inline',
mainClass:'mfp-zoom-in',
removalDelay: 400
});
})(jQuery);
效果:
此效果可实现鼠标拨开粒子的效果,适合做动态页面背景。