function BufferLoader(t,e,n){this.context=t,this.urlList=e,this.onload=n,this.bufferList=new Array,this.loadCount=0}function FlowZone(t,e,n,i){this.x=t,this.y=e,this.u=n,this.v=i}function FlowCalculator(t){this.step=t||8}function earcut(t,e,n){n=n||2;var i=e&&e.length,r=i?e[0]*n:t.length,o=linkedList(t,0,r,n,!0),s=[];if(!o)return s;var a,u,h,l,c,p,d;if(i&&(o=eliminateHoles(t,e,o,n)),t.length>80*n){a=h=t[0],u=l=t[1];for(var f=n;r>f;f+=n)c=t[f],p=t[f+1],a>c&&(a=c),u>p&&(u=p),c>h&&(h=c),p>l&&(l=p);d=Math.max(h-a,l-u)}return earcutLinked(o,s,n,a,u,d),s}function linkedList(t,e,n,i,r){var o,s,a,u=0;for(o=e,s=n-i;n>o;o+=i)u+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;if(r===u>0)for(o=e;n>o;o+=i)a=insertNode(o,t[o],t[o+1],a);else for(o=n-i;o>=e;o-=i)a=insertNode(o,t[o],t[o+1],a);return a}function filterPoints(t,e){if(!t)return t;e||(e=t);var n,i=t;do if(n=!1,i.steiner||!equals(i,i.next)&&0!==area(i.prev,i,i.next))i=i.next;else{if(removeNode(i),i=e=i.prev,i===i.next)return null;n=!0}while(n||i!==e);return e}function earcutLinked(t,e,n,i,r,o,s){if(t){!s&&o&&indexCurve(t,i,r,o);for(var a,u,h=t;t.prev!==t.next;)if(a=t.prev,u=t.next,o?isEarHashed(t,i,r,o):isEar(t))e.push(a.i/n),e.push(t.i/n),e.push(u.i/n),removeNode(t),t=u.next,h=u.next;else if(t=u,t===h){s?1===s?(t=cureLocalIntersections(t,e,n),earcutLinked(t,e,n,i,r,o,2)):2===s&&splitEarcut(t,e,n,i,r,o):earcutLinked(filterPoints(t),e,n,i,r,o,1);break}}}function isEar(t){var e=t.prev,n=t,i=t.next;if(area(e,n,i)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(pointInTriangle(e.x,e.y,n.x,n.y,i.x,i.y,r.x,r.y)&&area(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function isEarHashed(t,e,n,i){var r=t.prev,o=t,s=t.next;if(area(r,o,s)>=0)return!1;for(var a=r.xo.x?r.x>s.x?r.x:s.x:o.x>s.x?o.x:s.x,l=r.y>o.y?r.y>s.y?r.y:s.y:o.y>s.y?o.y:s.y,c=zOrder(a,u,e,n,i),p=zOrder(h,l,e,n,i),d=t.nextZ;d&&d.z<=p;){if(d!==t.prev&&d!==t.next&&pointInTriangle(r.x,r.y,o.x,o.y,s.x,s.y,d.x,d.y)&&area(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(d=t.prevZ;d&&d.z>=c;){if(d!==t.prev&&d!==t.next&&pointInTriangle(r.x,r.y,o.x,o.y,s.x,s.y,d.x,d.y)&&area(d.prev,d,d.next)>=0)return!1;d=d.prevZ}return!0}function cureLocalIntersections(t,e,n){var i=t;do{var r=i.prev,o=i.next.next;intersects(r,i,i.next,o)&&locallyInside(r,o)&&locallyInside(o,r)&&(e.push(r.i/n),e.push(i.i/n),e.push(o.i/n),removeNode(i),removeNode(i.next),i=t=o),i=i.next}while(i!==t);return i}function splitEarcut(t,e,n,i,r,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&isValidDiagonal(s,a)){var u=splitPolygon(s,a);return s=filterPoints(s,s.next),u=filterPoints(u,u.next),earcutLinked(s,e,n,i,r,o),void earcutLinked(u,e,n,i,r,o)}a=a.next}s=s.next}while(s!==t)}function eliminateHoles(t,e,n,i){var r,o,s,a,u,h=[];for(r=0,o=e.length;o>r;r++)s=e[r]*i,a=o-1>r?e[r+1]*i:t.length,u=linkedList(t,s,a,i,!1),u===u.next&&(u.steiner=!0),h.push(getLeftmost(u));for(h.sort(compareX),r=0;r=i.next.y){var a=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);r>=a&&a>s&&(s=a,n=i.x=i.x&&i.x>=n.x&&pointInTriangle(ou||u===l&&i.x>n.x)&&locallyInside(i,t)&&(n=i,l=u)),i=i.next;return n}function indexCurve(t,e,n,i){var r=t;do null===r.z&&(r.z=zOrder(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,sortLinked(r)}function sortLinked(t){var e,n,i,r,o,s,a,u,h=1;do{for(n=t,t=null,o=null,s=0;n;){for(s++,i=n,a=0,e=0;h>e&&(a++,i=i.nextZ,i);e++);for(u=h;a>0||u>0&&i;)0===a?(r=i,i=i.nextZ,u--):0!==u&&i?n.z<=i.z?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,u--):(r=n,n=n.nextZ,a--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;n=i}o.nextZ=null,h*=2}while(s>1);return t}function zOrder(t,e,n,i,r){return t=32767*(t-n)/r,e=32767*(e-i)/r,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1}function getLeftmost(t){var e=t,n=t;do e.x=0&&(t-s)*(i-a)-(n-s)*(e-a)>=0&&(n-s)*(o-a)-(r-s)*(i-a)>=0}function isValidDiagonal(t,e){return equals(t,e)||t.next.i!==e.i&&t.prev.i!==e.i&&!intersectsPolygon(t,e)&&locallyInside(t,e)&&locallyInside(e,t)&&middleInside(t,e)}function area(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function equals(t,e){return t.x===e.x&&t.y===e.y}function intersects(t,e,n,i){return area(t,e,n)>0!=area(t,e,i)>0&&area(n,i,t)>0!=area(n,i,e)>0}function intersectsPolygon(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&intersects(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}function locallyInside(t,e){return area(t.prev,t,t.next)<0?area(t,e,t.next)>=0&&area(t,t.prev,e)>=0:area(t,e,t.prev)<0||area(t,t.next,e)<0}function middleInside(t,e){var n=t,i=!1,r=(t.x+e.x)/2,o=(t.y+e.y)/2;do n.y>o!=n.next.y>o&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next;while(n!==t);return i}function splitPolygon(t,e){var n=new Node(t.i,t.x,t.y),i=new Node(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function insertNode(t,e,n,i){var r=new Node(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function removeNode(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Node(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}!function(t){function e(t,e,n){this.x=t,this.y=e,this.z=n}function n(t){return t*t*t*(t*(6*t-15)+10)}function i(t,e,n){return(1-n)*t+n*e}var r=t.noise={};e.prototype.dot2=function(t,e){return this.x*t+this.y*e},e.prototype.dot3=function(t,e,n){return this.x*t+this.y*e+this.z*n};var o=[new e(1,1,0),new e(-1,1,0),new e(1,-1,0),new e(-1,-1,0),new e(1,0,1),new e(-1,0,1),new e(1,0,-1),new e(-1,0,-1),new e(0,1,1),new e(0,-1,1),new e(0,1,-1),new e(0,-1,-1)],s=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],a=new Array(512),u=new Array(512);r.seed=function(t){t>0&&1>t&&(t*=65536),t=Math.floor(t),256>t&&(t|=t<<8);for(var e=0;256>e;e++){var n;n=1&e?s[e]^255&t:s[e]^t>>8&255,a[e]=a[e+256]=n,u[e]=u[e+256]=o[n%12]}},r.seed(0);var h=.5*(Math.sqrt(3)-1),l=(3-Math.sqrt(3))/6,c=1/3,p=1/6;r.simplex2=function(t,e){var n,i,r,o,s,c=(t+e)*h,p=Math.floor(t+c),d=Math.floor(e+c),f=(p+d)*l,x=t-p+f,y=e-d+f;x>y?(o=1,s=0):(o=0,s=1);var g=x-o+l,v=y-s+l,m=x-1+2*l,_=y-1+2*l;p&=255,d&=255;var A=u[p+a[d]],L=u[p+o+a[d+s]],C=u[p+1+a[d+1]],w=.5-x*x-y*y;0>w?n=0:(w*=w,n=w*w*A.dot2(x,y));var O=.5-g*g-v*v;0>O?i=0:(O*=O,i=O*O*L.dot2(g,v));var b=.5-m*m-_*_;return 0>b?r=0:(b*=b,r=b*b*C.dot2(m,_)),70*(n+i+r)},r.simplex3=function(t,e,n){var i,r,o,s,h,l,d,f,x,y,g=(t+e+n)*c,v=Math.floor(t+g),m=Math.floor(e+g),_=Math.floor(n+g),A=(v+m+_)*p,L=t-v+A,C=e-m+A,w=n-_+A;L>=C?C>=w?(h=1,l=0,d=0,f=1,x=1,y=0):L>=w?(h=1,l=0,d=0,f=1,x=0,y=1):(h=0,l=0,d=1,f=1,x=0,y=1):w>C?(h=0,l=0,d=1,f=0,x=1,y=1):w>L?(h=0,l=1,d=0,f=0,x=1,y=1):(h=0,l=1,d=0,f=1,x=1,y=0);var O=L-h+p,b=C-l+p,G=w-d+p,T=L-f+2*p,E=C-x+2*p,S=w-y+2*p,P=L-1+3*p,R=C-1+3*p,D=w-1+3*p;v&=255,m&=255,_&=255;var N=u[v+a[m+a[_]]],I=u[v+h+a[m+l+a[_+d]]],M=u[v+f+a[m+x+a[_+y]]],q=u[v+1+a[m+1+a[_+1]]],U=.6-L*L-C*C-w*w;0>U?i=0:(U*=U,i=U*U*N.dot3(L,C,w));var k=.6-O*O-b*b-G*G;0>k?r=0:(k*=k,r=k*k*I.dot3(O,b,G));var W=.6-T*T-E*E-S*S;0>W?o=0:(W*=W,o=W*W*M.dot3(T,E,S));var V=.6-P*P-R*R-D*D;return 0>V?s=0:(V*=V,s=V*V*q.dot3(P,R,D)),32*(i+r+o+s)},r.perlin2=function(t,e){var r=Math.floor(t),o=Math.floor(e);t-=r,e-=o,r=255&r,o=255&o;var s=u[r+a[o]].dot2(t,e),h=u[r+a[o+1]].dot2(t,e-1),l=u[r+1+a[o]].dot2(t-1,e),c=u[r+1+a[o+1]].dot2(t-1,e-1),p=n(t);return i(i(s,l,p),i(h,c,p),n(e))},r.perlin3=function(t,e,r){var o=Math.floor(t),s=Math.floor(e),h=Math.floor(r);t-=o,e-=s,r-=h,o=255&o,s=255&s,h=255&h;var l=u[o+a[s+a[h]]].dot3(t,e,r),c=u[o+a[s+a[h+1]]].dot3(t,e,r-1),p=u[o+a[s+1+a[h]]].dot3(t,e-1,r),d=u[o+a[s+1+a[h+1]]].dot3(t,e-1,r-1),f=u[o+1+a[s+a[h]]].dot3(t-1,e,r),x=u[o+1+a[s+a[h+1]]].dot3(t-1,e,r-1),y=u[o+1+a[s+1+a[h]]].dot3(t-1,e-1,r),g=u[o+1+a[s+1+a[h+1]]].dot3(t-1,e-1,r-1),v=n(t),m=n(e),_=n(r);return i(i(i(l,f,v),i(c,x,v),_),i(i(p,y,v),i(d,g,v),_),m)}}(this),!function(t){if("object"==typeof exports)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.poly2tri=t()}}(function(){return function t(e,n,i){function r(s,a){if(!n[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var h=n[s]={exports:{}};e[s][0].call(h.exports,function(t){var n=e[s][1][t];return r(n?n:t)},h,h.exports,t,e,n,i)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s=e.value)return this.search_node_=e,e}else for(;e=e.next;)if(te)for(;(n=n.prev)&&t!==n.point;);else for(;(n=n.next)&&t!==n.point;);return n&&(this.search_node_=n),n},e.exports=r,e.exports.Node=i},{}],3:[function(t,e,n){"use strict";function i(t,e){if(!t)throw new Error(e||"Assert Failed")}e.exports=i},{}],4:[function(t,e,n){"use strict";var i=t("./xy"),r=function(t,e){this.x=+t||0,this.y=+e||0,this._p2t_edge_list=null};r.prototype.toString=function(){return i.toStringBase(this)},r.prototype.toJSON=function(){return{x:this.x,y:this.y}},r.prototype.clone=function(){return new r(this.x,this.y)},r.prototype.set_zero=function(){return this.x=0,this.y=0,this},r.prototype.set=function(t,e){return this.x=+t||0,this.y=+e||0,this},r.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},r.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},r.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this},r.prototype.mul=function(t){return this.x*=t,this.y*=t,this},r.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},r.prototype.normalize=function(){var t=this.length();return this.x/=t,this.y/=t,t},r.prototype.equals=function(t){return this.x===t.x&&this.y===t.y},r.negate=function(t){return new r(-t.x,-t.y)},r.add=function(t,e){return new r(t.x+e.x,t.y+e.y)},r.sub=function(t,e){return new r(t.x-e.x,t.y-e.y)},r.mul=function(t,e){return new r(t*e.x,t*e.y)},r.cross=function(t,e){return"number"==typeof t?"number"==typeof e?t*e:new r(-t*e.y,t*e.x):"number"==typeof e?new r(e*t.y,-e*t.x):t.x*e.y-t.y*e.x},r.toString=i.toString,r.compare=i.compare,r.cmp=i.compare,r.equals=i.equals,r.dot=function(t,e){return t.x*e.x+t.y*e.y},e.exports=r},{"./xy":11}],5:[function(t,e,n){"use strict";var i=t("./xy"),r=function(t,e){this.name="PointError",this.points=e=e||[],this.message=t||"Invalid Points!";for(var n=0;ne;++e)for(var i=t.getPoint(e),r=s(t,i),o=i._p2t_edge_list,u=0;o&&ue.q.x,h(n.triangle,e.p,e.q)||(_(t,e,n),u(t,e.p,e.q,n.triangle,e.q))}function u(t,e,n,i,r){if(!h(i,e,n)){var o=i.pointCCW(r),s=W(n,o,e);if(s===k.COLLINEAR)throw new N("poly2tri EdgeEvent: Collinear not supported!",[n,o,e]);var a=i.pointCW(r),l=W(n,a,e);if(l===k.COLLINEAR)throw new N("poly2tri EdgeEvent: Collinear not supported!",[n,a,e]);s===l?(i=s===k.CW?i.neighborCCW(r):i.neighborCW(r),u(t,e,n,i,r)):E(t,e,n,i,r)}}function h(t,e,n){var i=t.edgeIndex(e,n);if(-1!==i){t.markConstrainedEdgeByIndex(i);var r=t.getNeighbor(i);return r&&r.markConstrainedEdgeByPoints(e,n),!0}return!1}function l(t,e,n){var i=new I(e,n.point,n.next.point);i.markNeighbor(n.triangle),t.addToMap(i);var r=new M(e);return r.next=n.next,r.prev=n,n.next.prev=r,n.next=r,f(t,i)||t.mapTriangleToNodes(i),r}function c(t,e){var n=new I(e.prev.point,e.point,e.next.point);n.markNeighbor(e.prev.triangle),n.markNeighbor(e.triangle),t.addToMap(n),e.prev.next=e.next,e.next.prev=e.prev,f(t,n)||t.mapTriangleToNodes(n)}function p(t,e){for(var n=e.next;n.next&&!B(n.point,n.next.point,n.prev.point);)c(t,n),n=n.next;for(n=e.prev;n.prev&&!B(n.point,n.next.point,n.prev.point);)c(t,n),n=n.prev;e.next&&e.next.next&&d(e)&&g(t,e)}function d(t){var e=t.point.x-t.next.next.point.x,n=t.point.y-t.next.next.point.y;return D(n>=0,"unordered y"),e>=0||Math.abs(e)n;++n)if(!e.delaunay_edge[n]){var i=e.getNeighbor(n);if(i){var r=e.getPoint(n),o=i.oppositePoint(e,r),s=i.index(o);if(i.constrained_edge[s]||i.delaunay_edge[s]){e.constrained_edge[n]=i.constrained_edge[s];continue}var a=x(r,e.pointCCW(r),e.pointCW(r),o);if(a){e.delaunay_edge[n]=!0,i.delaunay_edge[s]=!0,y(e,r,i,o);var u=!f(t,e);return u&&t.mapTriangleToNodes(e),u=!f(t,i),u&&t.mapTriangleToNodes(i),e.delaunay_edge[n]=!1,i.delaunay_edge[s]=!1,!0}}}return!1}function x(t,e,n,i){var r=t.x-i.x,o=t.y-i.y,s=e.x-i.x,a=e.y-i.y,u=r*a,h=s*o,l=u-h;if(0>=l)return!1;var c=n.x-i.x,p=n.y-i.y,d=c*o,f=r*p,x=d-f;if(0>=x)return!1;var y=s*p,g=c*a,v=r*r+o*o,m=s*s+a*a,_=c*c+p*p,A=v*(y-g)+m*x+_*l;return A>0}function y(t,e,n,i){var r,o,s,a;r=t.neighborCCW(e),o=t.neighborCW(e),s=n.neighborCCW(i),a=n.neighborCW(i);var u,h,l,c;u=t.getConstrainedEdgeCCW(e),h=t.getConstrainedEdgeCW(e),l=n.getConstrainedEdgeCCW(i),c=n.getConstrainedEdgeCW(i);var p,d,f,x;p=t.getDelaunayEdgeCCW(e),d=t.getDelaunayEdgeCW(e),f=n.getDelaunayEdgeCCW(i),x=n.getDelaunayEdgeCW(i),t.legalize(e,i),n.legalize(i,e),n.setDelaunayEdgeCCW(e,p),t.setDelaunayEdgeCW(e,d),t.setDelaunayEdgeCCW(i,f),n.setDelaunayEdgeCW(i,x),n.setConstrainedEdgeCCW(e,u),t.setConstrainedEdgeCW(e,h),t.setConstrainedEdgeCCW(i,l),n.setConstrainedEdgeCW(i,c),t.clearNeighbors(),n.clearNeighbors(),r&&n.markNeighbor(r),o&&t.markNeighbor(o),s&&t.markNeighbor(s),a&&n.markNeighbor(a),t.markNeighbor(n)}function g(t,e){for(t.basin.left_node=W(e.point,e.next.point,e.next.next.point)===k.CCW?e.next.next:e.next,t.basin.bottom_node=t.basin.left_node;t.basin.bottom_node.next&&t.basin.bottom_node.point.y>=t.basin.bottom_node.next.point.y;)t.basin.bottom_node=t.basin.bottom_node.next;if(t.basin.bottom_node!==t.basin.left_node){for(t.basin.right_node=t.basin.bottom_node;t.basin.right_node.next&&t.basin.right_node.point.yt.basin.right_node.point.y,v(t,t.basin.bottom_node))}}function v(t,e){if(!m(t,e)){c(t,e);var n;if(e.prev!==t.basin.left_node||e.next!==t.basin.right_node){if(e.prev===t.basin.left_node){if(n=W(e.point,e.next.point,e.next.next.point),n===k.CW)return;e=e.next}else if(e.next===t.basin.right_node){if(n=W(e.point,e.prev.point,e.prev.prev.point),n===k.CCW)return;e=e.prev}else e=e.prev.point.yn?!0:!1}function _(t,e,n){t.edge_event.right?A(t,e,n):O(t,e,n)}function A(t,e,n){for(;n.next.point.xe.p.x;)W(e.q,n.prev.point,e.p)===k.CW?b(t,e,n):n=n.prev}function b(t,e,n){n.point.x>e.p.x&&(W(n.point,n.prev.point,n.prev.prev.point)===k.CW?T(t,e,n):(G(t,e,n),b(t,e,n)))}function G(t,e,n){W(n.prev.point,n.prev.prev.point,n.prev.prev.prev.point)===k.CW?T(t,e,n.prev):W(e.q,n.prev.prev.point,e.p)===k.CW&&G(t,e,n.prev)}function T(t,e,n){c(t,n.prev),n.prev.point!==e.p&&W(e.q,n.prev.point,e.p)===k.CW&&W(n.point,n.prev.point,n.prev.prev.point)===k.CW&&T(t,e,n)}function E(t,e,n,i,r){var o=i.neighborAcross(r);D(o,"FLIP failed due to missing triangle!");var s=o.oppositePoint(i,r);if(i.getConstrainedEdgeAcross(r)){var a=i.index(r);throw new N("poly2tri Intersecting Constraints",[r,s,i.getPoint((a+1)%3),i.getPoint((a+2)%3)])}if(V(r,i.pointCCW(r),i.pointCW(r),s))if(y(i,r,o,s),t.mapTriangleToNodes(i),t.mapTriangleToNodes(o),r===n&&s===e)n===t.edge_event.constrained_edge.q&&e===t.edge_event.constrained_edge.p&&(i.markConstrainedEdgeByPoints(e,n),o.markConstrainedEdgeByPoints(e,n),f(t,i),f(t,o));else{var h=W(n,s,e);i=S(t,h,i,o,r,s),E(t,e,n,i,r)}else{var l=P(e,n,o,s);R(t,e,n,i,o,l),u(t,e,n,i,r)}}function S(t,e,n,i,r,o){var s;return e===k.CCW?(s=i.edgeIndex(r,o),i.delaunay_edge[s]=!0,f(t,i),i.clearDelaunayEdges(),n):(s=n.edgeIndex(r,o),n.delaunay_edge[s]=!0,f(t,n),n.clearDelaunayEdges(),i)}function P(t,e,n,i){var r=W(e,i,t);if(r===k.CW)return n.pointCCW(i);if(r===k.CCW)return n.pointCW(i);throw new N("poly2tri [Unsupported] nextFlipPoint: opposing point on constrained edge!",[e,i,t])}function R(t,e,n,i,r,o){var s=r.neighborAcross(o);D(s,"FLIP failed due to missing triangle");var a=s.oppositePoint(r,o);if(V(n,i.pointCCW(n),i.pointCW(n),a))E(t,n,a,s,a);else{var u=P(e,n,s,a);R(t,e,n,i,s,u)}}var D=t("./assert"),N=t("./pointerror"),I=t("./triangle"),M=t("./advancingfront").Node,q=t("./utils"),U=q.EPSILON,k=q.Orientation,W=q.orient2d,V=q.inScanArea,B=q.isAngleObtuse;n.triangulate=i},{"./advancingfront":2,"./assert":3,"./pointerror":5,"./triangle":9,"./utils":10}],8:[function(t,e,n){"use strict";var i=t("./pointerror"),r=t("./point"),o=t("./triangle"),s=t("./sweep"),a=t("./advancingfront"),u=a.Node,h=.3,l=function(t,e){if(this.p=t,this.q=e,t.y>e.y)this.q=t,this.p=e;else if(t.y===e.y)if(t.x>e.x)this.q=t,this.p=e;else if(t.x===e.x)throw new i("poly2tri Invalid Edge constructor: repeated points!",[t]);this.q._p2t_edge_list||(this.q._p2t_edge_list=[]),this.q._p2t_edge_list.push(this)},c=function(){this.left_node=null,this.bottom_node=null,this.right_node=null,this.width=0,this.left_highest=!1};c.prototype.clear=function(){this.left_node=null,this.bottom_node=null,this.right_node=null,this.width=0,this.left_highest=!1};var p=function(){this.constrained_edge=null,this.right=!1},d=function(t,e){e=e||{},this.triangles_=[],this.map_=[],this.points_=e.cloneArrays?t.slice(0):t,this.edge_list=[],this.pmin_=this.pmax_=null,this.front_=null,this.head_=null,this.tail_=null,this.af_head_=null,this.af_middle_=null,this.af_tail_=null,this.basin=new c,this.edge_event=new p,this.initEdges(this.points_)};d.prototype.addHole=function(t){this.initEdges(t);var e,n=t.length;for(e=0;n>e;e++)this.points_.push(t[e]);return this},d.prototype.AddHole=d.prototype.addHole,d.prototype.addHoles=function(t){var e,n=t.length;for(e=0;n>e;e++)this.initEdges(t[e]);return this.points_=this.points_.concat.apply(this.points_,t),this},d.prototype.addPoint=function(t){return this.points_.push(t),this},d.prototype.AddPoint=d.prototype.addPoint,d.prototype.addPoints=function(t){return this.points_=this.points_.concat(t),this},d.prototype.triangulate=function(){return s.triangulate(this),this},d.prototype.getBoundingBox=function(){return{min:this.pmin_,max:this.pmax_}},d.prototype.getTriangles=function(){return this.triangles_},d.prototype.GetTriangles=d.prototype.getTriangles,d.prototype.front=function(){return this.front_},d.prototype.pointCount=function(){return this.points_.length},d.prototype.head=function(){return this.head_},d.prototype.setHead=function(t){this.head_=t},d.prototype.tail=function(){return this.tail_},d.prototype.setTail=function(t){this.tail_=t},d.prototype.getMap=function(){return this.map_},d.prototype.initTriangulation=function(){var t,e=this.points_[0].x,n=this.points_[0].x,i=this.points_[0].y,o=this.points_[0].y,s=this.points_.length;for(t=1;s>t;t++){var a=this.points_[t];a.x>e&&(e=a.x),a.xi&&(i=a.y),a.ye;++e)this.edge_list.push(new l(t[e],t[(e+1)%n]))},d.prototype.getPoint=function(t){return this.points_[t]},d.prototype.addToMap=function(t){this.map_.push(t)},d.prototype.locateNode=function(t){return this.front_.locateNode(t.x)},d.prototype.createAdvancingFront=function(){var t,e,n,i=new o(this.points_[0],this.tail_,this.head_);this.map_.push(i),t=new u(i.getPoint(1),i),e=new u(i.getPoint(0),i),n=new u(i.getPoint(2)),this.front_=new a(t,n),t.next=e,e.next=n,e.prev=t,n.prev=e},d.prototype.removeNode=function(t){},d.prototype.mapTriangleToNodes=function(t){for(var e=0;3>e;++e)if(!t.getNeighbor(e)){var n=this.front_.locatePoint(t.pointCW(t.getPoint(e)));n&&(n.triangle=t)}},d.prototype.removeFromMap=function(t){var e,n=this.map_,i=n.length;for(e=0;i>e;e++)if(n[e]===t){n.splice(e,1);break}},d.prototype.meshClean=function(t){for(var e,n,i=[t];e=i.pop();)if(!e.isInterior())for(e.setInterior(!0),this.triangles_.push(e),n=0;3>n;n++)e.constrained_edge[n]||i.push(e.getNeighbor(n))},e.exports=d},{"./advancingfront":2,"./point":4,"./pointerror":5,"./sweep":7,"./triangle":9}],9:[function(t,e,n){"use strict";var i=t("./xy"),r=function(t,e,n){this.points_=[t,e,n],this.neighbors_=[null,null,null],this.interior_=!1,this.constrained_edge=[!1,!1,!1],this.delaunay_edge=[!1,!1,!1]},o=i.toString;r.prototype.toString=function(){return"["+o(this.points_[0])+o(this.points_[1])+o(this.points_[2])+"]"},r.prototype.getPoint=function(t){return this.points_[t]},r.prototype.GetPoint=r.prototype.getPoint,r.prototype.getPoints=function(){return this.points_},r.prototype.getNeighbor=function(t){return this.neighbors_[t]},r.prototype.containsPoint=function(t){var e=this.points_;return t===e[0]||t===e[1]||t===e[2]},r.prototype.containsEdge=function(t){return this.containsPoint(t.p)&&this.containsPoint(t.q)},r.prototype.containsPoints=function(t,e){return this.containsPoint(t)&&this.containsPoint(e)},r.prototype.isInterior=function(){return this.interior_},r.prototype.setInterior=function(t){return this.interior_=t,this},r.prototype.markNeighborPointers=function(t,e,n){var i=this.points_;if(t===i[2]&&e===i[1]||t===i[1]&&e===i[2])this.neighbors_[0]=n;else if(t===i[0]&&e===i[2]||t===i[2]&&e===i[0])this.neighbors_[1]=n;else{if(!(t===i[0]&&e===i[1]||t===i[1]&&e===i[0]))throw new Error("poly2tri Invalid Triangle.markNeighborPointers() call");this.neighbors_[2]=n}},r.prototype.markNeighbor=function(t){var e=this.points_;t.containsPoints(e[1],e[2])?(this.neighbors_[0]=t,t.markNeighborPointers(e[1],e[2],this)):t.containsPoints(e[0],e[2])?(this.neighbors_[1]=t,t.markNeighborPointers(e[0],e[2],this)):t.containsPoints(e[0],e[1])&&(this.neighbors_[2]=t,t.markNeighborPointers(e[0],e[1],this))},r.prototype.clearNeighbors=function(){this.neighbors_[0]=null,this.neighbors_[1]=null,this.neighbors_[2]=null},r.prototype.clearDelaunayEdges=function(){this.delaunay_edge[0]=!1,this.delaunay_edge[1]=!1,this.delaunay_edge[2]=!1},r.prototype.pointCW=function(t){var e=this.points_;return t===e[0]?e[2]:t===e[1]?e[0]:t===e[2]?e[1]:null},r.prototype.pointCCW=function(t){var e=this.points_;return t===e[0]?e[1]:t===e[1]?e[2]:t===e[2]?e[0]:null},r.prototype.neighborCW=function(t){return t===this.points_[0]?this.neighbors_[1]:t===this.points_[1]?this.neighbors_[2]:this.neighbors_[0]},r.prototype.neighborCCW=function(t){return t===this.points_[0]?this.neighbors_[2]:t===this.points_[1]?this.neighbors_[0]:this.neighbors_[1]},r.prototype.getConstrainedEdgeCW=function(t){return t===this.points_[0]?this.constrained_edge[1]:t===this.points_[1]?this.constrained_edge[2]:this.constrained_edge[0]},r.prototype.getConstrainedEdgeCCW=function(t){return t===this.points_[0]?this.constrained_edge[2]:t===this.points_[1]?this.constrained_edge[0]:this.constrained_edge[1]},r.prototype.getConstrainedEdgeAcross=function(t){return t===this.points_[0]?this.constrained_edge[0]:t===this.points_[1]?this.constrained_edge[1]:this.constrained_edge[2]},r.prototype.setConstrainedEdgeCW=function(t,e){t===this.points_[0]?this.constrained_edge[1]=e:t===this.points_[1]?this.constrained_edge[2]=e:this.constrained_edge[0]=e},r.prototype.setConstrainedEdgeCCW=function(t,e){t===this.points_[0]?this.constrained_edge[2]=e:t===this.points_[1]?this.constrained_edge[0]=e:this.constrained_edge[1]=e},r.prototype.getDelaunayEdgeCW=function(t){return t===this.points_[0]?this.delaunay_edge[1]:t===this.points_[1]?this.delaunay_edge[2]:this.delaunay_edge[0]},r.prototype.getDelaunayEdgeCCW=function(t){return t===this.points_[0]?this.delaunay_edge[2]:t===this.points_[1]?this.delaunay_edge[0]:this.delaunay_edge[1]},r.prototype.setDelaunayEdgeCW=function(t,e){t===this.points_[0]?this.delaunay_edge[1]=e:t===this.points_[1]?this.delaunay_edge[2]=e:this.delaunay_edge[0]=e},r.prototype.setDelaunayEdgeCCW=function(t,e){t===this.points_[0]?this.delaunay_edge[2]=e:t===this.points_[1]?this.delaunay_edge[0]=e:this.delaunay_edge[1]=e},r.prototype.neighborAcross=function(t){return t===this.points_[0]?this.neighbors_[0]:t===this.points_[1]?this.neighbors_[1]:this.neighbors_[2]},r.prototype.oppositePoint=function(t,e){var n=t.pointCW(e);return this.pointCW(n)},r.prototype.legalize=function(t,e){var n=this.points_;if(t===n[0])n[1]=n[0],n[0]=n[2],n[2]=e;else if(t===n[1])n[2]=n[1],n[1]=n[0],n[0]=e;else{if(t!==n[2])throw new Error("poly2tri Invalid Triangle.legalize() call");n[0]=n[2],n[2]=n[1],n[1]=e}},r.prototype.index=function(t){var e=this.points_;if(t===e[0])return 0;if(t===e[1])return 1;if(t===e[2])return 2;throw new Error("poly2tri Invalid Triangle.index() call")},r.prototype.edgeIndex=function(t,e){var n=this.points_;if(t===n[0]){if(e===n[1])return 2;if(e===n[2])return 1}else if(t===n[1]){if(e===n[2])return 0;if(e===n[0])return 2}else if(t===n[2]){if(e===n[0])return 1;if(e===n[1])return 0}return-1},r.prototype.markConstrainedEdgeByIndex=function(t){this.constrained_edge[t]=!0},r.prototype.markConstrainedEdgeByEdge=function(t){this.markConstrainedEdgeByPoints(t.p,t.q)},r.prototype.markConstrainedEdgeByPoints=function(t,e){var n=this.points_;e===n[0]&&t===n[1]||e===n[1]&&t===n[0]?this.constrained_edge[2]=!0:e===n[0]&&t===n[2]||e===n[2]&&t===n[0]?this.constrained_edge[1]=!0:(e===n[1]&&t===n[2]||e===n[2]&&t===n[1])&&(this.constrained_edge[0]=!0)},e.exports=r},{"./xy":11}],10:[function(t,e,n){"use strict";function i(t,e,n){var i=(t.x-n.x)*(e.y-n.y),r=(t.y-n.y)*(e.x-n.x),o=i-r;return o>-s&&s>o?a.COLLINEAR:o>0?a.CCW:a.CW}function r(t,e,n,i){var r=(t.x-e.x)*(i.y-e.y)-(i.x-e.x)*(t.y-e.y);if(r>=-s)return!1;var o=(t.x-n.x)*(i.y-n.y)-(i.x-n.x)*(t.y-n.y);return s>=o?!1:!0}function o(t,e,n){var i=e.x-t.x,r=e.y-t.y,o=n.x-t.x,s=n.y-t.y;return 0>i*o+r*s}var s=1e-12;n.EPSILON=s;var a={CW:1,CCW:-1,COLLINEAR:0};n.Orientation=a,n.orient2d=i,n.inScanArea=r,n.isAngleObtuse=o},{}],11:[function(t,e,n){"use strict";function i(t){return"("+t.x+";"+t.y+")"}function r(t){var e=t.toString();return"[object Object]"===e?i(t):e}function o(t,e){return t.y===e.y?t.x-e.x:t.y-e.y}function s(t,e){return t.x===e.x&&t.y===e.y}e.exports={toString:r,toStringBase:i,compare:o,equals:s}},{}]},{},[6])(6)}),BufferLoader.prototype.loadBuffer=function(t,e){var n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType="arraybuffer";var i=this;n.onload=function(){i.context.decodeAudioData(n.response,function(n){return n?(i.bufferList[e]=n,void(++i.loadCount==i.urlList.length&&i.onload(i.bufferList))):void alert("error decoding file data: "+t)},function(t){console.error("decodeAudioData error",t)})},n.onerror=function(){alert("BufferLoader: XHR error")},n.send()},BufferLoader.prototype.load=function(){for(var t=0;ty;y+=x)for(g=f+1;_>g;g+=x){for(r=o=s=a=u=0,v=-f;f>=v;v++)for(m=-f;f>=m;m++){var L=(y+v)*n+g+m,C=e[4*(L-1)]-e[4*(L+1)],w=e[4*(L-n)]-e[4*(L+n)],O=t[4*L]-e[4*L];r+=C*C,o+=C*w,s+=w*w,u+=C*O,a+=w*O}var b=o*o-r*s;if(0!==b){var G=f/b,T=-(a*o-u*s),E=-(o*u-r*a);h=T*G,l=E*G}else{var S=(o+r)*(o+r)+(s+o)*(s+o);if(0!==S){var P=f/S,R=-(a+u)*P;h=(o+r)*R,l=(s+o)*R}else h=l=0}h>-x&&x>h&&l>-x&&x>l&&(c+=h,p+=l,d.push(new FlowZone(g,y,h,l)))}return{zones:d,u:c/d.length,v:p/d.length}};/*!* * algo.js * * JavaScript Creative Coding Framework * http://algojs.com * * Copyright 2015 hisa hayashi, HYS INC. */ var ALGO=function(){"use strict";function t(n){O=this,b=t.ObjectUtil.extend(b,n),e()}function e(){n(),i(),o()}function n(){O.width=b.width,O.height=b.height,O.backgroundAuto=b.backgroundAuto}function i(){O.render=new t.Render(O),O.render.setFramerate(O.framerate)}function r(){O.canvas=document.getElementById(b.id),O.canvas.width=b.width,O.canvas.height=b.height,O.renderer=new t.WebGLRenderer(O)}function o(){window.onload=function(){r(),O.setup&&O.setup.call(O),s()}}function s(){window.onmouseover=function(){O.mouseover&&O.mouseover.call(O)},window.onmouseout=function(){O.mouseout&&O.mouseout.call(O)},window.onmousedown=function(t){if(O.mousedown){var e=t.clientX,n=t.clientY;O.mousedown.call(O,e,n)}},window.onmouseup=function(){O.mouseup&&O.mouseup.call(O)},window.onmousemove=function(t){if(O.mousemove){var e=t.clientX,n=t.clientY;O.mousemove.call(O,e,n)}},window.onkeydown=function(){O.keydown&&O.keydown.call(O)},window.onkeyup=function(){O.keyup&&O.keyup.call(O)},window.onresize=function(){O.resize&&O.resize.call(O),O.renderer&&O.renderer.resize()},O.render.startRender()}function a(t,e){this[t]=e,O[t]=this[t],O=this}function u(t,e){this[t]=e,O[t]=null}function h(){}function l(){}function c(){}function p(){}function d(){}function f(){}function x(){}function y(){}function g(){}function v(){}function m(){}function _(t,e){O.canvas.width=t,O.canvas.height=e,O.width=t,O.height=e}function A(t){t.add(O)}function L(t){t.remove(O)}function C(t,e,n,i){void 0==t&&(t=0),void 0==e&&(e=0),void 0==n&&(n=this.width),void 0==i&&(i=this.height);var r=this.renderer.getContext(),o=new Uint8Array(n*i*4);r.readPixels(t,e,n,i,r.RGBA,r.UNSIGNED_BYTE,o);for(var s=new Uint8Array(n*i*4),a=0;i>a;a++){var u=(i-a)*n*4,h=a*n*4,l=o.slice(u,u+4*n);s.set(new Uint8Array(l),h)}return s}function w(t){this.backgroundAuto=t,this.renderer&&this.renderer.init(this)}var O,b={id:"",width:window.innerWidth,height:window.innerHeight,backgroundAuto:!0};return t.prototype={constructor:t,setup:h,frame:l,destroy:c,mouseover:p,mouseout:d,mousedown:f,mouseup:x,mousemove:y,keydown:g,keyup:v,resize:m,bind:a,unbind:u,size:_,add:A,remove:L,readPixels:C,setBackgroundAuto:w,render:null,renderer:null},t}();ALGO.debug=1,ALGO.BLEND_NONE=0,ALGO.BLEND_ADD=1,ALGO.BLEND_MULTIPLY=2,ALGO.BLEND_SCREEN=3,ALGO.BLEND_ALPHA=4,ALGO.prototype.__defineGetter__("framerate",function(){return this.framerate_}),ALGO.prototype.__defineSetter__("framerate",function(t){this.render&&this.render.setFramerate(t),this.framerate_=t}),ALGO.prototype.__defineGetter__("circleResolution",function(){return this.circleResolution_}),ALGO.prototype.__defineSetter__("circleResolution",function(t){ALGO.circleResolution=t,this.circleResolution_=t}),ALGO.prototype.width=0,ALGO.prototype.height=0,ALGO.prototype.blendMode=ALGO.BLEND_ALPHA,ALGO.prototype.background=13421772,ALGO.prototype.backgroundAlpha=1,ALGO.prototype.backgroundAuto=!0,ALGO.prototype.framerate=60,ALGO.prototype.circleResolution=32,ALGO.prototype.canvas=null,ALGO.prototype.displayObjects=[],ALGO.prototype.children=[],ALGO.Render=function(){"use strict";function t(){e(),n()}function e(){}function n(){}function i(t){h=t,l=1e3/h,ALGO.log("setFramerate = "+h)}function r(){return h}function o(){x=!0,l=1e3/h,d=Date.now(),c=d,a()}function s(){x=!1}function a(){if(x&&g(a),p=Date.now(),f=p-d,f>l){d=p-f%l,u.renderer&&u.renderer.update(),u.frame&&u.frame.call(u);{var t=p-c;Math.round(1e3/(t/++y)*100)/100}}}var u,h,l,c,p,d,f,x=!1,y=0,g=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/h)};return ALGO.Render=function(e){u=e,t()},ALGO.Render.prototype={constructor:ALGO.Render,setFramerate:i,getFramerate:r,startRender:o,stopRender:s},ALGO.Render}(),ALGO.Matrix3=function(t){"use strict";function e(){return new Float32Array(16)}function n(t){return t=[1,0,0,0,1,0,0,0,1]}function i(t,e,n){var i=t[0],r=t[1],o=t[2],s=t[3],a=t[4],u=t[5],h=t[6],l=t[7],c=t[8],p=e[0],d=e[1],f=e[2],x=e[3],y=e[4],g=e[5],v=e[6],m=e[7],_=e[8];return n[0]=i*p+r*x+o*v,n[1]=i*d+r*y+o*m,n[2]=i*f+r*g+o*_,n[3]=s*p+a*x+u*v,n[4]=s*d+a*y+u*m,n[5]=s*f+a*g+u*_,n[6]=h*p+l*x+c*v,n[7]=h*d+l*y+c*m,n[8]=h*f+l*g+c*_,n}function r(t,e,n){return n[0]=t[0]*e[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4]*e[1],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n}function o(t,e,n){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6]+e[0],n[7]=t[7]+e[1],n[8]=t[8],n}function s(t,e,n){var i=Math.cos(e),r=Math.sin(e);return n[0]=i,n[1]=-r,n[2]=t[2],n[3]=r,n[4]=i,n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n}function a(t,e){return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],e}function u(t,e){return e}return t.Matrix3=function(){},t.Matrix3.prototype={constructor:t.Matrix3,create:e,identity:n,multiply:i,scale:r,translate:o,rotate:s,transpose:a,inverse:u},t.Matrix3}(ALGO),ALGO.Matrix4=function(t){"use strict";function e(){return new Float32Array(16)}function n(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function i(t,e,n){var i=t[0],r=t[1],o=t[2],s=t[3],a=t[4],u=t[5],h=t[6],l=t[7],c=t[8],p=t[9],d=t[10],f=t[11],x=t[12],y=t[13],g=t[14],v=t[15],m=e[0],_=e[1],A=e[2],L=e[3],C=e[4],w=e[5],O=e[6],b=e[7],G=e[8],T=e[9],E=e[10],S=e[11],P=e[12],R=e[13],D=e[14],N=e[15];return n[0]=m*i+_*a+A*c+L*x,n[1]=m*r+_*u+A*p+L*y,n[2]=m*o+_*h+A*d+L*g,n[3]=m*s+_*l+A*f+L*v,n[4]=C*i+w*a+O*c+b*x,n[5]=C*r+w*u+O*p+b*y,n[6]=C*o+w*h+O*d+b*g,n[7]=C*s+w*l+O*f+b*v,n[8]=G*i+T*a+E*c+S*x,n[9]=G*r+T*u+E*p+S*y,n[10]=G*o+T*h+E*d+S*g,n[11]=G*s+T*l+E*f+S*v,n[12]=P*i+R*a+D*c+N*x,n[13]=P*r+R*u+D*p+N*y,n[14]=P*o+R*h+D*d+N*g,n[15]=P*s+R*l+D*f+N*v,n}function r(t,e,n){return n[0]=t[0]*e[0],n[1]=t[1]*e[0],n[2]=t[2]*e[0],n[3]=t[3]*e[0],n[4]=t[4]*e[1],n[5]=t[5]*e[1],n[6]=t[6]*e[1],n[7]=t[7]*e[1],n[8]=t[8]*e[2],n[9]=t[9]*e[2],n[10]=t[10]*e[2],n[11]=t[11]*e[2],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}function o(t,e,n){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[0]*e[0]+t[4]*e[1]+t[8]*e[2]+t[12],n[13]=t[1]*e[0]+t[5]*e[1]+t[9]*e[2]+t[13],n[14]=t[2]*e[0]+t[6]*e[1]+t[10]*e[2]+t[14],n[15]=t[3]*e[0]+t[7]*e[1]+t[11]*e[2]+t[15],n}function s(t,e,n,i){var r=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);if(!r)return null;var o=n[0],s=n[1],a=n[2];1!=r&&(r=1/r,o*=r,s*=r,a*=r);var u=Math.sin(e),h=Math.cos(e),l=1-h,c=t[0],p=t[1],d=t[2],f=t[3],x=t[4],y=t[5],g=t[6],v=t[7],m=t[8],_=t[9],A=t[10],L=t[11],C=o*o*l+h,w=s*o*l+a*u,O=a*o*l-s*u,b=o*s*l-a*u,G=s*s*l+h,T=a*s*l+o*u,E=o*a*l+s*u,S=s*a*l-o*u,P=a*a*l+h;return e?t!=i&&(i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15]):i=t,i[0]=c*C+x*w+m*O,i[1]=p*C+y*w+_*O,i[2]=d*C+g*w+A*O,i[3]=f*C+v*w+L*O,i[4]=c*b+x*G+m*T,i[5]=p*b+y*G+_*T,i[6]=d*b+g*G+A*T,i[7]=f*b+v*G+L*T,i[8]=c*E+x*S+m*P,i[9]=p*E+y*S+_*P,i[10]=d*E+g*S+A*P,i[11]=f*E+v*S+L*P,i}function a(t,e,i,r){var o=t[0],s=t[1],a=t[2],u=i[0],h=i[1],l=i[2],c=e[0],p=e[1],d=e[2];if(o==c&&s==p&&a==d)return n(r);var f,x,y,g,v,m,_,A,L,C;return _=o-e[0],A=s-e[1],L=a-e[2],C=1/Math.sqrt(_*_+A*A+L*L),_*=C,A*=C,L*=C,f=h*L-l*A,x=l*_-u*L,y=u*A-h*_,C=Math.sqrt(f*f+x*x+y*y),C?(C=1/C,f*=C,x*=C,y*=C):(f=0,x=0,y=0),g=A*y-L*x,v=L*f-_*y,m=_*x-A*f,C=Math.sqrt(g*g+v*v+m*m),C?(C=1/C,g*=C,v*=C,m*=C):(g=0,v=0,m=0),r[0]=f,r[1]=g,r[2]=_,r[3]=0,r[4]=x,r[5]=v,r[6]=A,r[7]=0,r[8]=y,r[9]=m,r[10]=L,r[11]=0,r[12]=-(f*o+x*s+y*a),r[13]=-(g*o+v*s+m*a),r[14]=-(_*o+A*s+L*a),r[15]=1,r}function u(t,e,n,i,r){var o=n*Math.tan(t*Math.PI/360),s=o*e,a=2*s,u=2*o,h=i-n;return r[0]=2*n/a,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=2*n/u,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=-(i+n)/h,r[11]=-1,r[12]=0,r[13]=0,r[14]=-(i*n*2)/h,r[15]=0,r}function h(t,e){return e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15],e}function l(t,e){var n=t[0],i=t[1],r=t[2],o=t[3],s=t[4],a=t[5],u=t[6],h=t[7],l=t[8],c=t[9],p=t[10],d=t[11],f=t[12],x=t[13],y=t[14],g=t[15],v=n*a-i*s,m=n*u-r*s,_=n*h-o*s,A=i*u-r*a,L=i*h-o*a,C=r*h-o*u,w=l*x-c*f,O=l*y-p*f,b=l*g-d*f,G=c*y-p*x,T=c*g-d*x,E=p*g-d*y,S=1/(v*E-m*T+_*G+A*b-L*O+C*w);return e[0]=(a*E-u*T+h*G)*S,e[1]=(-i*E+r*T-o*G)*S,e[2]=(x*C-y*L+g*A)*S,e[3]=(-c*C+p*L-d*A)*S,e[4]=(-s*E+u*b-h*O)*S,e[5]=(n*E-r*b+o*O)*S,e[6]=(-f*C+y*_-g*m)*S,e[7]=(l*C-p*_+d*m)*S,e[8]=(s*T-a*b+h*w)*S,e[9]=(-n*T+i*b-o*w)*S,e[10]=(f*L-x*_+g*v)*S,e[11]=(-l*L+c*_-d*v)*S,e[12]=(-s*G+a*O-u*w)*S,e[13]=(n*G-i*O+r*w)*S,e[14]=(-f*A+x*m-y*v)*S,e[15]=(l*A-c*m+p*v)*S,e}return t.Matrix4=function(){},t.Matrix4.prototype={constructor:t.Matrix4,create:e,identity:n,multiply:i,scale:r,translate:o,rotate:s,lookAt:a,perspective:u,transpose:h,inverse:l},t.Matrix4}(ALGO),ALGO.Loader=function(){"use strict";function t(){this.xhr.open("get",this.loaderURL,!0),this.xhr.send(null)}function e(t){this.xhr.open("post",this.loaderURL,!0),this.xhr.send(t)}function n(t){if(0!==this.xhr.status){{this.getReadyStateString(this.xhr.readyState)}if(this.xhr.readyState==this.xhr.UNSENT);else if(this.xhr.readyState==this.xhr.OPENED);else if(this.xhr.readyState==this.xhr.HEADERS_RECEIVED);else if(this.xhr.readyState==this.xhr.LOADING);else if(this.xhr.readyState==this.xhr.DONE){var e={};e.status=this.xhr.status,e.responseText=this.xhr.responseText,this.completeRequest(e)}}}function i(t){this.complete(t),this.remove()}function r(t){}function o(){this.loaderURL="",this.xhr=null}function s(t){var e;return t==this.xhr.UNSENT?e="UNSENT":t==this.xhr.OPENED?e="OPENED":t==this.xhr.HEADERS_RECEIVED?e="HEADERS_RECEIVED":t==this.xhr.LOADING?e="LOADING":t==this.xhr.DONE&&(e="DONE"),e}return ALGO.Loader=function(t){var e=this;this.loaderURL=t,this.xhr=new XMLHttpRequest,this.xhr.onreadystatechange=function(t){e.readyStateChange(t)}},ALGO.Loader.prototype={constructor:ALGO.Loader,loaderURL:"",xhr:null,get:t,post:e,complete:r,remove:o,readyStateChange:n,getReadyStateString:s,completeRequest:i},ALGO.Loader}(),ALGO.ShapeCtrl={createID:function(t,e){for(var n="abcdefghijklmnopqrstuvwxyz0123456789",i=e?e:12,r="",o=0;i>o;o++){var s=n.length,a=Math.floor(Math.random()*s);r+=n.charAt(a)}return t.indexOf(r)>-1&&arguments.callee(t,e),r}},ALGO.Shape=function(){"use strict";function t(){this.geometry=[],this.vertexPosition=[],this.vertexColors=[],this.vertexLineColors=[],this.index=[],this.m=new ALGO.Matrix3,this.matrix=this.m.identity(this.m.create()),this.matrixScale=this.m.identity(this.m.create()),this.matrixRotate=this.m.identity(this.m.create()),this.matrixTranslate=this.m.identity(this.m.create())}function e(){this.setGeometry(),this.setVertexPosition(),this.setVertexColor(this.color,this.vertexColors),this.setVertexAlpha(this.alpha,this.vertexColors),this.setVertexColor(this.lineColor,this.vertexLineColors),this.setVertexAlpha(this.lineAlpha,this.vertexLineColors),this.setIndex(),this.setTextureCoord(),this.setScale(this.scale),this.setRotate(this.rotate),this.setTranslate(this.x,this.y)}function n(t){this.id||(this.id=ALGO.ShapeCtrl.createID(t.displayObjects,8)),t.displayObjects.push(this.id),t.children.push(this)}function i(t){var e=t.displayObjects.indexOf(this.id);e>-1&&(t.displayObjects.splice(e,1),t.children.splice(e,1))}function r(){this.geometry=[],this.vertexPosition=[],this.vertexColors=[],this.vertexLineColors=[],this.setVertexPosition(),this.setVertexColor(this.color,this.vertexColors),this.setVertexAlpha(this.alpha,this.vertexColors),this.setVertexColor(this.lineColor,this.vertexLineColors),this.setVertexAlpha(this.lineAlpha,this.vertexLineColors),this.setIndex(),this.setTextureCoord(),this.setScale(this.scale),this.setRotate(this.rotate),this.setTranslate(this.x,this.y)}function o(){}function s(){var t=this.geometry;t[0]={x:0,y:-1},t[1]={x:-.87,y:.5},t[2]={x:.87,y:.5}}function a(){for(var t=this.vertexPosition,e=this.geometry.length,n=0;e>n;n++){var i=2*n;t[i]=this.geometry[n].x,t[i+1]=this.geometry[n].y}}function u(t,e){for(var n=e,i=this.geometry.length,r=ALGO.ColorUtil.hexToRgbNormalize(t),o=0;i>o;o++){var s=4*o;n[s]=r.r,n[s+1]=r.g,n[s+2]=r.b}}function h(t,e){for(var n=e,i=this.geometry.length,r=0;i>r;r++){var o=4*r;n[o+3]=t}}function l(){var t=[0,1,2];this.index=t}function c(){var t=[0,0,1,0,0,1,1,1];this.textureCoord=t}function p(){this.setVertexPosition(),this.setVertexColor(this.color,this.vertexColors),this.setVertexAlpha(this.alpha,this.vertexColors),this.setVertexColor(this.lineColor,this.vertexLineColors),this.setVertexAlpha(this.lineAlpha,this.vertexLineColors),this.setIndex(),this.setTextureCoord()}function d(t){if(this.m){var e=this.radius*t,n=this.radius*t;this.m.scale(this.matrix,[e,n,0],this.matrixScale)}}function f(t){if(this.m){var e=t*Math.PI/180;this.m.rotate(this.matrix,e,this.matrixRotate)}}function x(t,e){this.m&&this.m.translate(this.matrix,[t,e,0],this.matrixTranslate)}function y(){var t=null;return this.m&&(t=this.m.identity(this.m.create()),this.m.multiply(t,this.matrixScale,t),this.m.multiply(t,this.matrixRotate,t),this.m.multiply(t,this.matrixTranslate,t)),t}return ALGO.Shape=function(t,e,n){this.x=t,this.y=e,this.angles=3,this.radius=n,this.angles_=3,this.radius_=n,this.init(),this.setup()},ALGO.Shape.prototype={constructor:ALGO.Shape,name:"",type:"shape",id:null,x:0,y:0,angles:void 0,radius:null,alpha:1,visible:!0,color:16777215,scale:1,rotate:0,line:!1,lineColor:0,lineAlpha:1,lineWidth:1,fill:!0,m:void 0,matrix:void 0,matrixScale:void 0,matrixRotate:void 0,matrixTranslate:void 0,parent:void 0,children:[],geometry:[],vertexPosition:[],vertexColors:[],vertexLineColors:[],needsUpdate:!1,geometry:[],index:[],textureCoord:[],x_:0,y_:0,scale_:1,rotate_:0,radius_:null,color_:0,alpha_:1,angle_:void 0,needsUpdate_:!1,lineColor_:0,lineAlpha_:1,init:t,setup:e,add:n,remove:i,clone:o,clear:r,setGeometry:s,setVertexPosition:a,setVertexColor:u,setVertexAlpha:h,setIndex:l,setTextureCoord:c,vertexUpdate:p,setScale:d,setRotate:f,setTranslate:x,getMatrix:y},ALGO.Shape}(),ALGO.Shape.prototype.__defineGetter__("x",function(){return this.x_}),ALGO.Shape.prototype.__defineSetter__("x",function(t){this.x_=t,this.setTranslate(this.x,this.y)}),ALGO.Shape.prototype.__defineGetter__("y",function(){return this.y_}),ALGO.Shape.prototype.__defineSetter__("y",function(t){this.y_=t,this.setTranslate(this.x,this.y)}),ALGO.Shape.prototype.__defineGetter__("scale",function(){return this.scale_}),ALGO.Shape.prototype.__defineSetter__("scale",function(t){this.setScale(t),this.scale_=t}),ALGO.Shape.prototype.__defineGetter__("rotate",function(){return this.rotate_}),ALGO.Shape.prototype.__defineSetter__("rotate",function(t){this.setRotate(t),this.rotate_=t}),ALGO.Shape.prototype.__defineGetter__("radius",function(){return this.radius_}),ALGO.Shape.prototype.__defineSetter__("radius",function(t){this.setScale(this.scale),this.radius_=t}),ALGO.Shape.prototype.__defineGetter__("color",function(){return this.color_}),ALGO.Shape.prototype.__defineSetter__("color",function(t){this.setVertexColor(t,this.vertexColors),this.color_=t}),ALGO.Shape.prototype.__defineGetter__("alpha",function(){return this.alpha_}),ALGO.Shape.prototype.__defineSetter__("alpha",function(t){this.setVertexAlpha(t,this.vertexColors),this.alpha_=t}),ALGO.Shape.prototype.__defineGetter__("lineColor",function(){return this.lineColor_}),ALGO.Shape.prototype.__defineSetter__("lineColor",function(t){this.setVertexColor(t,this.vertexLineColors),this.lineColor_=t}),ALGO.Shape.prototype.__defineGetter__("lineAlpha",function(){return this.lineAlpha_}),ALGO.Shape.prototype.__defineSetter__("lineAlpha",function(t){this.setVertexAlpha(t,this.vertexLineColors),this.lineAlpha_=t}),ALGO.Shape.prototype.__defineGetter__("angle",function(){return this.angle_}),ALGO.Shape.prototype.__defineSetter__("angle",function(t){this.angle_=t}),ALGO.Shape.prototype.__defineGetter__("needsUpdate",function(){return this.needsUpdate_}),ALGO.Shape.prototype.__defineSetter__("needsUpdate",function(t){this.needsUpdate_=t}),ALGO.Polygon=function(t,e,n,i){"use strict";this.x=t,this.y=e,this.angles=n,this.radius=i,this.angles_=n,this.radius_=i,this.type="polygon",this.init(),this.setup()},ALGO.Polygon.prototype=Object.create(ALGO.Shape.prototype),ALGO.Polygon.prototype.constructor=ALGO.Polygon,ALGO.Polygon.prototype.setGeometry=function(){for(var t=0;t2&&(t=0)}},ALGO.Circle=function(t,e,n){"use strict";this.x=t,this.y=e,this.angles=ALGO.circleResolution,this.radius=n,this.angles_=ALGO.circleResolution,this.radius_=n,this.type="circle",this.init(),this.setup()},ALGO.Circle.prototype=Object.create(ALGO.Polygon.prototype),ALGO.Circle.prototype.constructor=ALGO.Circle,ALGO.Rectangle=function(t,e,n,i){"use strict";this.x=t,this.y=e,this.width=n,this.height=i,this.width_=n,this.height_=i,this.type="rectangle",this.init(),this.setup()},ALGO.Rectangle.prototype=Object.create(ALGO.Shape.prototype),ALGO.Rectangle.prototype.constructor=ALGO.Rectangle,ALGO.Rectangle.prototype.width=0,ALGO.Rectangle.prototype.height=0,ALGO.Rectangle.prototype.width_=0,ALGO.Rectangle.prototype.height_=0,ALGO.Rectangle.prototype.setScale=function(t){if(this.m){var e=.5*this.width*t,n=.5*this.height*t;this.m.scale(this.matrix,[e,n,0],this.matrixScale)}},ALGO.Rectangle.prototype.setGeometry=function(){var t=this.geometry=[];t[0]=[],t[0].x=-1,t[0].y=1,t[1]=[],t[1].x=1,t[1].y=1,t[2]=[],t[2].x=-1,t[2].y=-1,t[3]=[],t[3].x=1,t[3].y=-1},ALGO.Rectangle.prototype.setIndex=function(){var t=[0,1,2,3,2,1];this.index=t},ALGO.Rectangle.prototype.__defineGetter__("width",function(){return this.width_}),ALGO.Rectangle.prototype.__defineSetter__("width",function(t){this.width_=t,this.setScale(this.scale)}),ALGO.Rectangle.prototype.__defineGetter__("height",function(){return this.height_}),ALGO.Rectangle.prototype.__defineSetter__("height",function(t){this.height_=t,this.setScale(this.scale)}),ALGO.Path=function(t,e){"use strict";this.start=t,this.end=e,this.type="path",this.holes=[],this.triangles=null,this.init(),this.setup(),this.initLine()},ALGO.Path.prototype=Object.create(ALGO.Shape.prototype),ALGO.Path.prototype.constructor=ALGO.Path,ALGO.Path.prototype.closed=!1,ALGO.Path.prototype.holes=[],ALGO.Path.prototype.triangles=null,ALGO.Path.prototype.setGeometry=function(){},ALGO.Path.prototype.geometryToPoly=function(t,e){for(var n,i,r=[],o=t.length,s=e,a=0;o>a;a++){var u=t[a].x,h=t[a].y;if(n!==u||i!==h){var l={x:u,y:h,id:s};r.push(l),n=u,i=h,s++}}return r},ALGO.Path.prototype.setIndex=function(){this.index=[],this.index=earcut(this.geometry,this.hole,1)},ALGO.Path.prototype.setIndex_poly2tri=function(){var t=(this.index=[],this.geometry.length);if(t>2){var e=this.geometryToPoly(this.geometry,0),n=new poly2tri.SweepContext(e,{cloneArrays:!0}),i=this.holes.length,r=e.length;for(l=0;i>l;l++){var o=this.holes[l],s=this.geometryToPoly(o,r);e=e.concat(s),r+=s.length,n.addHole(s)}this.geometry=e;var a=n.triangulate(),u=a.getTriangles()||[];this.triangles=u;for(var h=[],l=0;ln;n++){switch(e){case 0:this.textureCoord.push(1),this.textureCoord.push(0);break;case 1:this.textureCoord.push(0),this.textureCoord.push(1);break;case 2:this.textureCoord.push(1),this.textureCoord.push(1)}e++,e>2&&(e=0)}},ALGO.Path.prototype.setScale=function(t){if(this.m){var e=t,n=t;this.m.scale(this.matrix,[e,n,0],this.matrixScale)}},ALGO.Path.prototype.initLine=function(){var t=this.start,e=this.end;t&&this.moveTo(t.x,t.y),e&&this.lineTo(e.x,e.y)},ALGO.Path.prototype.moveTo=function(t,e){var n={x:t,y:e};this.geometry.push(n),this.vertexUpdate()},ALGO.Path.prototype.lineTo=function(t,e){var n={x:t,y:e};this.geometry.push(n),this.vertexUpdate()},ALGO.Path.prototype.close=function(){this.closed=!0},ALGO.Path.prototype.clear=function(){this.geometry=[],this.vertexPosition=[],this.vertexColors=[],this.vertexLineColors=[],this.setVertexPosition(),this.setVertexColor(this.color,this.vertexColors),this.setVertexAlpha(this.alpha,this.vertexColors),this.setVertexColor(this.lineColor,this.vertexLineColors),this.setVertexAlpha(this.lineAlpha,this.vertexLineColors),this.setIndex(),this.setTextureCoord(),this.setScale(this.scale),this.setRotate(this.rotate),this.setTranslate(this.x,this.y),this.closed=!1},ALGO.Particle=function(t,e){"use strict";this.x=t,this.y=e,this.angles=10,this.angles_=10,this.radius=100,this.radius_=100,this.type="particle",this.init(),this.setup()},ALGO.Particle.prototype=Object.create(ALGO.Shape.prototype),ALGO.Particle.prototype.constructor=ALGO.Particle,ALGO.Particle.prototype.pointsize=1,ALGO.Particle.prototype.setGeometry=function(t){t&&(this.geometry=t,this.vertexUpdate())},ALGO.Particle.prototype.setIndex=function(){},ALGO.Particle.prototype.setTextureCoord=function(){var t=this.geometry.length;this.textureCoord=[0,0];for(var e=0,n=0;t>n;n++){switch(e){case 0:this.textureCoord.push(1),this.textureCoord.push(0);break;case 1:this.textureCoord.push(0),this.textureCoord.push(1);break;case 2:this.textureCoord.push(1),this.textureCoord.push(1)}e++,e>2&&(e=0)}},ALGO.Particle.prototype.setScale=function(t){if(this.m){var e=t,n=t;this.m.scale(this.matrix,[e,n,0],this.matrixScale)}},ALGO.Image=function(t,e,n,i,r){"use strict";this.path=r,this.x=t,this.y=e,this.width=n,this.height=i,this.mipmap=0;var o=this;this.width_=n,this.height_=i,this.mipmap_=this.mipmap,this.color=16777215,this.type="image",this.isLoaded=!1,this.isAttached=!1,this.texture=null,this.path&&(this.image=new Image,this.image.src=this.path,this.loader=new ALGO.Loader(this.path),this.loader.complete=function(t){o.complete(t)},this.loader.get()),this.init(),this.setup()},ALGO.Image.prototype=Object.create(ALGO.Rectangle.prototype),ALGO.Image.prototype.constructor=ALGO.Image,ALGO.Image.prototype.isLoaded=!1,ALGO.Image.prototype.texture=null,ALGO.Image.prototype.mipmap=0,ALGO.Image.prototype.mipmap_=0,ALGO.Image.prototype.complete=function(){this.isLoaded=!0,delete this.loader},ALGO.Image.prototype.getTexture=function(){return this.texture},ALGO.Image.prototype.setTexture=function(t){this.texture=t},ALGO.Image.prototype.setLoaded=function(t){this.isLoaded=t},ALGO.Image.prototype.setScale=function(t){if(this.m){var e=.5*this.width*t,n=.5*this.height*-t;this.m.scale(this.matrix,[e,n,0],this.matrixScale)}},ALGO.Image.prototype.__defineGetter__("mipmap",function(){return this.mipmap_}),ALGO.Image.prototype.__defineSetter__("mipmap",function(t){this.mipmap_=t}),ALGO.SVG=function(){"use strict";function t(){}function e(t){var e=new ALGO.Loader(t);e.get(),e.complete=function(t){var e=t.status,i=t.responseText;if(e>=200&&300>e){var r=o(i),s=n(r);if(s&&p.always){var a={verticles:s};p.always(a)}}}}function n(t){for(var e=t.childNodes,n=0;nd;d++){var x=u[d],y=x[0],g=y.toLowerCase(),i=x.match(/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g),v=i&&i.length;switch(h=y===g,"z"===r&&(/[mz]/.test(g)||ALGO.log("TEST TRUE")),g){case"m":case"l":for(var m=0;v>m;m+=2)l=n(m),ALGO.log("setx: "+l.x+", sety: "+l.y),p.push({x:l.x,y:l.y});break;case"h":case"v":for(var _="h"===g?"x":"y",m=0;v>m;m++)l[_]=e(m,_),ALGO.log("setx: "+l.x+", sety: "+l.y),p.push({x:l.x,y:l.y});break;case"c":for(var m=0;v>m;m+=6){var A=n(m),L=o=n(m+2),C=l;l=n(m+4);for(var w=s(C.x,C.y,A.x,A.y,L.x,L.y,l.x,l.y),O=1;Om;m+=4){var L=l;if(/[cs]/.test(r)){var b=2*l.x-o.x,G=2*l.y-o.y;L={x:b,y:G}}var A=o=n(m),C=l;l=n(m+2);for(var w=s(C.x,C.y,L.x,L.y,A.x,A.y,l.x,l.y),O=1;Om;m+=4)o=n(m),l=n(m+2),ALGO.log("setx: "+l.x+", sety: "+l.y),p.push({x:l.x,y:l.y});break;case"t":for(var m=0;v>m;m+=2)o=/[qt]/.test(r)?l.multiply(2).subtract(o):l,l=n(m),r=g;break;case"a":for(var m=0;v>m;m+=7)l=n(m+5),ALGO.log("setx: "+l.x+", sety: "+l.y),p.push({x:l.x,y:l.y});break;case"z":p.splice(p.length-1,1),c.push(p),ALGO.log("z end."),p=[]}r=g}return c}function o(t){if("undefined"!=typeof Windows&&"undefined"!=typeof Windows.Data&&"undefined"!=typeof Windows.Data.Xml){var e=new Windows.Data.Xml.Dom.XmlDocument,n=new Windows.Data.Xml.Dom.XmlLoadSettings;return n.prohibitDtd=!1,e.loadXml(t,n),e}if(window.DOMParser){var i=new DOMParser;return i.parseFromString(t,"text/xml")}t=t.replace(/]*>/,"");var e=new ActiveXObject("Microsoft.XMLDOM");return e.async="false",e.loadXML(t),e}function s(t,e,n,i,r,o,s,u){for(var h=[],l=0;1.01>=l;l+=.05)h.push(a({x:t,y:e},{x:n,y:i},{x:r,y:o},{x:s,y:u},l));return h}function a(t,e,n,i,r){var o={x:0,y:0},s=(1-r)*(1-r)*(1-r);return o.x+=s*t.x,o.y+=s*t.y,s=3*r*(1-r)*(1-r),o.x+=s*e.x,o.y+=s*e.y,s=3*r*r*(1-r),o.x+=s*n.x,o.y+=s*n.y,s=r*r*r,o.x+=s*i.x,o.y+=s*i.y,o}function u(){}function h(){}function l(t,e){this[t]=e}function c(t,e){p[t]=null}var p,d=[];return ALGO.SVG=function(){t(),p=this},ALGO.SVG.prototype={constructor:ALGO.SVG,load:e,bind:l,unbind:c,complete:u,always:h},ALGO.SVG}(),ALGO.WebGLRenderer=function(t){"use strict";function e(t){var e=!1;y=t,a(y),y.backgroundAuto||(e=!0);var n={preserveDrawingBuffer:e};g=w.getContext("webgl",n)||w.getContext("experimental-webgl",n);var o=c("vertex"),s=c("fragment");v=p(o,s),r(),C={},C.position=g.getUniformLocation(v,"position2d"),C.matrix=g.getUniformLocation(v,"matrix2d"),C.color=g.getUniformLocation(v,"color"),C.texture=g.getUniformLocation(v,"texture"),C.point_size=g.getUniformLocation(v,"point_size"),C.isTexture=g.getUniformLocation(v,"isTexture"),m={},m.position=g.getAttribLocation(v,"position2d"),m.color=g.getAttribLocation(v,"color"),m.texture_coord=g.getAttribLocation(v,"texture_coord"),_={},_.position=2,_.color=4,_.texture_coord=2,i()}function n(t,e){return[2/t,0,0,0,-2/e,0,-1,1,1]}function i(){for(var e=new t.Matrix3,i=n(A,L),r=0;r0&&g.enable(g.BLEND),e==t.BLEND_ADD?g.blendFunc(g.SRC_ALPHA,g.ONE):e==t.BLEND_MULTIPLY?g.blendFunc(g.DST_COLOR,g.ZERO):e==t.BLEND_SCREEN?g.blendFunc(g.ONE_MINUS_DST_COLOR,g.ONE):e==t.BLEND_ALPHA&&g.blendFunc(g.SRC_ALPHA,g.ONE_MINUS_SRC_ALPHA)}function c(t){var e,n="";return"vertex"==t?(n="\r\n attribute vec2 position2d;\r\n uniform mat3 matrix2d;\r\n uniform vec2 u_resolution;\r\n attribute vec4 color;\r\n varying vec4 v_color; \r\n attribute vec2 texture_coord;\r\n varying vec2 v_texture_coord;\r\n uniform float point_size;\r\n varying float vIsTexture;\r\n uniform float isTexture;\r\n \r\n void main(void){\r\n if(isTexture>0.5){\r\n v_texture_coord = texture_coord;\r\n vIsTexture = isTexture;\r\n }\r\n v_color = color;\r\n gl_PointSize = point_size;\r\n \r\n gl_Position = vec4((matrix2d * vec3(position2d, 1)).xy, 0, 1);\r\n }",e=g.createShader(g.VERTEX_SHADER)):"fragment"==t&&(n="\r\n precision mediump float;\r\n varying vec4 v_color;\r\n uniform sampler2D texture;\r\n varying vec2 v_texture_coord;\r\n varying float vIsTexture;\r\n \r\n void main(void){\r\n if(vIsTexture > 0.5){\r\n vec4 smp_color = texture2D(texture, v_texture_coord);\r\n gl_FragColor = v_color * smp_color;\r\n }\r\n else{\r\n gl_FragColor = v_color;\r\n }\r\n }",e=g.createShader(g.FRAGMENT_SHADER)),g.shaderSource(e,n),g.compileShader(e),g.getShaderParameter(e,g.COMPILE_STATUS)?e:void alert(g.getShaderInfoLog(e))}function p(t,e){var n=g.createProgram();return g.attachShader(n,t),g.attachShader(n,e),g.linkProgram(n),g.getProgramParameter(n,g.LINK_STATUS)?(g.useProgram(n),n):void alert(g.getProgramInfoLog(n))}function d(t){var e=g.createBuffer();return g.bindBuffer(g.ARRAY_BUFFER,e),g.bufferData(g.ARRAY_BUFFER,new Float32Array(t),g.STATIC_DRAW),g.bindBuffer(g.ARRAY_BUFFER,null),e}function f(t){var e=g.createBuffer();return g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,e),g.bufferData(g.ELEMENT_ARRAY_BUFFER,new Int16Array(t),g.STATIC_DRAW),g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,null),e}function x(t,e,n){for(var i in t)g.bindBuffer(g.ARRAY_BUFFER,t[i]),g.enableVertexAttribArray(e[i]),g.vertexAttribPointer(e[i],n[i],g.FLOAT,!1,0,0)}var y,g,v,m,_,A,L,C,w,O,b,G,T,E,S=[],P=[],R=[],D=[],N=0;return t.WebGLRenderer=function(t){e(t)},t.WebGLRenderer.prototype={constructor:t.WebGLRenderer,init:e,update:s, resize:r,getContext:o},t.WebGLRenderer}(ALGO),ALGO.Sound=function(t){"use strict";function e(){var e=this,n=t.Util.getBrowser(),i=t.Util.isSmartDevice(),r=null;"chrome"==n||"firefox"==n||"opera"==n?r=this.ogg:"safari"==n&&(r=this.mp3);var o=localStorage;this.isInitplay=Number(o.stopped)?!1:!0,i&&(this.isInitplay=!1);var s=new AudioContext,a=s.createAnalyser();a.connect(s.destination);var u=s.createBiquadFilter();u.connect(s.destination),u.type="allpass",u.frequency.value=220,s.createGain=s.createGain||s.createGainNode;var h=s.createGain();h.connect(a);var l=new Uint8Array(a.frequencyBinCount),c=new Uint8Array(a.frequencyBinCount),p=new BufferLoader(s,[r],function(t){e.finishedLoading(t)});p.load(),this.context=s,this.analyser=a,this.gainNode=h,this.filter=u,this.timeDomainData=l,this.frequencyData=c,this.bufferLoader=p}function n(){}function i(t){this.buffers=t,this.isInitplay&&this.play(0)}function r(){this.updateFFT(),this.updateNotes()}function o(){this.analyser.getByteTimeDomainData(this.timeDomainData),this.analyser.getByteFrequencyData(this.frequencyData),this.timeDomainTotal=0,this.timeDomainValues=[],this.frequencyTotal=0,this.frequencyValues=[];for(var t=this.timeDomainData.length,e=0;t>e;e++)this.timeDomainValues[e]=parseInt(this.timeDomainData[e])/255,this.timeDomainTotal+=this.timeDomainValues[e],this.frequencyValues[e]=parseInt(this.frequencyData[e])/255,this.frequencyTotal+=this.frequencyValues[e];this.timeDomainTotal=this.timeDomainTotal/t,this.frequencyTotal=this.frequencyTotal/t}function s(){var t=1e3*(this.context.currentTime-this.currentTimeBefore);this.noteCount+=t,this.noteHalfCount+=t,this.noteCount>=this.noteTime&&(this.noteCount=0,this.noteEvent(this.context.currentTime)),this.noteHalfCount>=this.noteHalfTime&&(this.noteHalfCount=0,this.halfNoteEvent(this.context.currentTime)),this.currentTimeBefore=this.context.currentTime}function a(){this.startTime=this.context.currentTime,this.source=this.context.createBufferSource(),this.source.buffer=this.buffers[0],this.source.loop=!0,this.source.connect(this.filter),this.source.connect(this.gainNode),t.log(this.source),this.gainNode.gain.value=this.volume,this.source.start(0),this.isPlay=!0;try{localStorage.stopped=0}catch(e){}}function u(){this.source.stop(0),this.isPlay=!1;try{localStorage.stopped=1}catch(t){}}function h(){var t=this.context.currentTime-this.startTime;return null==this.startTime&&(t=0),t}function l(){return this.noteTime}function c(){return this.isPlay}function p(){return this.timeDomainValues}function d(){return this.timeDomainTotal}function f(){return this.frequencyValues}function x(){return this.frequencyTotal}function y(t,e){for(var n=Math.floor(t.length/e),i=[],r=0;n>r;r++){var o=n*r,s=n*(r+1);i[r]=0;for(var a=o;s>a;a++)t[a]&&(i[r]+=t[a])}return i}return t.Sound=function(t,e,n){this.mp3=t,this.ogg=e,this.bpm=n,this.noteTime=6e4/this.bpm,this.noteHalfTime=.5*this.noteTime,window.AudioContext=window.AudioContext||window.webkitAudioContext,window.AudioContext?this.startLoading():this.startNotAvarableMode()},t.Sound.prototype={constructor:t.Sound,bpm:0,noteTime:0,noteHalfTime:0,noteCount:0,noteHalfCount:0,currentTimeBefore:0,mp3:"",ogg:"",context:null,analyser:null,gainNode:null,filter:null,bufferLoader:null,source:null,buffers:null,pauseTime:0,startTime:null,isPlay:!1,volume:1,isInitplay:0,timeDomainData:null,timeDomainTotal:0,timeDomainValues:[],frequencyData:null,frequencyTotal:0,frequencyValues:[],noteEvent:function(){},halfNoteEvent:function(){},play:a,stop:u,update:r,getCurrentTime:h,getNoteTime:l,getPlay:c,getTimeDomainValues:p,getTimeDomainTotal:d,getFrequencyValues:f,getFrequencyTotal:x,getSplitValues:y,startLoading:e,startNotAvarableMode:n,finishedLoading:i,updateFFT:o,updateNotes:s},t.Sound}(ALGO),ALGO.RTC=function(t){"use strict";function e(t){this.mediaStream=t,this.audioContext=new AudioContext,this.audioSource=this.audioContext.createMediaStreamSource(this.mediaStream),this.setupAudioAnalazer(),this.setupVideoRecorder()}function n(){this.audioFilter=this.audioContext.createBiquadFilter(),this.audioFilter.type="allpass",this.audioFilter.frequency.value=220,this.audioAnalyser=this.audioContext.createAnalyser(),this.audioSource.connect(this.audioFilter),this.audioFilter.connect(this.audioAnalyser),this.timeDomainData=new Uint8Array(this.audioAnalyser.frequencyBinCount),this.frequencyData=new Uint8Array(this.audioAnalyser.frequencyBinCount)}function i(){var e=window.URL||window.webkitURL;this.videoSource=e.createObjectURL(this.mediaStream),t.log(this.mediaStream),t.log(this.videoSource),this.videoElement=document.createElement("video"),this.videoElement.src=this.videoSource,this.videoElement.id="video",this.videoElement.muted=!0,this.videoElement.volume=0;var n=this;this.videoElement.addEventListener("canplay",function(t){n.videoCanPlay(t)},!0)}function r(t){this.videoElement.removeEventListener("canplay",null,!0),this.videoElement.play(),this.isPlaying=!0}function o(){this.enableAudio&&this.updateAudio(),this.enableVideo&&this.updateVideo()}function s(){this.audioAnalyser&&this.updateAudioAnalazer()}function a(){this.audioAnalyser.getByteTimeDomainData(this.timeDomainData),this.audioAnalyser.getByteFrequencyData(this.frequencyData),this.timeDomainTotal=0,this.timeDomainValues=[],this.frequencyTotal=0,this.frequencyValues=[];for(var t=this.frequencyData.length,e=0;t>e;e++)this.timeDomainValues[e]=parseInt(this.timeDomainData[e])/255,this.timeDomainTotal+=this.timeDomainValues[e],this.frequencyValues[e]=parseInt(this.frequencyData[e])/255,this.frequencyTotal+=this.frequencyValues[e];this.timeDomainTotal=this.timeDomainTotal/t,this.frequencyTotal=this.frequencyTotal/t}function u(){}function h(t,e){if(!this.videoElement)return!1;var n=document.createElement("canvas"),i=n.getContext("2d"),r=t,o=e;n.width=r,n.height=o,i.drawImage(this.videoElement,0,0,r,o);var s=i.getImageData(0,0,r,o);return s}function l(t){this.opticalFlow=new FlowCalculator(t)}function c(t,e,n){var i;return this.newImage=t,this.oldImage&&this.newImage&&(i=this.opticalFlow.calculate(this.oldImage,this.newImage,e,n)),this.oldImage=this.newImage,i}function p(){return this.timeDomainValues}function d(){return this.timeDomainTotal}function f(){return this.frequencyValues}function x(){return this.frequencyTotal}function y(t){this.enableAudio=t}function g(t){this.enableVideo=t}return t.RTC=function(e,n){var i=this;this.enableAudio=e,this.enableVideo=n,this.isPlaying=!1,navigator.getMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.msAudioContext,window.Recorder=window.StereoRecorder||window.MediaStreamRecorder;try{navigator.getMedia({video:!0,audio:!0},function(t){i.success(t)},function(t){i.error(t)})}catch(r){t.log("This browser is not support getUserMedia API. "+r)}},t.RTC.prototype={constructor:t.RTC,enableAudio:!1,enableVideo:!1,videoElement:null,frequencyValues:[],frequencyTotal:0,timeDomainValues:[],timeDomainTotal:0,mediaStream:null,audioContext:null,audioSource:null,audioFilter:null,audioAnalyser:null,timeDomainData:null,frequencyData:null,videoSource:null,isPlaying:!1,update:o,getTimeDomainValues:p,getTimeDomainTotal:d,getFrequencyValues:f,getFrequencyTotal:x,setEnableAudio:y,setEnableVideo:g,readVideoPixels:h,setupOpticalFlow:l,updateOpticalFlow:c,success:e,setupAudioAnalazer:n,setupVideoRecorder:i,videoCanPlay:r,updateAudio:s,updateVideo:u,updateAudioAnalazer:a},t.RTC}(ALGO),ALGO.log=function(){window.console&&window.console.log&&ALGO.debug&&window.console.log.apply(console,arguments)},ALGO.warn=function(){window.console&&window.console.log&&ALGO.debug&&window.console.warn.apply(console,arguments)},ALGO.error=function(){window.console&&window.console.log&&ALGO.debug&&window.console.error.apply(console,arguments)},ALGO.PointUtil={normalize:function(t,e){var n=Math.sqrt(t.x*t.x+t.y*t.y);0!=n&&(t.x=e*t.x/n,t.y=e*t.y/n)},normalize3:function(t,e){var n=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z);return 0!=n&&(t.x=e*t.x/n,t.y=e*t.y/n,t.z=e*t.z/n),t},pointLength3:function(t){return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z)},getDistance:function(t,e){var n=e.x-t.x,i=e.y-t.y;return Math.sqrt(n*n+i*i)},getSlope:function(t,e){return(e.y-t.y)/(e.x-t.x)},getIntercept:function(t,e,n){var i=t.x+e.x,r=t.y+e.y;return r/2-n*i/2},getMidpoint:function(t,e){var n=[];return n.x=(t.x+e.x)/2,n.y=(t.y+e.y)/2,n},getMidperpendicular:function(t,e){var n=getSlope(t,e);x=checkEQ(n)?1:-1/n;var i=getMidpoint(t,e);return y=checkEQ(n)?0:i.y-x*i.x,{x:x,y:y}},getThroughPoint3:function(t,e,n){var i=getMidperpendicular(t,e),r=getMidperpendicular(t,n),o=[];o.x=(r.y-i.y)/(i.x-r.x),o.y=i.x*o.x+i.y;var s=Math.sqrt(Math.pow(o.x-t.x,2)+Math.pow(o.y-t.y,2));return{x:o.x,y:o.y,rad:s}},getHugeTriangle:function(t,e,n){var i=getThroughPoint3(t,e,n),r=i.x-Math.sqrt(3)*i.rad,o=i.y-i.rad,s=i.x+Math.sqrt(3)*i.rad,a=i.y-i.rad,u=i.x,h=i.y+2*i.rad;return[{x:r,y:o},{x:s,y:a},{x:u,y:h}]},checkEQ:function(t){var e=1e-6;return t>=-e&&e>=t}},ALGO.StringUtil={zeroPadding:function(t,e){return(Array(e).join("0")+t).slice(-e)},numComma:function(t){return String(t).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,")},separate:function(t){return String(t).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,")}},ALGO.ObjectUtil={extend:function(t,e){ALGO.ObjectUtil.clone(t);for(key in e){var n=void 0!=e[key]?e[key]:t[key];t[key]=n}return t},clone:function(t){var e={};for(key in t)e[key]=t[key];return e}},ALGO.ColorUtil={rgbToHex:function(t,e,n){t=Math.floor(t),e=Math.floor(e),n=Math.floor(n);var i=(t<<16)+(e<<8)+n;return"0x"+i.toString(16)},hexToRgb:function(t){t=t.toString(16).replace("#","").replace("0x",""),t="0x"+t;var e={r:t>>16,g:t>>8&255,b:255&t};return e},hexToRgbNormalize:function(t){var e=ALGO.ColorUtil.hexToRgb(t);return e.r=e.r/256,e.g=e.g/256,e.b=e.b/256,e},rgbNormalize:function(t){return t.r=t.r/256,t.g=t.g/256,t.b=t.b/256,t},rgbToHsv:function(t,e,n,i){var r,o,s,a=Math.max(Math.max(t,e),n),u=Math.min(Math.min(t,e),n);for(r=a==u?0:a==t?60*(e-n)/(a-u)+0:a==e?60*(n-t)/(a-u)+120:60*(t-e)/(a-u)+240;0>r;)r+=360;return o=i?a-u:0==a?0:(a-u)/a*255,s=a,{h:r,s:o,v:s}},hsvToRgb:function(t,e,n){for(var i,r,o;0>t;)t+=360;if(t%=360,0==e)return n=Math.round(n),{r:n,g:n,b:n};e/=255;var s=Math.floor(t/60)%6,a=t/60-s,u=n*(1-e),h=n*(1-a*e),l=n*(1-(1-a)*e);switch(s){case 0:i=n,r=l,o=u;break;case 1:i=h,r=n,o=u;break;case 2:i=u,r=n,o=l;break;case 3:i=u,r=h,o=n;break;case 4:i=l,r=u,o=n;break;case 5:i=n,r=u,o=h}return{r:Math.round(i),g:Math.round(r),b:Math.round(o)}},getRandomColorHex:function(){var t=ALGO.ColorUtil.getRandomColor(0,256),e=ALGO.ColorUtil.getRandomColor(0,256),n=ALGO.ColorUtil.getRandomColor(0,256);return ALGO.ColorUtil.rgbToHex(t,e,n)},getRandomColorHexLight:function(){var t=ALGO.ColorUtil.getRandomColor(0,256),e=ALGO.ColorUtil.getRandomColor(0,256),n=ALGO.ColorUtil.getRandomColor(0,256);return ALGO.ColorUtil.rgbToHex(t,e,n)},getRandomColorRGB:function(){var t=ALGO.ColorUtil.getRandomColor(0,256),e=ALGO.ColorUtil.getRandomColor(0,256),n=ALGO.ColorUtil.getRandomColor(0,256);return{r:t,g:e,b:n}},getRandomColor:function(t,e){return 0>t&&(t=0),e>256&&(e=256),t>e&&(t=e),t>e&&(e=t),e++,Math.floor(Math.random()*(e-t))+t}},ALGO.Util={getPixelsIndex:function(t,e,n){},getBrowserLang:function(){var t=window.navigator.userAgent.toLowerCase();try{return-1!=t.indexOf("chrome")?(navigator.languages[0]||navigator.browserLanguage||navigator.language||navigator.userLanguage).substr(0,2):(navigator.browserLanguage||navigator.language||navigator.userLanguage).substr(0,2)}catch(e){return void 0}},isSmartDevice:function(){var t=navigator.userAgent,e=!1;return t.indexOf("iPhone")>0&&-1==t.indexOf("iPad")||t.indexOf("iPod")>0||t.indexOf("Android")>0&&t.indexOf("Mobile")>0?e="smartphone":(t.indexOf("iPad")>0||t.indexOf("Android")>0)&&(e="tablet"),e},getOS:function(){var t,e=window.navigator.userAgent.toLowerCase();return t=e.match(/win/)?"win":e.match(/mac|ppc/)?"mac":e.match(/linux/)?"linux":"other"},getBrowser:function(){var t=window.navigator.userAgent.toLowerCase(),e=window.navigator.appVersion.toLowerCase(),n="unknown";return-1!=t.indexOf("msie")?n=-1!=e.indexOf("msie 6.")?"ie6":-1!=e.indexOf("msie 7.")?"ie7":-1!=e.indexOf("msie 8.")?"ie8":-1!=e.indexOf("msie 9.")?"ie9":-1!=e.indexOf("msie 10.")?"ie10":"ie":-1!=t.indexOf("trident/7")?n="ie11":-1!=t.indexOf("chrome")?n="chrome":-1!=t.indexOf("safari")?n="safari":-1!=t.indexOf("opera")?n="opera":-1!=t.indexOf("firefox")&&(n="firefox"),n},isSupported:function(t){for(var e=getBrowser(),n=0;n0){var o=e[i].substring(0,r),s=e[i].substring(r+1);n[o]=s}}return n}};