/*! * MarchingSquaresJS * version 1.3.3 * https://github.com/RaumZeit/MarchingSquares.js * * @license GNU Affero General Public License. * Copyright (c) 2015-2019 Ronny Lorenz */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.MarchingSquaresJS=e.MarchingSquaresJS||{})}(this,function(e){"use strict";function l(e,t,n){return e>=1,i++;o===1<>=1,s++;r===1<=t||e[l][o-1]>=t){n=!1;break}if(n&&(e[r-1][0]>=t||e[r-1][o-1]>=t)&&(n=!1),n)for(a=0;a=t||e[r-1][a]>t){n=!1;break}return n}(n,r.threshold)&&(r.linearRing?V.push([[0,0],[0,x],[v,x],[v,0],[0,0]]):V.push([[0,0],[0,x],[v,x],[v,0]])),o.forEach(function(e,n){e.forEach(function(e,t){for(a=null,l=0;l<4;l++)if(a=k[l],"object"==typeof e.edges[a]){for(p=[],i=e.edges[a],g=a,m=t,u=!1,b=[(h=n)+i.path[0][0],t+i.path[0][1]],p.push(b);!u&&"object"==typeof(s=o[h][m]).edges[g];)if(i=s.edges[g],delete s.edges[g],(c=i.path[1])[0]+=h,c[1]+=m,p.push(c),g=i.move.enter,h+=i.move.x,m+=i.move.y,void 0===o[h]||void 0===o[h][m]){if(!r.linearRing)break;if(_=y=0,h===v?(h--,y=0):h<0?(h++,y=2):m===x?(m--,y=3):m<0&&(m++,y=1),h===n&&m===t&&y===E[a]){u=!0,g=a;break}for(;;){if(d=!1,4<_)throw new Error("Direction change counter overflow! This should never happen!");if(void 0!==o[h]&&void 0!==o[h][m]&&(s=o[h][m],f=k[y],"object"==typeof s.edges[f])){i=s.edges[f],p.push(W(h,m,y,i.path)),g=f,d=!0;break}if(d)break;if(p.push(O(h,m,y)),m+=B[y],void 0!==o[h+=w[y]]&&void 0!==o[h][m]||(0===y&&m<0||1===y&&h<0||2===y&&m===x||3===y&&h===v)&&(h-=w[y],m-=B[y],y=(y+1)%4,_++),h===n&&m===t&&y===E[a]){u=!0,g=a;break}}}!r.linearRing||p[p.length-1][0]===b[0]&&p[p.length-1][1]===b[1]||p.push(b),V.push(p)}})}),C=V}var n,o,r,a,l,i,s,p,g,h,m,u,b,c,y,_,d,f,V,x,v,k,w,B,E;S?D.push(C):D=C,"function"==typeof A.successCallback&&A.successCallback(D,e)}),D}function J(e,t,n,o){var r,a,l,i,s,p,g=0,h=e[n+1][t],m=e[n+1][t+1],u=e[n][t+1],b=e[n][t],c=o.threshold;if(!(isNaN(b)||isNaN(u)||isNaN(m)||isNaN(h))){switch(g|=c<=h?8:0,g|=c<=m?4:0,g|=c<=u?2:0,p={cval:g=+(g|=c<=b?1:0),polygons:[],edges:{},x0:b,x1:u,x2:m,x3:h},g){case 0:o.polygons&&p.polygons.push([[0,0],[0,1],[1,1],[1,0]]);break;case 15:break;case 14:r=o.interpolate(b,h,c),i=o.interpolate(b,u,c),o.polygons_full&&(p.edges.left={path:[[0,r],[i,0]],move:{x:0,y:-1,enter:"top"}}),o.polygons&&p.polygons.push([[0,0],[0,r],[i,0]]);break;case 13:i=o.interpolate(b,u,c),a=o.interpolate(u,m,c),o.polygons_full&&(p.edges.bottom={path:[[i,0],[1,a]],move:{x:1,y:0,enter:"left"}}),o.polygons&&p.polygons.push([[i,0],[1,a],[1,0]]);break;case 11:a=o.interpolate(u,m,c),l=o.interpolate(h,m,c),o.polygons_full&&(p.edges.right={path:[[1,a],[l,1]],move:{x:0,y:1,enter:"bottom"}}),o.polygons&&p.polygons.push([[1,a],[l,1],[1,1]]);break;case 7:r=o.interpolate(b,h,c),l=o.interpolate(h,m,c),o.polygons_full&&(p.edges.top={path:[[l,1],[0,r]],move:{x:-1,y:0,enter:"right"}}),o.polygons&&p.polygons.push([[l,1],[0,r],[0,1]]);break;case 1:r=o.interpolate(b,h,c),i=o.interpolate(b,u,c),o.polygons_full&&(p.edges.bottom={path:[[i,0],[0,r]],move:{x:-1,y:0,enter:"right"}}),o.polygons&&p.polygons.push([[i,0],[0,r],[0,1],[1,1],[1,0]]);break;case 2:i=o.interpolate(b,u,c),a=o.interpolate(u,m,c),o.polygons_full&&(p.edges.right={path:[[1,a],[i,0]],move:{x:0,y:-1,enter:"top"}}),o.polygons&&p.polygons.push([[0,0],[0,1],[1,1],[1,a],[i,0]]);break;case 4:a=o.interpolate(u,m,c),l=o.interpolate(h,m,c),o.polygons_full&&(p.edges.top={path:[[l,1],[1,a]],move:{x:1,y:0,enter:"left"}}),o.polygons&&p.polygons.push([[0,0],[0,1],[l,1],[1,a],[1,0]]);break;case 8:r=o.interpolate(b,h,c),l=o.interpolate(h,m,c),o.polygons_full&&(p.edges.left={path:[[0,r],[l,1]],move:{x:0,y:1,enter:"bottom"}}),o.polygons&&p.polygons.push([[0,0],[0,r],[l,1],[1,1],[1,0]]);break;case 12:r=o.interpolate(b,h,c),a=o.interpolate(u,m,c),o.polygons_full&&(p.edges.left={path:[[0,r],[1,a]],move:{x:1,y:0,enter:"left"}}),o.polygons&&p.polygons.push([[0,0],[0,r],[1,a],[1,0]]);break;case 9:i=o.interpolate(b,u,c),l=o.interpolate(h,m,c),o.polygons_full&&(p.edges.bottom={path:[[i,0],[l,1]],move:{x:0,y:1,enter:"bottom"}}),o.polygons&&p.polygons.push([[i,0],[l,1],[1,1],[1,0]]);break;case 3:r=o.interpolate(b,h,c),a=o.interpolate(u,m,c),o.polygons_full&&(p.edges.right={path:[[1,a],[0,r]],move:{x:-1,y:0,enter:"right"}}),o.polygons&&p.polygons.push([[0,r],[0,1],[1,1],[1,a]]);break;case 6:i=o.interpolate(b,u,c),l=o.interpolate(h,m,c),o.polygons_full&&(p.edges.top={path:[[l,1],[i,0]],move:{x:0,y:-1,enter:"top"}}),o.polygons&&p.polygons.push([[0,0],[0,1],[l,1],[i,0]]);break;case 10:r=o.interpolate(b,h,c),a=o.interpolate(u,m,c),i=o.interpolate(b,u,c),l=o.interpolate(h,m,c),s=(b+u+m+h)/4,o.polygons_full&&(st||this.upperBound=t)&&o.push({x:this.x,y:this.y})),o},h.prototype.cellsBelowThreshold=function(e,t){var n=[];return t=void 0===t||t,this.lowerBound>e||(this.childA||this.childB||this.childC||this.childD?(this.childA&&(n=n.concat(this.childA.cellsBelowThreshold(e,t))),this.childB&&(n=n.concat(this.childB.cellsBelowThreshold(e,t))),this.childD&&(n=n.concat(this.childD.cellsBelowThreshold(e,t))),this.childC&&(n=n.concat(this.childC.cellsBelowThreshold(e,t)))):(t||this.upperBound>=e)&&n.push({x:this.x,y:this.y})),n};var u={square:function(e,t,n,o,r,a){a.polygons&&e.polygons.push([[0,0],[0,1],[1,1],[1,0]])},triangle_bl:function(e,t,n,o,r,a){var l=a.interpolate(t,n,a.minV,a.maxV),i=a.interpolate(t,r,a.minV,a.maxV);a.polygons_full&&(e.edges.lb={path:[[0,i],[l,0]],move:{x:0,y:-1,enter:"tl"}}),a.polygons&&e.polygons.push([[0,i],[l,0],[0,0]])},triangle_br:function(e,t,n,o,r,a){var l=a.interpolate(t,n,a.minV,a.maxV),i=a.interpolate(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.br={path:[[l,0],[1,i]],move:{x:1,y:0,enter:"lb"}}),a.polygons&&e.polygons.push([[l,0],[1,i],[1,0]])},triangle_tr:function(e,t,n,o,r,a){var l=a.interpolate(n,o,a.minV,a.maxV),i=a.interpolate(r,o,a.minV,a.maxV);a.polygons_full&&(e.edges.rt={path:[[1,l],[i,1]],move:{x:0,y:1,enter:"br"}}),a.polygons&&e.polygons.push([[1,l],[i,1],[1,1]])},triangle_tl:function(e,t,n,o,r,a){var l=a.interpolate(r,o,a.minV,a.maxV),i=a.interpolate(t,r,a.minV,a.maxV);a.polygons_full&&(e.edges.tl={path:[[l,1],[0,i]],move:{x:-1,y:0,enter:"rt"}}),a.polygons&&e.polygons.push([[0,i],[0,1],[l,1]])},tetragon_t:function(e,t,n,o,r,a){var l=a.interpolate(n,o,a.minV,a.maxV),i=a.interpolate(t,r,a.minV,a.maxV);a.polygons_full&&(e.edges.rt={path:[[1,l],[0,i]],move:{x:-1,y:0,enter:"rt"}}),a.polygons&&e.polygons.push([[0,i],[0,1],[1,1],[1,l]])},tetragon_r:function(e,t,n,o,r,a){var l=a.interpolate(t,n,a.minV,a.maxV),i=a.interpolate(r,o,a.minV,a.maxV);a.polygons_full&&(e.edges.br={path:[[l,0],[i,1]],move:{x:0,y:1,enter:"br"}}),a.polygons&&e.polygons.push([[l,0],[i,1],[1,1],[1,0]])},tetragon_b:function(e,t,n,o,r,a){var l=a.interpolate(t,r,a.minV,a.maxV),i=a.interpolate(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.lb={path:[[0,l],[1,i]],move:{x:1,y:0,enter:"lb"}}),a.polygons&&e.polygons.push([[0,0],[0,l],[1,i],[1,0]])},tetragon_l:function(e,t,n,o,r,a){var l=a.interpolate(r,o,a.minV,a.maxV),i=a.interpolate(t,n,a.minV,a.maxV);a.polygons_full&&(e.edges.tl={path:[[l,1],[i,0]],move:{x:0,y:-1,enter:"tl"}}),a.polygons&&e.polygons.push([[0,0],[0,1],[l,1],[i,0]])},tetragon_bl:function(e,t,n,o,r,a){var l=a.interpolate_a(t,n,a.minV,a.maxV),i=a.interpolate_b(t,n,a.minV,a.maxV),s=a.interpolate_a(t,r,a.minV,a.maxV),p=a.interpolate_b(t,r,a.minV,a.maxV);a.polygons_full&&(e.edges.bl={path:[[l,0],[0,s]],move:{x:-1,y:0,enter:"rb"}},e.edges.lt={path:[[0,p],[i,0]],move:{x:0,y:-1,enter:"tr"}}),a.polygons&&e.polygons.push([[l,0],[0,s],[0,p],[i,0]])},tetragon_br:function(e,t,n,o,r,a){var l=a.interpolate_a(t,n,a.minV,a.maxV),i=a.interpolate_b(t,n,a.minV,a.maxV),s=a.interpolate_a(n,o,a.minV,a.maxV),p=a.interpolate_b(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.bl={path:[[l,0],[1,p]],move:{x:1,y:0,enter:"lt"}},e.edges.rb={path:[[1,s],[i,0]],move:{x:0,y:-1,enter:"tr"}}),a.polygons&&e.polygons.push([[l,0],[1,p],[1,s],[i,0]])},tetragon_tr:function(e,t,n,o,r,a){var l=a.interpolate_a(r,o,a.minV,a.maxV),i=a.interpolate_b(r,o,a.minV,a.maxV),s=a.interpolate_b(n,o,a.minV,a.maxV),p=a.interpolate_a(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.rb={path:[[1,p],[l,1]],move:{x:0,y:1,enter:"bl"}},e.edges.tr={path:[[i,1],[1,s]],move:{x:1,y:0,enter:"lt"}}),a.polygons&&e.polygons.push([[1,p],[l,1],[i,1],[1,s]])},tetragon_tl:function(e,t,n,o,r,a){var l=a.interpolate_a(r,o,a.minV,a.maxV),i=a.interpolate_b(r,o,a.minV,a.maxV),s=a.interpolate_b(t,r,a.minV,a.maxV),p=a.interpolate_a(t,r,a.minV,a.maxV);a.polygons_full&&(e.edges.tr={path:[[i,1],[0,p]],move:{x:-1,y:0,enter:"rb"}},e.edges.lt={path:[[0,s],[l,1]],move:{x:0,y:1,enter:"bl"}}),a.polygons&&e.polygons.push([[i,1],[0,p],[0,s],[l,1]])},tetragon_lr:function(e,t,n,o,r,a){var l=a.interpolate_a(t,r,a.minV,a.maxV),i=a.interpolate_b(t,r,a.minV,a.maxV),s=a.interpolate_b(n,o,a.minV,a.maxV),p=a.interpolate_a(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.lt={path:[[0,i],[1,s]],move:{x:1,y:0,enter:"lt"}},e.edges.rb={path:[[1,p],[0,l]],move:{x:-1,y:0,enter:"rb"}}),a.polygons&&e.polygons.push([[0,l],[0,i],[1,s],[1,p]])},tetragon_tb:function(e,t,n,o,r,a){var l=a.interpolate_a(r,o,a.minV,a.maxV),i=a.interpolate_b(r,o,a.minV,a.maxV),s=a.interpolate_b(t,n,a.minV,a.maxV),p=a.interpolate_a(t,n,a.minV,a.maxV);a.polygons_full&&(e.edges.tr={path:[[i,1],[s,0]],move:{x:0,y:-1,enter:"tr"}},e.edges.bl={path:[[p,0],[l,1]],move:{x:0,y:1,enter:"bl"}}),a.polygons&&e.polygons.push([[p,0],[l,1],[i,1],[s,0]])},pentagon_tr:function(e,t,n,o,r,a){var l=a.interpolate(r,o,a.minV,a.maxV),i=a.interpolate(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.tl={path:[[l,1],[1,i]],move:{x:1,y:0,enter:"lb"}}),a.polygons&&e.polygons.push([[0,0],[0,1],[l,1],[1,i],[1,0]])},pentagon_tl:function(e,t,n,o,r,a){var l=a.interpolate(t,r,a.minV,a.maxV),i=a.interpolate(r,o,a.minV,a.maxV);a.polygons_full&&(e.edges.lb={path:[[0,l],[i,1]],move:{x:0,y:1,enter:"br"}}),a.polygons&&e.polygons.push([[0,0],[0,l],[i,1],[1,1],[1,0]])},pentagon_br:function(e,t,n,o,r,a){var l=a.interpolate(t,n,a.minV,a.maxV),i=a.interpolate(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.rt={path:[[1,i],[l,0]],move:{x:0,y:-1,enter:"tl"}}),a.polygons&&e.polygons.push([[0,0],[0,1],[1,1],[1,i],[l,0]])},pentagon_bl:function(e,t,n,o,r,a){var l=a.interpolate(t,r,a.minV,a.maxV),i=a.interpolate(t,n,a.minV,a.maxV);a.polygons_full&&(e.edges.br={path:[[i,0],[0,l]],move:{x:-1,y:0,enter:"rt"}}),a.polygons&&e.polygons.push([[0,l],[0,1],[1,1],[1,0],[i,0]])},pentagon_tr_rl:function(e,t,n,o,r,a){var l=a.interpolate(t,r,a.minV,a.maxV),i=a.interpolate(r,o,a.minV,a.maxV),s=a.interpolate_b(n,o,a.minV,a.maxV),p=a.interpolate_a(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.tl={path:[[i,1],[1,s]],move:{x:1,y:0,enter:"lt"}},e.edges.rb={path:[[1,p],[0,l]],move:{x:-1,y:0,enter:"rt"}}),a.polygons&&e.polygons.push([[0,l],[0,1],[i,1],[1,s],[1,p]])},pentagon_rb_bt:function(e,t,n,o,r,a){var l=a.interpolate(n,o,a.minV,a.maxV),i=a.interpolate_b(t,n,a.minV,a.maxV),s=a.interpolate_a(t,n,a.minV,a.maxV),p=a.interpolate(r,o,a.minV,a.maxV);a.polygons_full&&(e.edges.rt={path:[[1,l],[i,0]],move:{x:0,y:-1,enter:"tr"}},e.edges.bl={path:[[s,0],[p,1]],move:{x:0,y:1,enter:"br"}}),a.polygons&&e.polygons.push([[p,1],[1,1],[1,l],[i,0],[s,0]])},pentagon_bl_lr:function(e,t,n,o,r,a){var l=a.interpolate(t,n,a.minV,a.maxV),i=a.interpolate_a(t,r,a.minV,a.maxV),s=a.interpolate_b(t,r,a.minV,a.maxV),p=a.interpolate(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.br={path:[[l,0],[0,i]],move:{x:-1,y:0,enter:"rb"}},e.edges.lt={path:[[0,s],[1,p]],move:{x:1,y:0,enter:"lb"}}),a.polygons&&e.polygons.push([[l,0],[0,i],[0,s],[1,p],[1,0]])},pentagon_lt_tb:function(e,t,n,o,r,a){var l=a.interpolate(t,r,a.minV,a.maxV),i=a.interpolate_a(r,o,a.minV,a.maxV),s=a.interpolate_b(r,o,a.minV,a.maxV),p=a.interpolate(t,n,a.minV,a.maxV);a.polygons_full&&(e.edges.lb={path:[[0,l],[i,1]],move:{x:0,y:1,enter:"bl"}},e.edges.tr={path:[[s,1],[p,0]],move:{x:0,y:-1,enter:"tl"}}),a.polygons&&e.polygons.push([[0,0],[0,l],[i,1],[s,1],[p,0]])},pentagon_bl_tb:function(e,t,n,o,r,a){var l=a.interpolate(t,r,a.minV,a.maxV),i=a.interpolate(r,o,a.minV,a.maxV),s=a.interpolate_b(t,n,a.minV,a.maxV),p=a.interpolate_a(t,n,a.minV,a.maxV);a.polygons_full&&(e.edges.bl={path:[[p,0],[0,l]],move:{x:-1,y:0,enter:"rt"}},e.edges.tl={path:[[i,1],[s,0]],move:{x:0,y:-1,enter:"tr"}}),a.polygons&&e.polygons.push([[0,l],[0,1],[i,1],[s,0],[p,0]])},pentagon_lt_rl:function(e,t,n,o,r,a){var l=a.interpolate_a(t,r,a.minV,a.maxV),i=a.interpolate_b(t,r,a.minV,a.maxV),s=a.interpolate(r,o,a.minV,a.maxV),p=a.interpolate(n,r,a.minV,a.maxV);a.polygons_full&&(e.edges.lt={path:[[0,i],[s,1]],move:{x:0,y:1,enter:"br"}},e.edges.rt={path:[[1,p],[0,l]],move:{x:-1,y:0,enter:"rb"}}),a.polygons&&e.polygons.push([[0,l],[0,i],[s,1],[1,1],[1,p]])},pentagon_tr_bt:function(e,t,n,o,r,a){var l=a.interpolate_a(r,o,a.minV,a.maxV),i=a.interpolate_b(r,o,a.minV,a.maxV),s=a.interpolate(n,o,a.minV,a.maxV),p=a.interpolate(t,n,a.minV,a.maxV);a.polygons_full&&(e.edges.br={path:[[p,0],[l,1]],move:{x:0,y:1,enter:"bl"}},e.edges.tr={path:[[i,1],[1,s]],move:{x:1,y:0,enter:"lb"}}),a.polygons&&e.polygons.push([[l,1],[i,1],[1,s],[1,0],[p,0]])},pentagon_rb_lr:function(e,t,n,o,r,a){var l=a.interpolate(t,r,a.minV,a.maxV),i=a.interpolate_b(n,o,a.minV,a.maxV),s=a.interpolate_a(n,o,a.minV,a.maxV),p=a.interpolate(t,n,a.minV,a.maxV);a.polygons_full&&(e.edges.lb={path:[[0,l],[1,i]],move:{x:1,y:0,enter:"lt"}},e.edges.rb={path:[[1,s],[p,0]],move:{x:0,y:-1,enter:"tl"}}),a.polygons&&e.polygons.push([[0,0],[0,l],[1,i],[1,s],[p,0]])},hexagon_lt_tr:function(e,t,n,o,r,a){var l=a.interpolate(t,r,a.minV,a.maxV),i=a.interpolate_a(r,o,a.minV,a.maxV),s=a.interpolate_b(r,o,a.minV,a.maxV),p=a.interpolate(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.lb={path:[[0,l],[i,1]],move:{x:0,y:1,enter:"bl"}},e.edges.tr={path:[[s,1],[1,p]],move:{x:1,y:0,enter:"lb"}}),a.polygons&&e.polygons.push([[0,0],[0,l],[i,1],[s,1],[1,p],[1,0]])},hexagon_bl_lt:function(e,t,n,o,r,a){var l=a.interpolate(t,n,a.minV,a.maxV),i=a.interpolate_a(t,r,a.minV,a.maxV),s=a.interpolate_b(t,r,a.minV,a.maxV),p=a.interpolate(r,o,a.minV,a.maxV);a.polygons_full&&(e.edges.br={path:[[l,0],[0,i]],move:{x:-1,y:0,enter:"rb"}},e.edges.lt={path:[[0,s],[p,1]],move:{x:0,y:1,enter:"br"}}),a.polygons&&e.polygons.push([[l,0],[0,i],[0,s],[p,1],[1,1],[1,0]])},hexagon_bl_rb:function(e,t,n,o,r,a){var l=a.interpolate_a(t,n,a.minV,a.maxV),i=a.interpolate_b(t,n,a.minV,a.maxV),s=a.interpolate(t,r,a.minV,a.maxV),p=a.interpolate(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.bl={path:[[l,0],[0,s]],move:{x:-1,y:0,enter:"rt"}},e.edges.rt={path:[[1,p],[i,0]],move:{x:0,y:-1,enter:"tr"}}),a.polygons&&e.polygons.push([[l,0],[0,s],[0,1],[1,1],[1,p],[i,0]])},hexagon_tr_rb:function(e,t,n,o,r,a){var l=a.interpolate(t,n,a.minV,a.maxV),i=a.interpolate(r,o,a.minV,a.maxV),s=a.interpolate_b(n,o,a.minV,a.maxV),p=a.interpolate_a(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.tl={path:[[i,1],[1,s]],move:{x:1,y:0,enter:"lt"}},e.edges.rb={path:[[1,p],[l,0]],move:{x:0,y:-1,enter:"tl"}}),a.polygons&&e.polygons.push([[0,0],[0,1],[i,1],[1,s],[1,p],[l,0]])},hexagon_lt_rb:function(e,t,n,o,r,a){var l=a.interpolate(t,r,a.minV,a.maxV),i=a.interpolate(r,o,a.minV,a.maxV),s=a.interpolate(n,o,a.minV,a.maxV),p=a.interpolate(t,n,a.minV,a.maxV);a.polygons_full&&(e.edges.lb={path:[[0,l],[i,1]],move:{x:0,y:1,enter:"br"}},e.edges.rt={path:[[1,s],[p,0]],move:{x:0,y:-1,enter:"tl"}}),a.polygons&&e.polygons.push([[0,0],[0,l],[i,1],[1,1],[1,s],[p,0]])},hexagon_bl_tr:function(e,t,n,o,r,a){var l=a.interpolate(t,n,a.minV,a.maxV),i=a.interpolate(t,r,a.minV,a.maxV),s=a.interpolate(r,o,a.minV,a.maxV),p=a.interpolate(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.br={path:[[l,0],[0,i]],move:{x:-1,y:0,enter:"rt"}},e.edges.tl={path:[[s,1],[1,p]],move:{x:1,y:0,enter:"lb"}}),a.polygons&&e.polygons.push([[l,0],[0,i],[0,1],[s,1],[1,p],[1,0]])},heptagon_tr:function(e,t,n,o,r,a){var l=a.interpolate_a(t,n,a.minV,a.maxV),i=a.interpolate_b(t,n,a.minV,a.maxV),s=a.interpolate_a(t,r,a.minV,a.maxV),p=a.interpolate_b(t,r,a.minV,a.maxV),g=a.interpolate(r,o,a.minV,a.maxV),h=a.interpolate(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.bl={path:[[l,0],[0,s]],move:{x:-1,y:0,enter:"rb"}},e.edges.lt={path:[[0,p],[g,1]],move:{x:0,y:1,enter:"br"}},e.edges.rt={path:[[1,h],[i,0]],move:{x:0,y:-1,enter:"tr"}}),a.polygons&&e.polygons.push([[l,0],[0,s],[0,p],[g,1],[1,1],[1,h],[i,0]])},heptagon_bl:function(e,t,n,o,r,a){var l=a.interpolate(t,n,a.minV,a.maxV),i=a.interpolate(t,r,a.minV,a.maxV),s=a.interpolate_a(r,o,a.minV,a.maxV),p=a.interpolate_b(r,o,a.minV,a.maxV),g=a.interpolate_b(n,o,a.minV,a.maxV),h=a.interpolate_a(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.lb={path:[[0,i],[s,1]],move:{x:0,y:1,enter:"bl"}},e.edges.tr={path:[[p,1],[1,g]],move:{x:1,y:0,enter:"lt"}},e.edges.rb={path:[[1,h],[l,0]],move:{x:0,y:-1,enter:"tl"}}),a.polygons&&e.polygons.push([[0,0],[0,i],[s,1],[p,1],[1,g],[1,h],[l,0]])},heptagon_tl:function(e,t,n,o,r,a){var l=a.interpolate_a(t,n,a.minV,a.maxV),i=a.interpolate_b(t,n,a.minV,a.maxV),s=a.interpolate(t,r,a.minV,a.maxV),p=a.interpolate(r,o,a.minV,a.maxV),g=a.interpolate_b(n,o,a.minV,a.maxV),h=a.interpolate_a(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.bl={path:[[l,0],[0,s]],move:{x:-1,y:0,enter:"rt"}},e.edges.tl={path:[[p,1],[1,g]],move:{x:1,y:0,enter:"lt"}},e.edges.rb={path:[[1,h],[i,0]],move:{x:0,y:-1,enter:"tr"}}),a.polygons&&e.polygons.push([[l,0],[0,s],[0,1],[p,1],[1,g],[1,h],[i,0]])},heptagon_br:function(e,t,n,o,r,a){var l=a.interpolate(t,n,a.minV,a.maxV),i=a.interpolate_a(t,r,a.minV,a.maxV),s=a.interpolate_b(t,r,a.minV,a.maxV),p=a.interpolate_a(r,o,a.minV,a.maxV),g=a.interpolate_b(r,o,a.minV,a.maxV),h=a.interpolate(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.br={path:[[l,0],[0,i]],move:{x:-1,y:0,enter:"rb"}},e.edges.lt={path:[[0,s],[p,1]],move:{x:0,y:1,enter:"bl"}},e.edges.tr={path:[[g,1],[1,h]],move:{x:1,y:0,enter:"lb"}}),a.polygons&&e.polygons.push([[l,0],[0,i],[0,s],[p,1],[g,1],[1,h],[1,0]])},octagon:function(e,t,n,o,r,a){var l=a.interpolate_a(t,n,a.minV,a.maxV),i=a.interpolate_b(t,n,a.minV,a.maxV),s=a.interpolate_a(t,r,a.minV,a.maxV),p=a.interpolate_b(t,r,a.minV,a.maxV),g=a.interpolate_a(r,o,a.minV,a.maxV),h=a.interpolate_b(r,o,a.minV,a.maxV),m=a.interpolate_b(n,o,a.minV,a.maxV),u=a.interpolate_a(n,o,a.minV,a.maxV);a.polygons_full&&(e.edges.bl={path:[[l,0],[0,s]],move:{x:-1,y:0,enter:"rb"}},e.edges.lt={path:[[0,p],[g,1]],move:{x:0,y:1,enter:"bl"}},e.edges.tr={path:[[h,1],[1,m]],move:{x:1,y:0,enter:"lt"}},e.edges.rb={path:[[1,u],[i,0]],move:{x:0,y:-1,enter:"tr"}}),a.polygons&&e.polygons.push([[l,0],[0,s],[0,p],[g,1],[h,1],[1,m],[1,u],[i,0]])}};function b(e,t,n,o,r,a){var l=(o+n+t+e)/4;return an||e[i][r-1]n){o=!1;break}if(o&&(e[a-1][0]n||e[a-1][r-1]n)&&(o=!1),o)for(l=0;ln||e[a-1][l]n){o=!1;break}return o}(n,r.minV,r.maxV)&&(r.linearRing?x.push([[0,0],[0,v],[k,v],[k,0],[0,0]]):x.push([[0,0],[0,v],[k,v],[k,0]])),o.forEach(function(e,n){e.forEach(function(e,t){for(a=null,i=0;i<8;i++)if(a=A[i],"object"==typeof e.edges[a]){for(l=[],s=e.edges[a],h=a,u=t,b=!1,c=[(m=n)+s.path[0][0],t+s.path[0][1]],l.push(c);!b&&"object"==typeof(y=o[m][u]).edges[h];)if(s=y.edges[h],delete y.edges[h],(f=s.path[1])[0]+=m,f[1]+=u,l.push(f),h=s.move.enter,m+=s.move.x,u+=s.move.y,void 0===o[m]||void 0===o[m][u]){if(d=_=0,m===k)m--,_=0;else if(m<0)m++,_=2;else if(u===v)u--,_=3;else{if(!(u<0))throw new Error("Left the grid somewhere in the interior!");u++,_=1}if(m===n&&u===t&&_===N[a]){b=!0,h=a;break}for(;;){if(V=!1,4