UNPKG

atum

Version:

A Procedural Graph Based Javascript Library

1 lines 52.5 kB
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Atum=e()}}(function(){return function e(t,r,n){function i(u,a){if(!r[u]){if(!t[u]){var s="function"==typeof require&&require;if(!a&&s)return s(u,!0);if(o)return o(u,!0);var l=new Error("Cannot find module '"+u+"'");throw l.code="MODULE_NOT_FOUND",l}var c=r[u]={exports:{}};t[u][0].call(c.exports,function(e){var r=t[u][1][e];return i(r||e)},c,c.exports,e,t,r,n)}return r[u].exports}for(var o="function"==typeof require&&require,u=0;u<n.length;u++)i(n[u]);return i}({1:[function(e,t,r){function n(){this.vertices=null,this.edges=null,this.cells=null,this.toRecycle=null,this.beachsectionJunkyard=[],this.circleEventJunkyard=[],this.vertexJunkyard=[],this.edgeJunkyard=[],this.cellJunkyard=[]}n.prototype.reset=function(){if(this.beachline||(this.beachline=new this.RBTree),this.beachline.root)for(var e=this.beachline.getFirst(this.beachline.root);e;)this.beachsectionJunkyard.push(e),e=e.rbNext;this.beachline.root=null,this.circleEvents||(this.circleEvents=new this.RBTree),this.circleEvents.root=this.firstCircleEvent=null,this.vertices=[],this.edges=[],this.cells=[]},n.prototype.sqrt=Math.sqrt,n.prototype.abs=Math.abs,n.prototype.ε=n.ε=1e-9,n.prototype.invε=n.invε=1/n.ε,n.prototype.equalWithEpsilon=function(e,t){return this.abs(e-t)<1e-9},n.prototype.greaterThanWithEpsilon=function(e,t){return e-t>1e-9},n.prototype.greaterThanOrEqualWithEpsilon=function(e,t){return t-e<1e-9},n.prototype.lessThanWithEpsilon=function(e,t){return t-e>1e-9},n.prototype.lessThanOrEqualWithEpsilon=function(e,t){return e-t<1e-9},n.prototype.RBTree=function(){this.root=null},n.prototype.RBTree.prototype.rbInsertSuccessor=function(e,t){var r;if(e){if(t.rbPrevious=e,t.rbNext=e.rbNext,e.rbNext&&(e.rbNext.rbPrevious=t),e.rbNext=t,e.rbRight){for(e=e.rbRight;e.rbLeft;)e=e.rbLeft;e.rbLeft=t}else e.rbRight=t;r=e}else this.root?(e=this.getFirst(this.root),t.rbPrevious=null,t.rbNext=e,e.rbPrevious=t,e.rbLeft=t,r=e):(t.rbPrevious=t.rbNext=null,this.root=t,r=null);t.rbLeft=t.rbRight=null,t.rbParent=r,t.rbRed=!0;var n,i;for(e=t;r&&r.rbRed;)r===(n=r.rbParent).rbLeft?(i=n.rbRight)&&i.rbRed?(r.rbRed=i.rbRed=!1,n.rbRed=!0,e=n):(e===r.rbRight&&(this.rbRotateLeft(r),r=(e=r).rbParent),r.rbRed=!1,n.rbRed=!0,this.rbRotateRight(n)):(i=n.rbLeft)&&i.rbRed?(r.rbRed=i.rbRed=!1,n.rbRed=!0,e=n):(e===r.rbLeft&&(this.rbRotateRight(r),r=(e=r).rbParent),r.rbRed=!1,n.rbRed=!0,this.rbRotateLeft(n)),r=e.rbParent;this.root.rbRed=!1},n.prototype.RBTree.prototype.rbRemoveNode=function(e){e.rbNext&&(e.rbNext.rbPrevious=e.rbPrevious),e.rbPrevious&&(e.rbPrevious.rbNext=e.rbNext),e.rbNext=e.rbPrevious=null;var t,r=e.rbParent,n=e.rbLeft,i=e.rbRight;t=n?i?this.getFirst(i):n:i,r?r.rbLeft===e?r.rbLeft=t:r.rbRight=t:this.root=t;var o;if(n&&i?(o=t.rbRed,t.rbRed=e.rbRed,t.rbLeft=n,n.rbParent=t,t!==i?(r=t.rbParent,t.rbParent=e.rbParent,e=t.rbRight,r.rbLeft=e,t.rbRight=i,i.rbParent=t):(t.rbParent=r,r=t,e=t.rbRight)):(o=e.rbRed,e=t),e&&(e.rbParent=r),!o)if(e&&e.rbRed)e.rbRed=!1;else{var u;do{if(e===this.root)break;if(e===r.rbLeft){if((u=r.rbRight).rbRed&&(u.rbRed=!1,r.rbRed=!0,this.rbRotateLeft(r),u=r.rbRight),u.rbLeft&&u.rbLeft.rbRed||u.rbRight&&u.rbRight.rbRed){u.rbRight&&u.rbRight.rbRed||(u.rbLeft.rbRed=!1,u.rbRed=!0,this.rbRotateRight(u),u=r.rbRight),u.rbRed=r.rbRed,r.rbRed=u.rbRight.rbRed=!1,this.rbRotateLeft(r),e=this.root;break}}else if((u=r.rbLeft).rbRed&&(u.rbRed=!1,r.rbRed=!0,this.rbRotateRight(r),u=r.rbLeft),u.rbLeft&&u.rbLeft.rbRed||u.rbRight&&u.rbRight.rbRed){u.rbLeft&&u.rbLeft.rbRed||(u.rbRight.rbRed=!1,u.rbRed=!0,this.rbRotateLeft(u),u=r.rbLeft),u.rbRed=r.rbRed,r.rbRed=u.rbLeft.rbRed=!1,this.rbRotateRight(r),e=this.root;break}u.rbRed=!0,e=r,r=r.rbParent}while(!e.rbRed);e&&(e.rbRed=!1)}},n.prototype.RBTree.prototype.rbRotateLeft=function(e){var t=e,r=e.rbRight,n=t.rbParent;n?n.rbLeft===t?n.rbLeft=r:n.rbRight=r:this.root=r,r.rbParent=n,t.rbParent=r,t.rbRight=r.rbLeft,t.rbRight&&(t.rbRight.rbParent=t),r.rbLeft=t},n.prototype.RBTree.prototype.rbRotateRight=function(e){var t=e,r=e.rbLeft,n=t.rbParent;n?n.rbLeft===t?n.rbLeft=r:n.rbRight=r:this.root=r,r.rbParent=n,t.rbParent=r,t.rbLeft=r.rbRight,t.rbLeft&&(t.rbLeft.rbParent=t),r.rbRight=t},n.prototype.RBTree.prototype.getFirst=function(e){for(;e.rbLeft;)e=e.rbLeft;return e},n.prototype.RBTree.prototype.getLast=function(e){for(;e.rbRight;)e=e.rbRight;return e},n.prototype.Diagram=function(e){this.site=e},n.prototype.Cell=function(e){this.site=e,this.halfedges=[],this.closeMe=!1},n.prototype.Cell.prototype.init=function(e){return this.site=e,this.halfedges=[],this.closeMe=!1,this},n.prototype.createCell=function(e){var t=this.cellJunkyard.pop();return t?t.init(e):new this.Cell(e)},n.prototype.Cell.prototype.prepareHalfedges=function(){for(var e,t=this.halfedges,r=t.length;r--;)(e=t[r].edge).vb&&e.va||t.splice(r,1);return t.sort(function(e,t){return t.angle-e.angle}),t.length},n.prototype.Cell.prototype.getNeighborIds=function(){for(var e,t=[],r=this.halfedges.length;r--;)null!==(e=this.halfedges[r].edge).lSite&&e.lSite.voronoiId!=this.site.voronoiId?t.push(e.lSite.voronoiId):null!==e.rSite&&e.rSite.voronoiId!=this.site.voronoiId&&t.push(e.rSite.voronoiId);return t},n.prototype.Cell.prototype.getBbox=function(){for(var e,t,r,n=this.halfedges,i=n.length,o=1/0,u=1/0,a=-1/0,s=-1/0;i--;)t=(e=n[i].getStartpoint()).x,r=e.y,t<o&&(o=t),r<u&&(u=r),t>a&&(a=t),r>s&&(s=r);return{x:o,y:u,width:a-o,height:s-u}},n.prototype.Cell.prototype.pointIntersection=function(e,t){for(var r,n,i,o,u=this.halfedges,a=u.length;a--;){if(r=u[a],n=r.getStartpoint(),i=r.getEndpoint(),!(o=(t-n.y)*(i.x-n.x)-(e-n.x)*(i.y-n.y)))return 0;if(o>0)return-1}return 1},n.prototype.Vertex=function(e,t){this.x=e,this.y=t},n.prototype.Edge=function(e,t){this.lSite=e,this.rSite=t,this.va=this.vb=null},n.prototype.Halfedge=function(e,t,r){if(this.site=t,this.edge=e,r)this.angle=Math.atan2(r.y-t.y,r.x-t.x);else{var n=e.va,i=e.vb;this.angle=e.lSite===t?Math.atan2(i.x-n.x,n.y-i.y):Math.atan2(n.x-i.x,i.y-n.y)}},n.prototype.createHalfedge=function(e,t,r){return new this.Halfedge(e,t,r)},n.prototype.Halfedge.prototype.getStartpoint=function(){return this.edge.lSite===this.site?this.edge.va:this.edge.vb},n.prototype.Halfedge.prototype.getEndpoint=function(){return this.edge.lSite===this.site?this.edge.vb:this.edge.va},n.prototype.createVertex=function(e,t){var r=this.vertexJunkyard.pop();return r?(r.x=e,r.y=t):r=new this.Vertex(e,t),this.vertices.push(r),r},n.prototype.createEdge=function(e,t,r,n){var i=this.edgeJunkyard.pop();return i?(i.lSite=e,i.rSite=t,i.va=i.vb=null):i=new this.Edge(e,t),this.edges.push(i),r&&this.setEdgeStartpoint(i,e,t,r),n&&this.setEdgeEndpoint(i,e,t,n),this.cells[e.voronoiId].halfedges.push(this.createHalfedge(i,e,t)),this.cells[t.voronoiId].halfedges.push(this.createHalfedge(i,t,e)),i},n.prototype.createBorderEdge=function(e,t,r){var n=this.edgeJunkyard.pop();return n?(n.lSite=e,n.rSite=null):n=new this.Edge(e,null),n.va=t,n.vb=r,this.edges.push(n),n},n.prototype.setEdgeStartpoint=function(e,t,r,n){e.va||e.vb?e.lSite===r?e.vb=n:e.va=n:(e.va=n,e.lSite=t,e.rSite=r)},n.prototype.setEdgeEndpoint=function(e,t,r,n){this.setEdgeStartpoint(e,r,t,n)},n.prototype.Beachsection=function(){},n.prototype.createBeachsection=function(e){var t=this.beachsectionJunkyard.pop();return t||(t=new this.Beachsection),t.site=e,t},n.prototype.leftBreakPoint=function(e,t){var r=e.site,n=r.x,i=r.y,o=i-t;if(!o)return n;var u=e.rbPrevious;if(!u)return-1/0;var a=(r=u.site).x,s=r.y,l=s-t;if(!l)return a;var c=a-n,f=1/o-1/l,h=c/l;return f?(-h+this.sqrt(h*h-2*f*(c*c/(-2*l)-s+l/2+i-o/2)))/f+n:(n+a)/2},n.prototype.rightBreakPoint=function(e,t){var r=e.rbNext;if(r)return this.leftBreakPoint(r,t);var n=e.site;return n.y===t?n.x:1/0},n.prototype.detachBeachsection=function(e){this.detachCircleEvent(e),this.beachline.rbRemoveNode(e),this.beachsectionJunkyard.push(e)},n.prototype.removeBeachsection=function(e){var t=e.circleEvent,r=t.x,n=t.ycenter,i=this.createVertex(r,n),o=e.rbPrevious,u=e.rbNext,a=[e],s=Math.abs;this.detachBeachsection(e);for(var l=o;l.circleEvent&&s(r-l.circleEvent.x)<1e-9&&s(n-l.circleEvent.ycenter)<1e-9;)o=l.rbPrevious,a.unshift(l),this.detachBeachsection(l),l=o;a.unshift(l),this.detachCircleEvent(l);for(var c=u;c.circleEvent&&s(r-c.circleEvent.x)<1e-9&&s(n-c.circleEvent.ycenter)<1e-9;)u=c.rbNext,a.push(c),this.detachBeachsection(c),c=u;a.push(c),this.detachCircleEvent(c);var f,h=a.length;for(f=1;f<h;f++)c=a[f],l=a[f-1],this.setEdgeStartpoint(c.edge,l.site,c.site,i);l=a[0],(c=a[h-1]).edge=this.createEdge(l.site,c.site,void 0,i),this.attachCircleEvent(l),this.attachCircleEvent(c)},n.prototype.addBeachsection=function(e){for(var t,r,n,i,o=e.x,u=e.y,a=this.beachline.root;a;)if((n=this.leftBreakPoint(a,u)-o)>1e-9)a=a.rbLeft;else{if(!((i=o-this.rightBreakPoint(a,u))>1e-9)){n>-1e-9?(t=a.rbPrevious,r=a):i>-1e-9?(t=a,r=a.rbNext):t=r=a;break}if(!a.rbRight){t=a;break}a=a.rbRight}var s=this.createBeachsection(e);if(this.beachline.rbInsertSuccessor(t,s),t||r){if(t===r)return this.detachCircleEvent(t),r=this.createBeachsection(t.site),this.beachline.rbInsertSuccessor(s,r),s.edge=r.edge=this.createEdge(t.site,s.site),this.attachCircleEvent(t),void this.attachCircleEvent(r);if(!t||r){if(t!==r){this.detachCircleEvent(t),this.detachCircleEvent(r);var l=t.site,c=l.x,f=l.y,h=e.x-c,d=e.y-f,p=r.site,y=p.x-c,b=p.y-f,v=2*(h*b-d*y),g=h*h+d*d,x=y*y+b*b,w=this.createVertex((b*g-d*x)/v+c,(h*x-y*g)/v+f);return this.setEdgeStartpoint(r.edge,l,p,w),s.edge=this.createEdge(l,e,void 0,w),r.edge=this.createEdge(e,p,void 0,w),this.attachCircleEvent(t),void this.attachCircleEvent(r)}}else s.edge=this.createEdge(t.site,s.site)}},n.prototype.CircleEvent=function(){this.arc=null,this.rbLeft=null,this.rbNext=null,this.rbParent=null,this.rbPrevious=null,this.rbRed=!1,this.rbRight=null,this.site=null,this.x=this.y=this.ycenter=0},n.prototype.attachCircleEvent=function(e){var t=e.rbPrevious,r=e.rbNext;if(t&&r){var n=t.site,i=e.site,o=r.site;if(n!==o){var u=i.x,a=i.y,s=n.x-u,l=n.y-a,c=o.x-u,f=o.y-a,h=2*(s*f-l*c);if(!(h>=-2e-12)){var d=s*s+l*l,p=c*c+f*f,y=(f*d-l*p)/h,b=(s*p-c*d)/h,v=b+a,g=this.circleEventJunkyard.pop();g||(g=new this.CircleEvent),g.arc=e,g.site=i,g.x=y+u,g.y=v+this.sqrt(y*y+b*b),g.ycenter=v,e.circleEvent=g;for(var x=null,w=this.circleEvents.root;w;)if(g.y<w.y||g.y===w.y&&g.x<=w.x){if(!w.rbLeft){x=w.rbPrevious;break}w=w.rbLeft}else{if(!w.rbRight){x=w;break}w=w.rbRight}this.circleEvents.rbInsertSuccessor(x,g),x||(this.firstCircleEvent=g)}}}},n.prototype.detachCircleEvent=function(e){var t=e.circleEvent;t&&(t.rbPrevious||(this.firstCircleEvent=t.rbNext),this.circleEvents.rbRemoveNode(t),this.circleEventJunkyard.push(t),e.circleEvent=null)},n.prototype.connectEdge=function(e,t){var r=e.vb;if(r)return!0;var n,i,o=e.va,u=t.xl,a=t.xr,s=t.yt,l=t.yb,c=e.lSite,f=e.rSite,h=c.x,d=c.y,p=f.x,y=f.y,b=(h+p)/2,v=(d+y)/2;if(this.cells[c.voronoiId].closeMe=!0,this.cells[f.voronoiId].closeMe=!0,y!==d&&(i=v-(n=(h-p)/(y-d))*b),void 0===n){if(b<u||b>=a)return!1;if(h>p){if(!o||o.y<s)o=this.createVertex(b,s);else if(o.y>=l)return!1;r=this.createVertex(b,l)}else{if(!o||o.y>l)o=this.createVertex(b,l);else if(o.y<s)return!1;r=this.createVertex(b,s)}}else if(n<-1||n>1)if(h>p){if(!o||o.y<s)o=this.createVertex((s-i)/n,s);else if(o.y>=l)return!1;r=this.createVertex((l-i)/n,l)}else{if(!o||o.y>l)o=this.createVertex((l-i)/n,l);else if(o.y<s)return!1;r=this.createVertex((s-i)/n,s)}else if(d<y){if(!o||o.x<u)o=this.createVertex(u,n*u+i);else if(o.x>=a)return!1;r=this.createVertex(a,n*a+i)}else{if(!o||o.x>a)o=this.createVertex(a,n*a+i);else if(o.x<u)return!1;r=this.createVertex(u,n*u+i)}return e.va=o,e.vb=r,!0},n.prototype.clipEdge=function(e,t){var r=e.va.x,n=e.va.y,i=0,o=1,u=e.vb.x-r,a=e.vb.y-n,s=r-t.xl;if(0===u&&s<0)return!1;var l=-s/u;if(u<0){if(l<i)return!1;l<o&&(o=l)}else if(u>0){if(l>o)return!1;l>i&&(i=l)}if(s=t.xr-r,0===u&&s<0)return!1;if(l=s/u,u<0){if(l>o)return!1;l>i&&(i=l)}else if(u>0){if(l<i)return!1;l<o&&(o=l)}if(s=n-t.yt,0===a&&s<0)return!1;if(l=-s/a,a<0){if(l<i)return!1;l<o&&(o=l)}else if(a>0){if(l>o)return!1;l>i&&(i=l)}if(s=t.yb-n,0===a&&s<0)return!1;if(l=s/a,a<0){if(l>o)return!1;l>i&&(i=l)}else if(a>0){if(l<i)return!1;l<o&&(o=l)}return i>0&&(e.va=this.createVertex(r+i*u,n+i*a)),o<1&&(e.vb=this.createVertex(r+o*u,n+o*a)),(i>0||o<1)&&(this.cells[e.lSite.voronoiId].closeMe=!0,this.cells[e.rSite.voronoiId].closeMe=!0),!0},n.prototype.clipEdges=function(e){for(var t,r=this.edges,n=r.length,i=Math.abs;n--;)t=r[n],(!this.connectEdge(t,e)||!this.clipEdge(t,e)||i(t.va.x-t.vb.x)<1e-9&&i(t.va.y-t.vb.y)<1e-9)&&(t.va=t.vb=null,r.splice(n,1))},n.prototype.closeCells=function(e){for(var t,r,n,i,o,u,a,s,l,c=e.xl,f=e.xr,h=e.yt,d=e.yb,p=this.cells,y=p.length,b=Math.abs;y--;)if((t=p[y]).prepareHalfedges()&&t.closeMe){for(i=(n=t.halfedges).length,r=0;r<i;){if(u=n[r].getEndpoint(),s=n[(r+1)%i].getStartpoint(),b(u.x-s.x)>=1e-9||b(u.y-s.y)>=1e-9)switch(!0){case this.equalWithEpsilon(u.x,c)&&this.lessThanWithEpsilon(u.y,d):if(l=this.equalWithEpsilon(s.x,c),a=this.createVertex(c,l?s.y:d),o=this.createBorderEdge(t.site,u,a),r++,n.splice(r,0,this.createHalfedge(o,t.site,null)),i++,l)break;u=a;case this.equalWithEpsilon(u.y,d)&&this.lessThanWithEpsilon(u.x,f):if(l=this.equalWithEpsilon(s.y,d),a=this.createVertex(l?s.x:f,d),o=this.createBorderEdge(t.site,u,a),r++,n.splice(r,0,this.createHalfedge(o,t.site,null)),i++,l)break;u=a;case this.equalWithEpsilon(u.x,f)&&this.greaterThanWithEpsilon(u.y,h):if(l=this.equalWithEpsilon(s.x,f),a=this.createVertex(f,l?s.y:h),o=this.createBorderEdge(t.site,u,a),r++,n.splice(r,0,this.createHalfedge(o,t.site,null)),i++,l)break;u=a;case this.equalWithEpsilon(u.y,h)&&this.greaterThanWithEpsilon(u.x,c):if(l=this.equalWithEpsilon(s.y,h),a=this.createVertex(l?s.x:c,h),o=this.createBorderEdge(t.site,u,a),r++,n.splice(r,0,this.createHalfedge(o,t.site,null)),i++,l)break;if(u=a,l=this.equalWithEpsilon(s.x,c),a=this.createVertex(c,l?s.y:d),o=this.createBorderEdge(t.site,u,a),r++,n.splice(r,0,this.createHalfedge(o,t.site,null)),i++,l)break;if(u=a,l=this.equalWithEpsilon(s.y,d),a=this.createVertex(l?s.x:f,d),o=this.createBorderEdge(t.site,u,a),r++,n.splice(r,0,this.createHalfedge(o,t.site,null)),i++,l)break;if(u=a,l=this.equalWithEpsilon(s.x,f),a=this.createVertex(f,l?s.y:h),o=this.createBorderEdge(t.site,u,a),r++,n.splice(r,0,this.createHalfedge(o,t.site,null)),i++,l)break;default:throw"Voronoi.closeCells() > this makes no sense!"}r++}t.closeMe=!1}},n.prototype.quantizeSites=function(e){for(var t,r=this.ε,n=e.length;n--;)(t=e[n]).x=Math.floor(t.x/r)*r,t.y=Math.floor(t.y/r)*r},n.prototype.recycle=function(e){if(e){if(!(e instanceof this.Diagram))throw"Voronoi.recycleDiagram() > Need a Diagram object.";this.toRecycle=e}},n.prototype.compute=function(e,t){var r=new Date;this.reset(),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 n=e.slice(0);n.sort(function(e,t){var r=t.y-e.y;return r||t.x-e.x});for(var i,o,u,a=n.pop(),s=0,l=this.cells;;)if(u=this.firstCircleEvent,a&&(!u||a.y<u.y||a.y===u.y&&a.x<u.x))a.x===i&&a.y===o||(l[s]=this.createCell(a),a.voronoiId=s++,this.addBeachsection(a),o=a.y,i=a.x),a=n.pop();else{if(!u)break;this.removeBeachsection(u.arc)}this.clipEdges(t),this.closeCells(t);var c=new Date,f=new this.Diagram;return f.cells=this.cells,f.edges=this.edges,f.vertices=this.vertices,f.execTime=c.getTime()-r.getTime(),this.reset(),f},void 0!==t&&(t.exports=n)},{}],2:[function(e,t,r){},{}],3:[function(e,t,r){function n(e,t,r,n){this.width=e,this.height=t,this.minDistance=r,this.sampleFrequency=n,this.reset()}function i(e,t,r){this.width=e,this.height=t,this.minDistance=r,this.cellSize=this.minDistance/Math.SQRT2,this.pointSize=2,this.cellsWide=Math.ceil(this.width/this.cellSize),this.cellsHigh=Math.ceil(this.height/this.cellSize),this.grid=[];for(var n=0;n<this.cellsWide;n++){this.grid[n]=[];for(var i=0;i<this.cellsHigh;i++)this.grid[n][i]=null}}function o(e){this.queue=e||new Array}function u(e,t){return Math.random()*(t-e)+e}function a(e,t){return Math.floor(Math.random()*(t-e+1))+e}n.prototype.reset=function(){this.grid=new i(this.width,this.height,this.minDistance),this.outputList=new Array,this.processingQueue=new o},n.prototype.sampleUntilSolution=function(){for(;this.sample(););return this.outputList},n.prototype.sample=function(){if(0==this.outputList.length)return this.queueToAll(this.grid.randomPoint()),!0;var e=this.processingQueue.pop();if(null==e)return!1;for(var t=0;t<this.sampleFrequency;t++)samplePoint=this.grid.randomPointAround(e),this.grid.inNeighborhood(samplePoint)||this.queueToAll(samplePoint);return!0},n.prototype.queueToAll=function(e){this.grid.addPointToGrid(e,this.grid.pixelsToGridCoords(e))&&(this.processingQueue.push(e),this.outputList.push(e))},i.prototype.pixelsToGridCoords=function(e){return{x:Math.floor(e.x/this.cellSize),y:Math.floor(e.y/this.cellSize)}},i.prototype.addPointToGrid=function(e,t){return!(t.x<0||t.x>this.grid.length-1)&&(!(t.y<0||t.y>this.grid[t.x].length-1)&&(this.grid[t.x][t.y]=e,!0))},i.prototype.randomPoint=function(){return{x:u(0,this.width),y:u(0,this.height)}},i.prototype.randomPointAround=function(e){var t=Math.random(),r=Math.random(),n=this.minDistance*(t+1),i=2*Math.PI*r;return{x:e.x+n*Math.cos(i),y:e.y+n*Math.sin(i)}},i.prototype.inNeighborhood=function(e){this.pixelsToGridCoords(e);for(var t=this.cellsAroundPoint(e),r=0;r<t.length;r++)if(null!=t[r]&&this.calcDistance(t[r],e)<this.minDistance)return!0;return!1},i.prototype.cellsAroundPoint=function(e){for(var t=this.pixelsToGridCoords(e),r=new Array,n=-2;n<3;n++){var i=t.x+n;i<0&&(i=0),i>this.grid.length-1&&(i=this.grid.length-1);for(var o=-2;o<3;o++){var u=t.y+o;u<0&&(u=0),u>this.grid[i].length-1&&(u=this.grid[i].length-1),r.push(this.grid[i][u])}}return r},i.prototype.calcDistance=function(e,t){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},o.prototype.push=function(e){this.queue.push(e)},o.prototype.pop=function(){for(randomIndex=a(0,this.queue.length);void 0===this.queue[randomIndex];){for(var e=!0,t=0;t<this.queue.length;t++)void 0!==this.queue[t]&&(e=!1);if(e)return null;randomIndex=a(0,this.queue.length)}return element=this.queue[randomIndex],this.queue.remove(randomIndex),element},Array.prototype.remove=function(e,t){var r=this.slice((t||e)+1||this.length);return this.length=e<0?this.length+e:e,this.push.apply(this,r)},t.exports=n},{}],4:[function(e,t,r){var n=e("./lib/alea"),i=e("./lib/xor128"),o=e("./lib/xorwow"),u=e("./lib/xorshift7"),a=e("./lib/xor4096"),s=e("./lib/tychei"),l=e("./seedrandom");l.alea=n,l.xor128=i,l.xorwow=o,l.xorshift7=u,l.xor4096=a,l.tychei=s,t.exports=l},{"./lib/alea":5,"./lib/tychei":6,"./lib/xor128":7,"./lib/xor4096":8,"./lib/xorshift7":9,"./lib/xorwow":10,"./seedrandom":11}],5:[function(e,t,r){!function(e,t,r){function n(e){var t=this,r=u();t.next=function(){var e=2091639*t.s0+2.3283064365386963e-10*t.c;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=0|e)},t.c=1,t.s0=r(" "),t.s1=r(" "),t.s2=r(" "),t.s0-=r(e),t.s0<0&&(t.s0+=1),t.s1-=r(e),t.s1<0&&(t.s1+=1),t.s2-=r(e),t.s2<0&&(t.s2+=1),r=null}function i(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function o(e,t){var r=new n(e),o=t&&t.state,u=r.next;return u.int32=function(){return 4294967296*r.next()|0},u.double=function(){return u()+1.1102230246251565e-16*(2097152*u()|0)},u.quick=u,o&&("object"==typeof o&&i(o,r),u.state=function(){return i(r,{})}),u}function u(){var e=4022871197;return function(t){t=t.toString();for(var r=0;r<t.length;r++){var n=.02519603282416938*(e+=t.charCodeAt(r));n-=e=n>>>0,e=(n*=e)>>>0,e+=4294967296*(n-=e)}return 2.3283064365386963e-10*(e>>>0)}}t&&t.exports?t.exports=o:r&&r.amd?r(function(){return o}):this.alea=o}(0,"object"==typeof t&&t,!1)},{}],6:[function(e,t,r){!function(e,t,r){function n(e){var t=this,r="";t.next=function(){var e=t.b,r=t.c,n=t.d,i=t.a;return e=e<<25^e>>>7^r,r=r-n|0,n=n<<24^n>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^r,t.c=r=r-n|0,t.d=n<<16^r>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):r+=e;for(var n=0;n<r.length+20;n++)t.b^=0|r.charCodeAt(n),t.next()}function i(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function o(e,t){var r=new n(e),o=t&&t.state,u=function(){return(r.next()>>>0)/4294967296};return u.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},u.int32=r.next,u.quick=u,o&&("object"==typeof o&&i(o,r),u.state=function(){return i(r,{})}),u}t&&t.exports?t.exports=o:r&&r.amd?r(function(){return o}):this.tychei=o}(0,"object"==typeof t&&t,!1)},{}],7:[function(e,t,r){!function(e,t,r){function n(e){var t=this,r="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:r+=e;for(var n=0;n<r.length+64;n++)t.x^=0|r.charCodeAt(n),t.next()}function i(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function o(e,t){var r=new n(e),o=t&&t.state,u=function(){return(r.next()>>>0)/4294967296};return u.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},u.int32=r.next,u.quick=u,o&&("object"==typeof o&&i(o,r),u.state=function(){return i(r,{})}),u}t&&t.exports?t.exports=o:r&&r.amd?r(function(){return o}):this.xor128=o}(0,"object"==typeof t&&t,!1)},{}],8:[function(e,t,r){!function(e,t,r){function n(e){var t=this;t.next=function(){var e,r,n=t.w,i=t.X,o=t.i;return t.w=n=n+1640531527|0,r=i[o+34&127],e=i[o=o+1&127],r^=r<<13,e^=e<<17,r^=r>>>15,e^=e>>>12,r=i[o]=r^e,t.i=o,r+(n^n>>>16)|0},function(e,t){var r,n,i,o,u,a=[],s=128;for(t===(0|t)?(n=t,t=null):(t+="\0",n=0,s=Math.max(s,t.length)),i=0,o=-32;o<s;++o)t&&(n^=t.charCodeAt((o+32)%t.length)),0===o&&(u=n),n^=n<<10,n^=n>>>15,n^=n<<4,n^=n>>>13,o>=0&&(u=u+1640531527|0,i=0==(r=a[127&o]^=n+u)?i+1:0);for(i>=128&&(a[127&(t&&t.length||0)]=-1),i=127,o=512;o>0;--o)n=a[i+34&127],r=a[i=i+1&127],n^=n<<13,r^=r<<17,n^=n>>>15,r^=r>>>12,a[i]=n^r;e.w=u,e.X=a,e.i=i}(t,e)}function i(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function o(e,t){null==e&&(e=+new Date);var r=new n(e),o=t&&t.state,u=function(){return(r.next()>>>0)/4294967296};return u.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},u.int32=r.next,u.quick=u,o&&(o.X&&i(o,r),u.state=function(){return i(r,{})}),u}t&&t.exports?t.exports=o:r&&r.amd?r(function(){return o}):this.xor4096=o}(0,"object"==typeof t&&t,!1)},{}],9:[function(e,t,r){!function(e,t,r){function n(e){var t=this;t.next=function(){var e,r,n=t.x,i=t.i;return e=n[i],e^=e>>>7,r=e^e<<24,e=n[i+1&7],r^=e^e>>>10,e=n[i+3&7],r^=e^e>>>3,e=n[i+4&7],r^=e^e<<7,e=n[i+7&7],e^=e<<13,r^=e^e<<9,n[i]=r,t.i=i+1&7,r},function(e,t){var r,n=[];if(t===(0|t))n[0]=t;else for(t=""+t,r=0;r<t.length;++r)n[7&r]=n[7&r]<<15^t.charCodeAt(r)+n[r+1&7]<<13;for(;n.length<8;)n.push(0);for(r=0;r<8&&0===n[r];++r);for(8==r?n[7]=-1:n[r],e.x=n,e.i=0,r=256;r>0;--r)e.next()}(t,e)}function i(e,t){return t.x=e.x.slice(),t.i=e.i,t}function o(e,t){null==e&&(e=+new Date);var r=new n(e),o=t&&t.state,u=function(){return(r.next()>>>0)/4294967296};return u.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},u.int32=r.next,u.quick=u,o&&(o.x&&i(o,r),u.state=function(){return i(r,{})}),u}t&&t.exports?t.exports=o:r&&r.amd?r(function(){return o}):this.xorshift7=o}(0,"object"==typeof t&&t,!1)},{}],10:[function(e,t,r){!function(e,t,r){function n(e){var t=this,r="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:r+=e;for(var n=0;n<r.length+64;n++)t.x^=0|r.charCodeAt(n),n==r.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function i(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function o(e,t){var r=new n(e),o=t&&t.state,u=function(){return(r.next()>>>0)/4294967296};return u.double=function(){do{var e=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},u.int32=r.next,u.quick=u,o&&("object"==typeof o&&i(o,r),u.state=function(){return i(r,{})}),u}t&&t.exports?t.exports=o:r&&r.amd?r(function(){return o}):this.xorwow=o}(0,"object"==typeof t&&t,!1)},{}],11:[function(e,t,r){!function(r,n){function i(e,t,i){var f=[],h=s(a((t=1==t?{entropy:!0}:t||{}).entropy?[e,c(r)]:null==e?l():e,3),f),x=new o(f),w=function(){for(var e=x.g(p),t=b,r=0;e<v;)e=(e+r)*d,t*=d,r=x.g(1);for(;e>=g;)e/=2,t/=2,r>>>=1;return(e+r)/t};return w.int32=function(){return 0|x.g(4)},w.quick=function(){return x.g(4)/4294967296},w.double=w,s(c(x.S),r),(t.pass||i||function(e,t,r,i){return i&&(i.S&&u(i,x),e.state=function(){return u(x,{})}),r?(n[y]=e,t):e})(w,h,"global"in t?t.global:this==n,t.state)}function o(e){var t,r=e.length,n=this,i=0,o=n.i=n.j=0,u=n.S=[];for(r||(e=[r++]);i<d;)u[i]=i++;for(i=0;i<d;i++)u[i]=u[o=x&o+e[i%r]+(t=u[i])],u[o]=t;(n.g=function(e){for(var t,r=0,i=n.i,o=n.j,u=n.S;e--;)t=u[i=x&i+1],r=r*d+u[x&(u[i]=u[o=x&o+t])+(u[o]=t)];return n.i=i,n.j=o,r})(d)}function u(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function a(e,t){var r,n=[],i=typeof e;if(t&&"object"==i)for(r in e)try{n.push(a(e[r],t-1))}catch(e){}return n.length?n:"string"==i?e:e+"\0"}function s(e,t){for(var r,n=e+"",i=0;i<n.length;)t[x&i]=x&(r^=19*t[x&i])+n.charCodeAt(i++);return c(t)}function l(){try{var e;return f&&(e=f.randomBytes)?e=e(d):(e=new Uint8Array(d),(h.crypto||h.msCrypto).getRandomValues(e)),c(e)}catch(e){var t=h.navigator,n=t&&t.plugins;return[+new Date,h,n,h.screen,c(r)]}}function c(e){return String.fromCharCode.apply(0,e)}var f,h=this,d=256,p=6,y="random",b=n.pow(d,p),v=n.pow(2,52),g=2*v,x=d-1;if(n["seed"+y]=i,s(n.random(),r),"object"==typeof t&&t.exports){t.exports=i;try{f=e("crypto")}catch(e){}}}([],Math)},{crypto:2}],12:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0}),r.random=function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=r?new a.default(r):a.default,i=e.area/(t*t),o=[],u=0;u<i;u++)o.push(n.vector(e));return o},r.square=function(e,t){for(var r=t/2,n=r,i=[],u=0;u<e.height;u+=t)for(var a=0;a<e.width;a+=t)i.push(new o.default(r+a,n+u));return i},r.hexagon=function(e,t){!(arguments.length>2&&void 0!==arguments[2])||arguments[2],arguments[3],arguments[4];for(var r=[],n=(Math.sqrt(3),Math.sqrt(e.area/(t*t))),i=0;i<n;i++)for(var u=0;u<n;u++)r.push(new o.default((.5+u)/n*e.width,(.25+.5*u%2+i)/n*e.height));return r},r.jitteredGrid=function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=r?new a.default(r):a.default,s=[],l=void 0,c=0;c<e.height-t;c+=t)for(var f=0;f<e.width-t;f+=t){var h=new o.default(f-t+n,c-t+n);l=new u.default(h,f-n,c-n),s.push(i.vector(l))}return s},r.poisson=function(e,t){return new i.default(e.width,e.height,t,t).sampleUntilSolution().map(function(e){return new o.default(e)})},r.recursiveWang=function(e,t){throw"Error: Not Implemented"},r.circular=function(e,t){throw"Error: Not Implemented"};var i=n(e("poisson-disk-sample")),o=n(e("../geometry/Vector")),u=n(e("../geometry/Rectangle")),a=n(e("./Rand"))},{"../geometry/Rectangle":16,"../geometry/Vector":19,"./Rand":13,"poisson-disk-sample":3}],13:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),u=n(e("seedRandom")),a=n(e("../geometry/Vector")),s=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;i(this,e),this.rng=(0,u.default)(t)}return o(e,[{key:"setSeed",value:function(e){var t={entropy:void 0===e};this.rng=(0,u.default)(e,t)}},{key:"rand",value:function(){return this.rng()}},{key:"randRange",value:function(t,r){return e._randRange(this,t,r)}},{key:"randInt",value:function(t,r){return e._randInt(this,t,r)}},{key:"randHex",value:function(){return e._randHex(this)}},{key:"randHexColor",value:function(){return e._randHexColor(this)}},{key:"vector",value:function(t){return e._vector(this,t)}}],[{key:"setSeed",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t={global:!0,entropy:void 0===e};(0,u.default)(e,t)}},{key:"rand",value:function(){return Math.random()}},{key:"_randRange",value:function(e,t,r){return e.rand()*(r-t)+t}},{key:"randRange",value:function(t,r){return e._randRange(e,t,r)}},{key:"_randInt",value:function(e,t,r){return Math.floor(e.rand()*(r-t+1))+t}},{key:"randInt",value:function(t,r){return e._randInt(e,t,r)}},{key:"_randHex",value:function(e){return e.randInt(0,16777215)}},{key:"randHex",value:function(){return e._randHex(e)}},{key:"_randHexColor",value:function(e){return"#"+e.randHex().toString(16)}},{key:"randHexColor",value:function(){return e._randHexColor(e)}},{key:"_vector",value:function(t,r){return new a.default(e.randRange(r.x,r.x+r.width),e.randRange(r.y,r.y+r.height))}},{key:"vector",value:function(t){return e._vector(e,t)}}]),e}();r.default=s,t.exports=r.default},{"../geometry/Vector":19,seedRandom:4}],14:[function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(r,"__esModule",{value:!0});var u=function(e){return e&&e.__esModule?e:{default:e}}(e("./Shape")),a=function(e){function t(e,r){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,[e,r]))}return o(t,u.default),t}();r.default=a,t.exports=r.default},{"./Shape":17}],15:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){function t(){var t=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}Object.defineProperty(r,"__esModule",{value:!0});var l=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),c=n(e("./Vector")),f=(n(e("./Shape")),function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(o(this,t),e)var n,a=u(this,(n=t.__proto__||Object.getPrototypeOf(t)).call.apply(n,[this].concat(i(e))));else a=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return a.center=r||a.centroid(),u(a)}return a(t,s(Array)),l(t,[{key:"centroid",value:function(){return c.default.avg(this)}},{key:"inset",value:function(e){return e}},{key:"isConvex",value:function(){}},{key:"rotate",value:function(){}}]),t}());r.default=f,t.exports=r.default},{"./Shape":17,"./Vector":19}],16:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(r,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),s=n(e("./Vector")),l=n(e("./Polygon")),c=function(e){function t(e,r,n){i(this,t);var u=[e,s.default.add(e,new s.default(r,0)),s.default.add(e,new s.default(r,n)),s.default.add(e,new s.default(0,n))],a=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,u));return a.position=e,a.x=e.x,a.y=e.y,a.width=r,a.height=n,a.area=r*n,a}return u(t,l.default),a(t,[{key:"contains",value:function(e){return e.x>this.position.x&&e.x<this.position.x+this.width&&e.y>this.position.y&&e.y<this.positoin.y+this.height}}]),t}();r.default=c,t.exports=r.default},{"./Polygon":15,"./Vector":19}],17:[function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e){function t(){var t=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}Object.defineProperty(r,"__esModule",{value:!0});!function(e){e&&e.__esModule}(e("./Vector"));var s=function(e){function t(e){if(i(this,t),e)var r,u=o(this,(r=t.__proto__||Object.getPrototypeOf(t)).call.apply(r,[this].concat(n(e))));else u=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return o(u)}return u(t,a(Array)),t}();r.default=s,t.exports=r.default},{"./Vector":19}],18:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(r,"__esModule",{value:!0});n(e("./Vector"));var a=n(e("./Polygon")),s=function(e){function t(e,r,n){i(this,t);var u=[e,r,n],a=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,u));return a.v1=e,a.v2=r,a.v3=n,a}return u(t,a.default),t}();r.default=s,t.exports=r.default},{"./Polygon":15,"./Vector":19}],19:[function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=function(){function e(t,r){n(this,e),t instanceof e||t.x&&t.y&&!r?this._set(t.x,t.y):this._set(t,r)}return i(e,[{key:"_set",value:function(e,t){this.__proto__[0]=e,this.__proto__[1]=t,this.x=e,this.y=t}},{key:"key",value:function(){return this.list()}},{key:"list",value:function(){return[this.x,this.y]}},{key:"toString",value:function(){return"("+this.x+", "+this.y+")"}},{key:"toString",value:function(){return"("+this.x+", "+this.y+")"}},{key:"add",value:function(t){return e.add(this,t)}},{key:"subtract",value:function(t){return e.subtract(this,t)}},{key:"multiply",value:function(t){return new e(this.x*t,this.y*t)}},{key:"divide",value:function(t){return new e(this.x/t,this.y/t)}},{key:"magnitude",value:function(){return Math.sqrt(this.x*this.x+this.y*this.y)}},{key:"normalize",value:function(){return e.divide(this.magnitude())}},{key:"rotate",value:function(t){var r=Math.cos(t),n=Math.sin(t);return new e(r*this.x-n*this.y,n*this.x+r*this.y)}},{key:"dot",value:function(t){return e.dot(this,t)}},{key:"cross",value:function(t){return e.cross(this,t)}},{key:"perpendiculars",value:function(){return[new e(-this.y,this.x).normalize(),new e(this.y,-this.x).normalize()]}}],[{key:"copy",value:function(t){return new e(t.x,t.y)}},{key:"add",value:function(t,r){return new e(t.x+r.x,t.y+r.y)}},{key:"subtract",value:function(t,r){return new e(t.x-r.x,t.y-r.y)}},{key:"dot",value:function(e,t){return e.x*t.x+e.y*t.y}},{key:"avg",value:function(t){var r=e.zero(),n=!0,i=!1,o=void 0;try{for(var u,a=t[Symbol.iterator]();!(n=(u=a.next()).done);n=!0){var s=u.value;r=e.add(r,s)}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return r.divide(t.length)}},{key:"cross",value:function(e,t){return e.x*t.y-e.y*t.x}},{key:"midpoint",value:function(t,r){return new e((t.x+r.x)/2,(t.y+r.y)/2)}},{key:"proj",value:function(t,r){return r.multiply(e.dot(t,r)/Math.pow(r.magnitude(),2))}},{key:"angle",value:function(t,r){return Math.acos(e.dot(t,r)/(t.magnitude()*r.magnitude()))}},{key:"distance",value:function(t,r){return Math.sqrt(e.dist2(t,r))}},{key:"dist2",value:function(e,t){var r=e.x-t.x,n=e.y-t.y;return r*r+n*n}},{key:"distToSeg",value:function(t,r,n){return Math.sqrt(e.distToSeg2(t,r,n))}},{key:"distToSegSquared",value:function(t,r,n){var i=e.dist2(r,n);if(0===i)return e.dist2(t,r);var o=((t.x-r.x)*(n.x-r.x)+(t.y-r.y)*(n.y-r.y))/i;return o=Math.max(0,Math.min(1,o)),e.dist2(t,new e(r.x+o*(n.x-r.x),r.y+o*(n.y-r.y)))}},{key:"zero",value:function(){return new e(0,0)}},{key:"up",value:function(){return new e(0,1)}},{key:"down",value:function(){return new e(0,-1)}},{key:"left",value:function(){return new e(-1,0)}},{key:"right",value:function(){return new e(1,0)}}]),e}();r.default=o,t.exports=r.default},{}],20:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(r,"__esModule",{value:!0});var a=n(e("../geometry/Vector")),s=n(e("../geometry/Polygon")),l=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;i(this,t);var u=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return u.id=-1,u.neighbors=new s.default,u.borders=[],u.corners=new s.default,u.border=!1,u.data={},u.parent=r,u.children=n||[],u}return u(t,a.default),t}();r.default=l,t.exports=r.default},{"../geometry/Polygon":15,"../geometry/Vector":19}],21:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(r,"__esModule",{value:!0});var a=n(e("../geometry/Vector")),s=n(e("../geometry/Polygon")),l=function(e){function t(e){i(this,t);var r=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.id=-1,r.touches=new s.default,r.protrudes=[],r.adjacent=new s.default,r}return u(t,a.default),t}();r.default=l,t.exports=r.default},{"../geometry/Polygon":15,"../geometry/Vector":19}],22:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),u=n(e("../geometry/Vector")),a=n(e("./Center")),s=n(e("./Corner")),l=n(e("./Edge")),c=e("../utilities/Util"),f=n(e("Voronoi")),h=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i(this,e),this.bbox=r,this._rhillbbox={xl:this.bbox.x,xr:this.bbox.x+this.bbox.width,yt:this.bbox.y,yb:this.bbox.y+this.bbox.height};var u=new f.default;for(this._voronoi=u.compute(t,this._rhillbbox);n--;){var a=this.relaxSites(this._voronoi);u.recycle(this._voronoi),this._voronoi=u.compute(a,this._rhillbbox)}this.convertDiagram(this._voronoi),o&&this.improveCorners(),this.sortCorners()}return o(e,[{key:"relaxSites",value:function(e){for(var t=e.cells,r=t.length,n=void 0,i=void 0,o=[];r--;)n=t[r],i=this.cellCentroid(n),o.push(new u.default(i.x,i.y));return o}},{key:"cellArea",value:function(e){for(var t=0,r=e.halfedges,n=r.length,i=void 0,o=void 0,u=void 0;n--;)o=(i=r[n]).getStartpoint(),u=i.getEndpoint(),t+=o.x*u.y,t-=o.y*u.x;return t/=2}},{key:"cellCentroid",value:function(e){for(var t=0,r=0,n=e.halfedges,i=n.length,o=void 0,u=void 0,a=void 0,s=void 0;i--;)a=(o=n[i]).getStartpoint(),s=o.getEndpoint(),u=a.x*s.y-s.x*a.y,t+=(a.x+s.x)*u,r+=(a.y+s.y)*u;return u=6*this.cellArea(e),{x:t/u,y:r/u}}},{key:"convertDiagram",value:function(e){var t={},r={};this.centers=[],this.corners=[],this.edges=[];var n=0,i=0,o=!0,f=!1,h=void 0;try{for(var d,p=e.cells[Symbol.iterator]();!(o=(d=p.next()).done);o=!0){var y=d.value.site,b=new u.default(y.x,y.y),v=new a.default(b);v.id=y.voronoiId,t[b.key()]=v,this.centers.push(v)}}catch(e){f=!0,h=e}finally{try{!o&&p.return&&p.return()}finally{if(f)throw h}}var g=!0,x=!1,w=void 0;try{for(var _,m=e.edges[Symbol.iterator]();!(g=(_=m.next()).done);g=!0){var R=_.value,P=new u.default(Math.round(R.va.x),Math.round(R.va.y)),E=new u.default(Math.round(R.vb.x),Math.round(R.vb.y)),k=new u.default(R.lSite.x,R.lSite.y),O=R.rSite?new u.default(R.rSite.x,R.rSite.y):null,j=t[k.key()],M=O?t[O.key()]:null,S=void 0,C=void 0,L=function(e,t){return e.x<=t.xl||e.x>=t.xr||e.y<=t.yt||e.y>=t.yb};(0,c.has)(r,P.key())?S=r[P.key()]:((S=new s.default(P)).id=n++,S.border=L(P,this.bbox),r[P.key()]=S,this.corners.push(S)),(0,c.has)(r,E.key())?C=r[E.key()]:((C=new s.default(E)).id=n++,C.border=L(E,this.bbox),r[E.key()]=C,this.corners.push(C));var T=new l.default;T.id=i++,T.d0=j,T.d1=M,T.v0=S,T.v1=C,T.midpoint=u.default.midpoint(S,C),S.protrudes.push(T),C.protrudes.push(T),S.touches.includes(j)||S.touches.push(j),M&&!S.touches.includes(M)&&S.touches.push(M),C.touches.includes(j)||C.touches.push(j),M&&!C.touches.includes(M)&&C.touches.push(M),S.adjacent.push(C),C.adjacent.push(S),j.borders.push(T),M&&M.borders.push(T),j.corners.includes(S)||j.corners.push(S),j.corners.includes(C)||j.corners.push(C),M&&!M.corners.includes(S)&&M.corners.push(S),M&&!M.corners.includes(C)&&M.corners.push(C),M&&(j.neighbors.push(M),M.neighbors.push(j)),j.border=j.border||S.border||C.border,M&&(M.border=M.border||S.border||C.border),this.edges.push(T)}}catch(e){x=!0,w=e}finally{try{!g&&m.return&&m.return()}finally{if(x)throw w}}}},{key:"improveCorners",value:function(){for(var e=[],t=0;t<this.corners.length;t++){var r=this.corners[t];if(r.border)e[t]=r;else{var n=u.default.zero(),i=!0,o=!1,a=void 0;try{for(var s,l=r.touches[Symbol.iterator]();!(i=(s=l.next()).done);i=!0){var c=s.value;n=u.default.add(n,c)}}catch(e){o=!0,a=e}finally{try{!i&&l.return&&l.return()}finally{if(o)throw a}}n=n.divide(r.touches.length),e[t]=n}}for(var f=0;f<this.corners.length;f++){this.corners[f];e[f]}var h=!0,d=!1,p=void 0;try{for(var y,b=this.edges[Symbol.iterator]();!(h=(y=b.next()).done);h=!0){var v=y.value;v.v0&&v.v1&&(v.midpoint=u.default.midpoint(v.v0,v.v1))}}catch(e){d=!0,p=e}finally{try{!h&&b.return&&b.return()}finally{if(d)throw p}}}},{key:"sortCorners",value:function(){var e=!0,t=!1,r=void 0;try{for(var n,i=this.centers[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){var o=n.value,u=this.comparePolyPoints(o);o.corners.sort(u)}}catch(e){t=!0,r=e}finally{try{!e&&i.return&&i.return()}finally{if(t)throw r}}}},{key:"comparePolyPoints",value:function(e){var t=e;return function(e,r){var n=e,i=r;if(n.x-t.x>=0&&i.x-t.x<0)return-1;if(n.x-t.x<0&&i.x-t.x>=0)return 1;if(n.x-t.x==0&&i.x-t.x==0)return n.y-t.y>=0||i.y-t.y>=0?n.y>i.y?-1:1:i.y>n.y?-1:1;var o=(n.x-t.x)*(i.y-t.y)-(i.x-t.x)*(n.y-t.y);return o<0?-1:o>0?1:(n.x-t.x)*(n.x-t.x)+(n.y-t.y)*(n.y-t.y)>(i.x-t.x)*(i.x-t.x)+(i.y-t.y)*(i.y-t.y)?-1:1}}}]),e}();r.default=h,t.exports=r.default},{"../geometry/Vector":19,"../utilities/Util":28,"./Center":20,"./Corner":21,"./Edge":23,Voronoi:1}],23:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(r,"__esModule",{value:!0});n(e("../geometry/Vector"));var a=n(e("../geometry/Line")),s=function(e){function t(e,r){i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r));return n.id=-1,n.d0=null,n.d1=null,n.v0=null,n.v1=null,n.midpoint=null,n.border=!1,n}return u(t,a.default),t}();r.default=s,t.exports=r.default},{"../geometry/Line":14,"../geometry/Vector":19}],24:[function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(r,"__esModule",{value:!0});var u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),a=function(e){return e&&e.__esModule?e:{default:e}}(e("./Diagram")),s=function(e){function t(e,r){arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3&&void 0!==arguments[3]&&arguments[3];return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r,0,!1))}return o(t,a.default),u(t,[{key:"generate",value:function(e){var t=!0,r=!1,n=void 0;try{for(var i,o=this.centers[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var u=i.value;u._data=e(u)}}catch(e){r=!0,n=e}finally{try{!t&&o.return&&o.return()}finally{if(r)throw n}}var a=!0,s=!1,l=void 0;try{for(var c,f=this.centers[Symbol.iterator]();!(a=(c=f.next()).done);a=!0){var h=c.value;for(var d in h._data)h._data.hasOwnProperty(d)&&(h.data[d]=h._data[d]);delete h._data}}catch(e){s=!0,l=e}finally{try{!a&&f.return&&f.re