text: (function(e,t){if(typeof define==="function"&&define.amd){define(["exports"],t)}else if(typeof exports==="object"){t(exports)}else{t(e.commonJsStrict={})}})(this,function(e){function t(e,t,n){this.obj=e;this.left=null;this.right=null;this.parent=n;this.dimension=t}function n(e,n,i){function o(e,n,r){var s=n%i.length,u,a;if(e.length===0){return null}if(e.length===1){return new t(e[0],s,r)}e.sort(function(e,t){return e[i[s]]-t[i[s]]});u=Math.floor(e.length/2);a=new t(e[u],s,r);a.left=o(e.slice(0,u),n+1,a);a.right=o(e.slice(u+1),n+1,a);return a}function u(e){function t(e){if(e.left){e.left.parent=e;t(e.left)}if(e.right){e.right.parent=e;t(e.right)}}s.root=e;t(s.root)}var s=this;if(!Array.isArray(e))u(e,n,i);else this.root=o(e,0,null);this.toJSON=function(e){if(!e)e=this.root;var n=new t(e.obj,e.dimension,null);if(e.left)n.left=s.toJSON(e.left);if(e.right)n.right=s.toJSON(e.right);return n};this.insert=function(e){function n(t,r){if(t===null){return r}var s=i[t.dimension];if(e[s]<t.obj[s]){return n(t.left,t)}else{return n(t.right,t)}}var r=n(this.root,null),s,o;if(r===null){this.root=new t(e,0,null);return}s=new t(e,(r.dimension+1)%i.length,r);o=i[r.dimension];if(e[o]<r.obj[o]){r.left=s}else{r.right=s}};this.remove=function(e){function n(t){if(t===null){return null}if(t.obj===e){return t}var r=i[t.dimension];if(e[r]<t.obj[r]){return n(t.left,t)}else{return n(t.right,t)}}function r(e){function u(e,t){var n,r,s,o,a;if(e===null){return null}n=i[t];if(e.dimension===t){if(e.right!==null){return u(e.right,t)}return e}r=e.obj[n];s=u(e.left,t);o=u(e.right,t);a=e;if(s!==null&&s.obj[n]>r){a=s}if(o!==null&&o.obj[n]>a.obj[n]){a=o}return a}function a(e,t){var n,r,s,o,u;if(e===null){return null}n=i[t];if(e.dimension===t){if(e.left!==null){return a(e.left,t)}return e}r=e.obj[n];s=a(e.left,t);o=a(e.right,t);u=e;if(s!==null&&s.obj[n]<r){u=s}if(o!==null&&o.obj[n]<u.obj[n]){u=o}return u}var t,n,o;if(e.left===null&&e.right===null){if(e.parent===null){s.root=null;return}o=i[e.parent.dimension];if(e.obj[o]<e.parent.obj[o]){e.parent.left=null}else{e.parent.right=null}return}if(e.left!==null){t=u(e.left,e.dimension)}else{t=a(e.right,e.dimension)}n=t.obj;r(t);e.obj=n}var t;t=n(s.root);if(t===null){return}r(t)};this.nearest=function(e,t,o){function l(r){function d(e,n){f.push([e,n]);if(f.size()>t){f.pop()}}var s,o=i[r.dimension],u=n(e,r.obj),a={},c,h,p;for(p=0;p<i.length;p+=1){if(p===r.dimension){a[i[p]]=e[i[p]]}else{a[i[p]]=r.obj[i[p]]}}c=n(a,r.obj);if(r.right===null&&r.left===null){if(f.size()<t||u<f.peek()[1]){d(r,u)}return}if(r.right===null){s=r.left}else if(r.left===null){s=r.right}else{if(e[o]<r.obj[o]){s=r.left}else{s=r.right}}l(s);if(f.size()<t||u<f.peek()[1]){d(r,u)}if(f.size()<t||Math.abs(c)<f.peek()[1]){if(s===r.left){h=r.right}else{h=r.left}if(h!==null){l(h)}}}var u,a,f;f=new r(function(e){return-e[1]});if(o){for(u=0;u<t;u+=1){f.push([null,o])}}l(s.root);a=[];for(u=0;u<t;u+=1){if(f.content[u][0]){a.push([f.content[u][0].obj,f.content[u][1]])}}return a};this.balanceFactor=function(){function e(t){if(t===null){return 0}return Math.max(e(t.left),e(t.right))+1}function t(e){if(e===null){return 0}return t(e.left)+t(e.right)+1}return e(s.root)/(Math.log(t(s.root))/Math.log(2))}}function r(e){this.content=[];this.scoreFunction=e}r.prototype={push:function(e){this.content.push(e);this.bubbleUp(this.content.length-1)},pop:function(){var e=this.content[0];var t=this.content.pop();if(this.content.length>0){this.content[0]=t;this.sinkDown(0)}return e},peek:function(){return this.content[0]},remove:function(e){var t=this.content.length;for(var n=0;n<t;n++){if(this.content[n]==e){var r=this.content.pop();if(n!=t-1){this.content[n]=r;if(this.scoreFunction(r)<this.scoreFunction(e))this.bubbleUp(n);else this.sinkDown(n)}return}}throw new Error("Node not found.")},size:function(){return this.content.length},bubbleUp:function(e){var t=this.content[e];while(e>0){var n=Math.floor((e+1)/2)-1,r=this.content[n];if(this.scoreFunction(t)<this.scoreFunction(r)){this.content[n]=t;this.content[e]=r;e=n}else{break}}},sinkDown:function(e){var t=this.content.length,n=this.content[e],r=this.scoreFunction(n);while(true){var i=(e+1)*2,s=i-1;var o=null;if(s<t){var u=this.content[s],a=this.scoreFunction(u);if(a<r)o=s}if(i<t){var f=this.content[i],l=this.scoreFunction(f);if(l<(o==null?r:a)){o=i}}if(o!=null){this.content[e]=this.content[o];this.content[o]=n;e=o}else{break}}}};this.kdTree=n;e.kdTree=n;e.BinaryHeap=r})
  !function(a){function c(a,b,c){this.x=a,this.y=b,this.z=c}function l(a){return a*a*a*(a*(6*a-15)+10)}function m(a,b,c){return(1-c)*a+c*b}var b=a.perlin={};c.prototype.dot2=function(a,b){return this.x*a+this.y*b},c.prototype.dot3=function(a,b,c){return this.x*a+this.y*b+this.z*c};var d=[new c(1,1,0),new c(-1,1,0),new c(1,-1,0),new c(-1,-1,0),new c(1,0,1),new c(-1,0,1),new c(1,0,-1),new c(-1,0,-1),new c(0,1,1),new c(0,-1,1),new c(0,1,-1),new c(0,-1,-1)],e=[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],f=new Array(512),g=new Array(512);b.seed=function(a){a>0&&1>a&&(a*=65536),a=Math.floor(a),256>a&&(a|=a<<8);for(var b=0;256>b;b++){var c;c=1&b?e[b]^255&a:e[b]^255&a>>8,f[b]=f[b+256]=c,g[b]=g[b+256]=d[c%12]}},b.seed(0);var h=.5*(Math.sqrt(3)-1),i=(3-Math.sqrt(3))/6,j=1/3,k=1/6;b.simplex2=function(a,b){var c,d,e,p,q,j=(a+b)*h,k=Math.floor(a+j),l=Math.floor(b+j),m=(k+l)*i,n=a-k+m,o=b-l+m;n>o?(p=1,q=0):(p=0,q=1);var r=n-p+i,s=o-q+i,t=n-1+2*i,u=o-1+2*i;k&=255,l&=255;var v=g[k+f[l]],w=g[k+p+f[l+q]],x=g[k+1+f[l+1]],y=.5-n*n-o*o;0>y?c=0:(y*=y,c=y*y*v.dot2(n,o));var z=.5-r*r-s*s;0>z?d=0:(z*=z,d=z*z*w.dot2(r,s));var A=.5-t*t-u*u;return 0>A?e=0:(A*=A,e=A*A*x.dot2(t,u)),70*(c+d+e)},b.simplex3=function(a,b,c){var d,e,h,i,t,u,v,w,x,y,l=(a+b+c)*j,m=Math.floor(a+l),n=Math.floor(b+l),o=Math.floor(c+l),p=(m+n+o)*k,q=a-m+p,r=b-n+p,s=c-o+p;q>=r?r>=s?(t=1,u=0,v=0,w=1,x=1,y=0):q>=s?(t=1,u=0,v=0,w=1,x=0,y=1):(t=0,u=0,v=1,w=1,x=0,y=1):s>r?(t=0,u=0,v=1,w=0,x=1,y=1):s>q?(t=0,u=1,v=0,w=0,x=1,y=1):(t=0,u=1,v=0,w=1,x=1,y=0);var z=q-t+k,A=r-u+k,B=s-v+k,C=q-w+2*k,D=r-x+2*k,E=s-y+2*k,F=q-1+3*k,G=r-1+3*k,H=s-1+3*k;m&=255,n&=255,o&=255;var I=g[m+f[n+f[o]]],J=g[m+t+f[n+u+f[o+v]]],K=g[m+w+f[n+x+f[o+y]]],L=g[m+1+f[n+1+f[o+1]]],M=.5-q*q-r*r-s*s;0>M?d=0:(M*=M,d=M*M*I.dot3(q,r,s));var N=.5-z*z-A*A-B*B;0>N?e=0:(N*=N,e=N*N*J.dot3(z,A,B));var O=.5-C*C-D*D-E*E;0>O?h=0:(O*=O,h=O*O*K.dot3(C,D,E));var P=.5-F*F-G*G-H*H;return 0>P?i=0:(P*=P,i=P*P*L.dot3(F,G,H)),32*(d+e+h+i)},b.perlin2=function(a,b){var c=Math.floor(a),d=Math.floor(b);a-=c,b-=d,c=255&c,d=255&d;var e=g[c+f[d]].dot2(a,b),h=g[c+f[d+1]].dot2(a,b-1),i=g[c+1+f[d]].dot2(a-1,b),j=g[c+1+f[d+1]].dot2(a-1,b-1),k=l(a);return m(m(e,i,k),m(h,j,k),l(b))},b.perlin3=function(a,b,c){var d=Math.floor(a),e=Math.floor(b),h=Math.floor(c);a-=d,b-=e,c-=h,d=255&d,e=255&e,h=255&h;var i=g[d+f[e+f[h]]].dot3(a,b,c),j=g[d+f[e+f[h+1]]].dot3(a,b,c-1),k=g[d+f[e+1+f[h]]].dot3(a,b-1,c),n=g[d+f[e+1+f[h+1]]].dot3(a,b-1,c-1),o=g[d+1+f[e+f[h]]].dot3(a-1,b,c),p=g[d+1+f[e+f[h+1]]].dot3(a-1,b,c-1),q=g[d+1+f[e+1+f[h]]].dot3(a-1,b-1,c),r=g[d+1+f[e+1+f[h+1]]].dot3(a-1,b-1,c-1),s=l(a),t=l(b),u=l(c);return m(m(m(i,o,s),m(j,p,s),u),m(m(k,q,s),m(n,r,s),u),t)}}(this);
  Date.now===undefined&&(Date.now=function(){return(new Date).valueOf()});var TWEEN=TWEEN||function(){var e=[];return{REVISION:"14",getAll:function(){return e},removeAll:function(){e=[]},add:function(t){e.push(t)},remove:function(t){var n=e.indexOf(t);n!==-1&&e.splice(n,1)},update:function(t){if(e.length===0)return!1;var n=0;t=t!==undefined?t:typeof window!="undefined"&&window.performance!==undefined&&window.performance.now!==undefined?window.performance.now():Date.now();while(n<e.length)e[n].update(t)?n++:e.splice(n,1);return!0}}}();TWEEN.Tween=function(e){var t=e,n={},r={},i={},s=1e3,o=0,u=!1,a=!1,f=!1,l=0,c=null,h=TWEEN.Easing.Linear.None,p=TWEEN.Interpolation.Linear,d=[],v=null,m=!1,g=null,y=null,b=null;for(var w in e)n[w]=parseFloat(e[w],10);this.to=function(e,t){return t!==undefined&&(s=t),r=e,this},this.start=function(e){TWEEN.add(this),a=!0,m=!1,c=e!==undefined?e:typeof window!="undefined"&&window.performance!==undefined&&window.performance.now!==undefined?window.performance.now():Date.now(),c+=l;for(var s in r){if(r[s]instanceof Array){if(r[s].length===0)continue;r[s]=[t[s]].concat(r[s])}n[s]=t[s],n[s]instanceof Array==0&&(n[s]*=1),i[s]=n[s]||0}return this},this.stop=function(){return a?(TWEEN.remove(this),a=!1,b!==null&&b.call(t),this.stopChainedTweens(),this):this},this.stopChainedTweens=function(){for(var e=0,t=d.length;e<t;e++)d[e].stop()},this.delay=function(e){return l=e,this},this.repeat=function(e){return o=e,this},this.yoyo=function(e){return u=e,this},this.easing=function(e){return h=e,this},this.interpolation=function(e){return p=e,this},this.chain=function(){return d=arguments,this},this.onStart=function(e){return v=e,this},this.onUpdate=function(e){return g=e,this},this.onComplete=function(e){return y=e,this},this.onStop=function(e){return b=e,this},this.update=function(e){var a;if(e<c)return!0;m===!1&&(v!==null&&v.call(t),m=!0);var b=(e-c)/s;b=b>1?1:b;var w=h(b);for(a in r){var E=n[a]||0,S=r[a];S instanceof Array?t[a]=p(S,w):(typeof S=="string"&&(S=E+parseFloat(S,10)),typeof S=="number"&&(t[a]=E+(S-E)*w))}g!==null&&g.call(t,w);if(b==1){if(o>0){isFinite(o)&&o--;for(a in i){typeof r[a]=="string"&&(i[a]=i[a]+parseFloat(r[a],10));if(u){var x=i[a];i[a]=r[a],r[a]=x}n[a]=i[a]}return u&&(f=!f),c=e+l,!0}y!==null&&y.call(t);for(var T=0,N=d.length;T<N;T++)d[T].start(e);return!1}return!0}},TWEEN.Easing={Linear:{None:function(e){return e}},Quadratic:{In:function(e){return e*e},Out:function(e){return e*(2-e)},InOut:function(e){return(e*=2)<1?.5*e*e:-0.5*(--e*(e-2)-1)}},Cubic:{In:function(e){return e*e*e},Out:function(e){return--e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}},Quartic:{In:function(e){return e*e*e*e},Out:function(e){return 1- --e*e*e*e},InOut:function(e){return(e*=2)<1?.5*e*e*e*e:-0.5*((e-=2)*e*e*e-2)}},Quintic:{In:function(e){return e*e*e*e*e},Out:function(e){return--e*e*e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)}},Sinusoidal:{In:function(e){return 1-Math.cos(e*Math.PI/2)},Out:function(e){return Math.sin(e*Math.PI/2)},InOut:function(e){return.5*(1-Math.cos(Math.PI*e))}},Exponential:{In:function(e){return e===0?0:Math.pow(1024,e-1)},Out:function(e){return e===1?1:1-Math.pow(2,-10*e)},InOut:function(e){return e===0?0:e===1?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(-Math.pow(2,-10*(e-1))+2)}},Circular:{In:function(e){return 1-Math.sqrt(1-e*e)},Out:function(e){return Math.sqrt(1- --e*e)},InOut:function(e){return(e*=2)<1?-0.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)}},Elastic:{In:function(e){var t,n=.1,r=.4;return e===0?0:e===1?1:(!n||n<1?(n=1,t=r/4):t=r*Math.asin(1/n)/(2*Math.PI),-(n*Math.pow(2,10*(e-=1))*Math.sin((e-t)*2*Math.PI/r)))},Out:function(e){var t,n=.1,r=.4;return e===0?0:e===1?1:(!n||n<1?(n=1,t=r/4):t=r*Math.asin(1/n)/(2*Math.PI),n*Math.pow(2,-10*e)*Math.sin((e-t)*2*Math.PI/r)+1)},InOut:function(e){var t,n=.1,r=.4;return e===0?0:e===1?1:(!n||n<1?(n=1,t=r/4):t=r*Math.asin(1/n)/(2*Math.PI),(e*=2)<1?-0.5*n*Math.pow(2,10*(e-=1))*Math.sin((e-t)*2*Math.PI/r):n*Math.pow(2,-10*(e-=1))*Math.sin((e-t)*2*Math.PI/r)*.5+1)}},Back:{In:function(e){var t=1.70158;return e*e*((t+1)*e-t)},Out:function(e){var t=1.70158;return--e*e*((t+1)*e+t)+1},InOut:function(e){var t=2.5949095;return(e*=2)<1?.5*e*e*((t+1)*e-t):.5*((e-=2)*e*((t+1)*e+t)+2)}},Bounce:{In:function(e){return 1-TWEEN.Easing.Bounce.Out(1-e)},Out:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},InOut:function(e){return e<.5?TWEEN.Easing.Bounce.In(e*2)*.5:TWEEN.Easing.Bounce.Out(e*2-1)*.5+.5}}},TWEEN.Interpolation={Linear:function(e,t){var n=e.length-1,r=n*t,i=Math.floor(r),s=TWEEN.Interpolation.Utils.Linear;return t<0?s(e[0],e[1],r):t>1?s(e[n],e[n-1],n-r):s(e[i],e[i+1>n?n:i+1],r-i)},Bezier:function(e,t){var n=0,r=e.length-1,i=Math.pow,s=TWEEN.Interpolation.Utils.Bernstein,o;for(o=0;o<=r;o++)n+=i(1-t,r-o)*i(t,o)*e[o]*s(r,o);return n},CatmullRom:function(e,t){var n=e.length-1,r=n*t,i=Math.floor(r),s=TWEEN.Interpolation.Utils.CatmullRom;return e[0]===e[n]?(t<0&&(i=Math.floor(r=n*(1+t))),s(e[(i-1+n)%n],e[i],e[(i+1)%n],e[(i+2)%n],r-i)):t<0?e[0]-(s(e[0],e[0],e[1],e[1],-r)-e[0]):t>1?e[n]-(s(e[n],e[n],e[n-1],e[n-1],r-n)-e[n]):s(e[i?i-1:0],e[i],e[n<i+1?n:i+1],e[n<i+2?n:i+2],r-i)},Utils:{Linear:function(e,t,n){return(t-e)*n+e},Bernstein:function(e,t){var n=TWEEN.Interpolation.Utils.Factorial;return n(e)/n(t)/n(e-t)},Factorial:function(){var e=[1];return function(t){var n=1,r;if(e[t])return e[t];for(r=t;r>1;r--)n*=r;return e[t]=n}}(),CatmullRom:function(e,t,n,r,i){var s=(n-e)*.5,o=(r-t)*.5,u=i*i,a=i*u;return(2*t-2*n+s+o)*a+(-3*t+3*n-2*s-o)*u+s*i+t}}},typeof module!="undefined"&&module.exports&&(module.exports=TWEEN)
  !function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.glitch=b()}(this,function(){function p(d,e,f){if(y(d)&&z(e,"parameters","object")&&z(f,"callback","function")){for(h=x(e),q(a,d),q(b,d),i=s(d,h.quality),j=u(i),k=t(j),n=0,o=h.iterations;o>n;n++)r(j,k,h.seed,h.amount,n,h.iterations);l=new Image,l.onload=function(){c.drawImage(l,0,0),m=c.getImageData(0,0,d.width,d.height),f(m)},l.src=v(j)}}function q(a,b){a.width!==b.width&&(a.width=b.width),a.height!==b.height&&(a.height=b.height)}function r(a,b,c,d,e,f){var g=a.length-b-4,h=parseInt(g/f*e,10),i=parseInt(g/f*(e+1),10),j=i-h,k=parseInt(h+j*c,10);k>g&&(k=g);var l=Math.floor(b+k);a[l]=Math.floor(256*d)}function s(a,c){var e="number"==typeof c&&1>c&&c>0?c:.1;return d.putImageData(a,0,0),b.toDataURL("image/jpeg",e)}function t(a){var b=417;for(n=0,o=a.length;o>n;n++)if(255===a[n]&&218===a[n+1]){b=n+2;break}return b}function u(a){var c,d,e,b=[];for(n=23,o=a.length;o>n;n++){switch(d=g[a.charAt(n)],c=(n-23)%4){case 1:b.push(e<<2|d>>4);break;case 2:b.push((15&e)<<4|d>>2);break;case 3:b.push((3&e)<<6|d)}e=d}return b}function v(a){var c,d,e,b=["data:image/jpeg;base64,"];for(n=0,o=a.length;o>n;n++){switch(d=a[n],c=n%3){case 0:b.push(f[d>>2]);break;case 1:b.push(f[(3&e)<<4|d>>4]);break;case 2:b.push(f[(15&e)<<2|d>>6]),b.push(f[63&d])}e=d}return 0===c?(b.push(f[(3&e)<<4]),b.push("==")):1===c&&(b.push(f[(15&e)<<2]),b.push("=")),b.join("")}function x(a){return{seed:(a.seed||0)/100,quality:(a.quality||0)/100,amount:(a.amount||0)/100,iterations:a.iterations||0}}function y(a){return z(a,"image_data","object")&&z(a.width,"image_data.width","number")&&z(a.height,"image_data.height","number")&&z(a.data,"image_data.data","object")&&z(a.data.length,"image_data.data.length","number")&&A(a.data.length,"image_data.data.length",B,"> 0")?!0:!1}function z(a,b,c){return typeof a===c?!0:(C(a,"typeof "+b,'"'+c+'"','"'+typeof a+'"'),!1)}function A(a,b,c,d){return c(a)===!0?!0:(C(a,b,d,"not"),void 0)}function B(a){return a>0}function C(a,b,c,d){throw new Error("glitch(): Expected "+b+" to be "+c+", but it was "+d+".")}var h,i,j,k,l,m,n,o,a=document.createElement("canvas"),b=document.createElement("canvas"),c=a.getContext("2d"),d=b.getContext("2d"),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=e.split(""),g={};return f.forEach(function(a,b){g[a]=b}),p});
  !function(_root){_root.requestAnimationFrame||(_root.requestAnimationFrame=function(){return _root.webkitRequestAnimationFrame||_root.mozRequestAnimationFrame||_root.oRequestAnimationFrame||_root.msRequestAnimationFrame||function(a,b){_root.setTimeout(a,1e3/60)}}()),_root.cancelAnimationFrame||(_root.cancelAnimationFrame=_root.cancelAnimationFrame||_root.mozCancelAnimationFrame||_root.webkitCancelAnimationFrame||_root.msCancelAnimationFrame),_root.XMLHttpRequest||(_root.XMLHttpRequest=function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(a){}throw new Error("This browser does not support XMLHttpRequest.")}),_root.evalInContext||(_root.evalInContext=function(source,context){function values(){var a=[];for(var b in context)context.hasOwnProperty(b)&&a.push(context[b]);return a}source="(function("+Object.keys(context).join(", ")+") {"+source+"})";var compiled=eval(source);return compiled.apply(context,values())}),_root.get_url_vars||(_root.get_url_vars=function(){for(var b,a=new Object,c=_root.location.href.slice(_root.location.href.indexOf("?")+1).split("&"),d=0;d<c.length;d++)b=c[d].split("="),2==b.length&&(a[decodeURIComponent(b[0])]=decodeURIComponent(b[1]));return a}),_root.checkFileReaderApi||(_root.checkFileReaderApi=function(){return _root.File&&_root.FileReader&&_root.FileList&&_root.Blob}),_root.checkFileWriterApi||(_root.checkFileWriterApi=function(){return _root.File&&_root.saveAs&&_root.FileList&&_root.Blob}),_root.audioContext||(_root.audioContext=null),_root.audioContextClass||(_root.audioContextClass=_root.AudioContext||_root.webkitAudioContext||_root.mozAudioContext||_root.oAudioContext||_root.msAudioContext),_root.getAudioContext||(_root.getAudioContext=function(){return _root.audioContext?_root.audioContext:!_root.audioContext&&_root.audioContextClass?_root.audioContext=new _root.audioContextClass:null}),_root.audioContext||(_root.audioContext=null),_root.getAudioAnalyser||(_root.getAudioAnalyser=function(){return _root.audioAnalyser||(_root.audioAnalyser=_root.getAudioContext().createAnalyser())}),Array.prototype.forEach||(Array.prototype.forEach=function(a,b){for(var c=0;c<this.length;c++)a.call(b||null,this[c],c,this)}),Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)}),_root.WindowResizeHelper||(_root.WindowResizeHelper=function(a){this.func=a,this.timer=0},_root.WindowResizeHelper.prototype.dispose=function(){this.func=null,this.disable()},_root.WindowResizeHelper.prototype.enable=function(){_root.addEventListener?_root.addEventListener("resize",this.onResize.bind(this),!1):_root.attachEvent?_root.attachEvent("onresize",this.onResize.bind(this)):_root.onresize},_root.WindowResizeHelper.prototype.disable=function(){_root.removevEventListener?_root.removevEventListener("resize",this.onResize.bind(this),!1):_root.detachEvent?_root.detachEvent("onresize",this.onResize.bind(this)):_root.onresize},_root.WindowResizeHelper.prototype.onResize=function(a){this.func&&(clearTimeout(this.timer),this.timer=setTimeout(this.func,500,a))})}(window);
  
  var MATH_PROPS=["E","LN2","LN10","LOG2E","LOG10E","PI","PI2","HALF_PI","SQRT1_2","SQRT2"],MATHS=["abs","acos","asin","atan","atan2","ceil","cos","exp","floor","imul","log","max","min","pow","random","round","sin","sqrt","tan"],CTX_FUNCS=Object.getOwnPropertyNames(CanvasRenderingContext2D.prototype);Math.PI2=Math.PI*2,Math.HALF_PI=Math.PI/2;var CT_PROPS,Centi=function(e,t){this.ver="0.4.9j",this.name=e?e:"ct",this.editor=t?t:null,this.canvas=null,this.ctx=null,this.tempCanvas=null,this.tempCtx=null,this.dsp={enable:!1,context:null,analyser:null,processor:null},this.sampleRate=44100,this.fft=new Uint8Array(1024),this.waveUint=new Uint8Array(2048),this.wave=new Float32Array(2048),this.GOLD=(1+Math.sqrt(5))/2,this.x=0,this.y=0,this.c=0,this.time=0,this.w=720,this.h=360,this.sizeW=this.w,this.sizeH=this.h,this.cx=this.w/2,this.cy=this.h/2,this.mx=0,this.my=0,this.down=!1,this.tempo={bpm:120,sec:.5,preSec:0,divide:4},this.beat=0,this.initSec=this.now(),this.bgcolor={r:0,g:0,b:0,a:255},this.drawcolor={r:0,g:0,b:0,a:255},this.bFill=!0,this.gradient=null,this.kdtree,this.centiCode,this.setupMethod="",this.drawMethod="",this.beatMethod="",this.dspMethod="",this.setupFunc=null,this.drawFunc=null,this.beatFunc=null,this.dspFunc=null,this.mouseMoveMethod="",this.mouseDownMethod="",this.mouseUpMethod="",this.mouseMove=null,this.mouseDown=null,this.mouseUp=null,this.toGifFunc=null,this.b3d=!1,this.pluginInstances=[];for(var n=0;n<MATHS.length;n++)this[MATHS[n]]=Math[MATHS[n]];for(var n=0;n<MATH_PROPS.length;n++)this[MATH_PROPS[n]]=Math[MATH_PROPS[n]];this.ease=TWEEN.Easing,this.Linear=TWEEN.Easing.Linear.None,this.eases=[this.Linear];var r=["Quad","Cubic","Quart","Quint","Sine","Expo","Circ","Elastic","Back","Bounce"],i=["Quadratic","Cubic","Quartic","Quintic","Sinusoidal","Exponential","Circular","Elastic","Back","Bounce"];for(var n=0;n<r.length;n++)this[r[n]+"In"]=TWEEN.Easing[i[n]].In,this[r[n]+"Out"]=TWEEN.Easing[i[n]].Out,this[r[n]+"InOut"]=TWEEN.Easing[i[n]].InOut,this.eases.push(this[r[n]+"In"],this[r[n]+"Out"],this[r[n]+"InOut"]);if(!CT_PROPS){var s=[];for(var o in this)CT_FUNCS.indexOf(o)==-1&&s.push(o);CT_PROPS=s}};Centi.plugins=[],Centi.prototype.destroy=function(){this.dsp.processor&&(this.dsp.processor.disconnect(),this.dsp.processor.onaudioprocess=null,this.dsp.processor=null),this.dsp.analyser&&(this.dsp.analyser.disconnect(),this.dsp.analyser=null),this.dsp.context,this.dsp.context=null,this.canvas=null,this.ctx=null,this.tempCanvas=null,this.tempCtx=null,this.dsp=null,this.tempo=null,this.toGifFunc=null,this.setupFunc=null,this.drawFunc=null,this.beatFunc=null,this.dspFunc=null,this.mouseMove=null,this.mouseDown=null,this.mouseUp=null,this.fft=null,this.wave=null,this.b3d=!1,this.pluginInstances=null},Centi.prototype.init=function(e,t){this.canvas=e,this.tempCanvas=document.createElement("canvas"),this.tempCtx=this.tempCanvas.getContext("2d"),this.initSec=this.now(),this.time=0;if(t){this.dsp.enable=!0,this.dsp.context=t,this.dsp.context.createScriptProcessor=this.dsp.context.createScriptProcessor||this.dsp.context.createJavaScriptNode;var n=function(){return/(Win(dows )?NT 6\.2)/.test(navigator.userAgent)?1024:/(Win(dows )?NT 6\.1)/.test(navigator.userAgent)?1024:/(Win(dows )?NT 6\.0)/.test(navigator.userAgent)?2048:/Win(dows )?(NT 5\.1|XP)/.test(navigator.userAgent)?4096:/Mac|PPC/.test(navigator.userAgent)?4096:/Linux/.test(navigator.userAgent)?8192:/iPhone|iPad|iPod/.test(navigator.userAgent)?2048:16384};this.dsp.analyser=this.dsp.context.createAnalyser(),this.dsp.analyser.connect(this.dsp.context.destination),this.sampleRate=this.dsp.context.sampleRate;var r=1/this.dsp.context.sampleRate,i=this.dsp.context.createScriptProcessor(n(),0,2);this.dsp.processor=i;var s=this.dsp.context.createBufferSource();s.connect(i),i.connect(this.dsp.analyser);var o=this;i.onaudioprocess=function(e){o.updateBeat();var t=e.outputBuffer.getChannelData(0),n=e.outputBuffer.getChannelData(1),i=typeof o.doDsp()=="number";for(var s=0;s<this.bufferSize;s++){var u=o.time,a=o.doDsp();i?(t[s]=a,n[s]=a):a.length==2&&(t[s]=a[0],n[s]=a[1]),o.time+=r}}}else this.dsp.enable=!1;for(var u=0;u<Centi.plugins.length;u++){var a=new Centi.plugins[u](this);this.pluginInstances.push(a)}return e.getContext?!0:!1},Centi.prototype.doDsp=function(){return this.dspFunc?this.dspFunc():0},Centi.prototype.feedback=function(e){function r(e){var t="";if(s("Array",e)){t="[";if(e.length>0){for(var n=0;n<e.length;n++)t+=r(e[n])+",";t=t.slice(0,-1)}t+="]"}else s("Number",e)?t=e.toString():s("Object",e)?t=i(e):s("Boolean",e)&&(t=e?"1":"0");return t}function i(e){var t="{";for(var n in e)t+=n+":"+e[n]+",";return t.length>1&&(t=t.slice(0,-1)),t+="}",t}function s(e,t){var n=Object.prototype.toString.call(t).slice(8,-1);return t!==undefined&&t!==null&&n===e}function o(e,t,n){var r=e;if(r.length>0){var i=0;i=r.indexOf(t+"="),i==-1&&(i=r.indexOf(t+" ="));if(i>-1){var s=i,o=0,u=o;while(i<r.length){var a=r.charAt(i);a=="("&&o++,a==")"&&o--;if(u==1&&o==0){r=r.slice(0,s+t.length)+"=("+n+")"+r.slice(i+1);break}u=o,i++}}}return r}if(!this.editor)return;var t=r(e);for(var n in this)if(CT_PROPS.indexOf(n)==-1&&this[n]===e){this.centiCode=o(this.centiCode,n,t),this.editor.setValue(this.centiCode);break}},Centi.prototype.parse=function(e){function w(e,t){e=e.replace(d,t+"."+"$1"+"$2"),e=e.replace(p,"$2"),e=e.replace(a,"for("),e=e.replace(f,"while("),e=e.replace(l,"if("),e=e.replace(c,"else{"),e=e.replace(h,"else if("),e=e.replace(v,"function("),e=e.replace(m,"arguments[$2]"),e=e.replace(g,"return ("),e=e.replace(y,".");for(var n=0;n<b.length;n++){var r=new RegExp(t+"."+b[n].prefix+".","g");e=e.replace(r,b[n].prefix+"."),b[n].shortPrefix&&(r=new RegExp(t+"."+b[n].shortPrefix+".","g"),e=e.replace(r,b[n].prefix+"."))}var i=["Infinity","NaN","undefined","null","this","true","false"];for(var n=0;n<i.length;n++)e=e.replace(new RegExp(t+"."+i[n],"g"),i[n]);var s=["MAX_VALUE","MIN_VALUE","POSITIVE_INFINITY","NEGATIVE_INFINITY"];for(var n=0;n<s.length;n++)e=e.replace(new RegExp(t+"."+s[n],"g"),"Number."+s[n]);var o=new RegExp(t+".([A-Za-z0-9_]+)(:)([A-Za-z0-9_.()]+)(,)","g");e=e.replace(o,"$1:$3,");var u=new RegExp(t+".([A-Za-z0-9_]+)(:)([A-Za-z0-9_.()]+)(})","g");return e=e.replace(u,"$1:$3}"),e}this.centiCode=e,e=e.replace(/\s/g,""),e=e.replace(/\b/g,""),e=e.replace(/(\))([A-Za-z0-9_\}])/g,");$2"),e=e.replace(/(for\()([A-Za-z_\-\.\(\)]+)(\,)([A-Za-z0-9_\-\.\(\)]+)(\,)([A-Za-z0-9_\-\.\(\)\*\+\/]+)(\))/g,"for($2=$4;$2<$6;$2++)");var t=this.getInnerExpression(e.slice(e.indexOf("frame(){"))),n=this.getInnerExpression(e.slice(e.indexOf("beat(){"))),r=this.getInnerExpression(e.slice(e.indexOf("dsp(){"))),i=this.getInnerExpression(e.slice(e.indexOf("move(){"))),s=this.getInnerExpression(e.slice(e.indexOf("down(){"))),o=this.getInnerExpression(e.slice(e.indexOf("up(){"))),u=e.replace("frame(){"+t+"}","");u=u.replace("beat(){"+n+"}",""),u=u.replace("dsp(){"+r+"}",""),u=u.replace("move(){"+i+"}",""),u=u.replace("down(){"+s+"}",""),u=u.replace("up(){"+o+"}",""),/c3d\(\)/.test(u)?this.c3d():this.c2d();var a=new RegExp(this.name+".for\\(","g"),f=new RegExp(this.name+".while\\(","g"),l=new RegExp(this.name+".if\\(","g"),c=new RegExp(this.name+".else\\{","g"),h=new RegExp(this.name+".elseIf\\(","g"),p=new RegExp("("+this.name+").([0-9.]+)","g"),d=/([A-Za-z0-9_]+)([\.\!\~\|\%\&\:\(\)\{\}\;\=\+\-\<\>\*\/\[\]\,\^])/g,v=new RegExp(this.name+".func\\(","g"),m=/(\$)([0-9]+)/g,g=new RegExp(this.name+".return\\(","g"),y=new RegExp("\\."+this.name+"\\.","g"),b=this.pluginInstances;return u=w(u,this.name),u=this.modFunction(u),t=w(t,this.name),t=this.modFunction(t),n=w(n,this.name),n=this.modFunction(n),r=w(r,this.name),r=this.modFunction(r),i=w(i,this.name),i=this.modFunction(i),s=w(s,this.name),s=this.modFunction(s),o=w(o,this.name),o=this.modFunction(o),this.drawMethod=t,this.beatMethod=n,this.dspMethod=r,this.mouseMoveMethod=i,this.mouseDownMethod=s,this.mouseUpMethod=o,this.drawMethod!=""?this.drawFunc=evalInContext("return (function(){"+this.drawMethod+"});",this):this.drawFunc=null,this.beatMethod!=""?this.beatFunc=evalInContext("return (function(){"+this.beatMethod+"});",this):this.beatFunc=null,this.dspMethod!=""?this.dspFunc=evalInContext("return (function(){"+this.dspMethod+"});",this):this.dspFunc=null,this.mouseMoveMethod!=""?this.mouseMove=evalInContext("return (function(){"+this.mouseMoveMethod+"});",this):this.mouseMove=null,this.mouseDownMethod!=""?this.mouseDown=evalInContext("return (function(){"+this.mouseDownMethod+"});",this):this.mouseDown=null,this.mouseUpMethod!=""?this.mouseUp=evalInContext("return (function(){"+this.mouseUpMethod+"});",this):this.mouseUp=null,this.setupMethod=u,this.setupMethod!=""?this.setupFunc=evalInContext("return (function(){"+this.setupMethod+"});",this):this.setupFunc=null,!0},Centi.prototype.start=function(){for(var e=0;e<this.pluginInstances.length;e++)this.pluginInstances[e].preSetup();this.b3d==0&&(this.ctx=this.canvas.getContext("2d"),this.clear()),this.reset(),this.bg(0),this.bpm(120,4),this.setupFunc&&this.setupFunc();for(var e=0;e<this.pluginInstances.length;e++)this.pluginInstances[e].postSetup();this.col(255),this.canvas.addEventListener&&(this.canvas.removeEventListener("mousemove",this),this.canvas.removeEventListener("mousedown",this),this.canvas.removeEventListener("mouseup",this),this.canvas.addEventListener("mousemove",this,!1),this.canvas.addEventListener("mousedown",this,!1),this.canvas.addEventListener("mouseup",this,!1)),this.canvas.addEventListener&&document.addEventListener&&(this.canvas.removeEventListener("touchstart",this),this.canvas.removeEventListener("touchmove",this),document.removeEventListener("touchend",this),document.removeEventListener("touchcancel",this),this.canvas.addEventListener("touchstart",this,!1),this.canvas.addEventListener("touchmove",this,!1),document.addEventListener("touchend",this,!1),document.addEventListener("touchcancel",this,!1))},Centi.prototype.handleEvent=function(e){function n(e){var n=t.canvas.getBoundingClientRect();t.mx=e.clientX-n.left,t.my=e.clientY-n.top}function r(e){t.mx=e.layerX,t.my=e.layerY}var t=this;switch(e.type){case"mousedown":n(e),this.down=!0,this.mouseDown&&this.mouseDown(e);break;case"mousemove":n(e),this.mouseMove&&this.mouseMove(e);break;case"mouseup":n(e),this.down=!1,this.mouseUp&&this.mouseUp(e);break;case"touchstart":r(e),this.down=!0,this.mouseDown&&this.mouseDown(e);break;case"touchmove":r(e),this.mouseMove&&this.mouseMove(e),e.preventDefault();break;case"touchend":case"touchcancel":r(e),this.down=!1,this.mouseUp&&this.mouseUp(e)}},Centi.prototype.modFunction=function(e){var t=(e.match(/function/g)||[]).length;if(t>0){var n=e,r=0;r=n.indexOf("function",r)+7;var i=0,s=i;while(r<n.length){var o=n.charAt(r);o=="{"&&i++,o=="}"&&i--;if(s==1&&i==0){n=n.slice(0,r+1)+";"+n.slice(r+1),t--;if(t>0)r=n.indexOf("function",r)+7;else if(t==0)break}s=i,r++}e=n,e=e.replace(";};);",";});")}return e},Centi.prototype.getInnerExpression=function(e){var t=e,n=0,r=0;n=r=t.indexOf("{",r);if(n==-1)return"";var i=0,s=i;while(r<t.length){var o=t.charAt(r);o=="{"&&i++,o=="}"&&i--;if(s==1&&i==0){t=t.slice(n+1,r);break}s=i,r++}return i==0?t:""},Centi.prototype.update=function(){for(var e=0;e<this.pluginInstances.length;e++)this.pluginInstances[e].preUpdate();if(this.dsp.enable==0)this.time=this.now()-this.initSec,this.updateBeat();else{this.dsp.analyser.getByteFrequencyData(this.fft),this.dsp.analyser.getByteTimeDomainData(this.waveUint);for(var e=0;e<this.waveUint.length;e++)this.wave[e]=(this.waveUint[e]/255-.5)*2}TWEEN.update(),this.ctx.shadowBlur=0,this.push(),this.drawFunc&&this.drawFunc(),this.pop();for(var e=0;e<this.pluginInstances.length;e++)this.pluginInstances[e].postUpdate();this.c++,this.toGifFunc!=null&&this.toGifFunc(this.ctx)},Centi.prototype.updateBeat=function(){this.time-this.tempo.preSec>=this.tempo.sec&&(this.beatFunc&&this.beatFunc(),this.tempo.preSec=this.time,this.beat++)},Centi.prototype.reset=function(){this.c=0,this.initSec=this.now(),this.time=0,this.bFill=!0,this.lw(1),this.lj(0),this.lc(0),this.bm(0),this.bg(0),this.col(255)},Centi.prototype.c2d=function(){this.b3d=!1},Centi.prototype.c3d=function(){this.b3d=!0},Centi.prototype.bg=function(){if(this.ctx==null)return;var e=arguments.length;e==1?(this.bgcolor.r=parseInt(arguments[0]),this.bgcolor.g=parseInt(arguments[0]),this.bgcolor.b=parseInt(arguments[0]),this.bgcolor.a=255):e==2?(this.bgcolor.r=parseInt(arguments[0]),this.bgcolor.g=parseInt(arguments[0]),this.bgcolor.b=parseInt(arguments[0]),this.bgcolor.a=parseInt(arguments[1])):e==3?(this.bgcolor.r=parseInt(arguments[0]),this.bgcolor.g=parseInt(arguments[1]),this.bgcolor.b=parseInt(arguments[2]),this.bgcolor.a=255):e==4&&(this.bgcolor.r=parseInt(arguments[0]),this.bgcolor.g=parseInt(arguments[1]),this.bgcolor.b=parseInt(arguments[2]),this.bgcolor.a=parseInt(arguments[3])),this.clear()},Centi.prototype.lg=function(){console.log(arguments)},Centi.prototype.log=function(){console.log(arguments)},Centi.prototype.sz=Centi.prototype.size=function(e,t){this.sizeW=e,this.sizeH=t;var n,r;e<=1?n=window.innerWidth*e:n=e,t<=1?r=window.innerHeight*t:r=t,this.w=n,this.h=r,this.canvas.width=this.w,this.canvas.height=this.h,this.cx=this.w/2,this.cy=this.h/2,this.tempCanvas.width=this.w,this.tempCanvas.height=this.h},Centi.prototype.clr=Centi.prototype.clear=function(){if(this.ctx==null)return;var e=this.ctx.globalCompositeOperation;this.ctx.globalCompositeOperation="source-over",this.ctx.clearRect(0,0,this.w,this.h),this.ctx.fillStyle="rgba("+this.bgcolor.r+","+this.bgcolor.g+","+this.bgcolor.b+","+this.bgcolor.a/255+")",this.ctx.fillRect(0,0,this.w,this.h),this.ctx.globalCompositeOperation=e,this.col(255)},Centi.prototype.Obj=Centi.prototype.obj=function(){return new Object},Centi.prototype.rnd=Centi.prototype.rand=function(){var e=arguments.length;return e==1?Math.random()*arguments[0]:e==2?Math.random()*(arguments[1]-arguments[0])+arguments[0]:Math.random()},Centi.prototype.nz=Centi.prototype.noise=function(){var e=arguments.length;return e==1?perlin.perlin2(arguments[0],0):e==2?perlin.perlin2(arguments[0],arguments[1]):e==3?perlin.perlin3(arguments[0],arguments[1],arguments[2]):0},Centi.prototype.pixel=function(e,t,n){if(this.ctx==null)return;n=n===undefined?!0:n,n?this.rect(Math.floor(e),Math.floor(t),1,1):this.rect(e,t,1,1)},Centi.prototype.tri=function(){if(this.ctx==null)return;arguments.length==6?(this.beginShape(),this.moveTo(arguments[0],arguments[1]),this.lineTo(arguments[2],arguments[3]),this.lineTo(arguments[4],arguments[5]),this.lineTo(arguments[0],arguments[1]),this.endShape()):arguments.length==3&&(this.beginShape(),this.moveTo(arguments[0].x,arguments[0].y),this.lineTo(arguments[1].x,arguments[1].y),this.lineTo(arguments[2].x,arguments[2].y),this.lineTo(arguments[0].x,arguments[0].y),this.endShape())},Centi.prototype.rect=function(e,t,n,r){if(this.ctx==null)return;this.bFill?this.ctx.fillRect(e,t,n,r):this.ctx.strokeRect(e,t,n,r)},Centi.prototype.oval=function(e,t,n,r){if(this.ctx==null)return;r=r||-1;if(r==-1)this.ctx.beginPath(),this.ctx.arc(e,t,n,0,Math.PI*2,!0),this.bFill?this.ctx.fill():this.ctx.stroke();else{r<3&&(r=3);var i=Math.PI2/r;this.ctx.beginPath();var s=parseInt(r);for(var o=0;o<r;o++){var u=i*o,a=i*(o+1);o>s-1&&(a=0);var f=Math.cos(u)*n+e,l=Math.sin(u)*n+t,c=Math.cos(a)*n+e,h=Math.sin(a)*n+t;this.lineTo(f,l),this.lineTo(c,h)}this.bFill?this.ctx.fill():this.ctx.stroke()}},Centi.prototype.arc=function(e,t,n,r,i,s){if(this.ctx==null)return;s==undefined&&(s=!1),this.ctx.beginPath(),this.ctx.arc(e,t,n,r,i,s),this.bFill?this.ctx.fill():this.ctx.stroke()},Centi.prototype.ln=Centi.prototype.line=function(e,t,n,r){if(this.ctx==null)return;this.ctx.beginPath(),this.ctx.moveTo(e,t),this.ctx.lineTo(n,r),this.ctx.stroke()},Centi.prototype.curve=function(){if(this.ctx==null)return;arguments.length==8?(this.beginShape(),this.moveTo(arguments[0],arguments[1]),this.curveTo(arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]),this.endShape()):arguments.length==1&&arguments[0].length&&arguments[0].length==8&&this.curve(arguments[0][0],arguments[0][1],arguments[0][2],arguments[0][3],arguments[0][4],arguments[0][5],arguments[0][6],arguments[0][7])},Centi.prototype.moveTo=function(e,t){if(this.ctx==null)return;this.ctx.moveTo(e,t)},Centi.prototype.lineTo=function(e,t){if(this.ctx==null)return;this.ctx.lineTo(e,t)},Centi.prototype.curveTo=function(){if(this.ctx==null)return;arguments.length==6?this.ctx.bezierCurveTo(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]):arguments.length==1&&arguments[0].length&&arguments[0].length==6&&this.ctx.bezierCurveTo(arguments[0][0],arguments[0][1],arguments[0][2],arguments[0][3],arguments[0][4],arguments[0][5])},Centi.prototype.lines=function(e,t){t=t||!1;var n=e.length;if(n>=2){var r=e,i=r[0],s=i.hasOwnProperty("x")&&i.hasOwnProperty("y");if(s){var o;for(var u=0;u<n;u++)o=r[u],u==0?this.moveTo(o.x,o.y):this.lineTo(o.x,o.y);t&&(o=r[0],this.lineTo(o.x,o.y))}else{var a,f;for(var u=0;u<n;u+=2)a=r[u],f=r[u+1],u==0?this.moveTo(a,f):this.lineTo(a,f);t&&(a=r[0],f=r[1],this.lineTo(a,f))}}},Centi.prototype.text=function(){if(this.ctx==null)return;var e=arguments.length;e==1?this.bFill?this.ctx.fillText(arguments[0],0,0):this.ctx.strokeText(arguments[0],0,0):e==2?this.bFill?this.ctx.fillText(arguments[0],arguments[1],arguments[2]):this.ctx.strokeText(arguments[0],arguments[1],arguments[2]):e==3?this.bFill?this.ctx.fillText(arguments[0],arguments[1],arguments[2]):this.ctx.strokeText(arguments[0],arguments[1],arguments[2]):e==4&&(this.bFill?this.ctx.fillText(arguments[0],arguments[1],arguments[2],arguments[3]):this.ctx.strokeText(arguments[0],arguments[1],arguments[2],arguments[3]))},Centi.prototype.font=function(){var e=arguments.length;e==1?arguments[0]instanceof String?this.ctx.font="12px "+arguments[0]:this.ctx.font=arguments[0]+"px 'Helvetica'":e==2?this.ctx.font=arguments[1]+"px "+arguments[0]:e==3?this.ctx.font=(arguments[2]?"bold ":"")+arguments[1]+"px "+arguments[0]:e==4&&(this.ctx.font=(arguments[3]?"italic ":"")+(arguments[2]?"bold ":"")+arguments[1]+"px "+arguments[0])},Centi.prototype.boundingBox=function(e){var t=e.length,n=this.Vec2(Infinity,Infinity),r=this.Vec2(-Infinity,-Infinity);if(t>0){var i=e,s=i[0],o=s.hasOwnProperty("x")&&s.hasOwnProperty("y");if(o){var u;for(var a=0;a<t;a++)u=i[a],u.x<n.x&&(n.x=u.x),u.y<n.y&&(n.y=u.y),u.x>r.x&&(r.x=u.x),u.y>r.y&&(r.y=u.y)}else{var f,l;for(var a=0;a<t;a+=2)f=i[a],l=i[a+1],f<n.x&&(n.x=f),l<n.y&&(n.y=l),f>r.x&&(r.x=f),l>r.y&&(r.y=l)}return this.Rectangle(n.x,n.y,r.x-n.x,r.y-n.y)}return this.Rectangle(0,0,0,0)},Centi.prototype.strk2fill=function(e,t,n){if(!e)return[];var r=e.length;if(r==0)return[];t=t||1,n=parseInt(n)||1,n<=0&&(n=1);var i,s=[],o=[],u=[];for(var a=0;a<r;a+=n)if(i){var f=e[a],l=this.Vec2(i.y-f.y,f.x-i.x);l=l.normalized();var c=this.Vec2(f.x+l.x*t/2,f.y+l.y*t/2),h=this.Vec2(f.x-l.x*t/2,f.y-l.y*t/2),p=this.Vec2(i.x+l.x*t/2,i.y+l.y*t/2),d=this.Vec2(i.x-l.x*t/2,i.y-l.y*t/2);if(a==n)o.push(p),u.unshift(d);else if(a>n){var v=o[o.length-1],m=u[0];o[o.length-1].x=(v.x+p.x)/2,o[o.length-1].y=(v.y+p.y)/2,u[0].x=(m.x+d.x)/2,u[0].y=(m.y+d.y)/2}o.push(c),u.unshift(h),i=f}else i=e[a];return r=o.length,s=s.concat(o),s=s.concat(u),s},Centi.prototype.xys2pts=function(e){var t=e||[];if(t.length==0)return[];var n=t[0],r=n.hasOwnProperty("x")&&n.hasOwnProperty("y");if(r)return t;var i=[],s=t.length;for(var o=0;o<s;o+=2)i.push(this.Vec2(t[o],t[o+1]));return i},Centi.prototype.beginShape=function(){if(this.ctx==null)return;this.ctx.beginPath()},Centi.prototype.endShape=function(){if(this.ctx==null)return;this.bFill?this.ctx.fill():this.ctx.stroke()},Centi.prototype.me=Centi.prototype.drawMe=function(){if(this.ctx==null)return;var e=arguments.length;e==2?this.ctx.drawImage(this.canvas,arguments[0],arguments[1]):e==4?this.ctx.drawImage(this.canvas,arguments[0],arguments[1],arguments[2],arguments[3]):e==8&&this.ctx.drawImage(this.canvas,arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7])},Centi.prototype.lw=Centi.prototype.lineWidth=function(e){if(this.ctx==null)return;this.ctx.lineWidth=e},Centi.prototype.lj=Centi.prototype.lineJoin=function(e){if(this.ctx==null)return;e==0?this.ctx.lineJoin="bevel":e==1?this.ctx.lineJoin="round":e==2&&(this.ctx.lineJoin="miter")},Centi.prototype.lc=Centi.prototype.lineCap=function(e){if(this.ctx==null)return;e==0?this.ctx.lineCap="butt":e==1?this.ctx.lineCap="round":e==2&&(this.ctx.lineCap="square")},Centi.prototype.bm=Centi.prototype.blendMode=function(e){if(this.ctx==null)return;var t="source-over",n=["source-over","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"];e<n.length&&(t=n[e],this.ctx.globalCompositeOperation=t)},Centi.prototype.hcol=function(e){e>>24>0?this.col(e>>16&255,e>>8&255,e&255,e>>24&255):this.col(e>>16&255,e>>8&255,e&255)},Centi.prototype.col=function(){var e=arguments.length,t="rgb(0,0,0)";e==1?(this.drawcolor.r=arguments[0],this.drawcolor.g=arguments[0],this.drawcolor.b=arguments[0],this.drawcolor.a=255,t="rgb("+parseInt(arguments[0])+","+parseInt(arguments[0])+","+parseInt(arguments[0])+")"):e==2?(this.drawcolor.r=arguments[0],this.drawcolor.g=arguments[0],this.drawcolor.b=arguments[0],this.drawcolor.a=arguments[1],t="rgba("+parseInt(arguments[0])+","+parseInt(arguments[0])+","+parseInt(arguments[0])+","+parseInt(arguments[1])/255+")"):e==3?(this.drawcolor.r=arguments[0],this.drawcolor.g=arguments[1],this.drawcolor.b=arguments[2],this.drawcolor.a=255,t="rgb("+parseInt(arguments[0])+","+parseInt(arguments[1])+","+parseInt(arguments[2])+")"):e==4&&(this.drawcolor.r=arguments[0],this.drawcolor.g=arguments[1],this.drawcolor.b=arguments[2],this.drawcolor.a=arguments[3],t="rgba("+parseInt(arguments[0])+","+parseInt(arguments[1])+","+parseInt(arguments[2])+","+parseInt(arguments[3])/255+")"),this.ctx.fillStyle=t,this.ctx.strokeStyle=t,this.gradient=null},Centi.prototype.fill=function(){this.bFill=!0,this.gradient=null},Centi.prototype.strk=Centi.prototype.stroke=function(){this.bFill=!1,this.gradient=null},Centi.prototype.grad=function(e,t,n,r){this.bFill=!0;if(!this.ctx)return;this.gradient=this.ctx.createLinearGradient(e,t,n,r),this.ctx.fillStyle=this.gradient},Centi.prototype.gradR=function(e,t,n,r,i,s){this.bFill=!0;if(!this.ctx)return;this.gradient=this.ctx.createRadialGradient(e,t,n,r,i,s),this.ctx.fillStyle=this.gradient},Centi.prototype.gradColor=function(e,t,n,r,i){if(!this.gradient)return;e=this.minmax(e,0,1);var s=[];if(arguments.length>1)for(var o=1;o<arguments.length;o++)s.push(arguments[o]);this.gradient.addColorStop(e,this.colorString.apply(this,s))},Centi.prototype.gradHex=function(e,t){if(!this.gradient)return;e=this.minmax(e,0,1);var n=[];t=t===undefined?16777215:t,t>>24>0?n=[t>>16&255,t>>8&255,t&255,t>>24&255]:n=[t>>16&255,t>>8&255,t&255,255],this.gradient.addColorStop(e,this.colorString.apply(this,n))},Centi.prototype.colorString=function(){var e=arguments.length,t="rgb(0,0,0)";return e==1?t="rgb("+parseInt(arguments[0])+","+parseInt(arguments[0])+","+parseInt(arguments[0])+")":e==2?t="rgba("+parseInt(arguments[0])+","+parseInt(arguments[0])+","+parseInt(arguments[0])+","+parseInt(arguments[1])/255+")":e==3?t="rgb("+parseInt(arguments[0])+","+parseInt(arguments[1])+","+parseInt(arguments[2])+")":e==4&&(t="rgba("+parseInt(arguments[0])+","+parseInt(arguments[1])+","+parseInt(arguments[2])+","+parseInt(arguments[3])/255+")"),t},Centi.prototype.push=function(){if(this.ctx==null)return;this.ctx.save()},Centi.prototype.pop=function(){if(this.ctx==null)return;this.ctx.restore()},Centi.prototype.rotate=function(e){if(this.ctx==null)return;this.ctx.rotate(e)},Centi.prototype.scale=function(e,t){if(this.ctx==null)return;this.ctx.scale(e,t)},Centi.prototype.translate=function(e,t){if(this.ctx==null)return;this.ctx.translate(e,t)},Centi.prototype.transform=function(e,t,n,r,i,s){if(this.ctx==null)return;this.ctx.transform(e,t,n,r,i,s)},Centi.prototype.drawFFT=function(e,t,n,r,i,s){var o=s||2,u=i||9;u<1&&(u=1);var a=this.fft.length,f=n/a,l=r/255;for(var c=0;c<a;c+=u)this.rect(e+c*f,t+r,o,-this.fft[c]*l)},Centi.prototype.drawWave=function(e,t,n,r,i){var s=i||9;s<1&&(s=1);var o=this.wave.length,u=n/(o-1),a=r/2;this.beginShape();for(var f=0;f<o;f+=s)this.lineTo(e+f*u,t+a+this.wave[f]*a);this.endShape()},Centi.prototype.interp=function(e,t,n){return t+(e-t)*n},Centi.prototype.dist=function(){var e=arguments.length;if(e==4){var t=arguments[0]-arguments[2],n=arguments[1]-arguments[3];return Math.sqrt(t*t+n*n)}if(e==2&&arguments[0].hasOwnProperty("x")&&arguments[0].hasOwnProperty("y")&&arguments[1].hasOwnProperty("x")&&arguments[1].hasOwnProperty("y"))return this.dist(arguments[0].x,arguments[0].y,arguments[1].x,arguments[1].y)},Centi.prototype.wrap=function(e,t,n){var r=n-t;if(r>0){while(e<t)e+=r;while(e>n)e-=r;return e}return e},Centi.prototype.minmax=Centi.prototype.minMax=function(e,t,n){return Math.min(n,Math.max(e,t))},Centi.prototype.map=function(e,t,n,r,i){return(e-t)/(n-t)*(i-r)+r},Centi.prototype.zmap=function(e,t,n,r,i){return this.minMax(this.map(e,t,n,r,i),r,i)},Centi.prototype.avg=function(e){if(e&&e.length>0){var t=e.length,n=0;for(var r=0;r<t;r++)n+=e[r];return n/t}return 0},Centi.prototype.cent=function(){var e=arguments.length;if(e==1&&arguments[0].length>1){e=arguments[0].length;var t={x:0,y:0},n=0;for(var r=0;r<e;r++){var i=arguments[0][r],s=arguments[0][(r+1)%e];t.x+=(i.x+s.x)*(i.x*s.y-s.x*i.y),t.y+=(i.y+s.y)*(i.x*s.y-s.x*i.y),n+=i.x*s.y-s.x*i.y}return n/=2,t.x=t.x/(6*n),t.y=t.y/(6*n),t}return{x:0,y:0}},Centi.prototype.curves=function(){var e=arguments.length;if(e==9)return this.getPointsOnCurve(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7],arguments[8]);if(e==2){if(arguments[1].length&&arguments[1].length==8)return this.getPointsOnCurve(arguments[0],arguments[1][0],arguments[1][1],arguments[1][2],arguments[1][3],arguments[1][4],arguments[1][5],arguments[1][6],arguments[1][7])}else if(e==1&&arguments[0].length&&arguments[0].length==9)return this.getPointsOnCurve(arguments[0][0],arguments[0][1],arguments[0][2],arguments[0][3],arguments[0][4],arguments[0][5],arguments[0][6],arguments[0][7],arguments[0][8])},Centi.prototype.getPointsOnCurve=function(e,t,n,r,i,s,o,u,a){e<2&&(e=2);var f=[];for(var l=0;l<e;l++){var c=l/(e-1);f.push(this.getPointOnCubicBezier(c,t,r,s,u)),f.push(this.getPointOnCubicBezier(c,n,i,o,a))}return f},Centi.prototype.getPointOnCubicBezier=function(e,t,n,r,i){var s=1-e;return s*s*s*t+3*s*s*e*n+3*s*e*e*r+e*e*e*i},Centi.prototype.radToDeg=Centi.prototype.r2d=function(e){return e*180/Math.PI},Centi.prototype.degToRad=Centi.prototype.d2r=function(e){return e*Math.PI/180},Centi.prototype.tree=function(e){function t(e,t){return Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)}this.kdtree=new kdTree(e,t,["x","y"])},Centi.prototype.nears=function(e,t,n){return this.kdtree.nearest(e,t,n)},Centi.prototype.bpm=function(e,t){this.tempo.bpm=e?e:120,this.tempo.divide=t?t:4,this.tempo.sec=60/this.tempo.bpm*4/this.tempo.divide,this.tempo.preSec=this.time},Centi.prototype.noteToFreq=Centi.prototype.n2f=function(e){return Math.pow(2,(e-69)/12)*440},Centi.prototype.loop=function(e,t,n){var r=e,i=t,s=t-e>0?1:-1,o=s==1?t-e:-(t-e);while(o>=0)n(r),r+=s,o--},Centi.prototype.sortNum=function(e){e.sort(function(e,t){return e<t?-1:e>t?1:0})},Centi.prototype.reverse=function(e){e.reverse()},Centi.prototype.fold=function(e){if(e.reduce)return e.reduce(function(e,t){return e+t});var t=0;for(var n=0;n<e.length;n++)t+=e[n];return t},Centi.prototype.remove=function(e,t){var n=[],r=e.length;for(var i=0;i<r;i++)t(e[i])||n.push(e[i]);return n},Centi.prototype.clip=function(e,t){return e.length<t?e:e.slice(e.length-t)},Centi.prototype.Vec2=function(e,t){return new Centi.Vec2(e,t)},Centi.prototype.vec2=function(e,t){return new Centi.Vec2(e,t)},Centi.prototype.Rectangle=function(e,t,n,r){return new Centi.Rectangle(e,t,n,r)},Centi.Numerical=new function(){return{EPSILON:1e-11,isZero:function(e){return Math.abs(e)<=this.EPSILON}}},Centi.Vec2=function(e,t){this.x=e||0,this.y=t||0},Centi.Vec2.prototype.set=function(e,t){return this.x=e,this.y=t,this},Centi.Vec2.prototype.clone=function(){return new Centi.Vec2(this.x,this.y)},Centi.Vec2.prototype.equals=function(e){return this===_vec2||_vec2&&(this.x===_vec2.x&&this.y===_vec2.y||Array.isArray(_vec2)&&this.x===_vec2[0]&&this.y===_vec2[1])||!1},Centi.Vec2.prototype.normalized=function(){var e=1/Math.sqrt(this.x*this.x+this.y*this.y);return new Centi.Vec2(this.x/e,this.y/e)},Centi.Vec2.prototype.normalize=function(){var e=Math.sqrt(this.x*this.x+this.y*this.y);this.x=this.x/e,this.y=this.y/e},Centi.Vec2.prototype.dist=Centi.Vec2.prototype.distance=function(){var e=arguments.length;if(e==1){var t=arguments[0];if(t){var n=this.x-t.x,r=this.y-t.y,i=Math.sqrt(n*n+r*r);return i}}else{if(e==0){var i=Math.sqrt(this.x*this.x+this.y*this.y);return i}if(e==2){var n=this.x-arguments[0],r=this.y-arguments[1],i=Math.sqrt(n*n+r*r);return i}}},Centi.Vec2.prototype.dot=function(e){return this.x*e.x+this.y+e.y},Centi.Vec2.prototype.cross=function(e){return this.x*e.x-this.y+e.y},Centi.Vec2.prototype.rotation=function(){if(!arguments.length)return this.isZero()?this._rotation||0:this._rotation=Math.atan2(this.y,this.x);var e=arguments[0],t=this.len()*e.len();if(Numerical.isZero(t))return NaN;var n=this.dot(e)/t;return Math.acos(n<-1?-1:n>1?1:n)},Centi.Vec2.prototype.setRotation=function(e){this._rotation=e;if(!this.isZero()){var t=this.len();this.set(Math.cos(e)*t,Math.sin(e)*t)}},Centi.Vec2.prototype.len=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},Centi.Vec2.prototype.setLen=function(e){if(this.isZero()){var t=this._rotation||0;this.set(Math.cos(t)*e,Math.sin(t)*e)}else{var n=e/this.len();Centi.Numerical.isZero(n)&&this.rotation(),this.set(this.x*n,this.y*n)}},Centi.Vec2.prototype.rotate=function(e,t){if(e===0)return this.clone();var n=t?this.subtract(t):this,r=Math.sin(e),i=Math.cos(e);return n=new Centi.Vec2(n.x*i-n.y*r,n.x*r+n.y*i),t?n.add(t):n},Centi.Vec2.prototype.add=function(e){return new Centi.Vec2(this.x+e.x,this.y+e.y)},Centi.Vec2.prototype.subtract=function(e){return new Centi.Vec2(this.x-e.x,this.y-e.y)},Centi.Vec2.prototype.multiply=function(e){return new Centi.Vec2(this.x*e.x,this.y*e.y)},Centi.Vec2.prototype.divide=function(e){return new Centi.Vec2(this.x/e.x,this.y/e.y)},Centi.Vec2.prototype.modulo=function(e){return new Centi.Vec2(this.x%e.x,this.y%e.y)},Centi.Vec2.prototype.negate=function(){return new Centi.Vec2(-this.x,-this.y)},Centi.Vec2.prototype.isZero=function(){return Centi.Numerical.isZero(this.x)&&Centi.Numerical.isZero(this.y)},Centi.Rectangle=function(e,t,n,r){this.x=e||0,this.y=t||0,this.w=this.width=n||0,this.h=this.height=r||0,this.r=this.right=this.x+this.w,this.b=this.bottom=this.y+this.h},Centi.prototype.now=function(){return(new Date).getTime()/1e3},Centi.prototype.grid=function(e,t,n,r){var i=e/n,s=t/r,o,u,a=[];for(o=0;o<n;o++)for(u=0;u<r;u++)a.push({ix:o,iy:u,x:o*i,y:u*s,w:i,h:s});return a},Centi.prototype.tween=function(e){var t=new TWEEN.Tween(e);return t},Centi.prototype.new=function(e,t){function n(){e.apply(this,t)}return n.prototype=e.prototype,new n},Centi.prototype.seg=function(e,t,n,r,i){var s=[1,2,11,19,20,29,37],o=[119,36,93,109,46,107,123,37,127,111];e>9&&(e=9);var u=o[e];for(var a=0;a<7;a++){if(u&1){var f=s[a]&7,l=s[a]>>3;this.line(t+r*(f&1),n+.5*i*(f>>1),t+r*(l&1),n+.5*i*(l>>1))}u>>=1}},Centi.prototype.segs=function(e,t,n,r,i,s){var o=arguments.length,u=.1;if(o<5)return;o==6&&(u=s);var a=e.toString(10),f=t;for(var l=0,c;l<a.length;l++){var h=a.charAt(l),p=parseInt(h,10);isNaN(p)?f+=r*.1+r*u:(this.seg(p,f,n,r,i),f+=r+r*u)}},Centi.prototype.shrink=function(e,t){e=e||1,e=e<1?1:e,t=t||e,t=t<1?1:t;var n=this.w/e,r=this.h/t;this.tempCtx.clearRect(0,0,this.w,this.h),this.tempCtx.drawImage(this.canvas,0,0,this.w,this.h,0,0,n,r),this.ctx.drawImage(this.tempCanvas,0,0,n,r,0,0,this.w,this.h)},Centi.prototype.mosaic=function(e,t){e=e||1,e=e<1?1:e,t=t||e,t=t<1?1:t;var n=Math.floor(this.w/e),r=Math.floor(this.h/t);this.tempCtx.clearRect(0,0,this.w,this.h),this.tempCtx.drawImage(this.canvas,0,0,this.w,this.h,0,0,n,r);var i=this.tempCtx.getImageData(0,0,n,r).data;e=this.w/n,t=this.h/r;for(var s=0;s<r;s+=1)for(var o=0;o<n;o+=1){var u=(o+s*n)*4;this.ctx.fillStyle="rgb("+i[u]+", "+i[u+1]+", "+i[u+2]+")",this.ctx.fillRect(o*e,s*t,e,t)}},Centi.prototype.glitch=function(e,t,n,r){e=e||0,t=t||0,n=n||0,r=r||0;var i=this,s={amount:e,seed:t,iterations:n,quality:r};glitch(this.ctx.getImageData(0,0,this.w,this.h),s,function(e){i.ctx.putImageData(e,0,0)})},Centi.prototype.crash=function(e){var t,n,r=this.w,i=this.h,s,o=e||6,u=Math.floor(this.rand(-o*2,o*2))*r*+Math.floor(this.rand(-o,o))*4,a=o*o/100*r,f,l,c=this.tempCanvas,h=this.tempCtx,p,d,v;c.width=r,c.height=i,h.clearRect(0,0,this.w,this.h),h.drawImage(this.canvas,0,0,r,i),p=h.getImageData(0,0,r,i).data;for(s=0;s<o;s++)n=Math.floor(this.rand(0,i)),l=Math.min(Math.floor(this.rand(1,i/4)),i-n),t=Math.floor(this.rand(1,a)),f=r-t,h.drawImage(this.canvas,0,n,f,l,t,n,f,l),h.drawImage(this.canvas,f,n,t,l,0,n,t,l);d=h.getImageData(0,0,r,i),v=d.data;for(s=Math.floor(this.rand(0,3)),o=p.length;s<o;s+=4)v[s+u]=p[s];for(s=0;s<o;s++)v[s++]*=2,v[s++]*=2,v[s++]*=2;h.putImageData(d,0,0),h.fillStyle="rgb(0,0,0)";for(s=0;s<i;s+=2)h.fillRect(0,s,r,1);this.ctx.drawImage(c,0,0)},Centi.prototype.dropShadow=function(e,t,n,r){this.ctx.shadowBlur=n==undefined?0:n,this.ctx.shadowOffsetX=e==undefined?0:e,this.ctx.shadowOffsetY=t==undefined?0:t;var i=r==undefined?"000000":r.toString(16);while(i.length<6)i="0"+i;this.ctx.shadowColor="#"+i};var CT_FUNCS=Object.getOwnPropertyNames(Centi.prototype)
  
  !function(a){a.prototype.Matrix=function(){return this.new(a.Matrix,arguments)},a.Matrix=function(){var a=arguments.length,b=!0;if(6===a?this.set.apply(this,arguments):1===a?arg instanceof Matrix?this.set(arg._a,arg._c,arg._b,arg._d,arg._tx,arg._ty):Array.isArray(arg)?this.set.apply(this,arg):b=!1:0===a?this.reset():b=!1,!b)throw new Error("Unsupported matrix parameters")},a.Matrix.prototype.set=function(a,b,c,d,e,f,g){return this._a=a,this._c=b,this._b=c,this._d=d,this._tx=e,this._ty=f,g||this._changed(),this},a.Matrix.prototype._changed=function(){var a=this._owner;a&&(a._applyMatrix?a.transform(null,!0):a._changed(9))},a.Matrix.prototype.clone=function(){return new a.Matrix(this._a,this._c,this._b,this._d,this._tx,this._ty)},a.Matrix.prototype.equals=function(a){return a===this||a&&this._a===a._a&&this._b===a._b&&this._c===a._c&&this._d===a._d&&this._tx===a._tx&&this._ty===a._ty||!1},a.Matrix.prototype.reset=function(a){return this._a=this._d=1,this._c=this._b=this._tx=this._ty=0,a||this._changed(),this},a.Matrix.prototype.apply=function(){var a=this._owner;return a?(a.transform(null,!0),this.isIdentity()):!1},a.Matrix.prototype.translate=function(a,b){return this._tx+=a*this._a+b*this._b,this._ty+=a*this._c+b*this._d,this._changed(),this},a.Matrix.prototype.scale=function(b,c,d,e){var f=new a.Vec2(b,c);return 4==arguments.length&&this.translate(d,e),this._a*=f.x,this._c*=f.x,this._b*=f.y,this._d*=f.y,4==arguments.length&&this.translate(-d,-e),this._changed(),this},a.Matrix.prototype.rotate=function(a,b,c){a*=Math.PI/180,b=b||0,c=c||0;var d=Math.cos(a),e=Math.sin(a),f=b-b*d+c*e,g=c-b*e-c*d,h=this._a,i=this._b,j=this._c,k=this._d;return this._a=d*h+e*i,this._b=-e*h+d*i,this._c=d*j+e*k,this._d=-e*j+d*k,this._tx+=f*h+g*i,this._ty+=f*j+g*k,this._changed(),this},a.Matrix.prototype.shear=function(b,c,d,e){var f=new a.Vec2(b,c);4==arguments.length&&this.translate(d,e);var g=this._a,h=this._c;return this._a+=f.y*this._b,this._c+=f.y*this._d,this._b+=f.x*g,this._d+=f.x*h,4==arguments.length&&this.translate(-d,-e),this._changed(),this},a.Matrix.prototype.skew=function(b,c,d,e){var f=new a.Vec2(b,c),g=Math.PI/180,h=new a.Vec2(Math.tan(f.x*g),Math.tan(f.y*g));return this.shear(h.x,h.y,d,e)},a.Matrix.prototype.concatenate=function(a){var b=this._a,c=this._b,d=this._c,e=this._d,f=a._a,g=a._b,h=a._c,i=a._d,j=a._tx,k=a._ty;return this._a=f*b+h*c,this._b=g*b+i*c,this._c=f*d+h*e,this._d=g*d+i*e,this._tx+=j*b+k*c,this._ty+=j*d+k*e,this._changed(),this},a.Matrix.prototype.preConcatenate=function(a){var b=this._a,c=this._b,d=this._c,e=this._d,f=this._tx,g=this._ty,h=a._a,i=a._b,j=a._c,k=a._d,l=a._tx,m=a._ty;return this._a=h*b+i*d,this._b=h*c+i*e,this._c=j*b+k*d,this._d=j*c+k*e,this._tx=h*f+i*g+l,this._ty=j*f+k*g+m,this._changed(),this},a.Matrix.prototype.chain=function(b){var c=this._a,d=this._b,e=this._c,f=this._d,g=this._tx,h=this._ty,i=b._a,j=b._b,k=b._c,l=b._d,m=b._tx,n=b._ty;return new a.Matrix(i*c+k*d,i*e+k*f,j*c+l*d,j*e+l*f,g+m*c+n*d,h+m*e+n*f)},a.Matrix.prototype.isIdentity=function(){return 1===this._a&&0===this._c&&0===this._b&&1===this._d&&0===this._tx&&0===this._ty},a.Matrix.prototype.orNullIfIdentity=function(){return this.isIdentity()?null:this},a.Matrix.prototype.isInvertible=function(){return!!this._getDeterminant()},a.Matrix.prototype.isSingular=function(){return!this._getDeterminant()},a.Matrix.prototype.transform=function(a,b,c){return arguments.length<3?this._transformPoint(Point.read(arguments)):this._transformCoordinates(a,b,c)},a.Matrix.prototype._transformPoint=function(b,c,d){var e=b.x,f=b.y;return c||(c=new a.Vec2),c.set(e*this._a+f*this._b+this._tx,e*this._c+f*this._d+this._ty,d)},a.Matrix.prototype._transformCoordinates=function(a,b,c){for(var d=0,e=0,f=2*c;f>d;){var g=a[d++],h=a[d++];b[e++]=g*this._a+h*this._b+this._tx,b[e++]=g*this._c+h*this._d+this._ty}return b},a.Matrix.prototype._transformCorners=function(a){var b=a.x,c=a.y,d=b+a.width,e=c+a.height,f=[b,c,d,c,d,e,b,e];return this._transformCoordinates(f,f,4)},a.Matrix.prototype._transformBounds=function(b,c,d){for(var e=this._transformCorners(b),f=e.slice(0,2),g=e.slice(),h=2;8>h;h++){var i=e[h],j=1&h;i<f[j]?f[j]=i:i>g[j]&&(g[j]=i)}return c||(c=new a.Rectangle),c.set(f[0],f[1],g[0]-f[0],g[1]-f[1],d)},a.Matrix.prototype.inverseTransform=function(){return this._inverseTransform(Point.read(arguments))},a.Matrix.prototype._getDeterminant=function(){var a=this._a*this._d-this._b*this._c;return isFinite(a)&&!Numerical.isZero(a)&&isFinite(this._tx)&&isFinite(this._ty)?a:null},a.Matrix.prototype._inverseTransform=function(a,b,c){var d=this._getDeterminant();if(!d)return null;var e=a.x-this._tx,f=a.y-this._ty;return b||(b=new Point),b.set((e*this._d-f*this._b)/d,(f*this._a-e*this._c)/d,c)},a.Matrix.prototype.decompose=function(){var b=this._a,c=this._b,d=this._c,e=this._d;if(Numerical.isZero(b*e-c*d))return null;var f=Math.sqrt(b*b+c*c);b/=f,c/=f;var g=b*d+c*e;d-=b*g,e-=c*g;var h=Math.sqrt(d*d+e*e);return d/=h,e/=h,g/=h,c*d>b*e&&(b=-b,c=-c,g=-g,f=-f),{scaling:new a.Vec2(f,h),rotation:180*-Math.atan2(c,b)/Math.PI,shearing:g}},a.Matrix.prototype.getValues=function(){return[this._a,this._c,this._b,this._d,this._tx,this._ty]},a.Matrix.prototype.getTranslation=function(){return new a.Vec2(this._tx,this._ty)},a.Matrix.prototype.getScaling=function(){return(this.decompose()||{}).scaling},a.Matrix.prototype.getRotation=function(){return(this.decompose()||{}).rotation},a.Matrix.prototype.inverted=function(){var b=this._getDeterminant();return b&&new a.Matrix(this._d/b,-this._c/b,-this._b/b,this._a/b,(this._b*this._ty-this._d*this._tx)/b,(this._c*this._tx-this._a*this._ty)/b)},a.Matrix.prototype.shiftless=function(){return new a.Matrix(this._a,this._c,this._b,this._d,0,0)},a.Matrix.prototype.applyToContext=function(a){a.transform(this._a,this._c,this._b,this._d,this._tx,this._ty)}}(Centi);
  