-
Notifications
You must be signed in to change notification settings - Fork 6
/
particles.js
2 lines (2 loc) · 52.5 KB
/
particles.js
1
2
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Particles=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){require("../../modules/es6.string.iterator");require("../../modules/es6.array.from");module.exports=require("../../modules/_core").Array.from},{"../../modules/_core":8,"../../modules/es6.array.from":55,"../../modules/es6.string.iterator":57}],2:[function(require,module,exports){require("../../modules/es6.object.assign");module.exports=require("../../modules/_core").Object.assign},{"../../modules/_core":8,"../../modules/es6.object.assign":56}],3:[function(require,module,exports){module.exports=function(it){if(typeof it!="function")throw TypeError(it+" is not a function!");return it}},{}],4:[function(require,module,exports){var isObject=require("./_is-object");module.exports=function(it){if(!isObject(it))throw TypeError(it+" is not an object!");return it}},{"./_is-object":24}],5:[function(require,module,exports){var toIObject=require("./_to-iobject"),toLength=require("./_to-length"),toIndex=require("./_to-index");module.exports=function(IS_INCLUDES){return function($this,el,fromIndex){var O=toIObject($this),length=toLength(O.length),index=toIndex(fromIndex,length),value;if(IS_INCLUDES&&el!=el)while(length>index){value=O[index++];if(value!=value)return true}else for(;length>index;index++)if(IS_INCLUDES||index in O){if(O[index]===el)return IS_INCLUDES||index||0}return!IS_INCLUDES&&-1}}},{"./_to-index":46,"./_to-iobject":48,"./_to-length":49}],6:[function(require,module,exports){var cof=require("./_cof"),TAG=require("./_wks")("toStringTag"),ARG=cof(function(){return arguments}())=="Arguments";var tryGet=function(it,key){try{return it[key]}catch(e){}};module.exports=function(it){var O,T,B;return it===undefined?"Undefined":it===null?"Null":typeof(T=tryGet(O=Object(it),TAG))=="string"?T:ARG?cof(O):(B=cof(O))=="Object"&&typeof O.callee=="function"?"Arguments":B}},{"./_cof":7,"./_wks":53}],7:[function(require,module,exports){var toString={}.toString;module.exports=function(it){return toString.call(it).slice(8,-1)}},{}],8:[function(require,module,exports){var core=module.exports={version:"2.4.0"};if(typeof __e=="number")__e=core},{}],9:[function(require,module,exports){"use strict";var $defineProperty=require("./_object-dp"),createDesc=require("./_property-desc");module.exports=function(object,index,value){if(index in object)$defineProperty.f(object,index,createDesc(0,value));else object[index]=value}},{"./_object-dp":33,"./_property-desc":40}],10:[function(require,module,exports){var aFunction=require("./_a-function");module.exports=function(fn,that,length){aFunction(fn);if(that===undefined)return fn;switch(length){case 1:return function(a){return fn.call(that,a)};case 2:return function(a,b){return fn.call(that,a,b)};case 3:return function(a,b,c){return fn.call(that,a,b,c)}}return function(){return fn.apply(that,arguments)}}},{"./_a-function":3}],11:[function(require,module,exports){module.exports=function(it){if(it==undefined)throw TypeError("Can't call method on "+it);return it}},{}],12:[function(require,module,exports){module.exports=!require("./_fails")(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},{"./_fails":16}],13:[function(require,module,exports){var isObject=require("./_is-object"),document=require("./_global").document,is=isObject(document)&&isObject(document.createElement);module.exports=function(it){return is?document.createElement(it):{}}},{"./_global":17,"./_is-object":24}],14:[function(require,module,exports){module.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},{}],15:[function(require,module,exports){var global=require("./_global"),core=require("./_core"),hide=require("./_hide"),redefine=require("./_redefine"),ctx=require("./_ctx"),PROTOTYPE="prototype";var $export=function(type,name,source){var IS_FORCED=type&$export.F,IS_GLOBAL=type&$export.G,IS_STATIC=type&$export.S,IS_PROTO=type&$export.P,IS_BIND=type&$export.B,target=IS_GLOBAL?global:IS_STATIC?global[name]||(global[name]={}):(global[name]||{})[PROTOTYPE],exports=IS_GLOBAL?core:core[name]||(core[name]={}),expProto=exports[PROTOTYPE]||(exports[PROTOTYPE]={}),key,own,out,exp;if(IS_GLOBAL)source=name;for(key in source){own=!IS_FORCED&&target&&target[key]!==undefined;out=(own?target:source)[key];exp=IS_BIND&&own?ctx(out,global):IS_PROTO&&typeof out=="function"?ctx(Function.call,out):out;if(target)redefine(target,key,out,type&$export.U);if(exports[key]!=out)hide(exports,key,exp);if(IS_PROTO&&expProto[key]!=out)expProto[key]=out}};global.core=core;$export.F=1;$export.G=2;$export.S=4;$export.P=8;$export.B=16;$export.W=32;$export.U=64;$export.R=128;module.exports=$export},{"./_core":8,"./_ctx":10,"./_global":17,"./_hide":19,"./_redefine":41}],16:[function(require,module,exports){module.exports=function(exec){try{return!!exec()}catch(e){return true}}},{}],17:[function(require,module,exports){var global=module.exports=typeof window!="undefined"&&window.Math==Math?window:typeof self!="undefined"&&self.Math==Math?self:Function("return this")();if(typeof __g=="number")__g=global},{}],18:[function(require,module,exports){var hasOwnProperty={}.hasOwnProperty;module.exports=function(it,key){return hasOwnProperty.call(it,key)}},{}],19:[function(require,module,exports){var dP=require("./_object-dp"),createDesc=require("./_property-desc");module.exports=require("./_descriptors")?function(object,key,value){return dP.f(object,key,createDesc(1,value))}:function(object,key,value){object[key]=value;return object}},{"./_descriptors":12,"./_object-dp":33,"./_property-desc":40}],20:[function(require,module,exports){module.exports=require("./_global").document&&document.documentElement},{"./_global":17}],21:[function(require,module,exports){module.exports=!require("./_descriptors")&&!require("./_fails")(function(){return Object.defineProperty(require("./_dom-create")("div"),"a",{get:function(){return 7}}).a!=7})},{"./_descriptors":12,"./_dom-create":13,"./_fails":16}],22:[function(require,module,exports){var cof=require("./_cof");module.exports=Object("z").propertyIsEnumerable(0)?Object:function(it){return cof(it)=="String"?it.split(""):Object(it)}},{"./_cof":7}],23:[function(require,module,exports){var Iterators=require("./_iterators"),ITERATOR=require("./_wks")("iterator"),ArrayProto=Array.prototype;module.exports=function(it){return it!==undefined&&(Iterators.Array===it||ArrayProto[ITERATOR]===it)}},{"./_iterators":29,"./_wks":53}],24:[function(require,module,exports){module.exports=function(it){return typeof it==="object"?it!==null:typeof it==="function"}},{}],25:[function(require,module,exports){var anObject=require("./_an-object");module.exports=function(iterator,fn,value,entries){try{return entries?fn(anObject(value)[0],value[1]):fn(value)}catch(e){var ret=iterator["return"];if(ret!==undefined)anObject(ret.call(iterator));throw e}}},{"./_an-object":4}],26:[function(require,module,exports){"use strict";var create=require("./_object-create"),descriptor=require("./_property-desc"),setToStringTag=require("./_set-to-string-tag"),IteratorPrototype={};require("./_hide")(IteratorPrototype,require("./_wks")("iterator"),function(){return this});module.exports=function(Constructor,NAME,next){Constructor.prototype=create(IteratorPrototype,{next:descriptor(1,next)});setToStringTag(Constructor,NAME+" Iterator")}},{"./_hide":19,"./_object-create":32,"./_property-desc":40,"./_set-to-string-tag":42,"./_wks":53}],27:[function(require,module,exports){"use strict";var LIBRARY=require("./_library"),$export=require("./_export"),redefine=require("./_redefine"),hide=require("./_hide"),has=require("./_has"),Iterators=require("./_iterators"),$iterCreate=require("./_iter-create"),setToStringTag=require("./_set-to-string-tag"),getPrototypeOf=require("./_object-gpo"),ITERATOR=require("./_wks")("iterator"),BUGGY=!([].keys&&"next"in[].keys()),FF_ITERATOR="@@iterator",KEYS="keys",VALUES="values";var returnThis=function(){return this};module.exports=function(Base,NAME,Constructor,next,DEFAULT,IS_SET,FORCED){$iterCreate(Constructor,NAME,next);var getMethod=function(kind){if(!BUGGY&&kind in proto)return proto[kind];switch(kind){case KEYS:return function keys(){return new Constructor(this,kind)};case VALUES:return function values(){return new Constructor(this,kind)}}return function entries(){return new Constructor(this,kind)}};var TAG=NAME+" Iterator",DEF_VALUES=DEFAULT==VALUES,VALUES_BUG=false,proto=Base.prototype,$native=proto[ITERATOR]||proto[FF_ITERATOR]||DEFAULT&&proto[DEFAULT],$default=$native||getMethod(DEFAULT),$entries=DEFAULT?!DEF_VALUES?$default:getMethod("entries"):undefined,$anyNative=NAME=="Array"?proto.entries||$native:$native,methods,key,IteratorPrototype;if($anyNative){IteratorPrototype=getPrototypeOf($anyNative.call(new Base));if(IteratorPrototype!==Object.prototype){setToStringTag(IteratorPrototype,TAG,true);if(!LIBRARY&&!has(IteratorPrototype,ITERATOR))hide(IteratorPrototype,ITERATOR,returnThis)}}if(DEF_VALUES&&$native&&$native.name!==VALUES){VALUES_BUG=true;$default=function values(){return $native.call(this)}}if((!LIBRARY||FORCED)&&(BUGGY||VALUES_BUG||!proto[ITERATOR])){hide(proto,ITERATOR,$default)}Iterators[NAME]=$default;Iterators[TAG]=returnThis;if(DEFAULT){methods={values:DEF_VALUES?$default:getMethod(VALUES),keys:IS_SET?$default:getMethod(KEYS),entries:$entries};if(FORCED)for(key in methods){if(!(key in proto))redefine(proto,key,methods[key])}else $export($export.P+$export.F*(BUGGY||VALUES_BUG),NAME,methods)}return methods}},{"./_export":15,"./_has":18,"./_hide":19,"./_iter-create":26,"./_iterators":29,"./_library":30,"./_object-gpo":36,"./_redefine":41,"./_set-to-string-tag":42,"./_wks":53}],28:[function(require,module,exports){var ITERATOR=require("./_wks")("iterator"),SAFE_CLOSING=false;try{var riter=[7][ITERATOR]();riter["return"]=function(){SAFE_CLOSING=true};Array.from(riter,function(){throw 2})}catch(e){}module.exports=function(exec,skipClosing){if(!skipClosing&&!SAFE_CLOSING)return false;var safe=false;try{var arr=[7],iter=arr[ITERATOR]();iter.next=function(){return{done:safe=true}};arr[ITERATOR]=function(){return iter};exec(arr)}catch(e){}return safe}},{"./_wks":53}],29:[function(require,module,exports){module.exports={}},{}],30:[function(require,module,exports){module.exports=false},{}],31:[function(require,module,exports){"use strict";var getKeys=require("./_object-keys"),gOPS=require("./_object-gops"),pIE=require("./_object-pie"),toObject=require("./_to-object"),IObject=require("./_iobject"),$assign=Object.assign;module.exports=!$assign||require("./_fails")(function(){var A={},B={},S=Symbol(),K="abcdefghijklmnopqrst";A[S]=7;K.split("").forEach(function(k){B[k]=k});return $assign({},A)[S]!=7||Object.keys($assign({},B)).join("")!=K})?function assign(target,source){var T=toObject(target),aLen=arguments.length,index=1,getSymbols=gOPS.f,isEnum=pIE.f;while(aLen>index){var S=IObject(arguments[index++]),keys=getSymbols?getKeys(S).concat(getSymbols(S)):getKeys(S),length=keys.length,j=0,key;while(length>j)if(isEnum.call(S,key=keys[j++]))T[key]=S[key]}return T}:$assign},{"./_fails":16,"./_iobject":22,"./_object-gops":35,"./_object-keys":38,"./_object-pie":39,"./_to-object":50}],32:[function(require,module,exports){var anObject=require("./_an-object"),dPs=require("./_object-dps"),enumBugKeys=require("./_enum-bug-keys"),IE_PROTO=require("./_shared-key")("IE_PROTO"),Empty=function(){},PROTOTYPE="prototype";var createDict=function(){var iframe=require("./_dom-create")("iframe"),i=enumBugKeys.length,lt="<",gt=">",iframeDocument;iframe.style.display="none";require("./_html").appendChild(iframe);iframe.src="javascript:";iframeDocument=iframe.contentWindow.document;iframeDocument.open();iframeDocument.write(lt+"script"+gt+"document.F=Object"+lt+"/script"+gt);iframeDocument.close();createDict=iframeDocument.F;while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]];return createDict()};module.exports=Object.create||function create(O,Properties){var result;if(O!==null){Empty[PROTOTYPE]=anObject(O);result=new Empty;Empty[PROTOTYPE]=null;result[IE_PROTO]=O}else result=createDict();return Properties===undefined?result:dPs(result,Properties)}},{"./_an-object":4,"./_dom-create":13,"./_enum-bug-keys":14,"./_html":20,"./_object-dps":34,"./_shared-key":43}],33:[function(require,module,exports){var anObject=require("./_an-object"),IE8_DOM_DEFINE=require("./_ie8-dom-define"),toPrimitive=require("./_to-primitive"),dP=Object.defineProperty;exports.f=require("./_descriptors")?Object.defineProperty:function defineProperty(O,P,Attributes){anObject(O);P=toPrimitive(P,true);anObject(Attributes);if(IE8_DOM_DEFINE)try{return dP(O,P,Attributes)}catch(e){}if("get"in Attributes||"set"in Attributes)throw TypeError("Accessors not supported!");if("value"in Attributes)O[P]=Attributes.value;return O}},{"./_an-object":4,"./_descriptors":12,"./_ie8-dom-define":21,"./_to-primitive":51}],34:[function(require,module,exports){var dP=require("./_object-dp"),anObject=require("./_an-object"),getKeys=require("./_object-keys");module.exports=require("./_descriptors")?Object.defineProperties:function defineProperties(O,Properties){anObject(O);var keys=getKeys(Properties),length=keys.length,i=0,P;while(length>i)dP.f(O,P=keys[i++],Properties[P]);return O}},{"./_an-object":4,"./_descriptors":12,"./_object-dp":33,"./_object-keys":38}],35:[function(require,module,exports){exports.f=Object.getOwnPropertySymbols},{}],36:[function(require,module,exports){var has=require("./_has"),toObject=require("./_to-object"),IE_PROTO=require("./_shared-key")("IE_PROTO"),ObjectProto=Object.prototype;module.exports=Object.getPrototypeOf||function(O){O=toObject(O);if(has(O,IE_PROTO))return O[IE_PROTO];if(typeof O.constructor=="function"&&O instanceof O.constructor){return O.constructor.prototype}return O instanceof Object?ObjectProto:null}},{"./_has":18,"./_shared-key":43,"./_to-object":50}],37:[function(require,module,exports){var has=require("./_has"),toIObject=require("./_to-iobject"),arrayIndexOf=require("./_array-includes")(false),IE_PROTO=require("./_shared-key")("IE_PROTO");module.exports=function(object,names){var O=toIObject(object),i=0,result=[],key;for(key in O)if(key!=IE_PROTO)has(O,key)&&result.push(key);while(names.length>i)if(has(O,key=names[i++])){~arrayIndexOf(result,key)||result.push(key)}return result}},{"./_array-includes":5,"./_has":18,"./_shared-key":43,"./_to-iobject":48}],38:[function(require,module,exports){var $keys=require("./_object-keys-internal"),enumBugKeys=require("./_enum-bug-keys");module.exports=Object.keys||function keys(O){return $keys(O,enumBugKeys)}},{"./_enum-bug-keys":14,"./_object-keys-internal":37}],39:[function(require,module,exports){exports.f={}.propertyIsEnumerable},{}],40:[function(require,module,exports){module.exports=function(bitmap,value){return{enumerable:!(bitmap&1),configurable:!(bitmap&2),writable:!(bitmap&4),value:value}}},{}],41:[function(require,module,exports){var global=require("./_global"),hide=require("./_hide"),has=require("./_has"),SRC=require("./_uid")("src"),TO_STRING="toString",$toString=Function[TO_STRING],TPL=(""+$toString).split(TO_STRING);require("./_core").inspectSource=function(it){return $toString.call(it)};(module.exports=function(O,key,val,safe){var isFunction=typeof val=="function";if(isFunction)has(val,"name")||hide(val,"name",key);if(O[key]===val)return;if(isFunction)has(val,SRC)||hide(val,SRC,O[key]?""+O[key]:TPL.join(String(key)));if(O===global){O[key]=val}else{if(!safe){delete O[key];hide(O,key,val)}else{if(O[key])O[key]=val;else hide(O,key,val)}}})(Function.prototype,TO_STRING,function toString(){return typeof this=="function"&&this[SRC]||$toString.call(this)})},{"./_core":8,"./_global":17,"./_has":18,"./_hide":19,"./_uid":52}],42:[function(require,module,exports){var def=require("./_object-dp").f,has=require("./_has"),TAG=require("./_wks")("toStringTag");module.exports=function(it,tag,stat){if(it&&!has(it=stat?it:it.prototype,TAG))def(it,TAG,{configurable:true,value:tag})}},{"./_has":18,"./_object-dp":33,"./_wks":53}],43:[function(require,module,exports){var shared=require("./_shared")("keys"),uid=require("./_uid");module.exports=function(key){return shared[key]||(shared[key]=uid(key))}},{"./_shared":44,"./_uid":52}],44:[function(require,module,exports){var global=require("./_global"),SHARED="__core-js_shared__",store=global[SHARED]||(global[SHARED]={});module.exports=function(key){return store[key]||(store[key]={})}},{"./_global":17}],45:[function(require,module,exports){var toInteger=require("./_to-integer"),defined=require("./_defined");module.exports=function(TO_STRING){return function(that,pos){var s=String(defined(that)),i=toInteger(pos),l=s.length,a,b;if(i<0||i>=l)return TO_STRING?"":undefined;a=s.charCodeAt(i);return a<55296||a>56319||i+1===l||(b=s.charCodeAt(i+1))<56320||b>57343?TO_STRING?s.charAt(i):a:TO_STRING?s.slice(i,i+2):(a-55296<<10)+(b-56320)+65536}}},{"./_defined":11,"./_to-integer":47}],46:[function(require,module,exports){var toInteger=require("./_to-integer"),max=Math.max,min=Math.min;module.exports=function(index,length){index=toInteger(index);return index<0?max(index+length,0):min(index,length)}},{"./_to-integer":47}],47:[function(require,module,exports){var ceil=Math.ceil,floor=Math.floor;module.exports=function(it){return isNaN(it=+it)?0:(it>0?floor:ceil)(it)}},{}],48:[function(require,module,exports){var IObject=require("./_iobject"),defined=require("./_defined");module.exports=function(it){return IObject(defined(it))}},{"./_defined":11,"./_iobject":22}],49:[function(require,module,exports){var toInteger=require("./_to-integer"),min=Math.min;module.exports=function(it){return it>0?min(toInteger(it),9007199254740991):0}},{"./_to-integer":47}],50:[function(require,module,exports){var defined=require("./_defined");module.exports=function(it){return Object(defined(it))}},{"./_defined":11}],51:[function(require,module,exports){var isObject=require("./_is-object");module.exports=function(it,S){if(!isObject(it))return it;var fn,val;if(S&&typeof(fn=it.toString)=="function"&&!isObject(val=fn.call(it)))return val;if(typeof(fn=it.valueOf)=="function"&&!isObject(val=fn.call(it)))return val;if(!S&&typeof(fn=it.toString)=="function"&&!isObject(val=fn.call(it)))return val;throw TypeError("Can't convert object to primitive value")}},{"./_is-object":24}],52:[function(require,module,exports){var id=0,px=Math.random();module.exports=function(key){return"Symbol(".concat(key===undefined?"":key,")_",(++id+px).toString(36))}},{}],53:[function(require,module,exports){var store=require("./_shared")("wks"),uid=require("./_uid"),Symbol=require("./_global").Symbol,USE_SYMBOL=typeof Symbol=="function";var $exports=module.exports=function(name){return store[name]||(store[name]=USE_SYMBOL&&Symbol[name]||(USE_SYMBOL?Symbol:uid)("Symbol."+name))};$exports.store=store},{"./_global":17,"./_shared":44,"./_uid":52}],54:[function(require,module,exports){var classof=require("./_classof"),ITERATOR=require("./_wks")("iterator"),Iterators=require("./_iterators");module.exports=require("./_core").getIteratorMethod=function(it){if(it!=undefined)return it[ITERATOR]||it["@@iterator"]||Iterators[classof(it)]}},{"./_classof":6,"./_core":8,"./_iterators":29,"./_wks":53}],55:[function(require,module,exports){"use strict";var ctx=require("./_ctx"),$export=require("./_export"),toObject=require("./_to-object"),call=require("./_iter-call"),isArrayIter=require("./_is-array-iter"),toLength=require("./_to-length"),createProperty=require("./_create-property"),getIterFn=require("./core.get-iterator-method");$export($export.S+$export.F*!require("./_iter-detect")(function(iter){Array.from(iter)}),"Array",{from:function from(arrayLike){var O=toObject(arrayLike),C=typeof this=="function"?this:Array,aLen=arguments.length,mapfn=aLen>1?arguments[1]:undefined,mapping=mapfn!==undefined,index=0,iterFn=getIterFn(O),length,result,step,iterator;if(mapping)mapfn=ctx(mapfn,aLen>2?arguments[2]:undefined,2);if(iterFn!=undefined&&!(C==Array&&isArrayIter(iterFn))){for(iterator=iterFn.call(O),result=new C;!(step=iterator.next()).done;index++){createProperty(result,index,mapping?call(iterator,mapfn,[step.value,index],true):step.value)}}else{length=toLength(O.length);for(result=new C(length);length>index;index++){createProperty(result,index,mapping?mapfn(O[index],index):O[index])}}result.length=index;return result}})},{"./_create-property":9,"./_ctx":10,"./_export":15,"./_is-array-iter":23,"./_iter-call":25,"./_iter-detect":28,"./_to-length":49,"./_to-object":50,"./core.get-iterator-method":54}],56:[function(require,module,exports){var $export=require("./_export");$export($export.S+$export.F,"Object",{assign:require("./_object-assign")})},{"./_export":15,"./_object-assign":31}],57:[function(require,module,exports){"use strict";var $at=require("./_string-at")(true);require("./_iter-define")(String,"String",function(iterated){this._t=String(iterated);this._i=0},function(){var O=this._t,index=this._i,point;if(index>=O.length)return{value:undefined,done:true};point=$at(O,index);this._i+=point.length;return{value:point,done:false}})},{"./_iter-define":27,"./_string-at":45}],58:[function(require,module,exports){function Voronoi(){this.vertices=null;this.edges=null;this.cells=null;this.toRecycle=null;this.beachsectionJunkyard=[];this.circleEventJunkyard=[];this.vertexJunkyard=[];this.edgeJunkyard=[];this.cellJunkyard=[]}Voronoi.prototype.reset=function(){if(!this.beachline){this.beachline=new this.RBTree}if(this.beachline.root){var beachsection=this.beachline.getFirst(this.beachline.root);while(beachsection){this.beachsectionJunkyard.push(beachsection);beachsection=beachsection.rbNext}}this.beachline.root=null;if(!this.circleEvents){this.circleEvents=new this.RBTree}this.circleEvents.root=this.firstCircleEvent=null;this.vertices=[];this.edges=[];this.cells=[]};Voronoi.prototype.sqrt=Math.sqrt;Voronoi.prototype.abs=Math.abs;Voronoi.prototype.ε=Voronoi.ε=1e-9;Voronoi.prototype.invε=Voronoi.invε=1/Voronoi.ε;Voronoi.prototype.equalWithEpsilon=function(a,b){return this.abs(a-b)<1e-9};Voronoi.prototype.greaterThanWithEpsilon=function(a,b){return a-b>1e-9};Voronoi.prototype.greaterThanOrEqualWithEpsilon=function(a,b){return b-a<1e-9};Voronoi.prototype.lessThanWithEpsilon=function(a,b){return b-a>1e-9};Voronoi.prototype.lessThanOrEqualWithEpsilon=function(a,b){return a-b<1e-9};Voronoi.prototype.RBTree=function(){this.root=null};Voronoi.prototype.RBTree.prototype.rbInsertSuccessor=function(node,successor){var parent;if(node){successor.rbPrevious=node;successor.rbNext=node.rbNext;if(node.rbNext){node.rbNext.rbPrevious=successor}node.rbNext=successor;if(node.rbRight){node=node.rbRight;while(node.rbLeft){node=node.rbLeft}node.rbLeft=successor}else{node.rbRight=successor}parent=node}else if(this.root){node=this.getFirst(this.root);successor.rbPrevious=null;successor.rbNext=node;node.rbPrevious=successor;node.rbLeft=successor;parent=node}else{successor.rbPrevious=successor.rbNext=null;this.root=successor;parent=null}successor.rbLeft=successor.rbRight=null;successor.rbParent=parent;successor.rbRed=true;var grandpa,uncle;node=successor;while(parent&&parent.rbRed){grandpa=parent.rbParent;if(parent===grandpa.rbLeft){uncle=grandpa.rbRight;if(uncle&&uncle.rbRed){parent.rbRed=uncle.rbRed=false;grandpa.rbRed=true;node=grandpa}else{if(node===parent.rbRight){this.rbRotateLeft(parent);node=parent;parent=node.rbParent}parent.rbRed=false;grandpa.rbRed=true;this.rbRotateRight(grandpa)}}else{uncle=grandpa.rbLeft;if(uncle&&uncle.rbRed){parent.rbRed=uncle.rbRed=false;grandpa.rbRed=true;node=grandpa}else{if(node===parent.rbLeft){this.rbRotateRight(parent);node=parent;parent=node.rbParent}parent.rbRed=false;grandpa.rbRed=true;this.rbRotateLeft(grandpa)}}parent=node.rbParent}this.root.rbRed=false};Voronoi.prototype.RBTree.prototype.rbRemoveNode=function(node){if(node.rbNext){node.rbNext.rbPrevious=node.rbPrevious}if(node.rbPrevious){node.rbPrevious.rbNext=node.rbNext}node.rbNext=node.rbPrevious=null;var parent=node.rbParent,left=node.rbLeft,right=node.rbRight,next;if(!left){next=right}else if(!right){next=left}else{next=this.getFirst(right)}if(parent){if(parent.rbLeft===node){parent.rbLeft=next}else{parent.rbRight=next}}else{this.root=next}var isRed;if(left&&right){isRed=next.rbRed;next.rbRed=node.rbRed;next.rbLeft=left;left.rbParent=next;if(next!==right){parent=next.rbParent;next.rbParent=node.rbParent;node=next.rbRight;parent.rbLeft=node;next.rbRight=right;right.rbParent=next}else{next.rbParent=parent;parent=next;node=next.rbRight}}else{isRed=node.rbRed;node=next}if(node){node.rbParent=parent}if(isRed){return}if(node&&node.rbRed){node.rbRed=false;return}var sibling;do{if(node===this.root){break}if(node===parent.rbLeft){sibling=parent.rbRight;if(sibling.rbRed){sibling.rbRed=false;parent.rbRed=true;this.rbRotateLeft(parent);sibling=parent.rbRight}if(sibling.rbLeft&&sibling.rbLeft.rbRed||sibling.rbRight&&sibling.rbRight.rbRed){if(!sibling.rbRight||!sibling.rbRight.rbRed){sibling.rbLeft.rbRed=false;sibling.rbRed=true;this.rbRotateRight(sibling);sibling=parent.rbRight}sibling.rbRed=parent.rbRed;parent.rbRed=sibling.rbRight.rbRed=false;this.rbRotateLeft(parent);node=this.root;break}}else{sibling=parent.rbLeft;if(sibling.rbRed){sibling.rbRed=false;parent.rbRed=true;this.rbRotateRight(parent);sibling=parent.rbLeft}if(sibling.rbLeft&&sibling.rbLeft.rbRed||sibling.rbRight&&sibling.rbRight.rbRed){if(!sibling.rbLeft||!sibling.rbLeft.rbRed){sibling.rbRight.rbRed=false;sibling.rbRed=true;this.rbRotateLeft(sibling);sibling=parent.rbLeft}sibling.rbRed=parent.rbRed;parent.rbRed=sibling.rbLeft.rbRed=false;this.rbRotateRight(parent);node=this.root;break}}sibling.rbRed=true;node=parent;parent=parent.rbParent}while(!node.rbRed);if(node){node.rbRed=false}};Voronoi.prototype.RBTree.prototype.rbRotateLeft=function(node){var p=node,q=node.rbRight,parent=p.rbParent;if(parent){if(parent.rbLeft===p){parent.rbLeft=q}else{parent.rbRight=q}}else{this.root=q}q.rbParent=parent;p.rbParent=q;p.rbRight=q.rbLeft;if(p.rbRight){p.rbRight.rbParent=p}q.rbLeft=p};Voronoi.prototype.RBTree.prototype.rbRotateRight=function(node){var p=node,q=node.rbLeft,parent=p.rbParent;if(parent){if(parent.rbLeft===p){parent.rbLeft=q}else{parent.rbRight=q}}else{this.root=q}q.rbParent=parent;p.rbParent=q;p.rbLeft=q.rbRight;if(p.rbLeft){p.rbLeft.rbParent=p}q.rbRight=p};Voronoi.prototype.RBTree.prototype.getFirst=function(node){while(node.rbLeft){node=node.rbLeft}return node};Voronoi.prototype.RBTree.prototype.getLast=function(node){while(node.rbRight){node=node.rbRight}return node};Voronoi.prototype.Diagram=function(site){this.site=site};Voronoi.prototype.Cell=function(site){this.site=site;this.halfedges=[];this.closeMe=false};Voronoi.prototype.Cell.prototype.init=function(site){this.site=site;this.halfedges=[];this.closeMe=false;return this};Voronoi.prototype.createCell=function(site){var cell=this.cellJunkyard.pop();if(cell){return cell.init(site)}return new this.Cell(site)};Voronoi.prototype.Cell.prototype.prepareHalfedges=function(){var halfedges=this.halfedges,iHalfedge=halfedges.length,edge;while(iHalfedge--){edge=halfedges[iHalfedge].edge;if(!edge.vb||!edge.va){halfedges.splice(iHalfedge,1)}}halfedges.sort(function(a,b){return b.angle-a.angle});return halfedges.length};Voronoi.prototype.Cell.prototype.getNeighborIds=function(){var neighbors=[],iHalfedge=this.halfedges.length,edge;while(iHalfedge--){edge=this.halfedges[iHalfedge].edge;if(edge.lSite!==null&&edge.lSite.voronoiId!=this.site.voronoiId){neighbors.push(edge.lSite.voronoiId)}else if(edge.rSite!==null&&edge.rSite.voronoiId!=this.site.voronoiId){neighbors.push(edge.rSite.voronoiId)}}return neighbors};Voronoi.prototype.Cell.prototype.getBbox=function(){var halfedges=this.halfedges,iHalfedge=halfedges.length,xmin=Infinity,ymin=Infinity,xmax=-Infinity,ymax=-Infinity,v,vx,vy;while(iHalfedge--){v=halfedges[iHalfedge].getStartpoint();vx=v.x;vy=v.y;if(vx<xmin){xmin=vx}if(vy<ymin){ymin=vy}if(vx>xmax){xmax=vx}if(vy>ymax){ymax=vy}}return{x:xmin,y:ymin,width:xmax-xmin,height:ymax-ymin}};Voronoi.prototype.Cell.prototype.pointIntersection=function(x,y){var halfedges=this.halfedges,iHalfedge=halfedges.length,halfedge,p0,p1,r;while(iHalfedge--){halfedge=halfedges[iHalfedge];p0=halfedge.getStartpoint();p1=halfedge.getEndpoint();r=(y-p0.y)*(p1.x-p0.x)-(x-p0.x)*(p1.y-p0.y);if(!r){return 0}if(r>0){return-1}}return 1};Voronoi.prototype.Vertex=function(x,y){this.x=x;this.y=y};Voronoi.prototype.Edge=function(lSite,rSite){this.lSite=lSite;this.rSite=rSite;this.va=this.vb=null};Voronoi.prototype.Halfedge=function(edge,lSite,rSite){this.site=lSite;this.edge=edge;if(rSite){this.angle=Math.atan2(rSite.y-lSite.y,rSite.x-lSite.x)}else{var va=edge.va,vb=edge.vb;this.angle=edge.lSite===lSite?Math.atan2(vb.x-va.x,va.y-vb.y):Math.atan2(va.x-vb.x,vb.y-va.y)}};Voronoi.prototype.createHalfedge=function(edge,lSite,rSite){return new this.Halfedge(edge,lSite,rSite)};Voronoi.prototype.Halfedge.prototype.getStartpoint=function(){return this.edge.lSite===this.site?this.edge.va:this.edge.vb};Voronoi.prototype.Halfedge.prototype.getEndpoint=function(){return this.edge.lSite===this.site?this.edge.vb:this.edge.va};Voronoi.prototype.createVertex=function(x,y){var v=this.vertexJunkyard.pop();if(!v){v=new this.Vertex(x,y)}else{v.x=x;v.y=y}this.vertices.push(v);return v};Voronoi.prototype.createEdge=function(lSite,rSite,va,vb){var edge=this.edgeJunkyard.pop();if(!edge){edge=new this.Edge(lSite,rSite)}else{edge.lSite=lSite;edge.rSite=rSite;edge.va=edge.vb=null}this.edges.push(edge);if(va){this.setEdgeStartpoint(edge,lSite,rSite,va)}if(vb){this.setEdgeEndpoint(edge,lSite,rSite,vb)}this.cells[lSite.voronoiId].halfedges.push(this.createHalfedge(edge,lSite,rSite));this.cells[rSite.voronoiId].halfedges.push(this.createHalfedge(edge,rSite,lSite));return edge};Voronoi.prototype.createBorderEdge=function(lSite,va,vb){var edge=this.edgeJunkyard.pop();if(!edge){edge=new this.Edge(lSite,null)}else{edge.lSite=lSite;edge.rSite=null}edge.va=va;edge.vb=vb;this.edges.push(edge);return edge};Voronoi.prototype.setEdgeStartpoint=function(edge,lSite,rSite,vertex){if(!edge.va&&!edge.vb){edge.va=vertex;edge.lSite=lSite;edge.rSite=rSite}else if(edge.lSite===rSite){edge.vb=vertex}else{edge.va=vertex}};Voronoi.prototype.setEdgeEndpoint=function(edge,lSite,rSite,vertex){this.setEdgeStartpoint(edge,rSite,lSite,vertex)};Voronoi.prototype.Beachsection=function(){};Voronoi.prototype.createBeachsection=function(site){var beachsection=this.beachsectionJunkyard.pop();if(!beachsection){beachsection=new this.Beachsection}beachsection.site=site;return beachsection};Voronoi.prototype.leftBreakPoint=function(arc,directrix){var site=arc.site,rfocx=site.x,rfocy=site.y,pby2=rfocy-directrix;if(!pby2){return rfocx}var lArc=arc.rbPrevious;if(!lArc){return-Infinity}site=lArc.site;var lfocx=site.x,lfocy=site.y,plby2=lfocy-directrix;if(!plby2){return lfocx}var hl=lfocx-rfocx,aby2=1/pby2-1/plby2,b=hl/plby2;if(aby2){return(-b+this.sqrt(b*b-2*aby2*(hl*hl/(-2*plby2)-lfocy+plby2/2+rfocy-pby2/2)))/aby2+rfocx}return(rfocx+lfocx)/2};Voronoi.prototype.rightBreakPoint=function(arc,directrix){var rArc=arc.rbNext;if(rArc){return this.leftBreakPoint(rArc,directrix)}var site=arc.site;return site.y===directrix?site.x:Infinity;
};Voronoi.prototype.detachBeachsection=function(beachsection){this.detachCircleEvent(beachsection);this.beachline.rbRemoveNode(beachsection);this.beachsectionJunkyard.push(beachsection)};Voronoi.prototype.removeBeachsection=function(beachsection){var circle=beachsection.circleEvent,x=circle.x,y=circle.ycenter,vertex=this.createVertex(x,y),previous=beachsection.rbPrevious,next=beachsection.rbNext,disappearingTransitions=[beachsection],abs_fn=Math.abs;this.detachBeachsection(beachsection);var lArc=previous;while(lArc.circleEvent&&abs_fn(x-lArc.circleEvent.x)<1e-9&&abs_fn(y-lArc.circleEvent.ycenter)<1e-9){previous=lArc.rbPrevious;disappearingTransitions.unshift(lArc);this.detachBeachsection(lArc);lArc=previous}disappearingTransitions.unshift(lArc);this.detachCircleEvent(lArc);var rArc=next;while(rArc.circleEvent&&abs_fn(x-rArc.circleEvent.x)<1e-9&&abs_fn(y-rArc.circleEvent.ycenter)<1e-9){next=rArc.rbNext;disappearingTransitions.push(rArc);this.detachBeachsection(rArc);rArc=next}disappearingTransitions.push(rArc);this.detachCircleEvent(rArc);var nArcs=disappearingTransitions.length,iArc;for(iArc=1;iArc<nArcs;iArc++){rArc=disappearingTransitions[iArc];lArc=disappearingTransitions[iArc-1];this.setEdgeStartpoint(rArc.edge,lArc.site,rArc.site,vertex)}lArc=disappearingTransitions[0];rArc=disappearingTransitions[nArcs-1];rArc.edge=this.createEdge(lArc.site,rArc.site,undefined,vertex);this.attachCircleEvent(lArc);this.attachCircleEvent(rArc)};Voronoi.prototype.addBeachsection=function(site){var x=site.x,directrix=site.y;var lArc,rArc,dxl,dxr,node=this.beachline.root;while(node){dxl=this.leftBreakPoint(node,directrix)-x;if(dxl>1e-9){node=node.rbLeft}else{dxr=x-this.rightBreakPoint(node,directrix);if(dxr>1e-9){if(!node.rbRight){lArc=node;break}node=node.rbRight}else{if(dxl>-1e-9){lArc=node.rbPrevious;rArc=node}else if(dxr>-1e-9){lArc=node;rArc=node.rbNext}else{lArc=rArc=node}break}}}var newArc=this.createBeachsection(site);this.beachline.rbInsertSuccessor(lArc,newArc);if(!lArc&&!rArc){return}if(lArc===rArc){this.detachCircleEvent(lArc);rArc=this.createBeachsection(lArc.site);this.beachline.rbInsertSuccessor(newArc,rArc);newArc.edge=rArc.edge=this.createEdge(lArc.site,newArc.site);this.attachCircleEvent(lArc);this.attachCircleEvent(rArc);return}if(lArc&&!rArc){newArc.edge=this.createEdge(lArc.site,newArc.site);return}if(lArc!==rArc){this.detachCircleEvent(lArc);this.detachCircleEvent(rArc);var lSite=lArc.site,ax=lSite.x,ay=lSite.y,bx=site.x-ax,by=site.y-ay,rSite=rArc.site,cx=rSite.x-ax,cy=rSite.y-ay,d=2*(bx*cy-by*cx),hb=bx*bx+by*by,hc=cx*cx+cy*cy,vertex=this.createVertex((cy*hb-by*hc)/d+ax,(bx*hc-cx*hb)/d+ay);this.setEdgeStartpoint(rArc.edge,lSite,rSite,vertex);newArc.edge=this.createEdge(lSite,site,undefined,vertex);rArc.edge=this.createEdge(site,rSite,undefined,vertex);this.attachCircleEvent(lArc);this.attachCircleEvent(rArc);return}};Voronoi.prototype.CircleEvent=function(){this.arc=null;this.rbLeft=null;this.rbNext=null;this.rbParent=null;this.rbPrevious=null;this.rbRed=false;this.rbRight=null;this.site=null;this.x=this.y=this.ycenter=0};Voronoi.prototype.attachCircleEvent=function(arc){var lArc=arc.rbPrevious,rArc=arc.rbNext;if(!lArc||!rArc){return}var lSite=lArc.site,cSite=arc.site,rSite=rArc.site;if(lSite===rSite){return}var bx=cSite.x,by=cSite.y,ax=lSite.x-bx,ay=lSite.y-by,cx=rSite.x-bx,cy=rSite.y-by;var d=2*(ax*cy-ay*cx);if(d>=-2e-12){return}var ha=ax*ax+ay*ay,hc=cx*cx+cy*cy,x=(cy*ha-ay*hc)/d,y=(ax*hc-cx*ha)/d,ycenter=y+by;var circleEvent=this.circleEventJunkyard.pop();if(!circleEvent){circleEvent=new this.CircleEvent}circleEvent.arc=arc;circleEvent.site=cSite;circleEvent.x=x+bx;circleEvent.y=ycenter+this.sqrt(x*x+y*y);circleEvent.ycenter=ycenter;arc.circleEvent=circleEvent;var predecessor=null,node=this.circleEvents.root;while(node){if(circleEvent.y<node.y||circleEvent.y===node.y&&circleEvent.x<=node.x){if(node.rbLeft){node=node.rbLeft}else{predecessor=node.rbPrevious;break}}else{if(node.rbRight){node=node.rbRight}else{predecessor=node;break}}}this.circleEvents.rbInsertSuccessor(predecessor,circleEvent);if(!predecessor){this.firstCircleEvent=circleEvent}};Voronoi.prototype.detachCircleEvent=function(arc){var circleEvent=arc.circleEvent;if(circleEvent){if(!circleEvent.rbPrevious){this.firstCircleEvent=circleEvent.rbNext}this.circleEvents.rbRemoveNode(circleEvent);this.circleEventJunkyard.push(circleEvent);arc.circleEvent=null}};Voronoi.prototype.connectEdge=function(edge,bbox){var vb=edge.vb;if(!!vb){return true}var va=edge.va,xl=bbox.xl,xr=bbox.xr,yt=bbox.yt,yb=bbox.yb,lSite=edge.lSite,rSite=edge.rSite,lx=lSite.x,ly=lSite.y,rx=rSite.x,ry=rSite.y,fx=(lx+rx)/2,fy=(ly+ry)/2,fm,fb;this.cells[lSite.voronoiId].closeMe=true;this.cells[rSite.voronoiId].closeMe=true;if(ry!==ly){fm=(lx-rx)/(ry-ly);fb=fy-fm*fx}if(fm===undefined){if(fx<xl||fx>=xr){return false}if(lx>rx){if(!va||va.y<yt){va=this.createVertex(fx,yt)}else if(va.y>=yb){return false}vb=this.createVertex(fx,yb)}else{if(!va||va.y>yb){va=this.createVertex(fx,yb)}else if(va.y<yt){return false}vb=this.createVertex(fx,yt)}}else if(fm<-1||fm>1){if(lx>rx){if(!va||va.y<yt){va=this.createVertex((yt-fb)/fm,yt)}else if(va.y>=yb){return false}vb=this.createVertex((yb-fb)/fm,yb)}else{if(!va||va.y>yb){va=this.createVertex((yb-fb)/fm,yb)}else if(va.y<yt){return false}vb=this.createVertex((yt-fb)/fm,yt)}}else{if(ly<ry){if(!va||va.x<xl){va=this.createVertex(xl,fm*xl+fb)}else if(va.x>=xr){return false}vb=this.createVertex(xr,fm*xr+fb)}else{if(!va||va.x>xr){va=this.createVertex(xr,fm*xr+fb)}else if(va.x<xl){return false}vb=this.createVertex(xl,fm*xl+fb)}}edge.va=va;edge.vb=vb;return true};Voronoi.prototype.clipEdge=function(edge,bbox){var ax=edge.va.x,ay=edge.va.y,bx=edge.vb.x,by=edge.vb.y,t0=0,t1=1,dx=bx-ax,dy=by-ay;var q=ax-bbox.xl;if(dx===0&&q<0){return false}var r=-q/dx;if(dx<0){if(r<t0){return false}if(r<t1){t1=r}}else if(dx>0){if(r>t1){return false}if(r>t0){t0=r}}q=bbox.xr-ax;if(dx===0&&q<0){return false}r=q/dx;if(dx<0){if(r>t1){return false}if(r>t0){t0=r}}else if(dx>0){if(r<t0){return false}if(r<t1){t1=r}}q=ay-bbox.yt;if(dy===0&&q<0){return false}r=-q/dy;if(dy<0){if(r<t0){return false}if(r<t1){t1=r}}else if(dy>0){if(r>t1){return false}if(r>t0){t0=r}}q=bbox.yb-ay;if(dy===0&&q<0){return false}r=q/dy;if(dy<0){if(r>t1){return false}if(r>t0){t0=r}}else if(dy>0){if(r<t0){return false}if(r<t1){t1=r}}if(t0>0){edge.va=this.createVertex(ax+t0*dx,ay+t0*dy)}if(t1<1){edge.vb=this.createVertex(ax+t1*dx,ay+t1*dy)}if(t0>0||t1<1){this.cells[edge.lSite.voronoiId].closeMe=true;this.cells[edge.rSite.voronoiId].closeMe=true}return true};Voronoi.prototype.clipEdges=function(bbox){var edges=this.edges,iEdge=edges.length,edge,abs_fn=Math.abs;while(iEdge--){edge=edges[iEdge];if(!this.connectEdge(edge,bbox)||!this.clipEdge(edge,bbox)||abs_fn(edge.va.x-edge.vb.x)<1e-9&&abs_fn(edge.va.y-edge.vb.y)<1e-9){edge.va=edge.vb=null;edges.splice(iEdge,1)}}};Voronoi.prototype.closeCells=function(bbox){var xl=bbox.xl,xr=bbox.xr,yt=bbox.yt,yb=bbox.yb,cells=this.cells,iCell=cells.length,cell,iLeft,halfedges,nHalfedges,edge,va,vb,vz,lastBorderSegment,abs_fn=Math.abs;while(iCell--){cell=cells[iCell];if(!cell.prepareHalfedges()){continue}if(!cell.closeMe){continue}halfedges=cell.halfedges;nHalfedges=halfedges.length;iLeft=0;while(iLeft<nHalfedges){va=halfedges[iLeft].getEndpoint();vz=halfedges[(iLeft+1)%nHalfedges].getStartpoint();if(abs_fn(va.x-vz.x)>=1e-9||abs_fn(va.y-vz.y)>=1e-9){switch(true){case this.equalWithEpsilon(va.x,xl)&&this.lessThanWithEpsilon(va.y,yb):lastBorderSegment=this.equalWithEpsilon(vz.x,xl);vb=this.createVertex(xl,lastBorderSegment?vz.y:yb);edge=this.createBorderEdge(cell.site,va,vb);iLeft++;halfedges.splice(iLeft,0,this.createHalfedge(edge,cell.site,null));nHalfedges++;if(lastBorderSegment){break}va=vb;case this.equalWithEpsilon(va.y,yb)&&this.lessThanWithEpsilon(va.x,xr):lastBorderSegment=this.equalWithEpsilon(vz.y,yb);vb=this.createVertex(lastBorderSegment?vz.x:xr,yb);edge=this.createBorderEdge(cell.site,va,vb);iLeft++;halfedges.splice(iLeft,0,this.createHalfedge(edge,cell.site,null));nHalfedges++;if(lastBorderSegment){break}va=vb;case this.equalWithEpsilon(va.x,xr)&&this.greaterThanWithEpsilon(va.y,yt):lastBorderSegment=this.equalWithEpsilon(vz.x,xr);vb=this.createVertex(xr,lastBorderSegment?vz.y:yt);edge=this.createBorderEdge(cell.site,va,vb);iLeft++;halfedges.splice(iLeft,0,this.createHalfedge(edge,cell.site,null));nHalfedges++;if(lastBorderSegment){break}va=vb;case this.equalWithEpsilon(va.y,yt)&&this.greaterThanWithEpsilon(va.x,xl):lastBorderSegment=this.equalWithEpsilon(vz.y,yt);vb=this.createVertex(lastBorderSegment?vz.x:xl,yt);edge=this.createBorderEdge(cell.site,va,vb);iLeft++;halfedges.splice(iLeft,0,this.createHalfedge(edge,cell.site,null));nHalfedges++;if(lastBorderSegment){break}va=vb;lastBorderSegment=this.equalWithEpsilon(vz.x,xl);vb=this.createVertex(xl,lastBorderSegment?vz.y:yb);edge=this.createBorderEdge(cell.site,va,vb);iLeft++;halfedges.splice(iLeft,0,this.createHalfedge(edge,cell.site,null));nHalfedges++;if(lastBorderSegment){break}va=vb;lastBorderSegment=this.equalWithEpsilon(vz.y,yb);vb=this.createVertex(lastBorderSegment?vz.x:xr,yb);edge=this.createBorderEdge(cell.site,va,vb);iLeft++;halfedges.splice(iLeft,0,this.createHalfedge(edge,cell.site,null));nHalfedges++;if(lastBorderSegment){break}va=vb;lastBorderSegment=this.equalWithEpsilon(vz.x,xr);vb=this.createVertex(xr,lastBorderSegment?vz.y:yt);edge=this.createBorderEdge(cell.site,va,vb);iLeft++;halfedges.splice(iLeft,0,this.createHalfedge(edge,cell.site,null));nHalfedges++;if(lastBorderSegment){break}default:throw"Voronoi.closeCells() > this makes no sense!"}}iLeft++}cell.closeMe=false}};Voronoi.prototype.quantizeSites=function(sites){var ε=this.ε,n=sites.length,site;while(n--){site=sites[n];site.x=Math.floor(site.x/ε)*ε;site.y=Math.floor(site.y/ε)*ε}};Voronoi.prototype.recycle=function(diagram){if(diagram){if(diagram instanceof this.Diagram){this.toRecycle=diagram}else{throw"Voronoi.recycleDiagram() > Need a Diagram object."}}};Voronoi.prototype.compute=function(sites,bbox){var startTime=new Date;this.reset();if(this.toRecycle){this.vertexJunkyard=this.vertexJunkyard.concat(this.toRecycle.vertices);this.edgeJunkyard=this.edgeJunkyard.concat(this.toRecycle.edges);this.cellJunkyard=this.cellJunkyard.concat(this.toRecycle.cells);this.toRecycle=null}var siteEvents=sites.slice(0);siteEvents.sort(function(a,b){var r=b.y-a.y;if(r){return r}return b.x-a.x});var site=siteEvents.pop(),siteid=0,xsitex,xsitey,cells=this.cells,circle;for(;;){circle=this.firstCircleEvent;if(site&&(!circle||site.y<circle.y||site.y===circle.y&&site.x<circle.x)){if(site.x!==xsitex||site.y!==xsitey){cells[siteid]=this.createCell(site);site.voronoiId=siteid++;this.addBeachsection(site);xsitey=site.y;xsitex=site.x}site=siteEvents.pop()}else if(circle){this.removeBeachsection(circle.arc)}else{break}}this.clipEdges(bbox);this.closeCells(bbox);var stopTime=new Date;var diagram=new this.Diagram;diagram.cells=this.cells;diagram.edges=this.edges;diagram.vertices=this.vertices;diagram.execTime=stopTime.getTime()-startTime.getTime();this.reset();return diagram};if(typeof module!=="undefined")module.exports=Voronoi},{}],59:[function(require,module,exports){var Voronoi=require("voronoi");require("core-js/fn/object/assign");require("core-js/fn/array/from");function Particles(canvas,options){if(options===void 0)options={};options=Object.assign({edgeLightUpSpeed:.002,edgeFadeSpeed:.001,edgeLightUpBrightness:.2,eraseAlpha:.5,trailSize:25,pulseChance:.06,maxPulsesPerSpawn:1,maxPulses:10,minVertexRadius:1,minPulseSpeed:.03/2.25,pulseSpeedVariation:.04/2.25,vertexRadiusVariation:1,spacing:80,bg:[71,125,194],fg:[128,198,255]},options);var PI2=Math.PI*2;var dpi=window.devicePixelRatio;var ctx=canvas.getContext("2d");var bounds=canvas.getBoundingClientRect();var width=bounds.width*dpi;var height=bounds.height*dpi;var lastBliped=[];var clear=false;var repeat=function(times,callback){for(var i=0;i<times;i++){callback(i)}};var last=function(arr){return arr[arr.length-1]};function drawCircle(ctx,x,y,r){ctx.beginPath();ctx.arc(x*dpi,y*dpi,r*dpi,0,PI2);ctx.closePath()}function fillCircle(ctx,x,y,r){drawCircle(ctx,x,y,r);ctx.fill()}function strokeCircle(ctx,x,y,r){drawCircle(ctx,x,y,r);ctx.stroke()}function Color(r,g,b){this.r=r;this.g=g;this.b=b}Color.prototype={r:0,g:0,b:0,interpolate:function interpolate(color,p){var dr=color.r-this.r;var dg=color.g-this.g;var db=color.b-this.b;return new Color(this.r+dr*p,this.g+dg*p,this.b+db*p)},toString:function toString(){return"rgb("+Math.round(this.r)+","+Math.round(this.g)+","+Math.round(this.b)+")"}};var color={bg:new Color(options.bg[0],options.bg[1],options.bg[2]),fg:new Color(options.fg[0],options.fg[1],options.fg[2])};var getColor=function(v){return color.bg.interpolate(color.fg,v).toString()};function createGrid(width,height,spacing){var particles=[];var cols=Math.ceil(width/spacing)+1;var rows=Math.ceil(height/spacing)+1;var numParticles=cols*rows;particles=Array.from(Array(numParticles)).map(function(item,i){var col=i%cols;var row=Math.floor(i/cols);var dest={x:spacing*col+(row%2==0?spacing/2:0),y:row*spacing};return dest});var voronoi=new Voronoi;var margin=20;var bbox={xl:-margin,xr:width+margin,yt:-margin,yb:height+margin};var diagram=voronoi.compute(particles,bbox);return diagram}function getNeighbors(diagram,vertex,exclude){if(exclude===void 0)exclude=null;var edges=diagram.edges.filter(function(edge){return(edge.va==vertex||edge.vb==vertex)&&(edge.va!=exclude&&edge.vb!=exclude)});return edges.reduce(function(arr,cur){return arr.concat(cur.va,cur.vb)},[]).filter(function(v){return v!=vertex})}function initDiagram(diagram){diagram.pulses=[];diagram.pulse=function(origin,dest){var pulse=new Pulse(origin,dest);pulse.speed=options.minPulseSpeed+options.pulseSpeedVariation*Math.random();if(diagram.pulses.length<options.maxPulses){origin.lightUp();diagram.pulses.push(pulse);var edge=origin.diagram.edges.find(function(edge){return edge.va==origin&&edge.vb==dest||edge.vb==origin&&edge.va==dest});edge.lightUp();return pulse}else return null};initVertices(diagram);initEdges(diagram);diagram.outerVertices=diagram.vertices.filter(function(vertex){return vertex.y<=0||vertex.y>=diagram.height})}function initEdges(diagram){diagram.edges.forEach(function(edge){edge.color=0;edge.colorTo=0;edge.lightUp=function(){edge.colorTo=options.edgeLightUpBrightness;edge.color=Math.max(edge.color,1e-4)};edge.update=function(){if(edge.colorTo>0){edge.color+=options.edgeLightUpSpeed;edge.colorTo-=options.edgeLightUpSpeed;if(edge.colorTo<0)edge.colorTo=0}else if(edge.color>0){edge.color-=options.edgeFadeSpeed;if(edge.color<0)edge.color=0}}})}function initVertices(diagram){var maxClockSpeed=.001;var maxClockIntensity=0*.1;diagram.vertices.forEach(function(vertex){var depth=Math.random();vertex.diagram=diagram;vertex.clockSpeed=-maxClockSpeed+Math.random()*(maxClockSpeed*2);vertex.clock=Math.random()*PI2;vertex.originX=vertex.x;vertex.originY=vertex.y;vertex.clockIntensity=0+maxClockIntensity*Math.pow(depth,3);vertex.depth=depth;vertex.radius=options.minVertexRadius+depth*options.vertexRadiusVariation;vertex.color=0;vertex.colorFadeSpeed=.01;vertex.blips=[];vertex.blipSpeed=.04;vertex.blipRadius=vertex.radius*3.5+Math.random()*vertex.radius*1;vertex.forceStrength=4;vertex.forces=[];vertex.neighbors=getNeighbors(diagram,vertex);vertex.getRandomNeighbor=function(exclude){if(exclude===void 0)exclude=null;var neighbors=this.neighbors.filter(function(neighbor){return neighbor!=exclude});if(neighbors.length==0)return null;var neighbor=neighbors[Math.round(Math.random()*(neighbors.length-1))];return neighbor};vertex.lightUp=function(){this.color=1};vertex.blip=function(){this.blips.push(1)};vertex.applyForces=function(){var result={x:0,y:0};for(var i=vertex.forces.length-1;i>=0;i--){var force=vertex.forces[i];var p=Math.pow(force.power,3);result.x+=force.cosAngle*p*force.strength;result.y+=force.sinAngle*p*force.strength;force.update();if(force.dead){vertex.forces.splice(i,1)}}return result};vertex.update=function(){var this$1=this;if(this.color>0){this.color-=this.colorFadeSpeed;if(this.color<0)this.color=0}this.blips=this.blips.map(function(blip){return blip-=this$1.blipSpeed}).filter(function(blip){return blip>0})}})}function Force(angle,strength){this.angle=angle;this.power=1;this.strength=strength;this.cosAngle=Math.cos(angle);this.sinAngle=Math.sin(angle)}Force.prototype={angle:0,power:0,dead:false,cosAngle:0,sinAngle:0,update:function update(){this.power-=.03;if(this.power<=0)this.dead=true}};function Pulse(origin,dest){this.origin=origin;this.dest=dest;this.lastPos=[]}Pulse.prototype={origin:null,dest:null,v:0,speed:.03+Math.random()*.05,angle:0,dying:false,dyingCounter:options.trailSize,dead:false,lastPos:null,sparkRandom:.2,update:function update$1(delta){var this$1=this;if(delta===void 0)delta=1;if(this.dying){this.dyingCounter--;if(this.dyingCounter<=0)this.dead=true;return}if(this.v>=1){this.dying=true;var p=this;var newPulses=Math.round(Math.random()*2.45);var failedPulses=0;var lastTargets=[];if(newPulses>0){repeat(newPulses,function(i){var neighbor=this$1.dest.getRandomNeighbor(this$1.origin);if(neighbor==null){failedPulses++;return}if(lastTargets.indexOf(neighbor)>-1){failedPulses++;return}var newPulse=this$1.dest.diagram.pulse(this$1.dest,neighbor);if(newPulse==null){failedPulses++;return}lastTargets.push(neighbor);newPulse.speed=this$1.speed;newPulse.lastPos=this$1.lastPos.slice(this$1.lastPos.length-4)})}var forceStrength=1+Math.random()*1;if(newPulses==0||failedPulses>=newPulses){this.dest.blip();lastBliped=[this.dest].concat(lastBliped.slice(0,20));this.dest.lightUp();forceStrength=7.5+this.dest.depth*6}var dx=this.dest.x-this.origin.x;var dy=this.dest.y-this.origin.y;var angle=Math.atan2(dy,dx);this.dest.forces.push(new Force(angle,forceStrength))}this.v+=this.speed*delta;if(this.v>1)this.v=1},getPos:function getPos(){var pos={x:0,y:0};if(this.dying){pos=this.lastPos[this.lastPos.length-1]}else{var dx=this.dest.x-this.origin.x;var dy=this.dest.y-this.origin.y;var dist=Math.sqrt(dx*dx+dy*dy);var angle=Math.atan2(dy,dx);this.angle=angle;pos={x:this.origin.x+Math.cos(angle)*(dist*this.v),y:this.origin.y+Math.sin(angle)*(dist*this.v)};var sparkRandom=this.sparkRandom;pos.x+=-(sparkRandom/2)+Math.random()*sparkRandom;pos.y+=-(sparkRandom/2)+Math.random()*sparkRandom}this.lastPos=this.lastPos.slice(this.lastPos.length-options.trailSize).concat(pos);return pos}};function drawDiagram(diagram,ctx,width,height,delta){if(Math.random()<options.pulseChance){repeat(Math.random()*options.maxPulsesPerSpawn,function(i){var origin=diagram.outerVertices[Math.round(Math.random()*(diagram.outerVertices.length-1))];var dest=origin.getRandomNeighbor();if(lastBliped.length>0&&(dest==null||Math.random()<.1)){origin=lastBliped[Math.round(Math.random()*(lastBliped.length-1))];dest=origin.getRandomNeighbor();if(dest==null)return}else if(dest==null)return;var newPulse=diagram.pulse(origin,dest);if(newPulse!=null){var dx=dest.x-origin.x;var dy=dest.y-origin.y;var angle=Math.atan2(dy,dx);angle+=Math.PI}})}ctx.fillStyle=getColor(0);ctx.globalAlpha=options.eraseAlpha;ctx.fillRect(0,0,width,height);ctx.globalAlpha=1;ctx.fillStyle=getColor(.2);ctx.strokeStyle=getColor(.15);ctx.lineCap="round";diagram.edges.forEach(function(edge){if(edge.color<=0)return;ctx.beginPath();ctx.moveTo(edge.va.x*dpi,edge.va.y*dpi);ctx.lineTo(edge.vb.x*dpi,edge.vb.y*dpi);ctx.strokeStyle=getColor(edge.color);ctx.globalAlpha=1;ctx.lineWidth=1*dpi;ctx.stroke();edge.update()});diagram.pulses.forEach(function(pulse){var pos=pulse.getPos();pulse.update(delta);ctx.beginPath();ctx.moveTo(pulse.lastPos[0].x*dpi,pulse.lastPos[0].y*dpi);pulse.lastPos.slice(1).forEach(function(p){ctx.lineTo(p.x*dpi,p.y*dpi)});ctx.strokeStyle=getColor(1);ctx.globalAlpha=.7;ctx.lineWidth=1*dpi;ctx.stroke();if(pulse.lastPos.length>=2&&!pulse.dying){ctx.lineWidth=5*dpi;ctx.globalAlpha=.7;ctx.beginPath();var lastPos2=pulse.lastPos.length-2;var lastPos1=pulse.lastPos.length-1;ctx.moveTo(pulse.lastPos[lastPos2].x*dpi,pulse.lastPos[lastPos2].y*dpi);ctx.lineTo(pulse.lastPos[lastPos1].x*dpi,pulse.lastPos[lastPos1].y*dpi);ctx.strokeStyle=getColor(1);ctx.stroke()}});diagram.vertices.forEach(function(vertex){var forces=vertex.applyForces();vertex.x=vertex.originX+forces.x;vertex.y=vertex.originY+forces.y;if(vertex.color>0){var depth=vertex.depth;var minColor=.1+depth*depth*.2;minColor=0;var color=getColor(minColor+Math.min(1,vertex.color)*(1-minColor));ctx.fillStyle=color;ctx.globalAlpha=1-(1-depth)*.35;fillCircle(ctx,vertex.x,vertex.y,vertex.radius)}vertex.blips.forEach(function(blip){var iblip=1-blip;var blipRadius=vertex.radius+vertex.blipRadius*Math.pow(iblip,1/2);var blipAlpha=blip*1;ctx.globalAlpha=blipAlpha;ctx.lineWidth=1*dpi;ctx.strokeStyle=getColor(1);strokeCircle(ctx,vertex.x,vertex.y,blipRadius)});vertex.update()});diagram.pulses=diagram.pulses.filter(function(pulse){return!pulse.dead})}function init(ctx,width,height){var diagram=createGrid(width/dpi,height/dpi,options.spacing);diagram.width=width/dpi;diagram.height=height/dpi;initDiagram(diagram);var last=0;var fps=60;var maxDelta=1.5;(function draw(now){if(clear){return}var delta=(now-last)/(fps/1e3);if(delta>maxDelta)delta=maxDelta;drawDiagram(diagram,ctx,width,height,delta);requestAnimationFrame(draw)})()}function stop(){clear=true}function reset(){window.removeEventListener("resize",reset);stop();Particles(canvas,options)}window.addEventListener("resize",reset);canvas.setAttribute("width",width);canvas.setAttribute("height",height);init(ctx,width,height)}module.exports=Particles},{"core-js/fn/array/from":1,"core-js/fn/object/assign":2,voronoi:58}]},{},[59])(59)});