diff --git a/api-reference.md b/api-reference.md index d6680b2..6f76fd3 100644 --- a/api-reference.md +++ b/api-reference.md @@ -15,7 +15,7 @@ Change the dependencies file(s) to include your own selection of filters and plu ###Contents * [Image](#image-class) -* [Image Loader](#loader--htmlimageloader-classes) +* [Image Loader](#loader--binaryloader--htmlimageloader-classes) * [Abstract Filter](#generic-abstract-filter) * [Color Matrix Filter](#color-matrix-filter) (analogous to the ActionScript filter) * [Table Lookup Filter](#table-lookup-filter) @@ -82,21 +82,21 @@ __Methods:__ -###Loader / HTMLImageLoader Classes +###Loader / BinaryLoader / HTMLImageLoader Classes ````javascript -filterImageInstance = FILTER.HTMLImageLoader.load(imageUrl [, onLoad, onError]); +filterImageInstance = FILTER.HTMLImageLoader.load( imageUrl [, onLoad, onError] ); // this is similar to: -filterImageInstance = new FILTER.HTMLImageLoader().load(imageUrl [, onLoad, onError]); +filterImageInstance = new FILTER.HTMLImageLoader( ).load( imageUrl [, onLoad, onError] ); ```` -Loads an image url into a FILTER.Image instance. +Loads an image url into a `FILTER.Image` instance. -The same functionality to load a url into a FILTER.Image has been **removed from the FILTER.Image Class** +The same functionality to load a url into a `FILTER.Image` has been **removed from the FILTER.Image Class** -Use the FILTER.HTMLImageLoader instead. +Use the `FILTER.HTMLImageLoader` instead. In order to use the `FILTER.BinaryLoader` to load and decode a custom image format, see below. ###Generic Abstract Filter @@ -657,47 +657,47 @@ Native javascript `codecs` (`encoders` / `decoders`) are included for various `i 5. `TGA` (adapted from: https://github.com/vthibault/roBrowser/blob/master/src/Loaders/Targa.js) (**decoder only**) 6. `RGBE`/`HDR` (adapted from: http://www.graphics.cornell.edu/~bjw/rgbe.html) (**encoder + decoder**) -Instead of separate loaders per image format, only one binary loader is used, with the appropriate codecs as parameters. +Instead of separate loaders per image format, only one `binary loader` is used, with the appropriate codecs as parameters. This makes code more flexible and shorter, loaders can be adapted for nodejs easier and custom codecs can be used on the fly. **`PNG` example** Loads an image url in PNG format into a FILTER.Image instance. ````javascript -filterImageInstance = new FILTER.BinaryLoader( FILTER.Codec.PNG.decoder ).load(imageUrl [, onLoad, onError]); +filterImageInstance = FILTER.BinaryLoader( FILTER.Codec.PNG.decoder ).load( imageUrl [, onLoad, onError] ); ```` **`JPG` example** Loads an image url in JPG format into a FILTER.Image instance. ````javascript -filterImageInstance = new FILTER.BinaryLoader( FILTER.Codec.JPG.decoder ).load(imageUrl [, onLoad, onError]); +filterImageInstance = FILTER.BinaryLoader( FILTER.Codec.JPG.decoder ).load( imageUrl [, onLoad, onError] ); ```` **`GIF` example** Loads an image url in GIF format into a FILTER.Image instance. ````javascript -filterImageInstance = new FILTER.BinaryLoader( FILTER.Codec.GIF.decoder ).load(imageUrl [, onLoad, onError]); +filterImageInstance = FILTER.BinaryLoader( FILTER.Codec.GIF.decoder ).load( imageUrl [, onLoad, onError] ); ```` **`BMP` example** Loads an image url in BMP format into a FILTER.Image instance. ````javascript -filterImageInstance = new FILTER.BinaryLoader( FILTER.Codec.BMP.decoder ).load(imageUrl [, onLoad, onError]); +filterImageInstance = FILTER.BinaryLoader( FILTER.Codec.BMP.decoder ).load( imageUrl [, onLoad, onError] ); ```` **`TGA` example** Loads an image url in TGA format into a FILTER.Image instance. ````javascript -filterImageInstance = new FILTER.BinaryLoader( FILTER.Codec.TGA.decoder ).load(imageUrl [, onLoad, onError]); +filterImageInstance = FILTER.BinaryLoader( FILTER.Codec.TGA.decoder ).load( imageUrl [, onLoad, onError] ); ```` **`RGBE` example** Loads an image url in RGBE format into a FILTER.Image instance. ````javascript -filterImageInstance = new FILTER.BinaryLoader( FILTER.Codec.RGBE.decoder ).load(imageUrl [, onLoad, onError]); +filterImageInstance = FILTER.BinaryLoader( FILTER.Codec.RGBE.decoder ).load( imageUrl [, onLoad, onError] ); ```` diff --git a/build/filter.bundle.js b/build/filter.bundle.js index 2c13de6..0407f6d 100644 --- a/build/filter.bundle.js +++ b/build/filter.bundle.js @@ -22,16 +22,16 @@ * * FILTER.js * @version: 0.8.0 -* @built on 2016-07-19 20:00:58 +* @built on 2016-07-19 22:00:50 * @dependencies: Classy.js, Asynchronous.js * * JavaScript Image Processing Library * https://github.com/foo123/FILTER.js * **/!function(e,t,n){"use strict";function r(e,t,n,r){return e?t.map(function(t,a){return(n?e[a]:e[t])||(r?r(t):null)}):[]}"object"==typeof module&&module.exports?(module.$deps=module.$deps||{})&&(module.exports=module.$deps[t]=n.apply(e,r(module.$deps,["Classy","Asynchronous"],!1,function(e){return require("./"+e.toLowerCase())}))):"function"==typeof define&&define.amd&&"function"==typeof require&&"function"==typeof require.specified&&require.specified(t)?define(t,["module"].concat(["Classy","Asynchronous"]),function(t){return n.moduleUri=t.uri,n.apply(e,r(Array.prototype.slice.call(arguments,1),["Classy","Asynchronous"],!0))}):t in e||(e[t]=n.apply(e,r(e,["Classy","Asynchronous"])))&&"function"==typeof define&&define.amd&&define(function(){return e[t]})}(this,"FILTER",function ModuleFactory__FILTER(Classy,Asynchronous){"use strict";var FILTER=Classy.Merge({Classy:Classy,Asynchronous:Asynchronous,Path:Asynchronous.path(ModuleFactory__FILTER.moduleUri)},Classy);return FILTER.VERSION="0.8.0",!function(e,t,n){var r,a="prototype",i=(Object[a],Function[a],Array[a]),s=t.Path,o=t.Merge,l=t.Asynchronous,u=l.isPlatform(l.Platform.NODE),c=l.isPlatform(l.Platform.BROWSER),h=l.supportsMultiThreading(),f=l.isThread(),d=navigator?navigator.userAgent:"",p=function(){return"[FILTER Plugin: "+this.name+"]"},m=function(e,t,n,r){return e},_=function(){},g=function(e){return function(){this.$super("constructor"),e.apply(this,arguments)}},v=(t.devicePixelRatio=e.devicePixelRatio||1,t._notSupportClamp="undefined"==typeof Uint8ClampedArray),y=("undefined"==typeof Int16Array||"function"!=typeof Int16Array[a].set,function(e,t){var n=e.length;for(t=t||0;--n>=0;)this[n+t]=e[n]}),w=i.slice,C=0,A=t.Browser={isNode:u,isBrowser:c,isWorker:f,supportsWorker:h,isPhantom:/PhantomJS/.test(d),isOpera:c&&/Opera|OPR\//.test(d),isFirefox:c&&/Firefox\//.test(d),isChrome:c&&/Chrome\//.test(d),isSafari:c&&/Apple Computer/.test(navigator.vendor),isKhtml:c&&/KHTML\//.test(d),isIE:c&&(/MSIE \d/.test(d)||/Trident\/\d/.test(d)),isGecko:c&&/gecko\/\d/i.test(d),isWebkit:c&&/WebKit\//.test(d),isMac_geLion:c&&/Mac OS X 1\d\D([7-9]|\d\d)\D/.test(d),isMac_geMountainLion:c&&/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(d),isMobile:!1,isIOS:/AppleWebKit/.test(d)&&/Mobile\/\w+/.test(d),isWin:/windows/i.test(navigator.platform),isMac:!1,isIE_lt8:!1,isIE_lt9:!1,isQtWebkit:!1};A.isMobile=A.isIOS||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(d),A.isMac=A.isIOS||/Mac/.test(navigator.platform),A.isIE_lt8=A.isIE&&!f&&(null==document.documentMode||document.documentMode<8),A.isIE_lt9=A.isIE&&!f&&(null==document.documentMode||document.documentMode<9),A.isQtWebkit=A.isWebkit&&/Qt\/\d+\.\d+/.test(d),t.getPath=l.path,t.uuid=function(e){return[e||"filter",(new Date).getTime(),++C].join("_")},t.Array=Array,t.Array32F="undefined"!=typeof Float32Array?Float32Array:Array,t.Array64F="undefined"!=typeof Float64Array?Float64Array:Array,t.Array8I="undefined"!=typeof Int8Array?Int8Array:Array,t.Array16I="undefined"!=typeof Int16Array?Int16Array:Array,t.Array32I="undefined"!=typeof Int32Array?Int32Array:Array,t.Array8U="undefined"!=typeof Uint8Array?Uint8Array:Array,t.Array16U="undefined"!=typeof Uint16Array?Uint16Array:Array,t.Array32U="undefined"!=typeof Uint32Array?Uint32Array:Array,t.Array32F[a].set||(t.Array32F[a].set=y,t.Array64F[a].set=y,t.Array8I[a].set=y,t.Array16I[a].set=y,t.Array32I[a].set=y,t.Array8U[a].set=y,t.Array16U[a].set=y,t.Array32U[a].set=y),t.Array32F[a].subarray||(t.Array32F[a].subarray=w,t.Array64F[a].subarray=w,t.Array8I[a].subarray=w,t.Array16I[a].subarray=w,t.Array32I[a].subarray=w,t.Array8U[a].subarray=w,t.Array16U[a].subarray=w,t.Array32U[a].subarray=w),t.ImArray=v?t.Array8U:Uint8ClampedArray,t.ImArrayCopy=A.isNode||A.isOpera?t.Array8U:t.ImArray,v&&"undefined"!=typeof CanvasPixelArray&&"function"!==CanvasPixelArray[a].set&&(CanvasPixelArray[a].set=y),v=t._notSupportClamp=v||A.isOpera||A.isNode,t.NotImplemented=function(e){return e=e||"",function(){throw new Error("Method "+e+" not Implemented!")}},t.useWebGL=!1,t.useWebGLSharedResources=!1,t.useWebGLIfAvailable=function(e){},t.useWebGLSharedResourcesIfAvailable=function(e){},t.CHANNEL={RED:0,GREEN:1,BLUE:2,ALPHA:3},t.MODE={IGNORE:0,WRAP:1,CLAMP:2,COLOR:4},t.LUMA=new t.Array32F([.212671,.71516,.072169]),t.FORMAT={IMAGE:1,DATA:4,PNG:8,JPG:16,GIF:32,BMP:64,TGA:128,RGBE:256},t.MIME={PNG:"image/png",JPG:"image/jpeg",GIF:"image/gif",BMP:"image/bmp"},t.FORMAT.JPEG=t.FORMAT.JPG,t.MIME.JPEG=t.MIME.JPG,t.Utils={},t.Codec={},t.Interpolation={},t.Transform={},t.MachineLearning=t.ML={},r=t.log=console&&console.log?function(e){console.log(e)}:function(e){},t.warning=function(e){r("WARNING: "+e)},t.error=function(e,t){if(r("ERROR: "+e),t)throw new Error(e)};var b=t.FilterThread=t.Class(l,{path:s,name:null,constructor:function(){var e=this,t=null;f&&e.initThread().listen("load",function(e){e&&e.filter&&(t&&(t.dispose(!0),t=null),t=l.load("FILTER."+e.filter))}).listen("import",function(e){e&&e["import"]&&e["import"].length&&importScripts(e["import"])}).listen("params",function(e){t&&t.unserialize(e)}).listen("apply",function(n){if(t&&n&&n.im){n.params&&t.unserialize(n.params),n.im[0].id=n.id;var r={im:t._apply(n.im[0],n.im[1],n.im[2])};t.hasMeta&&(r.meta=t.getMeta()),e.send("apply",r)}else e.send("apply",{im:null})}).listen("dispose",function(n){t&&(t.dispose(!0),t=null),e.dispose(!0),close()})},thread:function(e){var t=this;return arguments.length||(e=!0),e=!!e,e&&!t.$thread?(t.fork("FILTER.FilterThread",s.file!==t.path.file?[s.file,t.path.file]:t.path.file),t.send("load",{filter:t.name})):!e&&t.$thread&&t.unfork(),t},sources:function(){var e=i.slice.call(arguments);if(e.length){var t,n=[];for(t=0;tn?n:t>e?t:e}function r(e){return _(2,g(R(e)))}function a(e,t){var n=new p(2);return n[I]=e||0,n[M]=t||0,n}function i(e,t,n){var r=new p(3);return r[I]=e||0,r[M]=t||0,r[L]=n||0,r}function s(e,t,n){var r=1-n;return a(n*e[I]+r*t[I],n*e[M]+r*t[M])}function o(e,t,n){var r=1-n;return i(n*e[I]+r*t[I],n*e[M]+r*t[M],n*e[L]+r*t[L])}function l(e,t){return e[I]*t[M]-t[I]*e[M]}function u(e,t){var n;return 0>e&&(e=-e),0>t&&(t=-t),0==e?t:0==t?e:e>t?(n=t/e,e*m(1+n*n)):(n=e/t,t*m(1+n*n))}function c(e,t){var n,r,i,s,o;return n=a(e[I]-t[I],e[M]-t[M]),0===n[M]&&0===n[I]?null:(r=a(0,0),0===n[I]&&(r[I]=10),0===n[M]&&(r[M]=10),0!==n[M]&&0!==n[I]&&(i=n[M]/n[I],s=-n[I]/n[M],r[I]=10,r[M]=s*r[I]),o=u(r[I],r[M]),r[I]/=o,r[M]/=o,0>l(n,r)&&(r[I]=-r[I],r[M]=-r[M]),r)}function h(e,t,n,r){var a,i,s,o,l,u,c,h,f,d,m=t<<2,_=e.length,g=_>>2;for(d=!0!==r,a=new p(g),h=0,c=0,o=l=u=0,f=0;t>f;f++,c+=4,h++)o+=e[c],a[h]=o;for(c=m,f=0,h=0,o=l=u=0,c=m;_>c;c+=4,h++,f++)f>=t&&(f=0,o=l=u=0),o+=e[c],a[h+t]=a[h]+o;if(d){for(i=new p(g),s=new p(g),h=0,c=0,o=l=u=0,f=0;t>f;f++,c+=4,h++)l+=e[c+1],u+=e[c+2],i[h]=l,s[h]=u;for(c=m,f=0,h=0,o=l=u=0,c=m;_>c;c+=4,h++,f++)f>=t&&(f=0,o=l=u=0),l+=e[c+1],u+=e[c+2],i[h+t]=i[h]+l,s[h+t]=s[h]+u;return[a,i,s]}return[a,a,a]}function f(e,t,n,r){var a,i,s,o,l,u,c,h,f,d,m,_=e.length,g=0,v=0,y=0,w=255,C=255,A=255,b=1/(_>>2);for(m=!0!==r,a=new p(256),d=0;256>d;d+=8)a[d]=0,a[d+1]=0,a[d+2]=0,a[d+3]=0,a[d+4]=0,a[d+5]=0,a[d+6]=0,a[d+7]=0;for(d=0;_>d;d+=4)o=e[d],a[o]+=b,o>g?g=o:w>o&&(w=o);for(c=h=f=0,d=0;256>d;d+=8)c+=a[d],a[d]=c,c+=a[d+1],a[d+1]=c,c+=a[d+2],a[d+2]=c,c+=a[d+3],a[d+3]=c,c+=a[d+4],a[d+4]=c,c+=a[d+5],a[d+5]=c,c+=a[d+6],a[d+6]=c,c+=a[d+7],a[d+7]=c;if(m){for(i=new p(256),s=new p(256),d=0;256>d;d+=8)i[d]=0,s[d]=0,i[d+1]=0,s[d+1]=0,i[d+2]=0,s[d+2]=0,i[d+3]=0,s[d+3]=0,i[d+4]=0,s[d+4]=0,i[d+5]=0,s[d+5]=0,i[d+6]=0,s[d+6]=0,i[d+7]=0,s[d+7]=0;for(d=0;_>d;d+=4)l=e[d+1],u=e[d+2],i[l]+=b,s[u]+=b,l>v?v=l:C>l&&(C=l),u>y?y=u:A>u&&(A=u);for(c=h=f=0,d=0;256>d;d+=8)h+=i[d],i[d]=h,f+=s[d],s[d]=f,h+=i[d+1],i[d+1]=h,f+=s[d+1],s[d+1]=f,h+=i[d+2],i[d+2]=h,f+=s[d+2],s[d+2]=f,h+=i[d+3],i[d+3]=h,f+=s[d+3],s[d+3]=f,h+=i[d+4],i[d+4]=h,f+=s[d+4],s[d+4]=f,h+=i[d+5],i[d+5]=h,f+=s[d+5],s[d+5]=f,h+=i[d+6],i[d+6]=h,f+=s[d+6],s[d+6]=f,h+=i[d+7],i[d+7]=h,f+=s[d+7],s[d+7]=f;return[a,i,s]}return[a,a,a]}function d(e,t,n,r){return null}var p=(e.ImArray,e.Array32F),m=(e.Array64F,Math.sqrt),_=Math.pow,g=Math.ceil,v=Math.log,y=Math.PI,w=y+y,C=.5*y,A=Math.LN2,b=Math.SQRT2,E=function(e){return v(e)/A},R=Math.log2||E,I=0,M=1,L=2;e.CONSTANTS=e.CONST={PI:y,PI2:w,PI_2:C,SQRT2:b,LN2:A,toRad:y/180,toDeg:180/y,X:I,Y:M,Z:L},e.Geometry={Point2:a,Point3:i,enorm2:u,cross2:l,normal2:c,interpolate2:s,interpolate3:o},e.Math={clamp:n,closestPower2:r,integral:h,histogram:f,spectrum:d}}(FILTER),!function(e,t){var n=e.ImArray,r=Math.min;e.Interpolation.crop=function(e,t,a,i,s,o,l){o=r(o,t-1),l=r(l,a-1);var u,c,h,f,d=o-i+1,p=l-s+1,m=d*p<<2,_=new n(m),g=d<<2;for(u=s,c=s*t,h=0;l>=u;u++,c+=t,h+=g)f=c+i<<2,_.set(e.subarray(f,f+g),h);return _},e.Interpolation.pad=function(e,t,r,a,i,s,o){a=a||0,i=i||0,s=s||0,o=o||0;var l,u,c,h,f=t+s+a,d=r+o+i,p=f*d<<2,m=new n(p),_=t<<2,g=f<<2,v=o*g,y=s<<2;for(l=0,u=0,c=v;r>l;l++,u+=t,c+=g)h=u<<2,m.set(e.subarray(h,h+_),y+c);return m}}(FILTER),!function(e,t){var n=e.Math.clamp,r=e.ImArray;e.Interpolation.bilinear=function(e,t,a,i,s){var o,l,u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E,R,I=i*s<<2,M=new r(I),L=(t-1)/i,x=(a-1)/s,N=t<<2;for(m=0,_=0,g=0,v=0,w=0,b=0,R=0,A=0;I>A;A+=4,_++,g+=L)_>=i&&(_=0,g=0,m++,v+=x,w=~~v,R=v-w,b=w*t),y=~~g,E=g-y,h=(1-E)*(1-R),f=E*(1-R),d=R*(1-E),p=E*R,C=b+y<<2,o=e[C],l=e[C+4],u=e[C+N],c=e[C+N+4],M[A]=n(~~(o*h+l*f+u*d+c*p+.5),0,255),o=e[C+1],l=e[C+5],u=e[C+N+1],c=e[C+N+5],M[A+1]=n(~~(o*h+l*f+u*d+c*p+.5),0,255),o=e[C+2],l=e[C+6],u=e[C+N+2],c=e[C+N+6],M[A+2]=n(~~(o*h+l*f+u*d+c*p+.5),0,255),o=e[C+3],l=e[C+7],u=e[C+N+3],c=e[C+N+7],M[A+3]=n(~~(o*h+l*f+u*d+c*p+.5),0,255);return M}}(FILTER),!function(e,t){var n,r;r=e.Class({constructor:function(e){var t=this;t._cnv=e,t._transform={scale:[1,1],translate:[0,0],rotate:[0,0]},t._data=null},_cnv:null,_transform:null,_data:null,dispose:function(){var e=this;return e._cnv=null,e._data=null,e._transform=null,e},drawImage:function(){},scale:function(e,t){var n=this;return n._transform.scale[0]=e,n._transform.scale[1]=t,n},translate:function(e,t){var n=this;return n._transform.translate[0]=e,n._transform.translate[1]=t,n}}),n=e.FilterCanvas=e.Class({constructor:function(e,t){var n=this;n.width=e||0,n.height=t||0,n.style={},n._ctx=new r(n)},_ctx:null,width:null,height:null,style:null,dispose:function(){var e=this;return e.width=null,e.height=null,e.style=null,e._ctx.dispose(),e._ctx=null,e},getContext:function(e){return this._ctx},toDataURL:function(e){return""}}),e.Canvas=function(t,r){var a=e.Browser.isNode?new n:document.createElement("canvas");return t=t||0,r=r||0,a.style.width=t+"px",a.style.height=r+"px",a.width=t*devicePixelRatio,a.height=r*devicePixelRatio,a}}(FILTER),!function(e){var t=Math.sqrt,n=Math.round,r=(Math.floor,Math.min),a=Math.max,i=(Math.abs,e.Math.clamp),s=/([.*+?^${}()|\[\]\/\\\-])/g,o=function(e){return e.replace(s,"\\$1")},l=/^\s+|\s+$/g,u=String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(l,"")},c=1/255,h=100/255,f=2.55,d={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]},p=e.Color=e.Class({__static__:{clamp:i,clampPixel:function(e){return r(255,a(e,0))},toGray:function(t,n,r){var a=e.LUMA;return~~(a[0]*t+a[1]*n+a[2]*r)},distance:function(e,n){var r=e[0]-n[0],a=e[1]-n[1],i=e[2]-n[2];return t(r*r+a*a+i*i)},RGB2Color:function(e){return e[0]<<16|e[1]<<8|255&e[2]},RGBA2Color:function(e){return e[3]<<24|e[0]<<16|e[1]<<8|255&e[2]},Color2RGBA:function(e){return e=~~e,[e>>>16&255,e>>>8&255,255&e,e>>>24&255]},RGB2YCbCr:function(e){var t,n,r,a=e[0],i=e[1],s=e[2];return t=~~(0+.299*a+.587*i+.114*s),n=~~(128-.168736*a-.331264*i+.5*s),r=~~(128+.5*a-.418688*i-.081312*s),[t,n,r]},YCbCr2RGB:function(e){var t,n,r,a=e[0],i=e[1],s=e[2];return t=~~(a+1.402*(s-128)),n=~~(a-.34414*(i-128)-.71414*(s-128)),r=~~(a+1.772*(i-128)),[t,n,r]},RGB2HSV:function(e){var t,n,i,s,o,l,u,c,h;return s=e[0],o=e[1],l=e[2],t=r(s,o,l),n=a(s,o,l),i=n-t,h=n,0==n?(c=0,u=0,[u,c,h]):(c=i/n,u=s==n?(o-l)/i:o==n?2+(l-s)/i:4+(s-o)/i,u*=60,0>u&&(u+=360),[u,c,h])},HSV2RGB:function(e){var t,n,r,a,i,s,o,l,u,c,h;return u=e[0],c=e[1],h=e[2],0==c?(s=o=l=h,[s,o,l]):(u/=60,t=~~u,n=u-t,r=h*(1-c),a=h*(1-c*n),i=h*(1-c*(1-n)),0===t?(s=h,o=i,l=r):1===t?(s=a,o=h,l=r):2===t?(s=r,o=h,l=i):3===t?(s=r,o=a,l=h):4===t?(s=i,o=r,l=h):(s=h,o=r,l=a),[s,o,l])},toString:function(){return"[FILTER: "+this.name+"]"},C2F:c,C2P:h,P2C:f,Keywords:d,hexieRE:/^#([0-9a-fA-F]{8})\b/,hexRE:/^#([0-9a-fA-F]{3,6})\b/,rgbRE:/^(rgba?)\b\s*\(([^\)]*)\)/i,hslRE:/^(hsla?)\b\s*\(([^\)]*)\)/i,keywordRE:new RegExp("^("+Object.keys(d).map(o).join("|")+")\\b","i"),colorstopRE:/^\s+(\d+(\.\d+)?%?)/,col2per:function(e,t){return e*h+(t||"")},per2col:function(e){return e*f},rgb2cmyk:function(e,t,a,s){var o,l,u=0,h=0,d=0,p=0;return s&&(e=i(n(e*f),0,255),t=i(n(t*f),0,255),a=i(n(a*f),0,255)),0==e&&0==t&&0==a?(p=1,[0,0,0,1]):(u=1-e*c,h=1-t*c,d=1-a*c,o=r(u,h,d),l=1/(1-o),u=(u-o)*l,h=(h-o)*l,d=(d-o)*l,p=o,[u,h,d,p])},cmyk2rgb:function(e,t,r,a){var s,o,l=0,u=0,c=0;return 0==e&&0==t&&0==r?[0,0,0]:(s=a,o=1-s,e=e*o+s,t=t*o+s,r=r*o+s,l=255*(1-e),u=255*(1-t),c=255*(1-r),[i(n(l),0,255),i(n(u),0,255),i(n(c),0,255)])},rgb2hex:function(e,t,r,a,s){var o;return s&&(e=i(n(e*f),0,255),t=i(n(t*f),0,255),r=i(n(r*f),0,255)),e=16>e?"0"+e.toString(16):e.toString(16),t=16>t?"0"+t.toString(16):t.toString(16),r=16>r?"0"+r.toString(16):r.toString(16),o=a&&e[0]==e[1]&&t[0]==t[1]&&r[0]==r[1]?"#"+e[0]+t[0]+r[0]:"#"+e+t+r},rgb2hexIE:function(e,t,r,a,s){var o;return s&&(e=i(n(e*f),0,255),t=i(n(t*f),0,255),r=i(n(r*f),0,255),a=i(n(a*f),0,255)),e=16>e?"0"+e.toString(16):e.toString(16),t=16>t?"0"+t.toString(16):t.toString(16),r=16>r?"0"+r.toString(16):r.toString(16),a=16>a?"0"+a.toString(16):a.toString(16),o="#"+a+e+t+r},hex2rgb:function(e){return!e||3>e.length?[0,0,0]:6>e.length?[i(parseInt(e[0]+e[0],16),0,255),i(parseInt(e[1]+e[1],16),0,255),i(parseInt(e[2]+e[2],16),0,255)]:[i(parseInt(e[0]+e[1],16),0,255),i(parseInt(e[2]+e[3],16),0,255),i(parseInt(e[4]+e[5],16),0,255)]},hue2rgb:function(e,t,n){return 0>n&&(n+=1),n>1&&(n-=1),1/6>n?e+6*(t-e)*n:.5>n?t:2/3>n?e+(t-e)*(2/3-n)*6:e},hsl2rgb:function(e,t,r){var a,s,o,l,u;return e=(e+360)%360/360,t*=.01,r*=.01,0==t?(a=1,s=1,o=1):(u=.5>r?r*(1+t):r+t-r*t,l=2*r-u,a=p.hue2rgb(l,u,e+1/3),s=p.hue2rgb(l,u,e),o=p.hue2rgb(l,u,e-1/3)),[i(n(255*a),0,255),i(n(255*s),0,255),i(n(255*o),0,255)]},rgb2hsl:function(e,t,s,o){var l,u,h,f,d,p;return o?(e*=.01,t*=.01,s*=.01):(e*=c,t*=c,s*=c),u=a(e,t,s),l=r(e,t,s),d=.5*(u+l),u==l?h=f=0:(p=u-l,f=d>.5?p/(2-a-r):p/(a+r),h=u==e?(t-s)/p+(s>t?6:0):u==t?(s-e)/p+2:(e-t)/p+4,h/=6),[n(360*h)%360,i(100*f,0,100),i(100*d,0,100)]},parse:function(e,t,n,r){var a,i,s,o,l,c=0,f=0;if("hsl"==n||!n&&(a=e.match(p.hslRE))){if("hsl"==n){l="hsla"==e[0].toLowerCase();var d=e[1].split(",").map(u)}else{c=a[0].length,f=0,l="hsla"==a[1].toLowerCase();var d=a[2].split(",").map(u)}var m=d[0]?d[0]:"0",e=d[1]?d[1]:"0",_=d[2]?d[2]:"0",g=l&&null!=d[3]?d[3]:"1";return m=parseFloat(m,10),e="%"==e.slice(-1)?parseFloat(e,10):parseFloat(e,10)*h,_="%"==_.slice(-1)?parseFloat(_,10):parseFloat(_,10)*h,g=parseFloat(g,10),o=(new p).fromHSL([m,e,_,g]),t&&(s=e.substr(c),(i=s.match(p.colorstopRE))&&(o.colorStop(i[1]),f=i[0].length)),r?o:[o,0,c+f]}if("rgb"==n||!n&&(a=e.match(p.rgbRE))){if("rgb"==n){l="rgba"==e[0].toLowerCase();var d=e[1].split(",").map(u)}else{c=a[0].length,f=0,l="rgba"==a[1].toLowerCase();var d=a[2].split(",").map(u)}var v=d[0]?d[0]:"0",y=d[1]?d[1]:"0",w=d[2]?d[2]:"0",g=l&&null!=d[3]?d[3]:"1";return v="%"==v.slice(-1)?2.55*parseFloat(v,10):parseFloat(v,10),y="%"==y.slice(-1)?2.55*parseFloat(y,10):parseFloat(y,10),w="%"==w.slice(-1)?2.55*parseFloat(w,10):parseFloat(w,10),g=parseFloat(g,10),o=(new p).fromRGB([v,y,w,g]),t&&(s=e.substr(c),(i=s.match(p.colorstopRE))&&(o.colorStop(i[1]),f=i[0].length)),r?o:[o,0,c+f]}if("hex"==n||!n&&(a=e.match(p.hexRE))){if("hex"==n)var d=p.hex2rgb(e[0]);else{c=a[0].length,f=0;var d=p.hex2rgb(a[1])}var C=d[0]?d[0]:0,A=d[1]?d[1]:0,b=d[2]?d[2]:0,g=null!=d[3]?d[3]:255;return o=(new p).fromHEX([C,A,b,g]),t&&(s=e.substr(c),(i=s.match(p.colorstopRE))&&(o.colorStop(i[1]),f=i[0].length)),r?o:[o,0,c+f]}if("keyword"==n||!n&&(a=e.match(p.keywordRE))){if("keyword"==n)var d=e[0];else{c=a[0].length,f=0;var d=a[1]}return o=(new p).fromKeyword(d),t&&(s=e.substr(c),(i=s.match(p.colorstopRE))&&(o.colorStop(i[1]),f=i[0].length)),r?o:[o,0,c+f]}return null},fromString:function(e,t,n){return p.parse(e,t,n,1)},fromRGB:function(e){return(new p).fromRGB(e)},fromHSL:function(e){return(new p).fromHSL(e)},fromCMYK:function(e){return(new p).fromCMYK(e)},fromHEX:function(e){return(new p).fromHEX(e)},fromKeyword:function(e){return(new p).fromKeyword(e)},fromPixel:function(e){return(new p).fromPixel(e)}},constructor:function m(e,t){return this instanceof m?(this.reset(),void(e&&this.set(e,t))):new m(e,t)},name:"Color",col:null,cstop:null,kword:null,clone:function(){var e=new p;return e.col=this.col.slice(),e.cstop=this.cstop+"",e.kword=this.kword,e},reset:function(){return this.col=[0,0,0,1],this.cstop="",this.kword=null,this},set:function(e,t){return e&&(undef!==e[0]&&(this.col[0]=i(e[0],0,255)),undef!==e[1]&&(this.col[1]=i(e[1],0,255)),undef!==e[2]&&(this.col[2]=i(e[2],0,255)),undef!==e[3]?this.col[3]=i(e[3],0,1):this.col[3]=1,t&&(this.cstop=t),this.kword=null),this},colorStop:function(e){return this.cstop=e,this},isTransparent:function(){return 1>this.col[3]},isKeyword:function(){return!!this.kword},fromPixel:function(e){return e=e||0,this.col=[i(e>>16&255,0,255),i(e>>8&255,0,255),i(255&e,0,255),i((e>>24&255)*c,0,1)],this.kword=null,this},fromKeyword:function(e){return e=e.toLowerCase(),p.Keywords[e]&&(this.col=p.Keywords[e].slice(),this.kword=e),this},fromHEX:function(e){return this.col[0]=e[0]?i(parseInt(e[0],10),0,255):0,this.col[1]=e[1]?i(parseInt(e[1],10),0,255):0,this.col[2]=e[2]?i(parseInt(e[2],10),0,255):0,this.col[3]=undef!==e[3]?i(parseInt(e[3],10)*c,0,1):1,this.kword=null,this},fromRGB:function(e){return this.col[0]=e[0]?i(n(e[0]),0,255):0,this.col[1]=e[1]?i(n(e[1]),0,255):0,this.col[2]=e[2]?i(n(e[2]),0,255):0,this.col[3]=undef!==e[3]?i(e[3],0,1):1,this.kword=null,this},fromCMYK:function(e){var t=p.cmyk2rgb(e[0]||0,e[1]||0,e[2]||0,e[3]||0);return this.col[0]=t[0],this.col[1]=t[1],this.col[2]=t[2],this.col[3]=undef!==e[4]?i(e[4],0,1):1,this.kword=null,this},fromHSL:function(e){var t=p.hsl2rgb(e[0]||0,e[1]||0,e[2]||0);return this.col[0]=t[0],this.col[1]=t[1],this.col[2]=t[2],this.col[3]=undef!==e[3]?i(e[3],0,1):1,this.kword=null,this},toPixel:function(e){return e?i(255*this.col[3],0,255)<<24|this.col[0]<<16|this.col[1]<<8|255&this.col[2]:this.col[0]<<16|this.col[1]<<8|255&this.col[2]},toCMYK:function(e,t,n){var r=p.rgb2cmyk(this.col[0],this.col[1],this.col[2]);return n?r:r.concat(this.col[3])},toKeyword:function(e,t,n){return this.kword?this.kword:this.toHEX(1,t,n)},toHEX:function(e,t,r){return r?p.rgb2hexIE(this.col[0],this.col[1],this.col[2],i(n(255*this.col[3]),0,255)):p.rgb2hex(this.col[0],this.col[1],this.col[2],t)},toRGB:function(e,t,n){var r=this.col[3];return e?(t&&(r=1>r&&r>0?r.toString().slice(1):r),n||1==this.col[3]?"rgb("+this.col.slice(0,3).join(",")+")":"rgba("+this.col.slice(0,3).concat(r).join(",")+")"):n?this.col.slice(0,3):this.col.slice()},toHSL:function(e,t,n){var r=this.col[3],a=p.rgb2hsl(this.col[0],this.col[1],this.col[2]);return e?(t&&(a[1]=0==a[1]?a[1]:a[1]+"%",a[2]=0==a[2]?a[2]:a[2]+"%",r=1>r&&r>0?r.toString().slice(1):r),n||1==this.col[3]?"hsl("+[a[0],a[1],a[2]].join(",")+")":"hsla("+[a[0],a[1],a[2],r].join(",")+")"):n?a:a.concat(this.col[3])},toColorStop:function(e){var t=this.cstop;return e?(t=t.length?t+",":"",1>this.col[3]?"color-stop("+t+this.toRGB(1,1)+")":"color-stop("+t+this.toHEX(1,1)+")"):(t=t.length?" "+t:"",1>this.col[3]?this.toRGB(1,1)+t:this.toHEX(1,1)+t)},toString:function(e,t){return e=e?e.toLowerCase():"hex","rgb"==e||"rgba"==e?this.toRGB(1,!1!==t,"rgb"==e):"hsl"==e||"hsla"==e?this.toHSL(1,!1!==t,"hsl"==e):"keyword"==e?this.toKeyword(1):this.toHEX(1,!1!==t,"hexie"==e)}})}(FILTER),!function(e,t){function n(e){var t=e.width,n=e.height,r=c(t,n);return r.width=t*o,r.height=n*o,r}function r(e,t,n,r){return r=r||R,r&b&&(e.width=t,e.oCanvas.style.width=t+"px",e.oCanvas.width=t*o,e._restorable&&(e.iCanvas.style.width=e.oCanvas.style.width,e.iCanvas.width=e.oCanvas.width),e.tmpCanvas&&(e.tmpCanvas.style.width=e.oCanvas.style.width,e.tmpCanvas.width=e.oCanvas.width)),r&E&&(e.height=n,e.oCanvas.style.height=n+"px",e.oCanvas.height=n*o,e._restorable&&(e.iCanvas.style.height=e.oCanvas.style.height,e.iCanvas.height=e.oCanvas.height),e.tmpCanvas&&(e.tmpCanvas.style.height=e.oCanvas.style.height,e.tmpCanvas.height=e.oCanvas.height)),e}function a(e,t){var n=e.width,r=e.height;return t=t||255,e._restorable&&t&_&&e._needsRefresh&_&&(e.iData=e.ictx.getImageData(0,0,n,r),e._needsRefresh&=~_),t&g&&e._needsRefresh&g&&(e.oData=e.octx.getImageData(0,0,n,r),e._needsRefresh&=~g),e}function i(e,t){if(e.selection){var n=e.selection,r=e.width-1,a=e.height-1,i=f(n[0]*r),s=f(n[1]*a),o=f(n[2]*r)-i+1,l=f(n[3]*a)-s+1;t=t||255,e._restorable&&t&v&&e._needsRefresh&v&&(e.iDataSel=e.ictx.getImageData(i,s,o,l),e._needsRefresh&=~v),t&y&&e._needsRefresh&y&&(e.oDataSel=e.octx.getImageData(i,s,o,l),e._needsRefresh&=~y)}return e}var s="prototype",o=e.devicePixelRatio,l=e.ImArray,u=e.ImArrayCopy,c=(e.Array32F,e.Canvas),h=e.FilterCanvas,f=(e._notSupportTypedArrays,Math.min,Math.floor),d=e.FORMAT,p=e.MIME,m=0,_=1,g=2,v=4,y=8,w=16,C=32,A=64,b=2,E=4,R=b|E,I=v|y,M=_|g,L=~I,x=~w,N=~C,S=e.Image=e.Class({name:"Image",constructor:function O(e){var t=this,n=0,r=0;return t instanceof O?(t.id=++m,t.width=n,t.height=r,t.iData=null,t.iDataSel=null,t.oData=null,t.oDataSel=null,t.iCanvas=c(n,r),t.oCanvas=c(n,r),t.tmpCanvas=null,t.domElement=t.oCanvas,t.ictx=t.iCanvas.getContext("2d"),t.octx=t.oCanvas.getContext("2d"),t.webgl=null,t._histogram=null,t._integral=null,t._spectrum=null,t.selection=null,t._needsRefresh=0,t._restorable=!0,t._grayscale=!1,void(e&&t.image(e))):new O(e)},id:null,width:0,height:0,selection:null,iCanvas:null,oCanvas:null,tmpCanvas:null,ictx:null,octx:null,iData:null,iDataSel:null,oData:null,oDataSel:null,domElement:null,webgl:null,_histogram:null,_integral:null,_spectrum:null,_needsRefresh:0,_restorable:!0,_grayscale:!1,dispose:function(){var e=this;return e.id=null,e.width=null,e.height=null,e.selection=null,e.ictx=null,e.octx=null,e.iData=null,e.iDataSel=null,e.oData=null,e.oDataSel=null,e.iCanvas=null,e.oCanvas=null,e.tmpCanvas=null,e.domElement=null,e.webgl=null,e._histogram=null,e._integral=null,e._spectrum=null,e._needsRefresh=null,e._restorable=null,e._grayscale=null,e},clone:function(e){return new S(!0===e?this.iCanvas:this.oCanvas)},grayscale:function(e){var t=this;return arguments.length?(t._grayscale=!!e,t):t._grayscale},restorable:function(e){var t=this;return arguments.length||(e=!0),t._restorable=!!e,t},apply:function(e,t){return e.apply(this,this,t||null),this},apply2:function(e,t,n){return e.apply(this,t,n||null),this},select:function(e,t,n,r){var a=this,i=arguments.length;return 1>i&&(e=0),2>i&&(t=0),3>i&&(n=1),4>i&&(r=1),a.selection=[0>e?0:e>1?1:e,0>t?0:t>1?1:t,0>n?0:n>1?1:n,0>r?0:r>1?1:r],a._needsRefresh|=I,a},deselect:function(){var e=this;return e.selection=null,e.iDataSel=null,e.oDataSel=null,e._needsRefresh&=L,e},store:function(){var e=this;return e._restorable&&(e.ictx.drawImage(e.oCanvas,0,0),e._needsRefresh|=_,e.selection&&(e._needsRefresh|=v)),e},restore:function(){var e=this;return e._restorable&&(e.octx.drawImage(e.iCanvas,0,0),e._needsRefresh|=g|w|C|A,e.selection&&(e._needsRefresh|=y)),e},dimensions:function(e,t){var n=this;return r(n,e,t,R),n._needsRefresh|=M|w|C|A,n.selection&&(n._needsRefresh|=I),n},scale:function(e,t){var r=this;if(e=e||1,t=t||e,1==e&&1==t)return r;r.tmpCanvas=r.tmpCanvas||n(r);var a=r.tmpCanvas.getContext("2d"),i=r.width,s=r.height;return a.scale(e,t),i=r.width=~~(e*i+.5),s=r.height=~~(t*s+.5),a.drawImage(r.oCanvas,0,0),r.oCanvas.style.width=i+"px",r.oCanvas.style.height=s+"px",r.oCanvas.width=i*o,r.oCanvas.height=s*o,r.octx.drawImage(r.tmpCanvas,0,0),r._restorable&&(a.drawImage(r.iCanvas,0,0),r.iCanvas.style.width=r.oCanvas.style.width,r.iCanvas.style.height=r.oCanvas.style.height,r.iCanvas.width=r.oCanvas.width,r.iCanvas.height=r.oCanvas.height,r.ictx.drawImage(r.tmpCanvas,0,0)),r.tmpCanvas.width=r.oCanvas.width,r.tmpCanvas.height=r.oCanvas.height,r._needsRefresh|=M|w|C|A,r.selection&&(r._needsRefresh|=I),r},flipHorizontal:function(){var e=this;e.tmpCanvas=e.tmpCanvas||n(e);var t=e.tmpCanvas.getContext("2d");return t.translate(e.width,0),t.scale(-1,1),t.drawImage(e.oCanvas,0,0),e.octx.drawImage(e.tmpCanvas,0,0),e._restorable&&(t.drawImage(e.iCanvas,0,0),e.ictx.drawImage(e.tmpCanvas,0,0)),e._needsRefresh|=M|w|C|A,e.selection&&(e._needsRefresh|=I),e},flipVertical:function(){var e=this;e.tmpCanvas=e.tmpCanvas||n(e);var t=e.tmpCanvas.getContext("2d");return t.translate(0,e.height),t.scale(1,-1),t.drawImage(e.oCanvas,0,0),e.octx.drawImage(e.tmpCanvas,0,0),e._restorable&&(t.drawImage(e.iCanvas,0,0),e.ictx.drawImage(e.tmpCanvas,0,0)),e._needsRefresh|=M|w|C|A,e.selection&&(e._needsRefresh|=I),e},draw:function(e,t,n,r){return this},clear:function(){var e=this,t=e.width,n=e.height;return t&&n&&(e._restorable&&e.ictx.clearRect(0,0,t,n),e.octx.clearRect(0,0,t,n),e._needsRefresh|=M|w|C|A,e.selection&&(e._needsRefresh|=I)),e},crop:function(e,t,r,a){var i,s,l,u,c,h,d,p,m=this,_=m.selection,g=m.width,v=m.height;if(arguments.length)c=e,h=t,d=r-e+1,p=a-t+1;else{if(!_)return m;i=f(_[0]*(g-1)),s=f(_[1]*(v-1)),l=f(_[2]*(g-1))-i+1,u=f(_[3]*(v-1))-s+1,c=i,h=s,d=l,p=u,_[0]=0,_[1]=0,_[2]=1,_[3]=1}m.tmpCanvas=m.tmpCanvas||n(m);var y=m.tmpCanvas.getContext("2d");return y.drawImage(m.oCanvas,0,0,g,v,c,h,d,p),m.oCanvas.style.width=d+"px",m.oCanvas.style.height=p+"px",m.oCanvas.width=d*o,m.oCanvas.height=p*o,m.octx.drawImage(m.tmpCanvas,0,0),m._restorable&&(y.drawImage(m.iCanvas,0,0,g,v,c,h,d,p),m.iCanvas.style.width=m.oCanvas.style.width,m.iCanvas.style.height=m.oCanvas.style.height,m.iCanvas.width=m.oCanvas.width,m.iCanvas.height=m.oCanvas.height,m.ictx.drawImage(m.tmpCanvas,0,0)),m.tmpCanvas.width=m.oCanvas.width,m.tmpCanvas.height=m.oCanvas.height,m._needsRefresh|=M|w|C|A,_&&(m._needsRefresh|=I),m},fill:function(e,n,r,a,i){var s,o,l,u,c=this,h=c.selection,d=c.width,p=c.height;h?(s=f(h[0]*(d-1)),o=f(h[1]*(p-1)),l=f(h[2]*(d-1))-s+1,u=f(h[3]*(p-1))-o+1):(s=0,o=0,l=d,u=p),t===n&&(n=s),t===r&&(r=o),t===a&&(a=l), -t===i&&(i=u),a&&!d&&i&&!p&&c.createImageData(a,i);var m=c.ictx,_=c.octx;return e=e||0,c._restorable&&(m.fillStyle=e,m.fillRect(n,r,a,i)),_.fillStyle=e,_.fillRect(n,r,a,i),c._needsRefresh|=M|w|C|A,h&&(c._needsRefresh|=I),c},getData:function(){var e,t=this;return t._restorable?(t._needsRefresh&_&&a(t,_),e=t.iData):(t._needsRefresh&g&&a(t,g),e=t.oData),new u(e.data)},getSelectedData:function(){var e,t=this;return t.selection?t._restorable?(t._needsRefresh&v&&i(t,v),e=t.iDataSel):(t._needsRefresh&y&&i(t,y),e=t.oDataSel):t._restorable?(t._needsRefresh&_&&a(t,_),e=t.iData):(t._needsRefresh&g&&a(t,g),e=t.oData),[new u(e.data),e.width,e.height]},getProcessedData:function(){var e=this;return e._needsRefresh&g&&a(e,g),new u(e.oData.data)},getProcessedSelectedData:function(){var e,t=this;return t.selection?(t._needsRefresh&y&&i(t,y),e=t.oDataSel):(t._needsRefresh&g&&a(t,g),e=t.oData),[new u(e.data),e.width,e.height]},setData:function(e){var t=this;return t._needsRefresh&g&&a(t,g),t.oData.data.set(e),t.octx.putImageData(t.oData,0,0),t._needsRefresh|=w|C|A,t.selection&&(t._needsRefresh|=y),t},setSelectedData:function(e){var t=this;if(t.selection){var n=t.selection,r=t.width-1,s=t.height-1,o=f(n[0]*r),l=f(n[1]*s);t._needsRefresh&y&&i(t,y),t.oDataSel.data.set(e),t.octx.putImageData(t.oDataSel,o,l),t._needsRefresh|=g}else t._needsRefresh&g&&a(t,g),t.oData.data.set(e),t.octx.putImageData(t.oData,0,0);return t._needsRefresh|=w|C|A,t},createImageData:function(e,t){var n,a,i=this;return r(i,e,t,R),i._restorable&&(n=i.ictx=i.iCanvas.getContext("2d"),n.createImageData(e,t)),a=i.octx=i.oCanvas.getContext("2d"),a.createImageData(e,t),i._needsRefresh|=M,i.selection&&(i._needsRefresh|=I),i},image:function(e){if(!e)return this;var t,n,i,s,o,l,u,c=this;return e instanceof S&&(e=e.oCanvas),o=e instanceof HTMLVideoElement,l=e instanceof HTMLCanvasElement||e instanceof h,u=e instanceof Image,o?(i=e.videoWidth,s=e.videoHeight):(i=e.width,s=e.height),u||l||o?(r(c,i,s,R),c._restorable&&(t=c.ictx=c.iCanvas.getContext("2d"),t.drawImage(e,0,0)),n=c.octx=c.oCanvas.getContext("2d"),n.drawImage(e,0,0),c._needsRefresh|=M):(c.oData||(c.createImageData(i,s),a(c,M)),c._restorable&&(t=c.ictx=c.iCanvas.getContext("2d"),c.iData.data.set(e.data),t.putImageData(c.iData,0,0)),n=c.octx=c.oCanvas.getContext("2d"),c.oData.data.set(e.data),n.putImageData(c.oData,0,0)),c._needsRefresh|=w|C|A,c.selection&&(c._needsRefresh|=I),c},getPixel:function(e,t){var n=this;n._needsRefresh&g&&a(n,g);var r=~~(t*n.width+e+.5)<<2,i=n.oData.data;return{r:i[r],g:i[r+1],b:i[r+2],a:i[r+3]}},setPixel:function(e,t,n,r,a,i){var s=this;return s.octx.putImageData(new l([255&n,255&r,255&a,255&i]),e,t),s._needsRefresh|=g|w|C|A,s.selection&&(s._needsRefresh|=y),s},getPixelData:function(){return this._needsRefresh&g&&a(this,g),this.oData},setPixelData:function(e){var t=this;return t.octx.putImageData(e,0,0),t._needsRefresh|=g|w|C|A,t.selection&&(t._needsRefresh|=y),t},integral:function(){var e=this;return e._needsRefresh&C&&(e._integral=S.integral(e.getPixelData().data,e.width,e.height,e._grayscale),e._needsRefresh&=N),e._integral},histogram:function(){var e=this;return e._needsRefresh&w&&(e._histogram=S.histogram(e.getPixelData().data,e.width,e.height,e._grayscale),e._needsRefresh&=x),e._histogram},spectrum:function(){var e=this;return e._spectrum},toImage:function(e){var t,n=this.oCanvas,r=1;if(t=e&d.JPG?n.toDataURL(p.JPG,r):e&d.GIF?n.toDataURL(p.GIF,r):n.toDataURL(p.PNG,r),e&d.IMAGE){var a=new Image;return a.src=t,a}return t},toString:function(){return"[FILTER Image: "+this.name+"]"}});S[s].setImage=S[s].image,S[s].setDimensions=S[s].dimensions,S.scale=S.resize=e.Interpolation.bilinear,S.crop=e.Interpolation.crop,S.pad=e.Interpolation.pad,S.integral=e.Math.integral,S.histogram=e.Math.histogram,S.spectrum=e.Math.spectrum;var T=e.ScaledImage=e.Class(S,{name:"ScaledImage",constructor:function F(e,t,n){var r=this;return r instanceof F?(r.scaleX=e||1,r.scaleY=t||r.scaleX,void r.$super("constructor",n)):new F(e,t,n)},scaleX:1,scaleY:1,dispose:function(){var e=this;return e.scaleX=null,e.scaleY=null,e.$super("dispose"),e},clone:function(e){var t=this;return new T(t.scaleX,t.scaleY,!0===e?t.iCanvas:t.oCanvas)},setScale:function(e,t){var n=this,r=arguments.length;return r>0&&null!=e&&(n.scaleX=e,n.scaleY=e),r>1&&null!=t&&(n.scaleY=t),n},image:function(e){if(!e)return this;var t,n,a,i,s,o,l,u,c,f=this,d=f.scaleX,p=f.scaleY;return e instanceof S&&(e=e.oCanvas),l=e instanceof HTMLVideoElement,u=e instanceof HTMLCanvasElement||e instanceof h,c=e instanceof Image,l?(a=e.videoWidth,i=e.videoHeight):(a=e.width,i=e.height),(c||u||l)&&(s=~~(d*a+.5),o=~~(p*i+.5),r(f,s,o,R),f._restorable&&(t=f.ictx=f.iCanvas.getContext("2d"),t.drawImage(e,0,0,a,i,0,0,s,o)),n=f.octx=f.oCanvas.getContext("2d"),n.drawImage(e,0,0,a,i,0,0,s,o),f._needsRefresh|=M|w|C|A,f.selection&&(f._needsRefresh|=I)),f}});T[s].setImage=T[s].image}(FILTER),!function(e,t){function n(e,t,n){var r="";if(!e)return xhr?xhr:r;var a,l,u,c,h,f=s(e);if(n){for(l=0,u=f.length;u>l;l++)a=f[l],n.setHeader(a,e[a]);return n}if(t){for(l=0,u=f.length;u>l;l++)if(a=f[l],"[object Array]"===i.call(e[a]))for(c=0,h=e[a].length;h>c;c++)t.setRequestHeader(a,String(e[a][c]));else t.setRequestHeader(a,String(e[a]));return t}for(l=0,u=f.length;u>l;l++)if(a=f[l],"[object Array]"===i.call(e[a]))for(r.length&&(r+=o),r+=a+": "+String(e[a][0]),c=1,h=e[a].length;h>c;c++)r+=o+String(e[a][c]);else r.length&&(r+=o),r+=a+": "+String(e[a]);return r}function r(e,t){var n,r,i,s,l={},c=null;if(e)for(t=!0===t,e=e.split(o),r=0,i=e.length;i>r;r++)s=e[r],n=s.split(":"),n.length>1?(c=u(n.shift()),t&&(c=c.toLowerCase()),l[a](c)?("string"==typeof l[c]&&(l[c]=[l[c]]),l[c].push(u(n.join(":")))):l[c]=u(n.join(":"))):n[0].length&&c&&(l[c]=o+n[0]);return l}var a="hasOwnProperty",i=Object.prototype.toString,s=Object.keys,o="\r\n",l=/^\s+|\s+$/g,u=String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(l,"")},c=e.Image,h=e.Class,f=e.Loader=h({name:"Loader",__static__:{load:e.Method(function(e,t,n){return function(e,t,r){return(new n).load(e,t,r)}},e.LATE|e.STATIC)},constructor:function(){},_crossOrigin:null,_responseType:null,dispose:function(){var e=this;return e._crossOrigin=null,e._responseType=null,e},load:function(e,t,n){return null},responseType:function(e){var t=this;return arguments.length?(t._responseType=e,t):t._responseType},crossOrigin:function(e){var t=this;return arguments.length?(t._crossOrigin=e,t):t._crossOrigin}}),d=e.XHR=function m(e,t){var n=this,r=!1;n.readyState=m.UNSENT,n.status=null,n.statusText=null,n.responseType="text",n.responseURL=null,n.response=null,n.responseText=null,n.responseXml=null,n._rawHeaders=null,n._headers=null,n.send=function(t){return r||m.UNSENT!==n.readyState?n:(e&&e(t),n.readyState=m.OPENED,n)},n.abort=function(){return r?n:(r=!0,t&&t(),n)},n.getAllResponseHeaders=function(e){return m.DONE!==n.readyState?null:!0===e?n._headers:n._rawHeaders},n.getResponseHeader=function(e,t){if(null==e||m.DONE!==n.readyState)return null;var r=n._headers||{};return!1!==t&&(e=e.toLowerCase()),r[a](e)?r[e]:null},n.dispose=function(){return n.readyState=null,n.status=null,n.statusText=null,n.responseType=null,n.responseURL=null,n.response=null,n.responseText=null,n.responseXml=null,n._rawHeaders=null,n._headers=null,n.getAllResponseHeaders=null,n.getResponseHeader=null,n.send=null,n.abort=null,n}};d.UNSENT=0,d.OPENED=1,d.HEADERS_RECEIVED=2,d.LOADING=3,d.DONE=4,d.create=e.Browser.isNode?function(e,t){if(e=e||{},!e.url)return null;var r,a,s="[object Object]"===i.call(e.url)?e.url:require("url").parse(e.url),o={method:e.method||"GET",agent:!1,protocol:s.protocol,host:s.hostname,hostname:s.hostname,port:s.port||80,path:(s.pathname||"/")+(s.query?"?"+s.query:"")};return a=new d(function(e){null!=e&&(e=String(e),r.setHeader("Content-Length",String(e.length)),r.write(e)),r.end()},function(){r.abort()}),r=("https:"===o.protocol?require("https").request:require("http").request)(o,function(t){var n="",r=0;a.readyState=d.OPENED,e.onStateChange&&e.onStateChange(a),a.readyState=d.HEADERS_RECEIVED,a._rawHeaders=t.rawHeaders.join("\r\n"),a._headers=t.headers,a.responseURL=t.url||null,a.status=t.statusCode||null,a.statusText=t.statusMessage||null,e.onStateChange&&e.onStateChange(a),t.on("data",function(t){n+=t.toString(),r||(r=1,a.readyState=d.LOADING,e.onStateChange&&e.onStateChange(a),e.onLoadStart&&e.onLoadStart(a)),e.onProgress&&e.onProgress(a)}),t.on("end",function(){a.readyState=d.DONE,a.responseType="text",a.response=a.responseText=n,e.onStateChange&&e.onStateChange(a),e.onLoadEnd&&e.onLoadEnd(a),d.DONE===a.readyState&&(200===a.status?e.onComplete&&e.onComplete(a):e.onRequestError?e.onRequestError(a):e.onError&&e.onError(a))}),t.on("error",function(t){a.statusText=t.toString(),e.onError&&e.onError(a)})}),r.setTimeout(e.timeout||3e4,function(t){e.onTimeout&&e.onTimeout(a)}),r.on("abort",function(t){e.onAbort&&e.onAbort(a)}),r.on("error",function(t){a.statusText=t.toString(),e.onError&&e.onError(a)}),e.headers&&n(e.headers,null,r),arguments.length>1&&a.send(t),a}:function(e,t){if(e=e||{},!e.url)return null;var a="undefined"!=typeof XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),i=new d(function(e){a.send(e)},function(){a.abort()}),s=function(e,t){return e.readyState=t.readyState,e.responseType=t.responseType,e.responseURL=t.responseURL,e.response=t.response,e.responseText=t.responseText,e.responseXml=t.responseXml,e.status=t.status,e.statusText=t.statusText,e};return i.getAllResponseHeaders=function(e){var t=a.getAllResponseHeaders();return!0===e?r(t):t},i.getResponseHeader=function(e){return a.getResponseHeader(e)},a.open(e.method||"GET",e.url,!e.sync),i.responseType=a.responseType=e.responseType||"text",a.timeout=e.timeout||3e4,e.onProgress&&(a.onprogress=function(){e.onProgress(s(i,a))}),e.onLoadStart&&(a.onloadstart=function(){e.onLoadStart(s(i,a))}),e.onLoadEnd&&(a.onloadend=function(){e.onLoadEnd(s(i,a))}),!e.sync&&e.onStateChange&&(a.onreadystatechange=function(){e.onStateChange(s(i,a))}),a.onload=function(){s(i,a),d.DONE===a.readyState&&(200===a.status?e.onComplete&&e.onComplete(i):e.onRequestError?e.onRequestError(i):e.onError&&e.onError(i))},a.onabort=function(){e.onAbort&&e.onAbort(s(i,a))},a.onerror=function(){e.onError&&e.onError(s(i,a))},a.ontimeout=function(){e.onTimeout&&e.onTimeout(s(i,a))},e.headers&&n(e.headers,a),e.mimeType&&a.overrideMimeType(e.mimeType),arguments.length>1&&i.send(t),i};var p=(e.XHRLoader=h(f,{name:"XHRLoader",constructor:function _(){var e=this;return e instanceof _?void 0:new _},load:function(e,t,n){var r=this;return d.create({url:e,onComplete:function(e){"function"==typeof t&&t("arraybuffer"===r._responseType?new Buffer(e.response):e.response)},onError:function(e){"function"==typeof n&&n(e.statusText)}}),r}}),e.FileLoader=h(f,{name:"FileLoader",constructor:function g(){var e=this;return e instanceof g?void 0:new g},load:function(t,n,r){var a=this;({encoding:"arraybuffer"===a._responseType?null:a._responseType,flag:"r"});return e.Browser.isNode?require("fs").readFile(t,{encoding:"arraybuffer"===a._responseType?null:a._responseType,flag:"r"},function(e,t){e?"function"==typeof r&&r(e.toString()):"function"==typeof n&&n(t)}):d.create({url:t,responseType:a._responseType,onComplete:function(e){"function"==typeof n&&n(e.response)},onError:function(e){"function"==typeof r&&r(e.statusText)}}),a}}));e.BinaryLoader=h(f,{name:"BinaryLoader",constructor:function v(e){var t=this;return t instanceof v?void(t._decoder="function"==typeof e?e:null):new v(e)},_decoder:null,_encoder:null,dispose:function(){var e=this;return e._decoder=null,e._encoder=null,e.$super("dispose"),e},decoder:function(e){var t=this;return t._decoder="function"==typeof e?e:null,t},encoder:function(e){var t=this;return t._encoder="function"==typeof e?e:null,t},load:function(e,t,n){var r=this,a=new c,i=r._decoder;return"function"==typeof i&&(new p).responseType(r._responseType||"arraybuffer").load(e,function(e){var n={},r=i(e,n);r&&(a.image(r),"function"==typeof t&&t(a,n))},n),a}})}(FILTER),!function(e,t){var n=e.Image;e.HTMLImageLoader=e.Class(e.Loader,{name:"HTMLImageLoader",constructor:function r(){return this instanceof r?void this.$super("constructor"):new r},load:function(e,t,r){var a,i=this,s=new n;return a=new Image,a.onload=function(e){s.setImage(a),"function"==typeof t&&t(s,a)},a.onerror=function(e){"function"==typeof r&&r(s,a)},i._crossOrigin?a.crossOrigin=i._crossOrigin:a.crossOrigin="",a.src=e,s}})}(FILTER),!function(e,t){var n=(Object.prototype,Function.prototype,Array.prototype),r=n.slice,a=n.splice,i=n.concat,s=e.CompositeFilter=e.Class(e.Filter,{name:"CompositeFilter",constructor:function(e){var t=this;t.$super("constructor"),t._stack=e&&e.length?e.slice():[]},_stack:null,_meta:null,_stable:!0,dispose:function(e){var t,n=this,r=n._stack;if(n.$super("dispose"),!0===e)for(t=0;tn;n++)l[n]=l[n].unserialize(i[n]);else{for(n=0;a>n;n++)l[n]&&l[n].dispose(!0),l[n]=null;for(l=[],n=0;r>n;n++){if(s=i[n]&&i[n].filter?e[i[n].filter]:null,!s)throw new Error('Filter "'+i[n].filter+'" could not be created');l.push((new s).unserialize(i[n]))}}o._stack=l}return o},getMeta:function(){return this._meta},setMeta:function(e){var t,n,r=this,a=r._stack;if(e&&(n=e.length)&&a.length)for(t=0;n>t;t++)a[e[t][0]].setMeta(e[t][1]);return r},stable:function(e){return arguments.length||(e=!0),this._stable=!!e,this},filters:function(e){return arguments.length?(this._stack=e.slice(),this):this._stack.slice()},push:function(){var e=r.call(arguments),t=e.length;return t&&(this._stack=i.apply(this._stack,e)),this},pop:function(){return this._stack.pop()},shift:function(){return this._stack.shift()},unshift:function(){var e=r.call(arguments),t=e.length;return t&&a.apply(this._stack,[0,0].concat(e)),this},getAt:function(e){return this._stack.length>e?this._stack[e]:null},setAt:function(e,t){return this._stack.length>e?this._stack[e]=t:this._stack.push(t),this},insertAt:function(e){var t=r.call(arguments);t.length;return argslen>1&&(t.shift(),a.apply(this._stack,[e,0].concat(t))),this},removeAt:function(e){return this._stack.splice(e,1)},remove:function(e){for(var t=this._stack.length;--t>=0;)e===this._stack[t]&&this._stack.splice(t,1);return this},reset:function(){return this._stack.length=0,this},_apply:function(e,t,n,r){var a=this;if(a.hasMeta=!1,a._meta=[],a._isOn&&a._stack.length){var i,s,o=a._stack,l=o.length;for(i=0;l>i;i++)s=o[i],s&&s._isOn&&(e=s._apply(e,t,n,r),s.hasMeta&&a._meta.push([i,s.getMeta()]))}return a.hasMeta=a._meta.length>0,e},canRun:function(){return this._isOn&&this._stack.length},toString:function(){var e,t=arguments.length&&arguments[0].substr?arguments[0]:" ",n=t+t,r=this._stack,a=[],i=r.length;for(e=0;i>e;e++)a.push(r[e].toString(n));return["[FILTER: "+this.name+"]","["," "+a.join("\n "),"]",""].join("\n")}});s.prototype.empty=s.prototype.reset,s.prototype.concat=s.prototype.push}(FILTER),!function(e,t){var n="hasOwnProperty";e.InlineFilter=e.Class(e.Filter,{name:"InlineFilter",constructor:function(e){var t=this;t.$super("constructor"),t._handler=e&&"function"==typeof e?e:null,t._params={}},_handler:null,_params:null,dispose:function(){var e=this;return e.$super("dispose"),e._handler=null,e._params=null,e},params:function(e){var t=this;if(arguments.length){for(var r in e)e[n](r)&&(t._params[r]=e[r]);return t}return t._params},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_handler:e._handler?e._handler.toString():null,_params:e._params}}},unserialize:function(t){var n,r=this;return t&&r.name===t.filter&&(r._isOn=!!t._isOn,n=t.params,r._handler=null,n._handler&&(r._handler=new Function("FILTER",'"use strict"; return '+n._handler+";")(e)),r._params=n._params||{}),r},_apply:function(e,t,n,r){var a=this;return a._isOn&&a._handler?a._handler(a,e,t,n,r):e},canRun:function(){return this._isOn&&this._handler}});e.CustomFilter=e.InlineFilter}(FILTER),!function(e,t){function n(e,t){var n,r,a,i,o,l=new s(20);return n=t[0],r=t[1],a=t[2],i=t[3],o=t[4],l[0]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[1]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[2]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[3]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[4]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,n=t[5],r=t[6],a=t[7],i=t[8],o=t[9],l[5]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[6]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[7]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[8]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[9]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,n=t[10],r=t[11],a=t[12],i=t[13],o=t[14],l[10]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[11]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[12]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[13]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[14]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,n=t[15],r=t[16],a=t[17],i=t[18],o=t[19],l[15]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[16]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[17]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[18]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[19]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,l}function r(e,t,n){var r=1-n,a=new s(20);return a[0]=r*e[0]+n*t[0],a[1]=r*e[1]+n*t[1],a[2]=r*e[2]+n*t[2],a[3]=r*e[3]+n*t[3],a[4]=r*e[4]+n*t[4],a[5]=r*e[5]+n*t[5],a[6]=r*e[6]+n*t[6],a[7]=r*e[7]+n*t[7],a[8]=r*e[8]+n*t[8],a[9]=r*e[9]+n*t[9],a[10]=r*e[10]+n*t[10],a[11]=r*e[11]+n*t[11],a[12]=r*e[12]+n*t[12],a[13]=r*e[13]+n*t[13],a[14]=r*e[14]+n*t[14],a[15]=r*e[15]+n*t[15],a[16]=r*e[16]+n*t[16],a[17]=r*e[17]+n*t[17],a[18]=r*e[18]+n*t[18],a[19]=r*e[19]+n*t[19],a}var a=Math.sin,i=Math.cos,s=e.Array32F,o=e.CONST.toRad,l=(e.CONST.toDeg,e._notSupportClamp),u=e.ColorMatrixFilter=e.Class(e.Filter,{name:"ColorMatrixFilter",constructor:function(t){var n=this;n.$super("constructor"),t&&t.length?n._matrix=new s(t):n._matrix=null,e.useWebGL&&(n._webglInstance=e.WebGLColorMatrixFilterInstance||null)},_matrix:null,_webglInstance:null,dispose:function(){var e=this;return e.$super("dispose"),e._webglInstance=null,e._matrix=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_matrix:e._matrix}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n._matrix=t._matrix),n},channel:function(n,r){r=r===t?!1:r;var a=r?1:0;switch(n){case e.CHANNEL.ALPHA:return this.set([0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,255]);case e.CHANNEL.BLUE:return this.set([0,0,a,0,0,0,0,a,0,0,0,0,1,0,0,0,0,0,0,255]);case e.CHANNEL.GREEN:return this.set([0,a,0,0,0,0,1,0,0,0,0,a,0,0,0,0,0,0,0,255]);case e.CHANNEL.RED:default:return this.set([1,0,0,0,0,a,0,0,0,0,a,0,0,0,0,0,0,0,0,255])}},redChannel:function(t){return this.channel(e.CHANNEL.RED,t)},greenChannel:function(t){return this.channel(e.CHANNEL.GREEN,t)},blueChannel:function(t){return this.channel(e.CHANNEL.BLUE,t)},alphaChannel:function(t){return this.channel(e.CHANNEL.ALPHA,!0)},maskChannel:function(t){switch(t){case e.CHANNEL.ALPHA:return this;case e.CHANNEL.BLUE:return this.set([1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0]);case e.CHANNEL.GREEN:return this.set([1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0]);case e.CHANNEL.RED:default:return this.set([0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0])}},swapChannels:function(t,n){switch(t){case e.CHANNEL.ALPHA:switch(n){case e.CHANNEL.ALPHA:return this;case e.CHANNEL.BLUE:return this.set([1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0]);case e.CHANNEL.GREEN:return this.set([1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0]);case e.CHANNEL.RED:default:return this.set([0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0])}break;case e.CHANNEL.BLUE:switch(n){case e.CHANNEL.ALPHA:return this.set([1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0]);case e.CHANNEL.BLUE:return this;case e.CHANNEL.GREEN:return this.set([1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0]);case e.CHANNEL.RED:default:return this.set([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])}break;case e.CHANNEL.GREEN:switch(n){case e.CHANNEL.ALPHA:return this.set([1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0]);case e.CHANNEL.BLUE:return this.set([1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0]);case e.CHANNEL.GREEN:return this;case e.CHANNEL.RED:default:return this.set([0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0])}break;case e.CHANNEL.RED:default:switch(n){case e.CHANNEL.ALPHA:return this.set([0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0]);case e.CHANNEL.BLUE:return this.set([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0]);case e.CHANNEL.GREEN:return this.set([0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0]);case e.CHANNEL.RED:default:return this}}},desaturate:function(){return this.set([e.LUMA[0],e.LUMA[1],e.LUMA[2],0,0,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,0,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,0,0,0,0,1,0])},colorize:function(n,r){var a,i,s,o;return r===t&&(r=1),a=.00392156862745098*(n>>16&255),i=.00392156862745098*(n>>8&255),s=.00392156862745098*(255&n),o=1-r,this.set([o+r*a*e.LUMA[0],r*a*e.LUMA[1],r*a*e.LUMA[2],0,0,r*i*e.LUMA[0],o+r*i*e.LUMA[1],r*i*e.LUMA[2],0,0,r*s*e.LUMA[0],r*s*e.LUMA[1],o+r*s*e.LUMA[2],0,0,0,0,0,1,0])},invert:function(){return this.set([-1,0,0,0,255,0,-1,0,0,255,0,0,-1,0,255,0,0,0,1,0])},invertAlpha:function(){return this.set([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,-1,255])},saturate:function(t){var n,r,a,i;return n=1-t,r=n*e.LUMA[0],a=n*e.LUMA[1],i=n*e.LUMA[2],this.set([r+t,a,i,0,0,r,a+t,i,0,0,r,a,i+t,0,0,0,0,0,1,0])},contrast:function(e,n,r){return n===t&&(n=e),r===t&&(r=e),e+=1,n+=1,r+=1,this.set([e,0,0,0,128*(1-e),0,n,0,0,128*(1-n),0,0,r,0,128*(1-r),0,0,0,1,0])},brightness:function(e,n,r){return n===t&&(n=e),r===t&&(r=e),this.set([1,0,0,0,e,0,1,0,0,n,0,0,1,0,r,0,0,0,1,0])},adjustHue:function(t){t*=o;var n=i(t),r=a(t);return this.set([e.LUMA[0]+n*(1-e.LUMA[0])+r*-e.LUMA[0],e.LUMA[1]+n*-e.LUMA[1]+r*-e.LUMA[1],e.LUMA[2]+n*-e.LUMA[2]+r*(1-e.LUMA[2]),0,0,e.LUMA[0]+n*-e.LUMA[0]+.143*r,e.LUMA[1]+n*(1-e.LUMA[1])+.14*r,e.LUMA[2]+n*-e.LUMA[2]+r*-.283,0,0,e.LUMA[0]+n*-e.LUMA[0]+r*-(1-e.LUMA[0]),e.LUMA[1]+n*-e.LUMA[1]+r*e.LUMA[1],e.LUMA[2]+n*(1-e.LUMA[2])+r*e.LUMA[2],0,0,0,0,0,1,0])},average:function(e,n,r){return e===t&&(e=.3333),n===t&&(n=.3333),r===t&&(r=.3334),this.set([e,n,r,0,0,e,n,r,0,0,e,n,r,0,0,0,0,0,1,0])},quickContrastCorrection:function(e){return e===t&&(e=1.2),this.set([e,0,0,0,0,0,e,0,0,0,0,0,e,0,0,0,0,0,1,0])},sepia:function(e){return e===t&&(e=.5),e>1?e=1:0>e&&(e=0),this.set([1-.607*e,.769*e,.189*e,0,0,.349*e,1-.314*e,.168*e,0,0,.272*e,.534*e,1-.869*e,0,0,0,0,0,1,0])},sepia2:function(n){return n===t&&(n=10),n>100&&(n=100),n*=2.55,this.set([e.LUMA[0],e.LUMA[1],e.LUMA[2],0,40,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,20,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,-n,0,0,0,1,0])},threshold:function(n,r){return r===t&&(r=256),this.set([e.LUMA[0]*r,e.LUMA[1]*r,e.LUMA[2]*r,0,-(r-1)*n,e.LUMA[0]*r,e.LUMA[1]*r,e.LUMA[2]*r,0,-(r-1)*n,e.LUMA[0]*r,e.LUMA[1]*r,e.LUMA[2]*r,0,-(r-1)*n,0,0,0,1,0])},threshold_rgb:function(e,n){return n===t&&(n=256),this.set([n,0,0,0,-(n-1)*e,0,n,0,0,-(n-1)*e,0,0,n,0,-(n-1)*e,0,0,0,1,0])},threshold_alpha:function(e,n){return e===t&&(e=.5),n===t&&(n=256),this.set([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,n,-n*e])},RGB2YCbCr:function(){return this.set([.5,-.418688,-.081312,0,128,.299,.587,.114,0,0,-.168736,-.331264,.5,0,128,0,0,0,1,0])},YCbCr2RGB:function(){return this.set([1.402,1,0,0,-179.456,-.71414,1,-.34414,0,135.45984,0,1,1.772,0,-226.816,0,0,0,1,0])},blend:function(e,t){return this._matrix=this._matrix?r(this._matrix,e.getMatrix(),t):new s(e.getMatrix()),this},set:function(e){return this._matrix=this._matrix?n(this._matrix,new s(e)):new s(e),this},reset:function(){return this._matrix=null,this},combineWith:function(e){return this.set(e.getMatrix())},getMatrix:function(){return this._matrix},setMatrix:function(e){return this._matrix=new s(e),this},_apply:function(e,t,n){var r=this;if(r._isOn&&r._matrix){var a,i,s,o,l,u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E,R=e.length,I=r._matrix,M=(R>>2)%4;for(a=0;R>a;a+=16)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+4],A=e[a+5],b=e[a+6],E=e[a+7],u=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],c=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],h=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],f=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+8],A=e[a+9],b=e[a+10],E=e[a+11],d=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],p=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],m=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],_=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+12],A=e[a+13],b=e[a+14],E=e[a+15],g=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],v=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],y=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],w=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l,e[a+4]=~~u,e[a+5]=~~c,e[a+6]=~~h,e[a+7]=~~f,e[a+8]=~~d,e[a+9]=~~p,e[a+10]=~~m,e[a+11]=~~_,e[a+12]=~~g,e[a+13]=~~v,e[a+14]=~~y,e[a+15]=~~w;if(M)for(M<<=2,a=R-M;R>a;a+=4)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l}return e},canRun:function(){return this._isOn&&this._matrix}});u.prototype.grayscale=u.prototype.desaturate,u.prototype.rotateHue=u.prototype.adjustHue,u.prototype.thresholdRgb=u.prototype.threshold_rgb,u.prototype.thresholdAlpha=u.prototype.threshold_alpha,l&&(u.prototype._apply=function(e,t,n){var r=this;if(r._isOn&&r._matrix){var a,i,s,o,l,u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E,R=e.length,I=r._matrix,M=(R>>2)%4;for(a=0;R>a;a+=16)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+4],A=e[a+5],b=e[a+6],E=e[a+7],u=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],c=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],h=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],f=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+8],A=e[a+9],b=e[a+10],E=e[a+11],d=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],p=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],m=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],_=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+12],A=e[a+13],b=e[a+14],E=e[a+15],g=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],v=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],y=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],w=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s,o=0>o?0:o>255?255:o,l=0>l?0:l>255?255:l,u=0>u?0:u>255?255:u,c=0>c?0:c>255?255:c,h=0>h?0:h>255?255:h,f=0>f?0:f>255?255:f,d=0>d?0:d>255?255:d,p=0>p?0:p>255?255:p,m=0>m?0:m>255?255:m,_=0>_?0:_>255?255:_,g=0>g?0:g>255?255:g,v=0>v?0:v>255?255:v,y=0>y?0:y>255?255:y,w=0>w?0:w>255?255:w,e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l,e[a+4]=~~u,e[a+5]=~~c,e[a+6]=~~h,e[a+7]=~~f,e[a+8]=~~d,e[a+9]=~~p,e[a+10]=~~m,e[a+11]=~~_,e[a+12]=~~g,e[a+13]=~~v,e[a+14]=~~y,e[a+15]=~~w;if(M)for(M<<=2,a=R-M;R>a;a+=4)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s,o=0>o?0:o>255?255:o,l=0>l?0:l>255?255:l,e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l}return e})}(FILTER),!function(e,t){var n=e.ImArrayCopy,r=e.Color.clampPixel,a=function(){var e,t=new n(256);for(e=0;256>e;e++)t[e]=e;return t},i=function(){var e,t=new n(256);for(e=0;256>e;e++)t[e]=255-e;return t},s=function(e){var t,r=new n(256);for(t=0;256>t;t++)r[t]=e;return r},o=function(e){return e?new n(e):null},l=Math.pow,u=Math.exp,c=1/255,h=e.TableLookupFilter=e.Class(e.Filter,{name:"TableLookupFilter",constructor:function(e,t,n,r){var a=this;a.$super("constructor"),a._tableR=e||null,a._tableG=t||a._tableR,a._tableB=n||a._tableG,a._tableA=r||null},_tableR:null,_tableG:null,_tableB:null,_tableA:null,dispose:function(){var e=this;return e.$super("dispose"),e._tableR=null,e._tableG=null,e._tableB=null,e._tableA=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_tableR:e._tableR,_tableG:e._tableG,_tableB:e._tableB,_tableA:e._tableA}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n._tableR=t._tableR,n._tableG=t._tableG,n._tableB=t._tableB,n._tableA=t._tableA),n},thresholds:function(e,t,a){e.length||(e=[e]),t||(t=e),a||(a=t);var i,s,o=e.length,l=o+1,u=t.length,c=u+1,h=a.length,f=h+1,d=new n(256),p=new n(l),m=new n(256),_=new n(c),g=new n(256),v=new n(f),y=255/(l-1),w=255/(c-1),C=255/(f-1);for(i=0;l>i;)p[i]=~~(y*i),i++;for(e[0]=~~(255*e[0]),i=1;o>i;)e[i]=e[i-1]+~~(255*e[i]),i++;for(i=0;c>i;)_[i]=~~(w*i),i++;for(t[0]=~~(255*t[0]),i=1;u>i;)t[i]=t[i-1]+~~(255*t[i]),i++;for(i=0;f>i;)v[i]=~~(C*i),i++;for(a[0]=~~(255*a[0]),i=1;h>i;)a[i]=a[i-1]+~~(255*a[i]),i++;for(i=0;256>i;i++){for(s=0;o>s&&i>e[s];)s++;for(d[i]=r(p[s]),s=0;u>s&&i>t[s];)s++;for(m[i]=r(_[s]),s=0;h>s&&i>a[s];)s++;g[i]=r(v[s])}return this.set(d,m,g)},threshold:function(e,t,n){return e=e||.5,t=t||e,n=n||t,this.thresholds([e],[t],[n])},quantize:function(e){e===t&&(e=64),2>e&&(e=2);var a,i=new n(256),s=new n(e),o=255/(e-1),l=e/256;for(a=0;e>a;)s[a]=~~(o*a),a++;for(a=0;256>a;a++)i[a]=r(s[~~(l*a)]);return this.set(i)},binarize:function(){return this.quantize(2)},solarize:function(e){e===t&&(e=.5);var a,i,s=0,o=new n(256),l=2/255;for(s=0;256>s;s++)a=l*s,i=a>e?255-255*a:255*a-255,o[s]=~~r(i);return this.set(o)},solarize2:function(e){e===t&&(e=.5),e=1-e;var a,i,s=0,o=new n(256),l=2/255;for(s=0;256>s;s++)a=l*s,i=e>a?255-255*a:255*a-255,o[s]=~~r(i);return this.set(o)},solarizeInverse:function(e){e===t&&(e=.5),e*=256;var r=0,a=new n(256);for(r=0;256>r;r++)a[r]=r>e?255-r:r;return this.set(a)},invert:function(){return this.set(i())},mask:function(e){var t=0,a=e>>16&255,i=e>>8&255,s=255&e;for(tR=new n(256),tG=new n(256),tB=new n(256),t=0;256>t;t++)tR[t]=r(t&a),tG[t]=r(t&i),tB[t]=r(t&s);return this.set(tR,tG,tB)},replace:function(e,t){if(e==t)return this;var n=e>>16&255,r=e>>8&255,i=255&e,s=t>>16&255,o=t>>8&255,l=255&t,u=a(),c=a(),h=a();return u[n]=s,c[r]=o,h[i]=l,this.set(u,c,h)},extract:function(t,n,a){if(!n||!n.length)return this;a=a||0;var i,o,l=a>>16&255,u=a>>8&255,c=255&a,h=s(l),f=s(u),d=s(c);switch(t){case e.CHANNEL.BLUE:for(i=n[0],o=n[1];o>=i;)d[i]=r(i),i++;break;case e.CHANNEL.GREEN:for(i=n[0],o=n[1];o>=i;)f[i]=r(i),i++;break;case e.CHANNEL.RED:default:for(i=n[0],o=n[1];o>=i;)h[i]=r(i),i++}return this.set(h,f,d)},gammaCorrection:function(e,t,a){e=e||1,t=t||e,a=a||t,e=1/e,t=1/t,a=1/a;var i=new n(256),s=new n(256),o=new n(256),u=0;for(u=0;256>u;u++)i[u]=r(~~(255*l(c*u,e))),s[u]=r(~~(255*l(c*u,t))),o[u]=r(~~(255*l(c*u,a)));return this.set(i,s,o)},exposure:function(e){e===t&&(e=1);var a=0,i=new n(256);for(a=0;256>a;a++)i[a]=r(~~(255*(1-u(-e*a*c))));return this.set(i)},set:function(e,t,n,i){if(!e)return this;t=t||e,n=n||t;var s,l,u,c,h,f=this._tableR||a(),d=o(f);if(t&&n){for(s=this._tableG||o(f),l=this._tableB||o(s),u=o(s),c=o(l),h=0;256>h;h++)f[h]=r(e[r(d[h])]),s[h]=r(t[r(u[h])]),l[h]=r(n[r(c[h])]);this._tableR=f,this._tableG=s,this._tableB=l}else{for(h=0;256>h;h++)f[h]=r(e[r(d[h])]);this._tableR=f,this._tableG=this._tableR,this._tableB=this._tableR}return this},reset:function(){return this._tableR=this._tableG=this._tableB=this._tableA=null,this},combineWith:function(e){return this.set(e.getTable(0),e.getTable(1),e.getTable(2))},getTable:function(t){switch(t=t||e.CHANNEL.RED){case e.CHANNEL.ALPHA:return this._tableA;case e.CHANNEL.BLUE:return this._tableB;case e.CHANNEL.GREEN:return this._tableG;case e.CHANNEL.RED:default:return this._tableR}},setTable:function(t,n){switch(n=n||e.CHANNEL.RED){case e.CHANNEL.ALPHA:return this._tableA=t,this;case e.CHANNEL.BLUE:return this._tableB=t,this;case e.CHANNEL.GREEN:return this._tableG=t,this;case e.CHANNEL.RED:default:return this._tableR=t,this}},_apply:function(e,t,n){var r=this;if(!r._isOn||!r._tableR)return e;var a,i,s,o,l,u=e.length,c=(u>>2)%4,h=r._tableR,f=r._tableG,d=r._tableB,p=r._tableA; -if(p){for(a=0;u>a;a+=16)i=e[a],s=e[a+1],o=e[a+2],l=e[a+3],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o],e[a+3]=p[l],i=e[a+4],s=e[a+5],o=e[a+6],l=e[a+7],e[a+4]=h[i],e[a+5]=f[s],e[a+6]=d[o],e[a+7]=p[l],i=e[a+8],s=e[a+9],o=e[a+10],l=e[a+11],e[a+8]=h[i],e[a+9]=f[s],e[a+10]=d[o],e[a+11]=p[l],i=e[a+12],s=e[a+13],o=e[a+14],l=e[a+15],e[a+12]=h[i],e[a+13]=f[s],e[a+14]=d[o],e[a+15]=p[l];if(c)for(c<<=2,a=u-c;u>a;a+=4)i=e[a],s=e[a+1],o=e[a+2],l=e[a+3],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o],e[a+3]=p[l]}else{for(a=0;u>a;a+=16)i=e[a],s=e[a+1],o=e[a+2],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o],i=e[a+4],s=e[a+5],o=e[a+6],e[a+4]=h[i],e[a+5]=f[s],e[a+6]=d[o],i=e[a+8],s=e[a+9],o=e[a+10],e[a+8]=h[i],e[a+9]=f[s],e[a+10]=d[o],i=e[a+12],s=e[a+13],o=e[a+14],e[a+12]=h[i],e[a+13]=f[s],e[a+14]=d[o];if(c)for(c<<=2,a=u-c;u>a;a+=4)i=e[a],s=e[a+1],o=e[a+2],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o]}return e},canRun:function(){return this._isOn&&this._tableR}});h.prototype.posterize=h.prototype.levels=h.prototype.quantize}(FILTER),!function(e,t){var n=(e.ImArray,e.ImArrayCopy),r=e.Array16I,a=Math.min,i=(Math.max,Math.floor);e.DisplacementMapFilter=e.Class(e.Filter,{name:"DisplacementMapFilter",constructor:function(e){var t=this;t.$super("constructor"),e&&t.setMap(e)},_map:null,map:null,scaleX:1,scaleY:1,startX:0,startY:0,componentX:0,componentY:0,color:0,red:0,green:0,blue:0,alpha:0,mode:e.MODE.CLAMP,dispose:function(){var e=this;return e.$super("dispose"),e._map=null,e.map=null,e.scaleX=null,e.scaleY=null,e.startX=null,e.startY=null,e.componentX=null,e.componentY=null,e.color=null,e.red=null,e.green=null,e.blue=null,e.alpha=null,e.mode=null,e},serialize:function(){var e=this,t=e.map;return{filter:e.name,_isOn:!!e._isOn,params:{_map:e._map||(t?{data:t.getData(),width:t.width,height:t.height}:null),scaleX:e.scaleX,scaleY:e.scaleY,startX:e.startX,startY:e.startY,componentX:e.componentX,componentY:e.componentY,color:e.color,red:e.red,green:e.green,blue:e.blue,alpha:e.alpha,mode:e.mode}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n.map=null,n._map=t._map,n.scaleX=t.scaleX,n.scaleY=t.scaleY,n.startX=t.startX,n.startY=t.startY,n.componentX=t.componentX,n.componentY=t.componentY,n.color=t.color,n.red=t.red,n.green=t.green,n.blue=t.blue,n.alpha=t.alpha,n.mode=t.mode),n},reset:function(){var e=this;return e._map=null,e.map=null,e},getMap:function(){return this.map},setMap:function(e){var t=this;return e&&(t.map=e,t._map=null),t},setColor:function(e){var t=this;return t.color=e,t.alpha=e>>24&255,t.red=e>>16&255,t.green=e>>8&255,t.blue=255&e,t},_apply:function(t,s,o){var l=this;if(!l._isOn||!l.map&&!l._map)return t;var u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E,R,I,M,L,x,N,S,T,O,F,D,P,k,G,H,U=l.map,X=l._map||{data:U.getData(),width:U.width,height:U.height},B=.00390625*l.scaleX,Y=.00390625*l.scaleY,W=l.componentX,q=l.componentY,z=l.alpha,$=l.red,j=l.green,K=l.blue,J=l.mode,V=e.MODE.IGNORE,Q=(e.MODE.CLAMP,e.MODE.COLOR),Z=e.MODE.WRAP;for(u=X.data,c=X.width,h=X.height,f=u.length>>2,p=a(c,s),m=a(h,o),P=t.length,F=p*m<<2,D=P>>2,g=i(l.startX*(s-1)),_=i(l.startY*(o-1)),v=_*s,y=-g,w=-_,C=s-g-1,A=o-_-1,d=new r(f<<1),k=new n(t),E=0,R=0,I=0,M=0,b=0;f>b;b++,E+=2,R++)R>=c&&(R=0,I++,M+=c),S=R+M<<2,d[E]=i((u[S+W]-128)*B),d[E+1]=i((u[S+q]-128)*Y);for(R=0,I=0,M=0,L=0,b=0;F>b;b+=4,R++)if(R>=p&&(R=0,I++,M+=s,L+=c),!(w>I||I>A||y>R||R>C)){if(N=R+g,x=I+_,T=N+M+v<<2,E=R+L<<1,G=N+d[E],H=x+d[E+1],H>=o||0>H||G>=s||0>G){if(J==V)continue;if(J==Q){t[T]=$,t[T+1]=j,t[T+2]=K,t[T+3]=z;continue}J==Z?(H>A?H-=o:0>H&&(H+=o),G>C?G-=s:0>G&&(G+=s)):(H>A?H=A:0>H&&(H=0),G>C?G=C:0>G&&(G=0))}O=G+H*s<<2,t[T]=k[O],t[T+1]=k[O+1],t[T+2]=k[O+2],t[T+3]=k[O+3]}return t},canRun:function(){return this._isOn&&(this._map||this.map)}})}(FILTER),!function(FILTER,undef){var IMG=FILTER.ImArray,IMGcopy=FILTER.ImArrayCopy,PI=FILTER.CONST.PI,DoublePI=FILTER.CONST.PI2,HalfPI=FILTER.CONST.PI_2,ThreePI2=1.5*PI,Sqrt=Math.sqrt,Atan2=Math.atan2,Atan=Math.atan,Sin=Math.sin,Cos=Math.cos,Floor=Math.floor,Round=Math.round,Asin=Math.asin,Tan=Math.tan,Abs=Math.abs,Max=Math.max,toRad=FILTER.CONST.toRad,Maps,GeometricMapFilter=FILTER.GeometricMapFilter=FILTER.Class(FILTER.Filter,{name:"GeometricMapFilter",constructor:function(e){var t=this;t.$super("constructor"),e&&t.generic(e)},_map:null,_mapName:null,inverseTransform:null,matrix:null,centerX:0,centerY:0,dx:0,dy:0,angle:0,radius:0,wavelength:0,amplitude:0,phase:0,xAmplitude:0,yAmplitude:0,xWavelength:0,yWavelength:0,mode:FILTER.MODE.CLAMP,dispose:function(){var e=this;return e.$super("dispose"),e._map=null,e._mapName=null,e.inverseTransform=null,e.matrix=null,e.centerX=null,e.centerY=null,e.dx=null,e.dy=null,e.angle=null,e.radius=null,e.wavelength=null,e.amplitude=null,e.phase=null,e.xAmplitude=null,e.yAmplitude=null,e.xWavelength=null,e.yWavelength=null,e.mode=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_mapName:e._mapName,inverseTransform:e.inverseTransform?e.inverseTransform.toString():null,matrix:e.matrix,centerX:e.centerX,centerY:e.centerY,dx:e.dx,dy:e.dy,angle:e.angle,radius:e.radius,wavelength:e.wavelength,amplitude:e.amplitude,phase:e.phase,xAmplitude:e.xAmplitude,yAmplitude:e.yAmplitude,xWavelength:e.xWavelength,yWavelength:e.yWavelength,mode:e.mode}}},unserialize:function(json){var self=this,params;return json&&self.name===json.filter&&(self._isOn=!!json._isOn,params=json.params,self.inverseTransform=null,self.matrix=params.matrix,self.centerX=params.centerX,self.centerY=params.centerY,self.dx=params.dx,self.dy=params.dy,self.angle=params.angle,self.radius=params.radius,self.wavelength=params.wavelength,self.amplitude=params.amplitude,self.phase=params.phase,self.xAmplitude=params.xAmplitude,self.yAmplitude=params.yAmplitude,self.xWavelength=params.xWavelength,self.yWavelength=params.yWavelength,self.mode=params.mode,params.inverseTransform&&(self.inverseTransform=eval('(function(){ "use strict"; return '+params.inverseTransform+"})();")),self._mapName=params._mapName,self._map=null,self._mapName&&Maps[self._mapName]&&(self._map=Maps[self._mapName])),self},generic:function(e){var t=this;return e&&(t.inverseTransform=e,t._mapName="generic",t._map=Maps.generic),t},affine:function(e){var t=this;return e&&(t.matrix=e,t._mapName="affine",t._map=Maps.affine),t},flipX:function(){var e=this;return e._mapName="flipX",e._map=Maps.flipX,e},flipY:function(){var e=this;return e._mapName="flipY",e._map=Maps.flipY,e},flipXY:function(){var e=this;return e._mapName="flipXY",e._map=Maps.flipXY,e},rotateCW:function(){var e=this;return e._mapName="rotateCW",e._map=Maps.rotateCW,e},rotateCCW:function(){var e=this;return e._mapName="rotateCCW",e._map=Maps.rotateCCW,e},polar:function(e,t){var n=this;return n.centerX=e||0,n.centerY=t||0,n._mapName="polar",n._map=Maps.polar,n},cartesian:function(e,t){var n=this;return n.centerX=e||0,n.centerY=t||0,n._mapName="cartesian",n._map=Maps.cartesian,n},twirl:function(e,t,n,r){var a=this;return a.angle=e||0,a.radius=t||0,a.centerX=n||0,a.centerY=r||0,a._mapName="twirl",a._map=Maps.twirl,a},sphere:function(e,t,n){var r=this;return r.radius=e||0,r.centerX=t||0,r.centerY=n||0,r._mapName="sphere",r._map=Maps.sphere,r},ripple:function(e,t,n,r,a,i){var s=this;return s.radius=e!==undef?e:50,s.centerX=a||0,s.centerY=i||0,s.wavelength=t!==undef?t:16,s.amplitude=n!==undef?n:10,s.phase=r||0,s._mapName="ripple",s._map=Maps.ripple,s},shift:function(e,t){var n=this;return n.dx=e!==undef?e:0,n.dy=t!==undef?t:n.dx,n._mapName="shift",n._map=Maps.shift,n},reset:function(){var e=this;return e._mapName=null,e._map=null,e},getMap:function(){return this._map},setMap:function(e){var t=this;return t._mapName=null,t._map=e,t},_apply:function(e,t,n,r){var a=this;return a._isOn&&a._map?a._map(a,e,t,n,r):e},canRun:function(){return this._isOn&&this._map}});GeometricMapFilter.prototype.translate=GeometricMapFilter.prototype.shift,Maps={generic:function(e,t,n,r){var a,i,s,o,l,u,c,h=t.length,f=new IMG(h),d=e.inverseTransform,p=e.mode,m=FILTER.MODE.CLAMP,_=FILTER.MODE.WRAP;for(a=0,i=0,s=0;h>s;s+=4,a++){if(a>=n&&(a=0,i++),l=d([a,i],n,r),u=~~l[0],c=~~l[1],0>u||u>=n||0>c||c>=r)switch(p){case _:c>=r?c-=r:0>c&&(c+=r),u>=n?u-=n:0>u&&(u+=n);break;case m:default:c>=r?c=r-1:0>c&&(c=0),u>=n?u=n-1:0>u&&(u=0)}o=u+c*n<<2,f[s]=t[o],f[s+1]=t[o+1],f[s+2]=t[o+2],f[s+3]=t[o+3]}return f},affine:function(e,t,n,r){var a,i,s,o,l,u,c,h,f,d=t.length,p=d>>2,m=new IMG(d),_=e.matrix,g=_[0],v=_[1],y=_[3],w=_[4],C=_[2],A=_[5],b=e.mode,E=FILTER.MODE.CLAMP,R=FILTER.MODE.WRAP,I=n-1,M=p-n;for(a=0,i=0,l=A*n,u=y*n,c=w*n,s=0;d>s;s+=4,a++){if(a>=n&&(a=0,i++),h=~~(g*a+v*i+C),f=~~(u*a+c*i+l),0>h||h>I||0>f||f>M)switch(b){case R:f>M?f-=p:0>f&&(f+=p),h>=n?h-=n:0>h&&(h+=n);break;case E:default:f>M?f=M:0>f&&(f=0),h>I?h=I:0>h&&(h=0)}o=h+f<<2,m[s]=t[o],m[s+1]=t[o+1],m[s+2]=t[o+2],m[s+3]=t[o+3]}return m},shift:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u),h=-e.dx,f=-e.dy;for(0>h&&(h+=n),0>f&&(f+=r),a=0,i=0,s=0,o=0;u>o;o+=4,a++)a>=n&&(a=0,i++,s+=n),l=(a+h)%n+(i+f)%r*n<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},flipX:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u);for(a=0,i=0,s=0,o=0;u>o;o+=4,a++)a>=n&&(a=0,i++,s+=n),l=n-1-a+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},flipY:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u);for(a=0,i=0,s=(r-1)*n,o=0;u>o;o+=4,a++)a>=n&&(a=0,i++,s-=n),l=a+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},flipXY:function(e,t,n,r){var a,i,s,o,l,u,c=t.length,h=new IMG(c);for(a=0,i=0,o=(r-1)*n,l=0;c>l;l+=4,a++)a>=n&&(a=0,i++,s+=n,o-=n),u=n-1-a+o<<2,h[l]=t[u],h[l+1]=t[u+1],h[l+2]=t[u+2],h[l+3]=t[u+3];return h},rotateCW:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u),h=u>>2;for(a=0,i=0,s=h-1,o=0;u>o;o+=4,a++,s-=n)a>=n&&(a=0,s=h-1,i++),l=i+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},rotateCCW:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u);for(a=0,i=0,s=0,o=0;u>o;o+=4,a++,s+=n)a>=n&&(a=0,s=0,i++),l=n-1-i+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},twirl:function(e,t,n,r){if(0>=e.radius)return t;var a,i,s,o,l,u,c,h,f=t.length,d=new IMGcopy(t),p=e.centerX,m=e.centerY,_=e.angle,g=e.radius,v=e.mode,y=FILTER.MODE.CLAMP,w=FILTER.MODE.WRAP,C=_/g,A=n-1,b=r-1;for(p=Floor(p*(n-1)),m=Floor(m*(r-1)),a=0,i=0,s=0;f>s;s+=4,a++)if(a>=n&&(a=0,i++),u=a-p,c=i-m,l=Sqrt(u*u+c*c),g>l){if(h=Atan2(c,u)+C*(g-l),u=~~(p+l*Cos(h)),c=~~(m+l*Sin(h)),0>u||u>A||0>c||c>b)switch(v){case w:c>b?c-=r:0>c&&(c+=r),u>A?u-=n:0>u&&(u+=n);break;case y:default:c>b?c=b:0>c&&(c=0),u>A?u=A:0>u&&(u=0)}o=u+c*n<<2,t[s]=d[o],t[s+1]=d[o+1],t[s+2]=d[o+2],t[s+3]=d[o+3]}return t},sphere:function(e,t,n,r){if(0>=e.radius)return t;var a,i,s,o,l,u,c,h,f,d,p,m,_,g=t.length,v=new IMGcopy(t),y=e.centerX,w=e.centerY,C=e.radius,A=e.mode,b=FILTER.MODE.CLAMP,E=FILTER.MODE.WRAP,R=C*C,I=.555556,M=1-I,L=n-1,x=r-1;for(y=Floor(y*(n-1)),w=Floor(w*(r-1)),a=0,i=0,s=0;g>s;s+=4,a++)if(a>=n&&(a=0,i++),l=a-y,u=i-w,m=l*l,_=u*u,c=m+_,R>c){if(d=R-c,p=Sqrt(d),h=Asin(l/Sqrt(m+d))*M,f=Asin(u/Sqrt(_+d))*M,l=~~(a-p*Tan(h)),u=~~(i-p*Tan(f)),0>l||l>L||0>u||u>x)switch(A){case E:u>x?u-=r:0>u&&(u+=r),l>L?l-=n:0>l&&(l+=n);break;case b:default:u>x?u=x:0>u&&(u=0),l>L?l=L:0>l&&(l=0)}o=l+u*n<<2,t[s]=v[o],t[s+1]=v[o+1],t[s+2]=v[o+2],t[s+3]=v[o+3]}return t},ripple:function(e,t,n,r){if(0>=e.radius)return t;var a,i,s,o,l,u,c,h,f,d,p,m=t.length,_=new IMGcopy(t),g=FILTER.MODE.CLAMP,v=FILTER.MODE.WRAP,y=n-1,w=r-1,C=e.centerX,A=e.centerY,b=e.radius,E=e.mode,R=b*b,I=e.wavelength,M=e.amplitude,L=e.phase;for(C=Floor(C*(n-1)),A=Floor(A*(r-1)),a=0,i=0,s=0;m>s;s+=4,a++)if(a>=n&&(a=0,i++),u=a-C,c=i-A,d=u*u,p=c*c,f=d+p,R>f){if(l=Sqrt(f),h=M*Sin(l/I*Math.PI*2-L),h*=(b-l)/b,l&&(h*=I/l),u=~~(a+u*h),c=~~(i+c*h),0>u||u>y||0>c||c>w)switch(E){case v:c>w?c-=r:0>c&&(c+=r),u>y?u-=n:0>u&&(u+=n);break;case g:default:c>w?c=w:0>c&&(c=0),u>y?u=y:0>u&&(u=0)}o=u+c*n<<2,t[s]=_[o],t[s+1]=_[o+1],t[s+2]=_[o+2],t[s+3]=_[o+3]}return t},polar:function(e,t,n,r){var a,i,s,o,l,u,c,h,f,d,p,m,_=t.length,g=new IMGcopy(t),v=FILTER.MODE.CLAMP,y=FILTER.MODE.WRAP,w=n-1,C=r-1,A=0,b=e.mode;for(p=~~(.5*n+.5),m=~~(.5*r+.5),d=Max(m,p),a=0,i=0,s=0;_>s;s+=4,a++){if(a>=n&&(a=0,i++),o=a-p,l=i-m,f=0,o>=0?l>0?(f=PI-Atan(o/l),A=Sqrt(o*o+l*l)):0>l?(f=Atan(o/l),A=Sqrt(o*o+l*l)):(f=HalfPI,A=o):0>o&&(0>l?(f=DoublePI-Atan(o/l),A=Sqrt(o*o+l*l)):l>0?(f=PI+Atan(o/l),A=Sqrt(o*o+l*l)):(f=ThreePI2,A=-o)),u=n-1-(n-1)/DoublePI*f,c=r*A/d,u=Round(u),c=Round(c),0>u||u>w||0>c||c>C)switch(b){case y:c>C?c-=r:0>c&&(c+=r),u>w?u-=n:0>u&&(u+=n);break;case v:default:c>C?c=C:0>c&&(c=0),u>w?u=w:0>u&&(u=0)}h=u+c*n<<2,t[s]=g[h],t[s+1]=g[h+1],t[s+2]=g[h+2],t[s+3]=g[h+3]}return t},cartesian:function(e,t,n,r){var a,i,s,o,l,u,c,h,f,d,p,m,_,g=t.length,v=new IMGcopy(t),y=FILTER.MODE.CLAMP,w=FILTER.MODE.WRAP,C=n-1,A=r-1,b=0,E=e.mode;for(m=~~(.5*n+.5),_=~~(.5*r+.5),p=Max(_,m),a=0,i=0,s=0;g>s;s+=4,a++){if(a>=n&&(a=0,i++),f=a/n*DoublePI,d=f>=ThreePI2?DoublePI-f:f>=PI?f-PI:f>=HalfPI?PI-f:f,b=p*(i/r),c=-b*Sin(d),h=b*Cos(d),f>=ThreePI2?(o=m-c,l=_-h):f>=PI?(o=m-c,l=_+h):f>=HalfPI?(o=m+c,l=_+h):(o=m+c,l=_-h),o=Round(o),l=Round(l),0>o||o>C||0>l||l>A)switch(E){case w:l>A?l-=r:0>l&&(l+=r),o>C?o-=n:0>o&&(o+=n);break;case y:default:l>A?l=A:0>l&&(l=0),o>C?o=C:0>o&&(o=0)}u=o+l*n<<2,t[s]=v[u],t[s+1]=v[u+1],t[s+2]=v[u+2],t[s+3]=v[u+3]}return t}}}(FILTER),!function(e,t){function n(e,t,n,r){var a,i=e.length,s=new w(e.length);for(n=n||1,r=r||1,a=0;i>a;)s[a]=n*e[a]+r*t[a],a++;return s}function r(e,t){var n,r,a,i=e.length,s=[],o=0;for(n=0;i>n;n++)for(r=0;i>r;r++)a=e[n]*t[r],o+=a,s.push(a);return{kernel:s,sum:o}}function a(e){var t,n=new Array(e);for(t=0;e>t;)n[t]=1,t++;return n}function i(e){var t,n,r,a,i=R.length;if(e--,i>e)t=new w(R[e]);else for(t=new w(R[i-1]);e>=i;){for(n=t,t=new w(n.length+1),t[0]=1,r=0,a=n.length-1;a>r;r++)t[r+1]=n[r]+n[r+1];t[n.length]=1,40>i&&R.push(new Array(t)),i++}return t}function s(e){var t,n=e>>1,r=-n,a=new Array(e);for(t=0;e>t;)a[t]=r,r++,t++;return a}function o(e){var t=i(e);return r(t,t)}function l(e,t){var n=i(e),a=s(e);return 1==t?r(a.reverse(),n):r(n,a)}function u(e,t){var n=a(e),i=s(e);return 1==t?r(i.reverse(),n):r(n,i)}function c(e,t,n){t=t||1,n=n||t;var r,a=e*e,i=a>>1,s=new w(a);for(r=0;a>r;)s[r]=t,r++;return s[i]=n,s}function h(e,t,n,r){var a,i,s,o,l,u=e*e,c=e>>1,h=u>>1,f=new w(u);for(o=0,a=0;c>=a;a++){for(i=0,l=0,s=0;c>=s;s++)f[h+a+i]=o+l,f[h-a-i]=-o-l,f[h-a+i]=-o+l,f[h+a-i]=o-l,i+=e,l+=n;o+=t}return f[h]=r||1,f}function f(e,t,n,r){var a,i,s,o,l,u,c=e*e,h=e>>1,f=c>>1,d=new w(c),p=new w(c),m=1/e,g=1e-8;for(_(t)>g?(l=1,u=n/t):(l=t/n,u=1),a=0,s=0,o=0,i=u*e;h>=a;)p[f+a]=~~(f+s+o+.5),p[f-a]=~~(f-s-o+.5),a++,s+=l,o+=i;for(a=0;h>=a;)d[p[f+a]]=d[p[f-a]]=m,a++;return d[f]=r||1,d}function d(e,t,n,r,a,i,s,o,l,u){var c,h,f,d,p,m,_,g,v,y,w,b,R,I,M,L,x,N,S,T,O,F,D,P,k,G,H,U,X,B,Y,W,q,z,$,j,K,J,V,Q,Z,ee,te,ne,re,ae,ie,se=e.length,oe=se>>2,le=i,ue=s;if(g=le*ue,m=le>>1,_=t*(ue>>1),w=-m-1,R=-_-t,b=m,I=_,B=0,W=t-1,Y=0,q=oe-t,h=(oe<<1)+oe,y=(t<<1)+t,u=u||1,ie=0,a)for(T=r[0],O=r[g>>1],F=O-T,D=a[0],P=a[g>>1],k=P-D;u>ie;){for(v=new C(se),c=new A(h),M=0,L=0,f=d=p=0,x=0;t>x;x++,M+=4,L+=3)f+=e[M],d+=e[M+1],p+=e[M+2],c[L]=f,c[L+1]=d,c[L+2]=p;for(L=0,x=0,f=d=p=0,M=y+t;se>M;M+=4,L+=3,x++)x>=t&&(x=0,f=d=p=0),f+=e[M],d+=e[M+1],p+=e[M+2],c[L+y]=c[L]+f,c[L+y+1]=c[L+1]+d,c[L+y+2]=c[L+2]+p;for(x=0,N=0,S=0,M=0;se>M;M+=4,x++)x>=t&&(x=0,N++,S+=t),G=x+w,H=S+R,U=x+b,X=S+I,G=B>G?B:G,U=U>W?W:U,H=Y>H?Y:H,X=X>q?q:X,z=G+H,K=U+X,$=U+H,j=G+X,z=(z<<1)+z,$=($<<1)+$,j=(j<<1)+j,K=(K<<1)+K,Z=T*(c[K]-c[$]-c[j]+c[z])+F*e[M],ee=T*(c[K+1]-c[$+1]-c[j+1]+c[z+1])+F*e[M+1],te=T*(c[K+2]-c[$+2]-c[j+2]+c[z+2])+F*e[M+2],ne=D*(c[K]-c[$]-c[j]+c[z])+k*e[M],re=D*(c[K+1]-c[$+1]-c[j+1]+c[z+1])+k*e[M+1],ae=D*(c[K+2]-c[$+2]-c[j+2]+c[z+2])+k*e[M+2],J=o*Z+l*ne,V=o*ee+l*re,Q=o*te+l*ae,E&&(J=0>J?0:J>255?255:J,V=0>V?0:V>255?255:V,Q=0>Q?0:Q>255?255:Q),v[M]=~~J,v[M+1]=~~V,v[M+2]=~~Q,v[M+3]=e[M+3];e=v,ie++}else for(T=r[0],O=r[g>>1],F=O-T;u>ie;){for(v=new C(se),c=new A(h),M=0,L=0,f=d=p=0,x=0;t>x;x++,M+=4,L+=3)f+=e[M],d+=e[M+1],p+=e[M+2],c[L]=f,c[L+1]=d,c[L+2]=p;for(L=0,x=0,f=d=p=0,M=y+t;se>M;M+=4,L+=3,x++)x>=t&&(x=0,f=d=p=0),f+=e[M],d+=e[M+1],p+=e[M+2],c[L+y]=c[L]+f,c[L+y+1]=c[L+1]+d,c[L+y+2]=c[L+2]+p;for(x=0,N=0,S=0,M=0;se>M;M+=4,x++)x>=t&&(x=0,N++,S+=t),G=x+w,H=S+R,U=x+b,X=S+I,G=B>G?B:G,U=U>W?W:U,H=Y>H?Y:H,X=X>q?q:X,z=G+H,K=U+X,$=U+H,j=G+X,z=(z<<1)+z,$=($<<1)+$,j=(j<<1)+j,K=(K<<1)+K,Z=T*(c[K]-c[$]-c[j]+c[z])+F*e[M],ee=T*(c[K+1]-c[$+1]-c[j+1]+c[z+1])+F*e[M+1],te=T*(c[K+2]-c[$+2]-c[j+2]+c[z+2])+F*e[M+2],J=o*Z+l,V=o*ee+l,Q=o*te+l,E&&(J=0>J?0:J>255?255:J,V=0>V?0:V>255?255:V,Q=0>Q?0:Q>255?255:Q),v[M]=~~J,v[M+1]=~~V,v[M+2]=~~Q,v[M+3]=e[M+3];e=v,ie++}return v}function p(e,t,n,r,a,i,s,o,l){var u,c,h,f,d,p,m,_,g,v,y,w,A,R,I,M,L,x,N,S,T,O,F,D,P,k,G,H=e.length,U=H>>2;for(u=[a,r],c=[s,i],P=[l,o],M=t-1,L=U-t,G=2;G--;){for(m=new C(H),f=u[G],d=c[G],h=f.length,p=d.length,k=P[G],_=new b(d),y=0;p>y;y+=2)_[y+1]*=t;if(E)for(w=0,A=0,g=0;H>g;g+=4,w++){for(w>=t&&(w=0,A+=t),O=0,F=0,D=0,y=0,v=0;h>y;y++,v+=2)R=w+_[v],I=A+_[v+1],R>=0&&M>=R&&I>=0&&L>=I&&(srcOff=R+I<<2,T=f[y],O+=e[srcOff]*T,F+=e[srcOff+1]*T,D+=e[srcOff+2]*T);x=k*O,N=k*F,S=k*D,x=0>x?0:x>255?255:x,N=0>N?0:N>255?255:N,S=0>S?0:S>255?255:S,m[g]=~~x,m[g+1]=~~N,m[g+2]=~~S,m[g+3]=e[g+3]}else for(w=0,A=0,g=0;H>g;g+=4,w++){for(w>=t&&(w=0,A+=t),O=0,F=0,D=0,y=0,v=0;h>y;y++,v+=2)R=w+_[v],I=A+_[v+1],R>=0&&M>=R&&I>=0&&L>=I&&(srcOff=R+I<<2,T=f[y],O+=e[srcOff]*T,F+=e[srcOff+1]*T,D+=e[srcOff+2]*T);x=k*O,N=k*F,S=k*D,m[g]=~~x,m[g+1]=~~N,m[g+2]=~~S,m[g+3]=e[g+3]}e=m}return m}var m=(e.CONST.SQRT2,e.CONST.toRad),_=(e.CONST.toDeg,Math.abs),g=Math.sqrt,v=Math.sin,y=Math.cos,w=e.Array32F,C=e.ImArray,A=e.Array32F,b=e.Array16I,E=(e.Array8U,e._notSupportClamp),R=[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1],[1,5,10,10,5,1],[1,6,15,20,15,6,1],[1,7,21,35,35,21,7,1],[1,8,28,56,70,56,28,8,1]],I=e.ConvolutionMatrixFilter=e.Class(e.Filter,{name:"ConvolutionMatrixFilter",constructor:function(t,n,r){var a=this;a.$super("constructor"),a._coeff=new w([1,0]),t&&t.length?a.set(t,~~(g(t.length)+.5),n||1,r||0):(a._matrix=null,a._dim=0),a._matrix2=null,a._dim2=0,a._isGrad=!1,a._doIntegral=0,a._doSeparable=!1,e.useWebGL&&(a._webglInstance=e.WebGLConvolutionMatrixFilterInstance||null)},_dim:0,_dim2:0,_matrix:null,_matrix2:null,_mat:null,_mat2:null,_coeff:null,_isGrad:!1,_doIntegral:0,_doSeparable:!1,_indices:null,_indices2:null,_indicesf:null,_indicesf2:null,_webglInstance:null,dispose:function(){var e=this;return e.$super("dispose"),e._webglInstance=null,e._dim=null,e._dim2=null,e._matrix=null,e._matrix2=null,e._mat=null,e._mat2=null,e._coeff=null,e._isGrad=null,e._doIntegral=null,e._doSeparable=null,e._indices=null,e._indices2=null,e._indicesf=null,e._indicesf2=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_dim:e._dim,_dim2:e._dim2,_matrix:e._matrix,_matrix2:e._matrix2,_mat:e._mat,_mat2:e._mat2,_coeff:e._coeff,_isGrad:e._isGrad,_doIntegral:e._doIntegral,_doSeparable:e._doSeparable,_indices:e._indices,_indices2:e._indices2,_indicesf:e._indicesf,_indicesf2:e._indicesf2}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n._dim=t._dim,n._dim2=t._dim2,n._matrix=t._matrix,n._matrix2=t._matrix2,n._mat=t._mat,n._mat2=t._mat2,n._coeff=t._coeff,n._isGrad=t._isGrad,n._doIntegral=t._doIntegral,n._doSeparable=t._doSeparable,n._indices=t._indices,n._indices2=t._indices2,n._indicesf=t._indicesf,n._indicesf2=t._indicesf2),n},lowPass:function(e){return e=e===t?3:e%2?e:e+1,this.set(c(e),e,1/(e*e),0),this._doIntegral=1,this},highPass:function(e,n){e=e===t?3:e%2?e:e+1,n=n===t?1:n;var r=e*e,a=-n/r,i=c(e,a,1+a);return this.set(i,e,1,0),this._doIntegral=1,this},glow:function(e,n){return e=e===t?.5:e,this.highPass(n,-e)},sharpen:function(e,n){return e=e===t?.5:e,this.highPass(n,e)},verticalBlur:function(e){return e=e===t?3:e%2?e:e+1,this.set(a(e),1,1/e,0),this._dim2=e,this._doIntegral=1,this},horizontalBlur:function(e){return e=e===t?3:e%2?e:e+1,this.set(a(e),e,1/e,0),this._dim2=1,this._doIntegral=1,this},directionalBlur:function(e,n){n=n===t?3:n%2?n:n+1,e*=m;var r=y(e),a=-v(e),i=f(n,r,a,1/n);return this.set(i,n,1,0)},fastGauss:function(e,n){return n=n===t?3:n%2?n:n+1,e=~~(e||1),1>e?e=1:e>3&&(e=3),this.set(c(n),n,1/(n*n),0),this._doIntegral=e,this},binomialLowPass:function(e){e=e===t?3:e%2?e:e+1;var n=i(e),r=1<>1;for(r=0,a=0,n=0;l>n;)s.push(r-c),s.push(a-c),e[n]&&(i.push(r-c),i.push(a-c),o.push(e[n])),n++,r++,r>=u&&(r=0,a++);return[new b(i),new b(s),new w(o)]},reset:function(){var e=this;return e._matrix=e._matrix2=null,e._mat=e._mat2=null,e._dim=e._dim2=0,e._indices=e._indices2=e._indicesf=e._indicesf2=null,e._isGrad=!1,e._doIntegral=0,e._doSeparable=!1,e},combineWith:function(e){return this},getMatrix:function(){return this._matrix},setMatrix:function(e,t){return this.set(e,t)},_apply:function(e,t,n){var r=this;if(!r._isOn||!r._matrix)return e;if(r._doIntegral)return r._matrix2?d(e,t,n,r._matrix,r._matrix2,r._dim,r._dim2,r._coeff[0],r._coeff[1],r._doIntegral):d(e,t,n,r._matrix,null,r._dim,r._dim,r._coeff[0],r._coeff[1],r._doIntegral);if(r._doSeparable)return p(e,t,n,r._mat,r._mat2,r._indices,r._indices2,r._coeff[0],r._coeff[1]);var a,i,s,o,l,u,c,h,f,m,g,v,y,w,A,R,I,M,L,x,N,S,T=e.length,O=T>>2,F=new C(T),D=t-1,P=O-t,k=r._coeff[0],G=r._coeff[1],H=r._matrix,U=r._matrix2,X=r._isGrad;if(U){for(x=r._indicesf.length,S=new b(r._indicesf),u=0;x>u;u+=2)S[u+1]*=t;for(N=H.length,c=0,h=0,o=0;T>o;o+=4,c++){for(c>=t&&(c=0,h+=t),v=0,y=0,w=0,A=0,R=0,I=0,u=0,l=0;N>u;u++,l+=2)f=c+S[l],m=h+S[l+1],f>=0&&D>=f&&m>=0&&P>=m&&(g=f+m<<2,M=H[u],v+=e[g]*M,y+=e[g+1]*M,w+=e[g+2]*M,L=U[u],A+=e[g]*L,R+=e[g+1]*L,I+=e[g+2]*L);X?(a=_(v)+_(A),i=_(y)+_(R),s=_(w)+_(I)):(a=k*v+G*A,i=k*y+G*R,s=k*w+G*I),E&&(a=0>a?0:a>255?255:a,i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s),F[o]=~~a,F[o+1]=~~i,F[o+2]=~~s,F[o+3]=e[o+3]}}else{for(x=r._indices.length,S=new b(r._indices),u=0;x>u;u+=2)S[u+1]*=t;for(H=r._mat,N=H.length,c=0,h=0,o=0;T>o;o+=4,c++){for(c>=t&&(c=0,h+=t),v=0,y=0,w=0,u=0,l=0;N>u;u++,l+=2)f=c+S[l],m=h+S[l+1],f>=0&&D>=f&&m>=0&&P>=m&&(g=f+m<<2,M=H[u],v+=e[g]*M,y+=e[g+1]*M,w+=e[g+2]*M);a=k*v+G,i=k*y+G,s=k*w+G,E&&(a=0>a?0:a>255?255:a,i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s),F[o]=~~a,F[o+1]=~~i,F[o+2]=~~s,F[o+3]=e[o+3]}}return F},canRun:function(){return this._isOn&&this._matrix}});I.prototype.bump=I.prototype.emboss,I.prototype.boxBlur=I.prototype.lowPass,I.prototype.gaussBlur=I.prototype.binomialLowPass,I.prototype.gradX=I.prototype.prewittX,I.prototype.gradY=I.prototype.prewittY,I.prototype.gradDirectional=I.prototype.prewittDirectional,I.prototype.grad=I.prototype.prewitt}(FILTER),!function(e,t){var n,r=e.ImArray,a=e.Array8U,i=e.Array32I,s=Math.sqrt,o=function(e){var t,n=e*e,r=new a(n);for(t=0;n>t;t++)r[t]=1;return r},l=o(3);e.MorphologicalFilter=e.Class(e.Filter,{name:"MorphologicalFilter",constructor:function(){var e=this;e.$super("constructor"),e._filterName=null,e._filter=null,e._dim=0,e._structureElement=null,e._indices=null},_filterName:null,_filter:null,_dim:0,_structureElement:null,_indices:null,dispose:function(){var e=this;return e.$super("dispose"),e._filterName=null,e._filter=null,e._dim=null,e._structureElement=null,e._indices=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_filterName:e._filterName,_dim:e._dim,_structureElement:e._structureElement,_indices:e._indices}}},unserialize:function(e){var t,r=this;return e&&r.name===e.filter&&(r._isOn=!!e._isOn,t=e.params,r._dim=t._dim,r._structureElement=t._structureElement,r._indices=t._indices,r._filterName=t._filterName,r._filterName&&n[r._filterName]&&(r._filter=n[r._filterName])),r},erode:function(e){return this.set(e,"erode")},dilate:function(e){return this.set(e,"dilate")},opening:function(e){return this.set(e,"open")},closing:function(e){return this.set(e,"close")},set:function(e,t){var r=this;r._filterName=t,r._filter=n[t],e&&e.length?(r._structureElement=new a(e),r._dim=~~(s(r._structureElement.length)+.5)):e&&e===e-0?(r._structureElement=o(e),r._dim=e):(r._structureElement=l,r._dim=3);var u,c,h,f=[],e=r._structureElement,d=e.length,p=r._dim,m=p>>1;for(c=0,h=0,u=0;d>u;)e[u]&&(f.push(c-m),f.push(h-m)),u++,c++,c>=p&&(c=0,h++);return r._indices=new i(f),r},reset:function(){var e=this;return e._filterName=null,e._filter=null,e._dim=0,e._structureElement=null,e._indices=null,e},_apply:function(e,t,n){var r=this;return r._isOn&&r._dim&&r._filter?r._filter(r,e,t,n):e},canRun:function(){return this._isOn&&this._dim&&this._filter}});n={dilate:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=0,v=0,y=0,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],p>g&&(g=p),m>v&&(v=m),_>y&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E},erode:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E},open:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}for(t=E,E=new r(A),u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E},close:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}for(t=E,E=new r(A),u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E}}}(FILTER),!function(e,t){var n,r=e.ImArray,a=e.Array32I,i=(Math.min,Math.max,e.StatisticalFilter=e.Class(e.Filter,{name:"StatisticalFilter",constructor:function(){var e=this;e.$super("constructor"),e._dim=0,e._indices=null,e._filterName=null,e._filter=null},_dim:0,_indices:null,_filter:null,_filterName:null,dispose:function(){var e=this;return e.$super("dispose"),e._dim=null,e._indices=null,e._filter=null,e._filterName=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_filterName:e._filterName,_dim:e._dim,_indices:e._indices}}},unserialize:function(e){var t,r=this;return e&&r.name===e.filter&&(r._isOn=!!e._isOn,t=e.params,r._dim=t._dim,r._indices=t._indices,r._filterName=t._filterName,r._filterName&&n[r._filterName]&&(r._filter=n[r._filterName])),r},median:function(e){return e=e===t?3:e%2?e:e+1,this.set(e,"median")},minimum:function(e){return e=e===t?3:e%2?e:e+1,this.set(e,"minimum")},maximum:function(e){return e=e===t?3:e%2?e:e+1,this.set(e,"maximum")},set:function(e,t){var r=this;r._filterName=t,r._filter=n[t],r._dim=e;var i,s,o,l=[],u=e*e,c=e,h=c>>1;for(s=0,o=0,i=0;u>i;)l.push(s-h),l.push(o-h),i++,s++,s>=c&&(s=0,o++);return r._indices=new a(l),r},reset:function(){var e=this;return e._filterName=null,e._filter=null,e._dim=0,e._indices=null,e},_apply:function(e,t,n){var r=this;return r._isOn&&r._dim?r._filter(r,e,t,n):e},canRun:function(){return this._isOn&&this._dim}}));i.prototype.erode=i.prototype.minimum,i.prototype.dilate=i.prototype.maximum,n={median:function(e,t,n,i){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E=e._dim,R=E*E,I=new a(e._indices),M=t.length,L=M>>2,x=new r(M),N=R<<1,S=n-1,T=L-n;for(d=[],p=[],m=[],o=0;N>o;o+=2)I[o+1]*=n;for(s=0,l=0,u=0;M>s;){for(d.length=0,p.length=0,m.length=0,o=0;N>o;)c=l+I[o],h=u+I[o+1],c>=0&&S>=c&&h>=0&&T>=h&&(f=c+h<<2,_=t[f],g=t[f+1],v=t[f+2],d.push(_),p.push(g),m.push(v)),o+=2;d.sort(),p.sort(),m.sort(),A=d.length,b=A>>1,y=A%2?d[b+1]:~~(.5*(d[b]+d[b+1])),A=p.length,b=A>>1,w=A%2?p[b+1]:~~(.5*(p[b]+p[b+1])),A=m.length,b=A>>1,C=A%2?m[b+1]:~~(.5*(m[b]+m[b+1])),x[s]=y,x[s+1]=w,x[s+2]=C,x[s+3]=t[s+3],s+=4,l++,l>=n&&(l=0,u+=n)}return x},maximum:function(e,t,n,i){var s,o,l,u,c,h,f,d,p,m,_,g,v,y=e._dim,w=y*y,C=new a(e._indices),A=t.length,b=A>>2,E=new r(A),R=w<<1,I=n-1,M=b-n;for(o=0;R>o;o+=2)C[o+1]*=n;for(s=0,l=0,u=0;A>s;){for(_=0,g=0,v=0,o=0;R>o;)c=l+C[o],h=u+C[o+1],c>=0&&I>=c&&h>=0&&M>=h&&(f=c+h<<2,d=t[f],p=t[f+1],m=t[f+2],d>_&&(_=d),p>g&&(g=p),m>v&&(v=m)),o+=2;E[s]=_,E[s+1]=g,E[s+2]=v,E[s+3]=t[s+3],s+=4,l++,l>=n&&(l=0,u+=n)}return E},minimum:function(e,t,n,i){var s,o,l,u,c,h,f,d,p,m,_,g,v,y=e._dim,w=y*y,C=new a(e._indices),A=t.length,b=A>>2,E=new r(A),R=w<<1,I=n-1,M=b-n;for(o=0;R>o;o+=2)C[o+1]*=n;for(s=0,l=0,u=0;A>s;){for(_=255,g=255,v=255,o=0;R>o;)c=l+C[o],h=u+C[o+1],c>=0&&I>=c&&h>=0&&M>=h&&(f=c+h<<2,d=t[f],p=t[f+1],m=t[f+2],_>d&&(_=d),g>p&&(g=p),v>m&&(v=m)),o+=2;E[s]=_,E[s+1]=g,E[s+2]=v,E[s+3]=t[s+3],s+=4,l++,l>=n&&(l=0,u+=n)}return E}}}(FILTER),!function(e,t){function n(e){var t,n;for(e>0&&1>e&&(e*=65536),e=u(e),256>e&&(e|=e<<8),n=0;256>n;n++)t=1&n?h[n]^255&e:h[n]^e>>8&255, -f[n]=f[n+256]=t}function r(e,t,n){var r=7&e,a=4>r?t:n,i=4>r?n:t;return(1&r?-a:a)+(2&r?-2*i:2*i)}function a(e,t){var n,a,i,s,o,l=.366025403,c=.211324865,h=(e+t)*l,d=e+h,p=t+h,m=u(d),_=u(p),g=(m+_)*c,v=m-g,y=_-g,w=e-v,C=t-y;w>C?(s=1,o=0):(s=0,o=1);var A=w-s+c,b=C-o+c,E=w-1+2*c,R=C-1+2*c,I=255&m,M=255&_,L=.5-w*w-C*C;0>L?n=0:(L*=L,n=L*L*r(f[I+f[M]],w,C));var x=.5-A*A-b*b;0>x?a=0:(x*=x,a=x*x*r(f[I+s+f[M+o]],A,b));var N=.5-E*E-R*R;return 0>N?i=0:(N*=N,i=N*N*r(f[I+1+f[M+1]],E,R)),40*(n+a+i)}function i(e){return e*e*e*(e*(6*e-15)+10)}function s(e,t,n){return t+e*(n-t)}function o(e,t){var n,a,o,l,c,h,d,p,m,_,g,v,y,w;return n=u(e),a=u(t),c=e-n,h=t-a,d=c-1,p=h-1,o=n+1&255,l=a+1&255,n=255&n,a=255&a,_=i(h),m=i(c),g=r(f[n+f[a]],c,h),v=r(f[n+f[l]],c,p),y=s(_,g,v),g=r(f[o+f[a]],d,h),v=r(f[o+f[l]],d,p),w=s(_,g,v),.507*s(m,y,w)}function l(e,t,n,r,a,i,s,o,l,u,c){var h,f,d,p=0,m=u,_=1,g=0;for(h=0;o>h;h++)f=(t+l[h][0])%r,d=(n+l[h][1])%a,p+=e(m*f*i,m*d*s)*_,m*=2,g+=_,_*=c;return p/g}var u=Math.floor,c=(Math.sin,Math.cos,e.CONST.PI2,e.Array8U),h=new c([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,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 c(h);e.PerlinNoise={seed:n,Image:function(t,n,r,i,s,u,c,h,f,d){var p,m,_,g,v,y,w=(new e.Image).restorable(!1).fill("rgb(0,0,0)",0,0,n,r),C=1/i,A=1/s,b=d?o:a,n=w.width,r=w.height,E=w.getData(),R=E.length,I=n>>>1,M=r>>>1;if(h=h||1,f=f||.5,u=u||1,c=c||[[0,0]],t)for(p=0,m=0,v=0;R>v;v+=4,p++)p>=n&&(p=0,m++),_=p>I?n-1-p:p,g=m>M?r-1-m:m,p>_||m>g?(y=g*n+_<<2,E[v]=E[y],E[v+1]=E[y+1],E[v+2]=E[y+2]):(E[v]=~~(255*(.5*l(b,_,g,n,r,C,A,u,c,h,f)+.5)),E[v+1]=E[v],E[v+2]=E[v]);else for(p=0,m=0,v=0;R>v;v+=4,p++)p>=n&&(p=0,m++),E[v]=~~(255*(.5*l(b,_,g,n,r,C,A,u,c,h,f)+.5)),E[v+1]=E[v],E[v+2]=E[v];return w.setData(E),w}}}(FILTER),FILTER}); +t===i&&(i=u),a&&!d&&i&&!p&&c.createImageData(a,i);var m=c.ictx,_=c.octx;return e=e||0,c._restorable&&(m.fillStyle=e,m.fillRect(n,r,a,i)),_.fillStyle=e,_.fillRect(n,r,a,i),c._needsRefresh|=M|w|C|A,h&&(c._needsRefresh|=I),c},getData:function(){var e,t=this;return t._restorable?(t._needsRefresh&_&&a(t,_),e=t.iData):(t._needsRefresh&g&&a(t,g),e=t.oData),new u(e.data)},getSelectedData:function(){var e,t=this;return t.selection?t._restorable?(t._needsRefresh&v&&i(t,v),e=t.iDataSel):(t._needsRefresh&y&&i(t,y),e=t.oDataSel):t._restorable?(t._needsRefresh&_&&a(t,_),e=t.iData):(t._needsRefresh&g&&a(t,g),e=t.oData),[new u(e.data),e.width,e.height]},getProcessedData:function(){var e=this;return e._needsRefresh&g&&a(e,g),new u(e.oData.data)},getProcessedSelectedData:function(){var e,t=this;return t.selection?(t._needsRefresh&y&&i(t,y),e=t.oDataSel):(t._needsRefresh&g&&a(t,g),e=t.oData),[new u(e.data),e.width,e.height]},setData:function(e){var t=this;return t._needsRefresh&g&&a(t,g),t.oData.data.set(e),t.octx.putImageData(t.oData,0,0),t._needsRefresh|=w|C|A,t.selection&&(t._needsRefresh|=y),t},setSelectedData:function(e){var t=this;if(t.selection){var n=t.selection,r=t.width-1,s=t.height-1,o=f(n[0]*r),l=f(n[1]*s);t._needsRefresh&y&&i(t,y),t.oDataSel.data.set(e),t.octx.putImageData(t.oDataSel,o,l),t._needsRefresh|=g}else t._needsRefresh&g&&a(t,g),t.oData.data.set(e),t.octx.putImageData(t.oData,0,0);return t._needsRefresh|=w|C|A,t},createImageData:function(e,t){var n,a,i=this;return r(i,e,t,R),i._restorable&&(n=i.ictx=i.iCanvas.getContext("2d"),n.createImageData(e,t)),a=i.octx=i.oCanvas.getContext("2d"),a.createImageData(e,t),i._needsRefresh|=M,i.selection&&(i._needsRefresh|=I),i},image:function(e){if(!e)return this;var t,n,i,s,o,l,u,c=this;return e instanceof S&&(e=e.oCanvas),o=e instanceof HTMLVideoElement,l=e instanceof HTMLCanvasElement||e instanceof h,u=e instanceof Image,o?(i=e.videoWidth,s=e.videoHeight):(i=e.width,s=e.height),u||l||o?(r(c,i,s,R),c._restorable&&(t=c.ictx=c.iCanvas.getContext("2d"),t.drawImage(e,0,0)),n=c.octx=c.oCanvas.getContext("2d"),n.drawImage(e,0,0),c._needsRefresh|=M):(c.oData||(c.createImageData(i,s),a(c,M)),c._restorable&&(t=c.ictx=c.iCanvas.getContext("2d"),c.iData.data.set(e.data),t.putImageData(c.iData,0,0)),n=c.octx=c.oCanvas.getContext("2d"),c.oData.data.set(e.data),n.putImageData(c.oData,0,0)),c._needsRefresh|=w|C|A,c.selection&&(c._needsRefresh|=I),c},getPixel:function(e,t){var n=this;n._needsRefresh&g&&a(n,g);var r=~~(t*n.width+e+.5)<<2,i=n.oData.data;return{r:i[r],g:i[r+1],b:i[r+2],a:i[r+3]}},setPixel:function(e,t,n,r,a,i){var s=this;return s.octx.putImageData(new l([255&n,255&r,255&a,255&i]),e,t),s._needsRefresh|=g|w|C|A,s.selection&&(s._needsRefresh|=y),s},getPixelData:function(){return this._needsRefresh&g&&a(this,g),this.oData},setPixelData:function(e){var t=this;return t.octx.putImageData(e,0,0),t._needsRefresh|=g|w|C|A,t.selection&&(t._needsRefresh|=y),t},integral:function(){var e=this;return e._needsRefresh&C&&(e._integral=S.integral(e.getPixelData().data,e.width,e.height,e._grayscale),e._needsRefresh&=N),e._integral},histogram:function(){var e=this;return e._needsRefresh&w&&(e._histogram=S.histogram(e.getPixelData().data,e.width,e.height,e._grayscale),e._needsRefresh&=x),e._histogram},spectrum:function(){var e=this;return e._spectrum},toImage:function(e){var t,n=this.oCanvas,r=1;if(t=e&d.JPG?n.toDataURL(p.JPG,r):e&d.GIF?n.toDataURL(p.GIF,r):n.toDataURL(p.PNG,r),e&d.IMAGE){var a=new Image;return a.src=t,a}return t},toString:function(){return"[FILTER Image: "+this.name+"]"}});S[s].setImage=S[s].image,S[s].setDimensions=S[s].dimensions,S.scale=S.resize=e.Interpolation.bilinear,S.crop=e.Interpolation.crop,S.pad=e.Interpolation.pad,S.integral=e.Math.integral,S.histogram=e.Math.histogram,S.spectrum=e.Math.spectrum;var T=e.ScaledImage=e.Class(S,{name:"ScaledImage",constructor:function F(e,t,n){var r=this;return r instanceof F?(r.scaleX=e||1,r.scaleY=t||r.scaleX,void r.$super("constructor",n)):new F(e,t,n)},scaleX:1,scaleY:1,dispose:function(){var e=this;return e.scaleX=null,e.scaleY=null,e.$super("dispose"),e},clone:function(e){var t=this;return new T(t.scaleX,t.scaleY,!0===e?t.iCanvas:t.oCanvas)},setScale:function(e,t){var n=this,r=arguments.length;return r>0&&null!=e&&(n.scaleX=e,n.scaleY=e),r>1&&null!=t&&(n.scaleY=t),n},image:function(e){if(!e)return this;var t,n,a,i,s,o,l,u,c,f=this,d=f.scaleX,p=f.scaleY;return e instanceof S&&(e=e.oCanvas),l=e instanceof HTMLVideoElement,u=e instanceof HTMLCanvasElement||e instanceof h,c=e instanceof Image,l?(a=e.videoWidth,i=e.videoHeight):(a=e.width,i=e.height),(c||u||l)&&(s=~~(d*a+.5),o=~~(p*i+.5),r(f,s,o,R),f._restorable&&(t=f.ictx=f.iCanvas.getContext("2d"),t.drawImage(e,0,0,a,i,0,0,s,o)),n=f.octx=f.oCanvas.getContext("2d"),n.drawImage(e,0,0,a,i,0,0,s,o),f._needsRefresh|=M|w|C|A,f.selection&&(f._needsRefresh|=I)),f}});T[s].setImage=T[s].image}(FILTER),!function(e,t){function n(e,t,n){var r="";if(!e)return xhr?xhr:r;var a,l,u,c,h,f=s(e);if(n){for(l=0,u=f.length;u>l;l++)a=f[l],n.setHeader(a,e[a]);return n}if(t){for(l=0,u=f.length;u>l;l++)if(a=f[l],"[object Array]"===i.call(e[a]))for(c=0,h=e[a].length;h>c;c++)t.setRequestHeader(a,String(e[a][c]));else t.setRequestHeader(a,String(e[a]));return t}for(l=0,u=f.length;u>l;l++)if(a=f[l],"[object Array]"===i.call(e[a]))for(r.length&&(r+=o),r+=a+": "+String(e[a][0]),c=1,h=e[a].length;h>c;c++)r+=o+String(e[a][c]);else r.length&&(r+=o),r+=a+": "+String(e[a]);return r}function r(e,t){var n,r,i,s,l={},c=null;if(e)for(t=!0===t,e=e.split(o),r=0,i=e.length;i>r;r++)s=e[r],n=s.split(":"),n.length>1?(c=u(n.shift()),t&&(c=c.toLowerCase()),l[a](c)?("string"==typeof l[c]&&(l[c]=[l[c]]),l[c].push(u(n.join(":")))):l[c]=u(n.join(":"))):n[0].length&&c&&(l[c]=o+n[0]);return l}var a="hasOwnProperty",i=Object.prototype.toString,s=Object.keys,o="\r\n",l=/^\s+|\s+$/g,u=String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(l,"")},c=e.Image,h=e.Class,f=e.Loader=h({name:"Loader",__static__:{load:e.Method(function(e,t,n){return function(e,t,r){return(new n).load(e,t,r)}},e.LATE|e.STATIC)},constructor:function(){},_crossOrigin:null,_responseType:null,dispose:function(){var e=this;return e._crossOrigin=null,e._responseType=null,e},load:function(e,t,n){return null},responseType:function(e){var t=this;return arguments.length?(t._responseType=e,t):t._responseType},crossOrigin:function(e){var t=this;return arguments.length?(t._crossOrigin=e,t):t._crossOrigin}}),d=e.XHR=function m(e,t){var n=this,r=!1;n.readyState=m.UNSENT,n.status=null,n.statusText=null,n.responseType="text",n.responseURL=null,n.response=null,n.responseText=null,n.responseXml=null,n._rawHeaders=null,n._headers=null,n.send=function(t){return r||m.UNSENT!==n.readyState?n:(e&&e(t),n.readyState=m.OPENED,n)},n.abort=function(){return r?n:(r=!0,t&&t(),n)},n.getAllResponseHeaders=function(e){return m.DONE!==n.readyState?null:!0===e?n._headers:n._rawHeaders},n.getResponseHeader=function(e,t){if(null==e||m.DONE!==n.readyState)return null;var r=n._headers||{};return!1!==t&&(e=e.toLowerCase()),r[a](e)?r[e]:null},n.dispose=function(){return n.readyState=null,n.status=null,n.statusText=null,n.responseType=null,n.responseURL=null,n.response=null,n.responseText=null,n.responseXml=null,n._rawHeaders=null,n._headers=null,n.getAllResponseHeaders=null,n.getResponseHeader=null,n.send=null,n.abort=null,n}};d.UNSENT=0,d.OPENED=1,d.HEADERS_RECEIVED=2,d.LOADING=3,d.DONE=4,d.create=e.Browser.isNode?function(e,t){if(e=e||{},!e.url)return null;var r,a,s="[object Object]"===i.call(e.url)?e.url:require("url").parse(e.url),o={method:e.method||"GET",agent:!1,protocol:s.protocol,host:s.hostname,hostname:s.hostname,port:s.port||80,path:(s.pathname||"/")+(s.query?"?"+s.query:"")};return a=new d(function(e){null!=e&&(e=String(e),r.setHeader("Content-Length",String(e.length)),r.write(e)),r.end()},function(){r.abort()}),r=("https:"===o.protocol?require("https").request:require("http").request)(o,function(t){var n="",r=0;a.readyState=d.OPENED,e.onStateChange&&e.onStateChange(a),a.readyState=d.HEADERS_RECEIVED,a._rawHeaders=t.rawHeaders.join("\r\n"),a._headers=t.headers,a.responseURL=t.url||null,a.status=t.statusCode||null,a.statusText=t.statusMessage||null,e.onStateChange&&e.onStateChange(a),t.on("data",function(t){r||(r=1,a.readyState=d.LOADING,e.onStateChange&&e.onStateChange(a),e.onLoadStart&&e.onLoadStart(a)),n+=t.toString(),e.onProgress&&e.onProgress(a)}),t.on("end",function(){a.readyState=d.DONE,a.responseType="text",a.response=a.responseText=n,e.onStateChange&&e.onStateChange(a),e.onLoadEnd&&e.onLoadEnd(a),d.DONE===a.readyState&&(200===a.status?e.onComplete&&e.onComplete(a):e.onRequestError?e.onRequestError(a):e.onError&&e.onError(a))}),t.on("error",function(t){a.statusText=t.toString(),e.onError&&e.onError(a)})}),r.setTimeout(e.timeout||3e4,function(t){e.onTimeout&&e.onTimeout(a)}),r.on("abort",function(t){e.onAbort&&e.onAbort(a)}),r.on("error",function(t){a.statusText=t.toString(),e.onError&&e.onError(a)}),e.headers&&n(e.headers,null,r),arguments.length>1&&a.send(t),a}:function(e,t){if(e=e||{},!e.url)return null;var a="undefined"!=typeof XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),i=new d(function(e){a.send(e)},function(){a.abort()}),s=function(e,t){return e.readyState=t.readyState,e.status=t.status,e.statusText=t.statusText,e};return i.getAllResponseHeaders=function(e){var t=a.getAllResponseHeaders();return!0===e?r(t):t},i.getResponseHeader=function(e){return a.getResponseHeader(e)},a.open(e.method||"GET",e.url,!e.sync),e.responseType&&(i.responseType=a.responseType=e.responseType),a.timeout=e.timeout||3e4,e.onProgress&&(a.onprogress=function(){e.onProgress(s(i,a))}),e.onLoadStart&&(a.onloadstart=function(){e.onLoadStart(s(i,a))}),e.onLoadEnd&&(a.onloadend=function(){e.onLoadEnd(s(i,a))}),!e.sync&&e.onStateChange&&(a.onreadystatechange=function(){e.onStateChange(s(i,a))}),a.onload=function(){d.DONE===a.readyState&&(s(i,a),200===a.status?(i.responseURL=a.responseURL,i.response=a.response,e.onComplete&&e.onComplete(i)):e.onRequestError?e.onRequestError(i):e.onError&&e.onError(i))},a.onabort=function(){e.onAbort&&e.onAbort(s(i,a))},a.onerror=function(){e.onError&&e.onError(s(i,a))},a.ontimeout=function(){e.onTimeout&&e.onTimeout(s(i,a))},e.headers&&n(e.headers,a),e.mimeType&&a.overrideMimeType(e.mimeType),arguments.length>1&&i.send(t),i};var p=(e.XHRLoader=h(f,{name:"XHRLoader",constructor:function _(){var e=this;return e instanceof _?void 0:new _},load:function(e,t,n){var r=this;return d.create({url:e,responseType:r._responseType,onComplete:function(e){"function"==typeof t&&t(e.response)},onError:function(e){"function"==typeof n&&n(e.statusText)}},null),r}}),e.FileLoader=h(f,{name:"FileLoader",constructor:function g(){var e=this;return e instanceof g?void 0:new g},load:function(t,n,r){var a=this;return e.Browser.isNode?require("fs").readFile(t,{encoding:"arraybuffer"===a._responseType?null:a._responseType,flag:"r"},function(e,t){e?"function"==typeof r&&r(e.toString()):"function"==typeof n&&n(t)}):d.create({url:t,responseType:a._responseType,onComplete:function(e){"function"==typeof n&&n(e.response)},onError:function(e){"function"==typeof r&&r(e.statusText)}},null),a}}));e.BinaryLoader=h(f,{name:"BinaryLoader",constructor:function v(e){var t=this;return t instanceof v?void(t._decoder="function"==typeof e?e:null):new v(e)},_decoder:null,_encoder:null,dispose:function(){var e=this;return e._decoder=null,e._encoder=null,e.$super("dispose"),e},decoder:function(e){var t=this;return t._decoder="function"==typeof e?e:null,t},encoder:function(e){var t=this;return t._encoder="function"==typeof e?e:null,t},load:function(e,t,n){var r=this,a=new c,i=r._decoder;return"function"==typeof i&&(new p).responseType(r._responseType||"arraybuffer").load(e,function(e){var n={},r=i(e,n);r&&(a.image(r),"function"==typeof t&&t(a,n))},n),a}})}(FILTER),!function(e,t){var n=e.Image;e.HTMLImageLoader=e.Class(e.Loader,{name:"HTMLImageLoader",constructor:function r(){return this instanceof r?void this.$super("constructor"):new r},load:function(e,t,r){var a,i=this,s=new n;return a=new Image,a.onload=function(e){s.setImage(a),"function"==typeof t&&t(s,a)},a.onerror=function(e){"function"==typeof r&&r(s,a)},a.crossOrigin=i._crossOrigin||"",a.src=e,s}})}(FILTER),!function(e,t){var n=(Object.prototype,Function.prototype,Array.prototype),r=n.slice,a=n.splice,i=n.concat,s=e.CompositeFilter=e.Class(e.Filter,{name:"CompositeFilter",constructor:function(e){var t=this;t.$super("constructor"),t._stack=e&&e.length?e.slice():[]},_stack:null,_meta:null,_stable:!0,dispose:function(e){var t,n=this,r=n._stack;if(n.$super("dispose"),!0===e)for(t=0;tn;n++)l[n]=l[n].unserialize(i[n]);else{for(n=0;a>n;n++)l[n]&&l[n].dispose(!0),l[n]=null;for(l=[],n=0;r>n;n++){if(s=i[n]&&i[n].filter?e[i[n].filter]:null,!s)throw new Error('Filter "'+i[n].filter+'" could not be created');l.push((new s).unserialize(i[n]))}}o._stack=l}return o},getMeta:function(){return this._meta},setMeta:function(e){var t,n,r=this,a=r._stack;if(e&&(n=e.length)&&a.length)for(t=0;n>t;t++)a[e[t][0]].setMeta(e[t][1]);return r},stable:function(e){return arguments.length||(e=!0),this._stable=!!e,this},filters:function(e){return arguments.length?(this._stack=e.slice(),this):this._stack.slice()},push:function(){var e=r.call(arguments),t=e.length;return t&&(this._stack=i.apply(this._stack,e)),this},pop:function(){return this._stack.pop()},shift:function(){return this._stack.shift()},unshift:function(){var e=r.call(arguments),t=e.length;return t&&a.apply(this._stack,[0,0].concat(e)),this},getAt:function(e){return this._stack.length>e?this._stack[e]:null},setAt:function(e,t){return this._stack.length>e?this._stack[e]=t:this._stack.push(t),this},insertAt:function(e){var t=r.call(arguments);t.length;return argslen>1&&(t.shift(),a.apply(this._stack,[e,0].concat(t))),this},removeAt:function(e){return this._stack.splice(e,1)},remove:function(e){for(var t=this._stack.length;--t>=0;)e===this._stack[t]&&this._stack.splice(t,1);return this},reset:function(){return this._stack.length=0,this},_apply:function(e,t,n,r){var a=this;if(a.hasMeta=!1,a._meta=[],a._isOn&&a._stack.length){var i,s,o=a._stack,l=o.length;for(i=0;l>i;i++)s=o[i],s&&s._isOn&&(e=s._apply(e,t,n,r),s.hasMeta&&a._meta.push([i,s.getMeta()]))}return a.hasMeta=a._meta.length>0,e},canRun:function(){return this._isOn&&this._stack.length},toString:function(){var e,t=arguments.length&&arguments[0].substr?arguments[0]:" ",n=t+t,r=this._stack,a=[],i=r.length;for(e=0;i>e;e++)a.push(r[e].toString(n));return["[FILTER: "+this.name+"]","["," "+a.join("\n "),"]",""].join("\n")}});s.prototype.empty=s.prototype.reset,s.prototype.concat=s.prototype.push}(FILTER),!function(e,t){var n="hasOwnProperty";e.InlineFilter=e.Class(e.Filter,{name:"InlineFilter",constructor:function(e){var t=this;t.$super("constructor"),t._handler=e&&"function"==typeof e?e:null,t._params={}},_handler:null,_params:null,dispose:function(){var e=this;return e.$super("dispose"),e._handler=null,e._params=null,e},params:function(e){var t=this;if(arguments.length){for(var r in e)e[n](r)&&(t._params[r]=e[r]);return t}return t._params},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_handler:e._handler?e._handler.toString():null,_params:e._params}}},unserialize:function(t){var n,r=this;return t&&r.name===t.filter&&(r._isOn=!!t._isOn,n=t.params,r._handler=null,n._handler&&(r._handler=new Function("FILTER",'"use strict"; return '+n._handler+";")(e)),r._params=n._params||{}),r},_apply:function(e,t,n,r){var a=this;return a._isOn&&a._handler?a._handler(a,e,t,n,r):e},canRun:function(){return this._isOn&&this._handler}});e.CustomFilter=e.InlineFilter}(FILTER),!function(e,t){function n(e,t){var n,r,a,i,o,l=new s(20);return n=t[0],r=t[1],a=t[2],i=t[3],o=t[4],l[0]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[1]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[2]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[3]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[4]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,n=t[5],r=t[6],a=t[7],i=t[8],o=t[9],l[5]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[6]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[7]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[8]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[9]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,n=t[10],r=t[11],a=t[12],i=t[13],o=t[14],l[10]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[11]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[12]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[13]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[14]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,n=t[15],r=t[16],a=t[17],i=t[18],o=t[19],l[15]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[16]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[17]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[18]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[19]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,l}function r(e,t,n){var r=1-n,a=new s(20);return a[0]=r*e[0]+n*t[0],a[1]=r*e[1]+n*t[1],a[2]=r*e[2]+n*t[2],a[3]=r*e[3]+n*t[3],a[4]=r*e[4]+n*t[4],a[5]=r*e[5]+n*t[5],a[6]=r*e[6]+n*t[6],a[7]=r*e[7]+n*t[7],a[8]=r*e[8]+n*t[8],a[9]=r*e[9]+n*t[9],a[10]=r*e[10]+n*t[10],a[11]=r*e[11]+n*t[11],a[12]=r*e[12]+n*t[12],a[13]=r*e[13]+n*t[13],a[14]=r*e[14]+n*t[14],a[15]=r*e[15]+n*t[15],a[16]=r*e[16]+n*t[16],a[17]=r*e[17]+n*t[17],a[18]=r*e[18]+n*t[18],a[19]=r*e[19]+n*t[19],a}var a=Math.sin,i=Math.cos,s=e.Array32F,o=e.CONST.toRad,l=(e.CONST.toDeg,e._notSupportClamp),u=e.ColorMatrixFilter=e.Class(e.Filter,{name:"ColorMatrixFilter",constructor:function(t){var n=this;n.$super("constructor"),t&&t.length?n._matrix=new s(t):n._matrix=null,e.useWebGL&&(n._webglInstance=e.WebGLColorMatrixFilterInstance||null)},_matrix:null,_webglInstance:null,dispose:function(){var e=this;return e.$super("dispose"),e._webglInstance=null,e._matrix=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_matrix:e._matrix}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n._matrix=t._matrix),n},channel:function(n,r){r=r===t?!1:r;var a=r?1:0;switch(n){case e.CHANNEL.ALPHA:return this.set([0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,255]);case e.CHANNEL.BLUE:return this.set([0,0,a,0,0,0,0,a,0,0,0,0,1,0,0,0,0,0,0,255]);case e.CHANNEL.GREEN:return this.set([0,a,0,0,0,0,1,0,0,0,0,a,0,0,0,0,0,0,0,255]);case e.CHANNEL.RED:default:return this.set([1,0,0,0,0,a,0,0,0,0,a,0,0,0,0,0,0,0,0,255])}},redChannel:function(t){return this.channel(e.CHANNEL.RED,t)},greenChannel:function(t){return this.channel(e.CHANNEL.GREEN,t)},blueChannel:function(t){return this.channel(e.CHANNEL.BLUE,t)},alphaChannel:function(t){return this.channel(e.CHANNEL.ALPHA,!0)},maskChannel:function(t){switch(t){case e.CHANNEL.ALPHA:return this;case e.CHANNEL.BLUE:return this.set([1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0]);case e.CHANNEL.GREEN:return this.set([1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0]);case e.CHANNEL.RED:default:return this.set([0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0])}},swapChannels:function(t,n){switch(t){case e.CHANNEL.ALPHA:switch(n){case e.CHANNEL.ALPHA:return this;case e.CHANNEL.BLUE:return this.set([1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0]);case e.CHANNEL.GREEN:return this.set([1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0]);case e.CHANNEL.RED:default:return this.set([0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0])}break;case e.CHANNEL.BLUE:switch(n){case e.CHANNEL.ALPHA:return this.set([1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0]);case e.CHANNEL.BLUE:return this;case e.CHANNEL.GREEN:return this.set([1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0]);case e.CHANNEL.RED:default:return this.set([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])}break;case e.CHANNEL.GREEN:switch(n){case e.CHANNEL.ALPHA:return this.set([1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0]);case e.CHANNEL.BLUE:return this.set([1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0]);case e.CHANNEL.GREEN:return this;case e.CHANNEL.RED:default:return this.set([0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0])}break;case e.CHANNEL.RED:default:switch(n){case e.CHANNEL.ALPHA:return this.set([0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0]);case e.CHANNEL.BLUE:return this.set([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0]);case e.CHANNEL.GREEN:return this.set([0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0]);case e.CHANNEL.RED:default:return this}}},desaturate:function(){return this.set([e.LUMA[0],e.LUMA[1],e.LUMA[2],0,0,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,0,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,0,0,0,0,1,0])},colorize:function(n,r){var a,i,s,o;return r===t&&(r=1),a=.00392156862745098*(n>>16&255),i=.00392156862745098*(n>>8&255),s=.00392156862745098*(255&n),o=1-r,this.set([o+r*a*e.LUMA[0],r*a*e.LUMA[1],r*a*e.LUMA[2],0,0,r*i*e.LUMA[0],o+r*i*e.LUMA[1],r*i*e.LUMA[2],0,0,r*s*e.LUMA[0],r*s*e.LUMA[1],o+r*s*e.LUMA[2],0,0,0,0,0,1,0])},invert:function(){return this.set([-1,0,0,0,255,0,-1,0,0,255,0,0,-1,0,255,0,0,0,1,0])},invertAlpha:function(){return this.set([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,-1,255])},saturate:function(t){var n,r,a,i;return n=1-t,r=n*e.LUMA[0],a=n*e.LUMA[1],i=n*e.LUMA[2],this.set([r+t,a,i,0,0,r,a+t,i,0,0,r,a,i+t,0,0,0,0,0,1,0])},contrast:function(e,n,r){return n===t&&(n=e),r===t&&(r=e),e+=1,n+=1,r+=1,this.set([e,0,0,0,128*(1-e),0,n,0,0,128*(1-n),0,0,r,0,128*(1-r),0,0,0,1,0])},brightness:function(e,n,r){return n===t&&(n=e),r===t&&(r=e),this.set([1,0,0,0,e,0,1,0,0,n,0,0,1,0,r,0,0,0,1,0])},adjustHue:function(t){t*=o;var n=i(t),r=a(t);return this.set([e.LUMA[0]+n*(1-e.LUMA[0])+r*-e.LUMA[0],e.LUMA[1]+n*-e.LUMA[1]+r*-e.LUMA[1],e.LUMA[2]+n*-e.LUMA[2]+r*(1-e.LUMA[2]),0,0,e.LUMA[0]+n*-e.LUMA[0]+.143*r,e.LUMA[1]+n*(1-e.LUMA[1])+.14*r,e.LUMA[2]+n*-e.LUMA[2]+r*-.283,0,0,e.LUMA[0]+n*-e.LUMA[0]+r*-(1-e.LUMA[0]),e.LUMA[1]+n*-e.LUMA[1]+r*e.LUMA[1],e.LUMA[2]+n*(1-e.LUMA[2])+r*e.LUMA[2],0,0,0,0,0,1,0])},average:function(e,n,r){return e===t&&(e=.3333),n===t&&(n=.3333),r===t&&(r=.3334),this.set([e,n,r,0,0,e,n,r,0,0,e,n,r,0,0,0,0,0,1,0])},quickContrastCorrection:function(e){return e===t&&(e=1.2),this.set([e,0,0,0,0,0,e,0,0,0,0,0,e,0,0,0,0,0,1,0])},sepia:function(e){return e===t&&(e=.5),e>1?e=1:0>e&&(e=0),this.set([1-.607*e,.769*e,.189*e,0,0,.349*e,1-.314*e,.168*e,0,0,.272*e,.534*e,1-.869*e,0,0,0,0,0,1,0])},sepia2:function(n){return n===t&&(n=10),n>100&&(n=100),n*=2.55,this.set([e.LUMA[0],e.LUMA[1],e.LUMA[2],0,40,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,20,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,-n,0,0,0,1,0])},threshold:function(n,r){return r===t&&(r=256),this.set([e.LUMA[0]*r,e.LUMA[1]*r,e.LUMA[2]*r,0,-(r-1)*n,e.LUMA[0]*r,e.LUMA[1]*r,e.LUMA[2]*r,0,-(r-1)*n,e.LUMA[0]*r,e.LUMA[1]*r,e.LUMA[2]*r,0,-(r-1)*n,0,0,0,1,0])},threshold_rgb:function(e,n){return n===t&&(n=256),this.set([n,0,0,0,-(n-1)*e,0,n,0,0,-(n-1)*e,0,0,n,0,-(n-1)*e,0,0,0,1,0])},threshold_alpha:function(e,n){return e===t&&(e=.5),n===t&&(n=256),this.set([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,n,-n*e])},RGB2YCbCr:function(){return this.set([.5,-.418688,-.081312,0,128,.299,.587,.114,0,0,-.168736,-.331264,.5,0,128,0,0,0,1,0])},YCbCr2RGB:function(){return this.set([1.402,1,0,0,-179.456,-.71414,1,-.34414,0,135.45984,0,1,1.772,0,-226.816,0,0,0,1,0])},blend:function(e,t){return this._matrix=this._matrix?r(this._matrix,e.getMatrix(),t):new s(e.getMatrix()),this},set:function(e){return this._matrix=this._matrix?n(this._matrix,new s(e)):new s(e),this},reset:function(){return this._matrix=null,this},combineWith:function(e){return this.set(e.getMatrix())},getMatrix:function(){return this._matrix},setMatrix:function(e){return this._matrix=new s(e),this},_apply:function(e,t,n){var r=this;if(r._isOn&&r._matrix){var a,i,s,o,l,u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E,R=e.length,I=r._matrix,M=(R>>2)%4;for(a=0;R>a;a+=16)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+4],A=e[a+5],b=e[a+6],E=e[a+7],u=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],c=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],h=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],f=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+8],A=e[a+9],b=e[a+10],E=e[a+11],d=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],p=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],m=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],_=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+12],A=e[a+13],b=e[a+14],E=e[a+15],g=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],v=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],y=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],w=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l,e[a+4]=~~u,e[a+5]=~~c,e[a+6]=~~h,e[a+7]=~~f,e[a+8]=~~d,e[a+9]=~~p,e[a+10]=~~m,e[a+11]=~~_,e[a+12]=~~g,e[a+13]=~~v,e[a+14]=~~y,e[a+15]=~~w;if(M)for(M<<=2,a=R-M;R>a;a+=4)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l}return e},canRun:function(){return this._isOn&&this._matrix}});u.prototype.grayscale=u.prototype.desaturate,u.prototype.rotateHue=u.prototype.adjustHue,u.prototype.thresholdRgb=u.prototype.threshold_rgb,u.prototype.thresholdAlpha=u.prototype.threshold_alpha,l&&(u.prototype._apply=function(e,t,n){var r=this;if(r._isOn&&r._matrix){var a,i,s,o,l,u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E,R=e.length,I=r._matrix,M=(R>>2)%4;for(a=0;R>a;a+=16)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+4],A=e[a+5],b=e[a+6],E=e[a+7],u=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],c=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],h=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],f=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+8],A=e[a+9],b=e[a+10],E=e[a+11],d=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],p=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],m=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],_=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+12],A=e[a+13],b=e[a+14],E=e[a+15],g=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],v=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],y=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],w=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s,o=0>o?0:o>255?255:o,l=0>l?0:l>255?255:l,u=0>u?0:u>255?255:u,c=0>c?0:c>255?255:c,h=0>h?0:h>255?255:h,f=0>f?0:f>255?255:f,d=0>d?0:d>255?255:d,p=0>p?0:p>255?255:p,m=0>m?0:m>255?255:m,_=0>_?0:_>255?255:_,g=0>g?0:g>255?255:g,v=0>v?0:v>255?255:v,y=0>y?0:y>255?255:y,w=0>w?0:w>255?255:w,e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l,e[a+4]=~~u,e[a+5]=~~c,e[a+6]=~~h,e[a+7]=~~f,e[a+8]=~~d,e[a+9]=~~p,e[a+10]=~~m,e[a+11]=~~_,e[a+12]=~~g,e[a+13]=~~v,e[a+14]=~~y,e[a+15]=~~w;if(M)for(M<<=2,a=R-M;R>a;a+=4)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s,o=0>o?0:o>255?255:o,l=0>l?0:l>255?255:l,e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l}return e})}(FILTER),!function(e,t){var n=e.ImArrayCopy,r=e.Color.clampPixel,a=function(){var e,t=new n(256);for(e=0;256>e;e++)t[e]=e;return t},i=function(){var e,t=new n(256);for(e=0;256>e;e++)t[e]=255-e;return t},s=function(e){var t,r=new n(256);for(t=0;256>t;t++)r[t]=e;return r},o=function(e){return e?new n(e):null},l=Math.pow,u=Math.exp,c=1/255,h=e.TableLookupFilter=e.Class(e.Filter,{name:"TableLookupFilter",constructor:function(e,t,n,r){var a=this;a.$super("constructor"),a._tableR=e||null,a._tableG=t||a._tableR,a._tableB=n||a._tableG,a._tableA=r||null},_tableR:null,_tableG:null,_tableB:null,_tableA:null,dispose:function(){var e=this;return e.$super("dispose"),e._tableR=null,e._tableG=null,e._tableB=null,e._tableA=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_tableR:e._tableR,_tableG:e._tableG,_tableB:e._tableB,_tableA:e._tableA}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n._tableR=t._tableR,n._tableG=t._tableG,n._tableB=t._tableB,n._tableA=t._tableA),n},thresholds:function(e,t,a){e.length||(e=[e]),t||(t=e),a||(a=t);var i,s,o=e.length,l=o+1,u=t.length,c=u+1,h=a.length,f=h+1,d=new n(256),p=new n(l),m=new n(256),_=new n(c),g=new n(256),v=new n(f),y=255/(l-1),w=255/(c-1),C=255/(f-1);for(i=0;l>i;)p[i]=~~(y*i),i++;for(e[0]=~~(255*e[0]),i=1;o>i;)e[i]=e[i-1]+~~(255*e[i]),i++;for(i=0;c>i;)_[i]=~~(w*i),i++;for(t[0]=~~(255*t[0]),i=1;u>i;)t[i]=t[i-1]+~~(255*t[i]),i++;for(i=0;f>i;)v[i]=~~(C*i),i++;for(a[0]=~~(255*a[0]),i=1;h>i;)a[i]=a[i-1]+~~(255*a[i]),i++;for(i=0;256>i;i++){for(s=0;o>s&&i>e[s];)s++;for(d[i]=r(p[s]),s=0;u>s&&i>t[s];)s++;for(m[i]=r(_[s]),s=0;h>s&&i>a[s];)s++;g[i]=r(v[s])}return this.set(d,m,g)},threshold:function(e,t,n){return e=e||.5,t=t||e,n=n||t,this.thresholds([e],[t],[n])},quantize:function(e){e===t&&(e=64),2>e&&(e=2);var a,i=new n(256),s=new n(e),o=255/(e-1),l=e/256;for(a=0;e>a;)s[a]=~~(o*a),a++;for(a=0;256>a;a++)i[a]=r(s[~~(l*a)]);return this.set(i)},binarize:function(){return this.quantize(2)},solarize:function(e){e===t&&(e=.5);var a,i,s=0,o=new n(256),l=2/255;for(s=0;256>s;s++)a=l*s,i=a>e?255-255*a:255*a-255,o[s]=~~r(i);return this.set(o)},solarize2:function(e){e===t&&(e=.5),e=1-e;var a,i,s=0,o=new n(256),l=2/255;for(s=0;256>s;s++)a=l*s,i=e>a?255-255*a:255*a-255,o[s]=~~r(i);return this.set(o)},solarizeInverse:function(e){e===t&&(e=.5),e*=256;var r=0,a=new n(256);for(r=0;256>r;r++)a[r]=r>e?255-r:r;return this.set(a)},invert:function(){return this.set(i())},mask:function(e){var t=0,a=e>>16&255,i=e>>8&255,s=255&e;for(tR=new n(256),tG=new n(256),tB=new n(256),t=0;256>t;t++)tR[t]=r(t&a),tG[t]=r(t&i),tB[t]=r(t&s);return this.set(tR,tG,tB)},replace:function(e,t){if(e==t)return this;var n=e>>16&255,r=e>>8&255,i=255&e,s=t>>16&255,o=t>>8&255,l=255&t,u=a(),c=a(),h=a();return u[n]=s,c[r]=o,h[i]=l,this.set(u,c,h)},extract:function(t,n,a){if(!n||!n.length)return this;a=a||0;var i,o,l=a>>16&255,u=a>>8&255,c=255&a,h=s(l),f=s(u),d=s(c);switch(t){case e.CHANNEL.BLUE:for(i=n[0],o=n[1];o>=i;)d[i]=r(i),i++;break;case e.CHANNEL.GREEN:for(i=n[0],o=n[1];o>=i;)f[i]=r(i),i++;break;case e.CHANNEL.RED:default:for(i=n[0],o=n[1];o>=i;)h[i]=r(i),i++}return this.set(h,f,d)},gammaCorrection:function(e,t,a){e=e||1,t=t||e,a=a||t,e=1/e,t=1/t,a=1/a;var i=new n(256),s=new n(256),o=new n(256),u=0;for(u=0;256>u;u++)i[u]=r(~~(255*l(c*u,e))),s[u]=r(~~(255*l(c*u,t))),o[u]=r(~~(255*l(c*u,a)));return this.set(i,s,o)},exposure:function(e){e===t&&(e=1);var a=0,i=new n(256);for(a=0;256>a;a++)i[a]=r(~~(255*(1-u(-e*a*c))));return this.set(i)},set:function(e,t,n,i){if(!e)return this;t=t||e,n=n||t;var s,l,u,c,h,f=this._tableR||a(),d=o(f);if(t&&n){for(s=this._tableG||o(f),l=this._tableB||o(s),u=o(s),c=o(l),h=0;256>h;h++)f[h]=r(e[r(d[h])]),s[h]=r(t[r(u[h])]),l[h]=r(n[r(c[h])]);this._tableR=f,this._tableG=s,this._tableB=l}else{for(h=0;256>h;h++)f[h]=r(e[r(d[h])]);this._tableR=f,this._tableG=this._tableR,this._tableB=this._tableR}return this},reset:function(){return this._tableR=this._tableG=this._tableB=this._tableA=null,this},combineWith:function(e){return this.set(e.getTable(0),e.getTable(1),e.getTable(2))},getTable:function(t){switch(t=t||e.CHANNEL.RED){case e.CHANNEL.ALPHA:return this._tableA;case e.CHANNEL.BLUE:return this._tableB;case e.CHANNEL.GREEN:return this._tableG;case e.CHANNEL.RED:default:return this._tableR}},setTable:function(t,n){switch(n=n||e.CHANNEL.RED){case e.CHANNEL.ALPHA:return this._tableA=t,this;case e.CHANNEL.BLUE:return this._tableB=t,this;case e.CHANNEL.GREEN:return this._tableG=t,this;case e.CHANNEL.RED:default:return this._tableR=t,this}},_apply:function(e,t,n){var r=this;if(!r._isOn||!r._tableR)return e;var a,i,s,o,l,u=e.length,c=(u>>2)%4,h=r._tableR,f=r._tableG,d=r._tableB,p=r._tableA;if(p){for(a=0;u>a;a+=16)i=e[a],s=e[a+1],o=e[a+2],l=e[a+3],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o],e[a+3]=p[l],i=e[a+4],s=e[a+5],o=e[a+6],l=e[a+7],e[a+4]=h[i],e[a+5]=f[s],e[a+6]=d[o],e[a+7]=p[l], +i=e[a+8],s=e[a+9],o=e[a+10],l=e[a+11],e[a+8]=h[i],e[a+9]=f[s],e[a+10]=d[o],e[a+11]=p[l],i=e[a+12],s=e[a+13],o=e[a+14],l=e[a+15],e[a+12]=h[i],e[a+13]=f[s],e[a+14]=d[o],e[a+15]=p[l];if(c)for(c<<=2,a=u-c;u>a;a+=4)i=e[a],s=e[a+1],o=e[a+2],l=e[a+3],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o],e[a+3]=p[l]}else{for(a=0;u>a;a+=16)i=e[a],s=e[a+1],o=e[a+2],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o],i=e[a+4],s=e[a+5],o=e[a+6],e[a+4]=h[i],e[a+5]=f[s],e[a+6]=d[o],i=e[a+8],s=e[a+9],o=e[a+10],e[a+8]=h[i],e[a+9]=f[s],e[a+10]=d[o],i=e[a+12],s=e[a+13],o=e[a+14],e[a+12]=h[i],e[a+13]=f[s],e[a+14]=d[o];if(c)for(c<<=2,a=u-c;u>a;a+=4)i=e[a],s=e[a+1],o=e[a+2],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o]}return e},canRun:function(){return this._isOn&&this._tableR}});h.prototype.posterize=h.prototype.levels=h.prototype.quantize}(FILTER),!function(e,t){var n=(e.ImArray,e.ImArrayCopy),r=e.Array16I,a=Math.min,i=(Math.max,Math.floor);e.DisplacementMapFilter=e.Class(e.Filter,{name:"DisplacementMapFilter",constructor:function(e){var t=this;t.$super("constructor"),e&&t.setMap(e)},_map:null,map:null,scaleX:1,scaleY:1,startX:0,startY:0,componentX:0,componentY:0,color:0,red:0,green:0,blue:0,alpha:0,mode:e.MODE.CLAMP,dispose:function(){var e=this;return e.$super("dispose"),e._map=null,e.map=null,e.scaleX=null,e.scaleY=null,e.startX=null,e.startY=null,e.componentX=null,e.componentY=null,e.color=null,e.red=null,e.green=null,e.blue=null,e.alpha=null,e.mode=null,e},serialize:function(){var e=this,t=e.map;return{filter:e.name,_isOn:!!e._isOn,params:{_map:e._map||(t?{data:t.getData(),width:t.width,height:t.height}:null),scaleX:e.scaleX,scaleY:e.scaleY,startX:e.startX,startY:e.startY,componentX:e.componentX,componentY:e.componentY,color:e.color,red:e.red,green:e.green,blue:e.blue,alpha:e.alpha,mode:e.mode}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n.map=null,n._map=t._map,n.scaleX=t.scaleX,n.scaleY=t.scaleY,n.startX=t.startX,n.startY=t.startY,n.componentX=t.componentX,n.componentY=t.componentY,n.color=t.color,n.red=t.red,n.green=t.green,n.blue=t.blue,n.alpha=t.alpha,n.mode=t.mode),n},reset:function(){var e=this;return e._map=null,e.map=null,e},getMap:function(){return this.map},setMap:function(e){var t=this;return e&&(t.map=e,t._map=null),t},setColor:function(e){var t=this;return t.color=e,t.alpha=e>>24&255,t.red=e>>16&255,t.green=e>>8&255,t.blue=255&e,t},_apply:function(t,s,o){var l=this;if(!l._isOn||!l.map&&!l._map)return t;var u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E,R,I,M,L,x,N,S,T,O,F,D,P,k,G,H,U=l.map,X=l._map||{data:U.getData(),width:U.width,height:U.height},B=.00390625*l.scaleX,Y=.00390625*l.scaleY,W=l.componentX,q=l.componentY,z=l.alpha,$=l.red,j=l.green,K=l.blue,J=l.mode,V=e.MODE.IGNORE,Q=(e.MODE.CLAMP,e.MODE.COLOR),Z=e.MODE.WRAP;for(u=X.data,c=X.width,h=X.height,f=u.length>>2,p=a(c,s),m=a(h,o),P=t.length,F=p*m<<2,D=P>>2,g=i(l.startX*(s-1)),_=i(l.startY*(o-1)),v=_*s,y=-g,w=-_,C=s-g-1,A=o-_-1,d=new r(f<<1),k=new n(t),E=0,R=0,I=0,M=0,b=0;f>b;b++,E+=2,R++)R>=c&&(R=0,I++,M+=c),S=R+M<<2,d[E]=i((u[S+W]-128)*B),d[E+1]=i((u[S+q]-128)*Y);for(R=0,I=0,M=0,L=0,b=0;F>b;b+=4,R++)if(R>=p&&(R=0,I++,M+=s,L+=c),!(w>I||I>A||y>R||R>C)){if(N=R+g,x=I+_,T=N+M+v<<2,E=R+L<<1,G=N+d[E],H=x+d[E+1],H>=o||0>H||G>=s||0>G){if(J==V)continue;if(J==Q){t[T]=$,t[T+1]=j,t[T+2]=K,t[T+3]=z;continue}J==Z?(H>A?H-=o:0>H&&(H+=o),G>C?G-=s:0>G&&(G+=s)):(H>A?H=A:0>H&&(H=0),G>C?G=C:0>G&&(G=0))}O=G+H*s<<2,t[T]=k[O],t[T+1]=k[O+1],t[T+2]=k[O+2],t[T+3]=k[O+3]}return t},canRun:function(){return this._isOn&&(this._map||this.map)}})}(FILTER),!function(FILTER,undef){var IMG=FILTER.ImArray,IMGcopy=FILTER.ImArrayCopy,PI=FILTER.CONST.PI,DoublePI=FILTER.CONST.PI2,HalfPI=FILTER.CONST.PI_2,ThreePI2=1.5*PI,Sqrt=Math.sqrt,Atan2=Math.atan2,Atan=Math.atan,Sin=Math.sin,Cos=Math.cos,Floor=Math.floor,Round=Math.round,Asin=Math.asin,Tan=Math.tan,Abs=Math.abs,Max=Math.max,toRad=FILTER.CONST.toRad,Maps,GeometricMapFilter=FILTER.GeometricMapFilter=FILTER.Class(FILTER.Filter,{name:"GeometricMapFilter",constructor:function(e){var t=this;t.$super("constructor"),e&&t.generic(e)},_map:null,_mapName:null,inverseTransform:null,matrix:null,centerX:0,centerY:0,dx:0,dy:0,angle:0,radius:0,wavelength:0,amplitude:0,phase:0,xAmplitude:0,yAmplitude:0,xWavelength:0,yWavelength:0,mode:FILTER.MODE.CLAMP,dispose:function(){var e=this;return e.$super("dispose"),e._map=null,e._mapName=null,e.inverseTransform=null,e.matrix=null,e.centerX=null,e.centerY=null,e.dx=null,e.dy=null,e.angle=null,e.radius=null,e.wavelength=null,e.amplitude=null,e.phase=null,e.xAmplitude=null,e.yAmplitude=null,e.xWavelength=null,e.yWavelength=null,e.mode=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_mapName:e._mapName,inverseTransform:e.inverseTransform?e.inverseTransform.toString():null,matrix:e.matrix,centerX:e.centerX,centerY:e.centerY,dx:e.dx,dy:e.dy,angle:e.angle,radius:e.radius,wavelength:e.wavelength,amplitude:e.amplitude,phase:e.phase,xAmplitude:e.xAmplitude,yAmplitude:e.yAmplitude,xWavelength:e.xWavelength,yWavelength:e.yWavelength,mode:e.mode}}},unserialize:function(json){var self=this,params;return json&&self.name===json.filter&&(self._isOn=!!json._isOn,params=json.params,self.inverseTransform=null,self.matrix=params.matrix,self.centerX=params.centerX,self.centerY=params.centerY,self.dx=params.dx,self.dy=params.dy,self.angle=params.angle,self.radius=params.radius,self.wavelength=params.wavelength,self.amplitude=params.amplitude,self.phase=params.phase,self.xAmplitude=params.xAmplitude,self.yAmplitude=params.yAmplitude,self.xWavelength=params.xWavelength,self.yWavelength=params.yWavelength,self.mode=params.mode,params.inverseTransform&&(self.inverseTransform=eval('(function(){ "use strict"; return '+params.inverseTransform+"})();")),self._mapName=params._mapName,self._map=null,self._mapName&&Maps[self._mapName]&&(self._map=Maps[self._mapName])),self},generic:function(e){var t=this;return e&&(t.inverseTransform=e,t._mapName="generic",t._map=Maps.generic),t},affine:function(e){var t=this;return e&&(t.matrix=e,t._mapName="affine",t._map=Maps.affine),t},flipX:function(){var e=this;return e._mapName="flipX",e._map=Maps.flipX,e},flipY:function(){var e=this;return e._mapName="flipY",e._map=Maps.flipY,e},flipXY:function(){var e=this;return e._mapName="flipXY",e._map=Maps.flipXY,e},rotateCW:function(){var e=this;return e._mapName="rotateCW",e._map=Maps.rotateCW,e},rotateCCW:function(){var e=this;return e._mapName="rotateCCW",e._map=Maps.rotateCCW,e},polar:function(e,t){var n=this;return n.centerX=e||0,n.centerY=t||0,n._mapName="polar",n._map=Maps.polar,n},cartesian:function(e,t){var n=this;return n.centerX=e||0,n.centerY=t||0,n._mapName="cartesian",n._map=Maps.cartesian,n},twirl:function(e,t,n,r){var a=this;return a.angle=e||0,a.radius=t||0,a.centerX=n||0,a.centerY=r||0,a._mapName="twirl",a._map=Maps.twirl,a},sphere:function(e,t,n){var r=this;return r.radius=e||0,r.centerX=t||0,r.centerY=n||0,r._mapName="sphere",r._map=Maps.sphere,r},ripple:function(e,t,n,r,a,i){var s=this;return s.radius=e!==undef?e:50,s.centerX=a||0,s.centerY=i||0,s.wavelength=t!==undef?t:16,s.amplitude=n!==undef?n:10,s.phase=r||0,s._mapName="ripple",s._map=Maps.ripple,s},shift:function(e,t){var n=this;return n.dx=e!==undef?e:0,n.dy=t!==undef?t:n.dx,n._mapName="shift",n._map=Maps.shift,n},reset:function(){var e=this;return e._mapName=null,e._map=null,e},getMap:function(){return this._map},setMap:function(e){var t=this;return t._mapName=null,t._map=e,t},_apply:function(e,t,n,r){var a=this;return a._isOn&&a._map?a._map(a,e,t,n,r):e},canRun:function(){return this._isOn&&this._map}});GeometricMapFilter.prototype.translate=GeometricMapFilter.prototype.shift,Maps={generic:function(e,t,n,r){var a,i,s,o,l,u,c,h=t.length,f=new IMG(h),d=e.inverseTransform,p=e.mode,m=FILTER.MODE.CLAMP,_=FILTER.MODE.WRAP;for(a=0,i=0,s=0;h>s;s+=4,a++){if(a>=n&&(a=0,i++),l=d([a,i],n,r),u=~~l[0],c=~~l[1],0>u||u>=n||0>c||c>=r)switch(p){case _:c>=r?c-=r:0>c&&(c+=r),u>=n?u-=n:0>u&&(u+=n);break;case m:default:c>=r?c=r-1:0>c&&(c=0),u>=n?u=n-1:0>u&&(u=0)}o=u+c*n<<2,f[s]=t[o],f[s+1]=t[o+1],f[s+2]=t[o+2],f[s+3]=t[o+3]}return f},affine:function(e,t,n,r){var a,i,s,o,l,u,c,h,f,d=t.length,p=d>>2,m=new IMG(d),_=e.matrix,g=_[0],v=_[1],y=_[3],w=_[4],C=_[2],A=_[5],b=e.mode,E=FILTER.MODE.CLAMP,R=FILTER.MODE.WRAP,I=n-1,M=p-n;for(a=0,i=0,l=A*n,u=y*n,c=w*n,s=0;d>s;s+=4,a++){if(a>=n&&(a=0,i++),h=~~(g*a+v*i+C),f=~~(u*a+c*i+l),0>h||h>I||0>f||f>M)switch(b){case R:f>M?f-=p:0>f&&(f+=p),h>=n?h-=n:0>h&&(h+=n);break;case E:default:f>M?f=M:0>f&&(f=0),h>I?h=I:0>h&&(h=0)}o=h+f<<2,m[s]=t[o],m[s+1]=t[o+1],m[s+2]=t[o+2],m[s+3]=t[o+3]}return m},shift:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u),h=-e.dx,f=-e.dy;for(0>h&&(h+=n),0>f&&(f+=r),a=0,i=0,s=0,o=0;u>o;o+=4,a++)a>=n&&(a=0,i++,s+=n),l=(a+h)%n+(i+f)%r*n<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},flipX:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u);for(a=0,i=0,s=0,o=0;u>o;o+=4,a++)a>=n&&(a=0,i++,s+=n),l=n-1-a+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},flipY:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u);for(a=0,i=0,s=(r-1)*n,o=0;u>o;o+=4,a++)a>=n&&(a=0,i++,s-=n),l=a+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},flipXY:function(e,t,n,r){var a,i,s,o,l,u,c=t.length,h=new IMG(c);for(a=0,i=0,o=(r-1)*n,l=0;c>l;l+=4,a++)a>=n&&(a=0,i++,s+=n,o-=n),u=n-1-a+o<<2,h[l]=t[u],h[l+1]=t[u+1],h[l+2]=t[u+2],h[l+3]=t[u+3];return h},rotateCW:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u),h=u>>2;for(a=0,i=0,s=h-1,o=0;u>o;o+=4,a++,s-=n)a>=n&&(a=0,s=h-1,i++),l=i+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},rotateCCW:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u);for(a=0,i=0,s=0,o=0;u>o;o+=4,a++,s+=n)a>=n&&(a=0,s=0,i++),l=n-1-i+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},twirl:function(e,t,n,r){if(0>=e.radius)return t;var a,i,s,o,l,u,c,h,f=t.length,d=new IMGcopy(t),p=e.centerX,m=e.centerY,_=e.angle,g=e.radius,v=e.mode,y=FILTER.MODE.CLAMP,w=FILTER.MODE.WRAP,C=_/g,A=n-1,b=r-1;for(p=Floor(p*(n-1)),m=Floor(m*(r-1)),a=0,i=0,s=0;f>s;s+=4,a++)if(a>=n&&(a=0,i++),u=a-p,c=i-m,l=Sqrt(u*u+c*c),g>l){if(h=Atan2(c,u)+C*(g-l),u=~~(p+l*Cos(h)),c=~~(m+l*Sin(h)),0>u||u>A||0>c||c>b)switch(v){case w:c>b?c-=r:0>c&&(c+=r),u>A?u-=n:0>u&&(u+=n);break;case y:default:c>b?c=b:0>c&&(c=0),u>A?u=A:0>u&&(u=0)}o=u+c*n<<2,t[s]=d[o],t[s+1]=d[o+1],t[s+2]=d[o+2],t[s+3]=d[o+3]}return t},sphere:function(e,t,n,r){if(0>=e.radius)return t;var a,i,s,o,l,u,c,h,f,d,p,m,_,g=t.length,v=new IMGcopy(t),y=e.centerX,w=e.centerY,C=e.radius,A=e.mode,b=FILTER.MODE.CLAMP,E=FILTER.MODE.WRAP,R=C*C,I=.555556,M=1-I,L=n-1,x=r-1;for(y=Floor(y*(n-1)),w=Floor(w*(r-1)),a=0,i=0,s=0;g>s;s+=4,a++)if(a>=n&&(a=0,i++),l=a-y,u=i-w,m=l*l,_=u*u,c=m+_,R>c){if(d=R-c,p=Sqrt(d),h=Asin(l/Sqrt(m+d))*M,f=Asin(u/Sqrt(_+d))*M,l=~~(a-p*Tan(h)),u=~~(i-p*Tan(f)),0>l||l>L||0>u||u>x)switch(A){case E:u>x?u-=r:0>u&&(u+=r),l>L?l-=n:0>l&&(l+=n);break;case b:default:u>x?u=x:0>u&&(u=0),l>L?l=L:0>l&&(l=0)}o=l+u*n<<2,t[s]=v[o],t[s+1]=v[o+1],t[s+2]=v[o+2],t[s+3]=v[o+3]}return t},ripple:function(e,t,n,r){if(0>=e.radius)return t;var a,i,s,o,l,u,c,h,f,d,p,m=t.length,_=new IMGcopy(t),g=FILTER.MODE.CLAMP,v=FILTER.MODE.WRAP,y=n-1,w=r-1,C=e.centerX,A=e.centerY,b=e.radius,E=e.mode,R=b*b,I=e.wavelength,M=e.amplitude,L=e.phase;for(C=Floor(C*(n-1)),A=Floor(A*(r-1)),a=0,i=0,s=0;m>s;s+=4,a++)if(a>=n&&(a=0,i++),u=a-C,c=i-A,d=u*u,p=c*c,f=d+p,R>f){if(l=Sqrt(f),h=M*Sin(l/I*Math.PI*2-L),h*=(b-l)/b,l&&(h*=I/l),u=~~(a+u*h),c=~~(i+c*h),0>u||u>y||0>c||c>w)switch(E){case v:c>w?c-=r:0>c&&(c+=r),u>y?u-=n:0>u&&(u+=n);break;case g:default:c>w?c=w:0>c&&(c=0),u>y?u=y:0>u&&(u=0)}o=u+c*n<<2,t[s]=_[o],t[s+1]=_[o+1],t[s+2]=_[o+2],t[s+3]=_[o+3]}return t},polar:function(e,t,n,r){var a,i,s,o,l,u,c,h,f,d,p,m,_=t.length,g=new IMGcopy(t),v=FILTER.MODE.CLAMP,y=FILTER.MODE.WRAP,w=n-1,C=r-1,A=0,b=e.mode;for(p=~~(.5*n+.5),m=~~(.5*r+.5),d=Max(m,p),a=0,i=0,s=0;_>s;s+=4,a++){if(a>=n&&(a=0,i++),o=a-p,l=i-m,f=0,o>=0?l>0?(f=PI-Atan(o/l),A=Sqrt(o*o+l*l)):0>l?(f=Atan(o/l),A=Sqrt(o*o+l*l)):(f=HalfPI,A=o):0>o&&(0>l?(f=DoublePI-Atan(o/l),A=Sqrt(o*o+l*l)):l>0?(f=PI+Atan(o/l),A=Sqrt(o*o+l*l)):(f=ThreePI2,A=-o)),u=n-1-(n-1)/DoublePI*f,c=r*A/d,u=Round(u),c=Round(c),0>u||u>w||0>c||c>C)switch(b){case y:c>C?c-=r:0>c&&(c+=r),u>w?u-=n:0>u&&(u+=n);break;case v:default:c>C?c=C:0>c&&(c=0),u>w?u=w:0>u&&(u=0)}h=u+c*n<<2,t[s]=g[h],t[s+1]=g[h+1],t[s+2]=g[h+2],t[s+3]=g[h+3]}return t},cartesian:function(e,t,n,r){var a,i,s,o,l,u,c,h,f,d,p,m,_,g=t.length,v=new IMGcopy(t),y=FILTER.MODE.CLAMP,w=FILTER.MODE.WRAP,C=n-1,A=r-1,b=0,E=e.mode;for(m=~~(.5*n+.5),_=~~(.5*r+.5),p=Max(_,m),a=0,i=0,s=0;g>s;s+=4,a++){if(a>=n&&(a=0,i++),f=a/n*DoublePI,d=f>=ThreePI2?DoublePI-f:f>=PI?f-PI:f>=HalfPI?PI-f:f,b=p*(i/r),c=-b*Sin(d),h=b*Cos(d),f>=ThreePI2?(o=m-c,l=_-h):f>=PI?(o=m-c,l=_+h):f>=HalfPI?(o=m+c,l=_+h):(o=m+c,l=_-h),o=Round(o),l=Round(l),0>o||o>C||0>l||l>A)switch(E){case w:l>A?l-=r:0>l&&(l+=r),o>C?o-=n:0>o&&(o+=n);break;case y:default:l>A?l=A:0>l&&(l=0),o>C?o=C:0>o&&(o=0)}u=o+l*n<<2,t[s]=v[u],t[s+1]=v[u+1],t[s+2]=v[u+2],t[s+3]=v[u+3]}return t}}}(FILTER),!function(e,t){function n(e,t,n,r){var a,i=e.length,s=new w(e.length);for(n=n||1,r=r||1,a=0;i>a;)s[a]=n*e[a]+r*t[a],a++;return s}function r(e,t){var n,r,a,i=e.length,s=[],o=0;for(n=0;i>n;n++)for(r=0;i>r;r++)a=e[n]*t[r],o+=a,s.push(a);return{kernel:s,sum:o}}function a(e){var t,n=new Array(e);for(t=0;e>t;)n[t]=1,t++;return n}function i(e){var t,n,r,a,i=R.length;if(e--,i>e)t=new w(R[e]);else for(t=new w(R[i-1]);e>=i;){for(n=t,t=new w(n.length+1),t[0]=1,r=0,a=n.length-1;a>r;r++)t[r+1]=n[r]+n[r+1];t[n.length]=1,40>i&&R.push(new Array(t)),i++}return t}function s(e){var t,n=e>>1,r=-n,a=new Array(e);for(t=0;e>t;)a[t]=r,r++,t++;return a}function o(e){var t=i(e);return r(t,t)}function l(e,t){var n=i(e),a=s(e);return 1==t?r(a.reverse(),n):r(n,a)}function u(e,t){var n=a(e),i=s(e);return 1==t?r(i.reverse(),n):r(n,i)}function c(e,t,n){t=t||1,n=n||t;var r,a=e*e,i=a>>1,s=new w(a);for(r=0;a>r;)s[r]=t,r++;return s[i]=n,s}function h(e,t,n,r){var a,i,s,o,l,u=e*e,c=e>>1,h=u>>1,f=new w(u);for(o=0,a=0;c>=a;a++){for(i=0,l=0,s=0;c>=s;s++)f[h+a+i]=o+l,f[h-a-i]=-o-l,f[h-a+i]=-o+l,f[h+a-i]=o-l,i+=e,l+=n;o+=t}return f[h]=r||1,f}function f(e,t,n,r){var a,i,s,o,l,u,c=e*e,h=e>>1,f=c>>1,d=new w(c),p=new w(c),m=1/e,g=1e-8;for(_(t)>g?(l=1,u=n/t):(l=t/n,u=1),a=0,s=0,o=0,i=u*e;h>=a;)p[f+a]=~~(f+s+o+.5),p[f-a]=~~(f-s-o+.5),a++,s+=l,o+=i;for(a=0;h>=a;)d[p[f+a]]=d[p[f-a]]=m,a++;return d[f]=r||1,d}function d(e,t,n,r,a,i,s,o,l,u){var c,h,f,d,p,m,_,g,v,y,w,b,R,I,M,L,x,N,S,T,O,F,D,P,k,G,H,U,X,B,Y,W,q,z,$,j,K,J,V,Q,Z,ee,te,ne,re,ae,ie,se=e.length,oe=se>>2,le=i,ue=s;if(g=le*ue,m=le>>1,_=t*(ue>>1),w=-m-1,R=-_-t,b=m,I=_,B=0,W=t-1,Y=0,q=oe-t,h=(oe<<1)+oe,y=(t<<1)+t,u=u||1,ie=0,a)for(T=r[0],O=r[g>>1],F=O-T,D=a[0],P=a[g>>1],k=P-D;u>ie;){for(v=new C(se),c=new A(h),M=0,L=0,f=d=p=0,x=0;t>x;x++,M+=4,L+=3)f+=e[M],d+=e[M+1],p+=e[M+2],c[L]=f,c[L+1]=d,c[L+2]=p;for(L=0,x=0,f=d=p=0,M=y+t;se>M;M+=4,L+=3,x++)x>=t&&(x=0,f=d=p=0),f+=e[M],d+=e[M+1],p+=e[M+2],c[L+y]=c[L]+f,c[L+y+1]=c[L+1]+d,c[L+y+2]=c[L+2]+p;for(x=0,N=0,S=0,M=0;se>M;M+=4,x++)x>=t&&(x=0,N++,S+=t),G=x+w,H=S+R,U=x+b,X=S+I,G=B>G?B:G,U=U>W?W:U,H=Y>H?Y:H,X=X>q?q:X,z=G+H,K=U+X,$=U+H,j=G+X,z=(z<<1)+z,$=($<<1)+$,j=(j<<1)+j,K=(K<<1)+K,Z=T*(c[K]-c[$]-c[j]+c[z])+F*e[M],ee=T*(c[K+1]-c[$+1]-c[j+1]+c[z+1])+F*e[M+1],te=T*(c[K+2]-c[$+2]-c[j+2]+c[z+2])+F*e[M+2],ne=D*(c[K]-c[$]-c[j]+c[z])+k*e[M],re=D*(c[K+1]-c[$+1]-c[j+1]+c[z+1])+k*e[M+1],ae=D*(c[K+2]-c[$+2]-c[j+2]+c[z+2])+k*e[M+2],J=o*Z+l*ne,V=o*ee+l*re,Q=o*te+l*ae,E&&(J=0>J?0:J>255?255:J,V=0>V?0:V>255?255:V,Q=0>Q?0:Q>255?255:Q),v[M]=~~J,v[M+1]=~~V,v[M+2]=~~Q,v[M+3]=e[M+3];e=v,ie++}else for(T=r[0],O=r[g>>1],F=O-T;u>ie;){for(v=new C(se),c=new A(h),M=0,L=0,f=d=p=0,x=0;t>x;x++,M+=4,L+=3)f+=e[M],d+=e[M+1],p+=e[M+2],c[L]=f,c[L+1]=d,c[L+2]=p;for(L=0,x=0,f=d=p=0,M=y+t;se>M;M+=4,L+=3,x++)x>=t&&(x=0,f=d=p=0),f+=e[M],d+=e[M+1],p+=e[M+2],c[L+y]=c[L]+f,c[L+y+1]=c[L+1]+d,c[L+y+2]=c[L+2]+p;for(x=0,N=0,S=0,M=0;se>M;M+=4,x++)x>=t&&(x=0,N++,S+=t),G=x+w,H=S+R,U=x+b,X=S+I,G=B>G?B:G,U=U>W?W:U,H=Y>H?Y:H,X=X>q?q:X,z=G+H,K=U+X,$=U+H,j=G+X,z=(z<<1)+z,$=($<<1)+$,j=(j<<1)+j,K=(K<<1)+K,Z=T*(c[K]-c[$]-c[j]+c[z])+F*e[M],ee=T*(c[K+1]-c[$+1]-c[j+1]+c[z+1])+F*e[M+1],te=T*(c[K+2]-c[$+2]-c[j+2]+c[z+2])+F*e[M+2],J=o*Z+l,V=o*ee+l,Q=o*te+l,E&&(J=0>J?0:J>255?255:J,V=0>V?0:V>255?255:V,Q=0>Q?0:Q>255?255:Q),v[M]=~~J,v[M+1]=~~V,v[M+2]=~~Q,v[M+3]=e[M+3];e=v,ie++}return v}function p(e,t,n,r,a,i,s,o,l){var u,c,h,f,d,p,m,_,g,v,y,w,A,R,I,M,L,x,N,S,T,O,F,D,P,k,G,H=e.length,U=H>>2;for(u=[a,r],c=[s,i],P=[l,o],M=t-1,L=U-t,G=2;G--;){for(m=new C(H),f=u[G],d=c[G],h=f.length,p=d.length,k=P[G],_=new b(d),y=0;p>y;y+=2)_[y+1]*=t;if(E)for(w=0,A=0,g=0;H>g;g+=4,w++){for(w>=t&&(w=0,A+=t),O=0,F=0,D=0,y=0,v=0;h>y;y++,v+=2)R=w+_[v],I=A+_[v+1],R>=0&&M>=R&&I>=0&&L>=I&&(srcOff=R+I<<2,T=f[y],O+=e[srcOff]*T,F+=e[srcOff+1]*T,D+=e[srcOff+2]*T);x=k*O,N=k*F,S=k*D,x=0>x?0:x>255?255:x,N=0>N?0:N>255?255:N,S=0>S?0:S>255?255:S,m[g]=~~x,m[g+1]=~~N,m[g+2]=~~S,m[g+3]=e[g+3]}else for(w=0,A=0,g=0;H>g;g+=4,w++){for(w>=t&&(w=0,A+=t),O=0,F=0,D=0,y=0,v=0;h>y;y++,v+=2)R=w+_[v],I=A+_[v+1],R>=0&&M>=R&&I>=0&&L>=I&&(srcOff=R+I<<2,T=f[y],O+=e[srcOff]*T,F+=e[srcOff+1]*T,D+=e[srcOff+2]*T);x=k*O,N=k*F,S=k*D,m[g]=~~x,m[g+1]=~~N,m[g+2]=~~S,m[g+3]=e[g+3]}e=m}return m}var m=(e.CONST.SQRT2,e.CONST.toRad),_=(e.CONST.toDeg,Math.abs),g=Math.sqrt,v=Math.sin,y=Math.cos,w=e.Array32F,C=e.ImArray,A=e.Array32F,b=e.Array16I,E=(e.Array8U,e._notSupportClamp),R=[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1],[1,5,10,10,5,1],[1,6,15,20,15,6,1],[1,7,21,35,35,21,7,1],[1,8,28,56,70,56,28,8,1]],I=e.ConvolutionMatrixFilter=e.Class(e.Filter,{name:"ConvolutionMatrixFilter",constructor:function(t,n,r){var a=this;a.$super("constructor"),a._coeff=new w([1,0]),t&&t.length?a.set(t,~~(g(t.length)+.5),n||1,r||0):(a._matrix=null,a._dim=0),a._matrix2=null,a._dim2=0,a._isGrad=!1,a._doIntegral=0,a._doSeparable=!1,e.useWebGL&&(a._webglInstance=e.WebGLConvolutionMatrixFilterInstance||null)},_dim:0,_dim2:0,_matrix:null,_matrix2:null,_mat:null,_mat2:null,_coeff:null,_isGrad:!1,_doIntegral:0,_doSeparable:!1,_indices:null,_indices2:null,_indicesf:null,_indicesf2:null,_webglInstance:null,dispose:function(){var e=this;return e.$super("dispose"),e._webglInstance=null,e._dim=null,e._dim2=null,e._matrix=null,e._matrix2=null,e._mat=null,e._mat2=null,e._coeff=null,e._isGrad=null,e._doIntegral=null,e._doSeparable=null,e._indices=null,e._indices2=null,e._indicesf=null,e._indicesf2=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_dim:e._dim,_dim2:e._dim2,_matrix:e._matrix,_matrix2:e._matrix2,_mat:e._mat,_mat2:e._mat2,_coeff:e._coeff,_isGrad:e._isGrad,_doIntegral:e._doIntegral,_doSeparable:e._doSeparable,_indices:e._indices,_indices2:e._indices2,_indicesf:e._indicesf,_indicesf2:e._indicesf2}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n._dim=t._dim,n._dim2=t._dim2,n._matrix=t._matrix,n._matrix2=t._matrix2,n._mat=t._mat,n._mat2=t._mat2,n._coeff=t._coeff,n._isGrad=t._isGrad,n._doIntegral=t._doIntegral,n._doSeparable=t._doSeparable,n._indices=t._indices,n._indices2=t._indices2,n._indicesf=t._indicesf,n._indicesf2=t._indicesf2),n},lowPass:function(e){return e=e===t?3:e%2?e:e+1,this.set(c(e),e,1/(e*e),0),this._doIntegral=1,this},highPass:function(e,n){e=e===t?3:e%2?e:e+1,n=n===t?1:n;var r=e*e,a=-n/r,i=c(e,a,1+a);return this.set(i,e,1,0),this._doIntegral=1,this},glow:function(e,n){return e=e===t?.5:e,this.highPass(n,-e)},sharpen:function(e,n){return e=e===t?.5:e,this.highPass(n,e)},verticalBlur:function(e){return e=e===t?3:e%2?e:e+1,this.set(a(e),1,1/e,0),this._dim2=e,this._doIntegral=1,this},horizontalBlur:function(e){return e=e===t?3:e%2?e:e+1,this.set(a(e),e,1/e,0),this._dim2=1,this._doIntegral=1,this},directionalBlur:function(e,n){n=n===t?3:n%2?n:n+1,e*=m;var r=y(e),a=-v(e),i=f(n,r,a,1/n);return this.set(i,n,1,0)},fastGauss:function(e,n){return n=n===t?3:n%2?n:n+1,e=~~(e||1),1>e?e=1:e>3&&(e=3),this.set(c(n),n,1/(n*n),0),this._doIntegral=e,this},binomialLowPass:function(e){e=e===t?3:e%2?e:e+1;var n=i(e),r=1<>1;for(r=0,a=0,n=0;l>n;)s.push(r-c),s.push(a-c),e[n]&&(i.push(r-c),i.push(a-c),o.push(e[n])),n++,r++,r>=u&&(r=0,a++);return[new b(i),new b(s),new w(o)]},reset:function(){var e=this;return e._matrix=e._matrix2=null,e._mat=e._mat2=null,e._dim=e._dim2=0,e._indices=e._indices2=e._indicesf=e._indicesf2=null,e._isGrad=!1,e._doIntegral=0,e._doSeparable=!1,e},combineWith:function(e){return this},getMatrix:function(){return this._matrix},setMatrix:function(e,t){return this.set(e,t)},_apply:function(e,t,n){var r=this;if(!r._isOn||!r._matrix)return e;if(r._doIntegral)return r._matrix2?d(e,t,n,r._matrix,r._matrix2,r._dim,r._dim2,r._coeff[0],r._coeff[1],r._doIntegral):d(e,t,n,r._matrix,null,r._dim,r._dim,r._coeff[0],r._coeff[1],r._doIntegral);if(r._doSeparable)return p(e,t,n,r._mat,r._mat2,r._indices,r._indices2,r._coeff[0],r._coeff[1]);var a,i,s,o,l,u,c,h,f,m,g,v,y,w,A,R,I,M,L,x,N,S,T=e.length,O=T>>2,F=new C(T),D=t-1,P=O-t,k=r._coeff[0],G=r._coeff[1],H=r._matrix,U=r._matrix2,X=r._isGrad;if(U){for(x=r._indicesf.length,S=new b(r._indicesf),u=0;x>u;u+=2)S[u+1]*=t;for(N=H.length,c=0,h=0,o=0;T>o;o+=4,c++){for(c>=t&&(c=0,h+=t),v=0,y=0,w=0,A=0,R=0,I=0,u=0,l=0;N>u;u++,l+=2)f=c+S[l],m=h+S[l+1],f>=0&&D>=f&&m>=0&&P>=m&&(g=f+m<<2,M=H[u],v+=e[g]*M,y+=e[g+1]*M,w+=e[g+2]*M,L=U[u],A+=e[g]*L,R+=e[g+1]*L,I+=e[g+2]*L);X?(a=_(v)+_(A),i=_(y)+_(R),s=_(w)+_(I)):(a=k*v+G*A,i=k*y+G*R,s=k*w+G*I),E&&(a=0>a?0:a>255?255:a,i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s),F[o]=~~a,F[o+1]=~~i,F[o+2]=~~s,F[o+3]=e[o+3]}}else{for(x=r._indices.length,S=new b(r._indices),u=0;x>u;u+=2)S[u+1]*=t;for(H=r._mat,N=H.length,c=0,h=0,o=0;T>o;o+=4,c++){for(c>=t&&(c=0,h+=t),v=0,y=0,w=0,u=0,l=0;N>u;u++,l+=2)f=c+S[l],m=h+S[l+1],f>=0&&D>=f&&m>=0&&P>=m&&(g=f+m<<2,M=H[u],v+=e[g]*M,y+=e[g+1]*M,w+=e[g+2]*M);a=k*v+G,i=k*y+G,s=k*w+G,E&&(a=0>a?0:a>255?255:a,i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s),F[o]=~~a,F[o+1]=~~i,F[o+2]=~~s,F[o+3]=e[o+3]}}return F},canRun:function(){return this._isOn&&this._matrix}});I.prototype.bump=I.prototype.emboss,I.prototype.boxBlur=I.prototype.lowPass,I.prototype.gaussBlur=I.prototype.binomialLowPass,I.prototype.gradX=I.prototype.prewittX,I.prototype.gradY=I.prototype.prewittY,I.prototype.gradDirectional=I.prototype.prewittDirectional,I.prototype.grad=I.prototype.prewitt}(FILTER),!function(e,t){var n,r=e.ImArray,a=e.Array8U,i=e.Array32I,s=Math.sqrt,o=function(e){var t,n=e*e,r=new a(n);for(t=0;n>t;t++)r[t]=1;return r},l=o(3);e.MorphologicalFilter=e.Class(e.Filter,{name:"MorphologicalFilter",constructor:function(){var e=this;e.$super("constructor"),e._filterName=null,e._filter=null,e._dim=0,e._structureElement=null,e._indices=null},_filterName:null,_filter:null,_dim:0,_structureElement:null,_indices:null,dispose:function(){var e=this;return e.$super("dispose"),e._filterName=null,e._filter=null,e._dim=null,e._structureElement=null,e._indices=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_filterName:e._filterName,_dim:e._dim,_structureElement:e._structureElement,_indices:e._indices}}},unserialize:function(e){var t,r=this;return e&&r.name===e.filter&&(r._isOn=!!e._isOn,t=e.params,r._dim=t._dim,r._structureElement=t._structureElement,r._indices=t._indices,r._filterName=t._filterName,r._filterName&&n[r._filterName]&&(r._filter=n[r._filterName])),r},erode:function(e){return this.set(e,"erode")},dilate:function(e){return this.set(e,"dilate")},opening:function(e){return this.set(e,"open")},closing:function(e){return this.set(e,"close")},set:function(e,t){var r=this;r._filterName=t,r._filter=n[t],e&&e.length?(r._structureElement=new a(e),r._dim=~~(s(r._structureElement.length)+.5)):e&&e===e-0?(r._structureElement=o(e),r._dim=e):(r._structureElement=l,r._dim=3);var u,c,h,f=[],e=r._structureElement,d=e.length,p=r._dim,m=p>>1;for(c=0,h=0,u=0;d>u;)e[u]&&(f.push(c-m),f.push(h-m)),u++,c++,c>=p&&(c=0,h++);return r._indices=new i(f),r},reset:function(){var e=this;return e._filterName=null,e._filter=null,e._dim=0,e._structureElement=null,e._indices=null,e},_apply:function(e,t,n){var r=this;return r._isOn&&r._dim&&r._filter?r._filter(r,e,t,n):e},canRun:function(){return this._isOn&&this._dim&&this._filter}});n={dilate:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=0,v=0,y=0,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],p>g&&(g=p),m>v&&(v=m),_>y&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E},erode:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E},open:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}for(t=E,E=new r(A),u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E},close:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}for(t=E,E=new r(A),u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E}}}(FILTER),!function(e,t){var n,r=e.ImArray,a=e.Array32I,i=(Math.min,Math.max,e.StatisticalFilter=e.Class(e.Filter,{name:"StatisticalFilter",constructor:function(){var e=this;e.$super("constructor"),e._dim=0,e._indices=null,e._filterName=null,e._filter=null},_dim:0,_indices:null,_filter:null,_filterName:null,dispose:function(){var e=this;return e.$super("dispose"),e._dim=null,e._indices=null,e._filter=null,e._filterName=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_filterName:e._filterName,_dim:e._dim,_indices:e._indices}}},unserialize:function(e){var t,r=this;return e&&r.name===e.filter&&(r._isOn=!!e._isOn,t=e.params,r._dim=t._dim,r._indices=t._indices,r._filterName=t._filterName,r._filterName&&n[r._filterName]&&(r._filter=n[r._filterName])),r},median:function(e){return e=e===t?3:e%2?e:e+1,this.set(e,"median")},minimum:function(e){return e=e===t?3:e%2?e:e+1,this.set(e,"minimum")},maximum:function(e){return e=e===t?3:e%2?e:e+1,this.set(e,"maximum")},set:function(e,t){var r=this;r._filterName=t,r._filter=n[t],r._dim=e;var i,s,o,l=[],u=e*e,c=e,h=c>>1;for(s=0,o=0,i=0;u>i;)l.push(s-h),l.push(o-h),i++,s++,s>=c&&(s=0,o++);return r._indices=new a(l),r},reset:function(){var e=this;return e._filterName=null,e._filter=null,e._dim=0,e._indices=null,e},_apply:function(e,t,n){var r=this;return r._isOn&&r._dim?r._filter(r,e,t,n):e},canRun:function(){return this._isOn&&this._dim}}));i.prototype.erode=i.prototype.minimum,i.prototype.dilate=i.prototype.maximum,n={median:function(e,t,n,i){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E=e._dim,R=E*E,I=new a(e._indices),M=t.length,L=M>>2,x=new r(M),N=R<<1,S=n-1,T=L-n;for(d=[],p=[],m=[],o=0;N>o;o+=2)I[o+1]*=n;for(s=0,l=0,u=0;M>s;){for(d.length=0,p.length=0,m.length=0,o=0;N>o;)c=l+I[o],h=u+I[o+1],c>=0&&S>=c&&h>=0&&T>=h&&(f=c+h<<2,_=t[f],g=t[f+1],v=t[f+2],d.push(_),p.push(g),m.push(v)),o+=2;d.sort(),p.sort(),m.sort(),A=d.length,b=A>>1,y=A%2?d[b+1]:~~(.5*(d[b]+d[b+1])),A=p.length,b=A>>1,w=A%2?p[b+1]:~~(.5*(p[b]+p[b+1])),A=m.length,b=A>>1,C=A%2?m[b+1]:~~(.5*(m[b]+m[b+1])),x[s]=y,x[s+1]=w,x[s+2]=C,x[s+3]=t[s+3],s+=4,l++,l>=n&&(l=0,u+=n)}return x},maximum:function(e,t,n,i){var s,o,l,u,c,h,f,d,p,m,_,g,v,y=e._dim,w=y*y,C=new a(e._indices),A=t.length,b=A>>2,E=new r(A),R=w<<1,I=n-1,M=b-n;for(o=0;R>o;o+=2)C[o+1]*=n;for(s=0,l=0,u=0;A>s;){for(_=0,g=0,v=0,o=0;R>o;)c=l+C[o],h=u+C[o+1],c>=0&&I>=c&&h>=0&&M>=h&&(f=c+h<<2,d=t[f],p=t[f+1],m=t[f+2],d>_&&(_=d),p>g&&(g=p),m>v&&(v=m)),o+=2;E[s]=_,E[s+1]=g,E[s+2]=v,E[s+3]=t[s+3],s+=4,l++,l>=n&&(l=0,u+=n)}return E},minimum:function(e,t,n,i){var s,o,l,u,c,h,f,d,p,m,_,g,v,y=e._dim,w=y*y,C=new a(e._indices),A=t.length,b=A>>2,E=new r(A),R=w<<1,I=n-1,M=b-n;for(o=0;R>o;o+=2)C[o+1]*=n;for(s=0,l=0,u=0;A>s;){for(_=255,g=255,v=255,o=0;R>o;)c=l+C[o],h=u+C[o+1],c>=0&&I>=c&&h>=0&&M>=h&&(f=c+h<<2,d=t[f],p=t[f+1],m=t[f+2],_>d&&(_=d),g>p&&(g=p),v>m&&(v=m)),o+=2;E[s]=_,E[s+1]=g,E[s+2]=v,E[s+3]=t[s+3],s+=4,l++,l>=n&&(l=0,u+=n)}return E}}}(FILTER),!function(e,t){function n(e){var t,n;for(e>0&&1>e&&(e*=65536),e=u(e),256>e&&(e|=e<<8),n=0;256>n;n++)t=1&n?h[n]^255&e:h[n]^e>>8&255,f[n]=f[n+256]=t}function r(e,t,n){var r=7&e,a=4>r?t:n,i=4>r?n:t;return(1&r?-a:a)+(2&r?-2*i:2*i)}function a(e,t){var n,a,i,s,o,l=.366025403,c=.211324865,h=(e+t)*l,d=e+h,p=t+h,m=u(d),_=u(p),g=(m+_)*c,v=m-g,y=_-g,w=e-v,C=t-y; +w>C?(s=1,o=0):(s=0,o=1);var A=w-s+c,b=C-o+c,E=w-1+2*c,R=C-1+2*c,I=255&m,M=255&_,L=.5-w*w-C*C;0>L?n=0:(L*=L,n=L*L*r(f[I+f[M]],w,C));var x=.5-A*A-b*b;0>x?a=0:(x*=x,a=x*x*r(f[I+s+f[M+o]],A,b));var N=.5-E*E-R*R;return 0>N?i=0:(N*=N,i=N*N*r(f[I+1+f[M+1]],E,R)),40*(n+a+i)}function i(e){return e*e*e*(e*(6*e-15)+10)}function s(e,t,n){return t+e*(n-t)}function o(e,t){var n,a,o,l,c,h,d,p,m,_,g,v,y,w;return n=u(e),a=u(t),c=e-n,h=t-a,d=c-1,p=h-1,o=n+1&255,l=a+1&255,n=255&n,a=255&a,_=i(h),m=i(c),g=r(f[n+f[a]],c,h),v=r(f[n+f[l]],c,p),y=s(_,g,v),g=r(f[o+f[a]],d,h),v=r(f[o+f[l]],d,p),w=s(_,g,v),.507*s(m,y,w)}function l(e,t,n,r,a,i,s,o,l,u,c){var h,f,d,p=0,m=u,_=1,g=0;for(h=0;o>h;h++)f=(t+l[h][0])%r,d=(n+l[h][1])%a,p+=e(m*f*i,m*d*s)*_,m*=2,g+=_,_*=c;return p/g}var u=Math.floor,c=(Math.sin,Math.cos,e.CONST.PI2,e.Array8U),h=new c([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,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 c(h);e.PerlinNoise={seed:n,Image:function(t,n,r,i,s,u,c,h,f,d){var p,m,_,g,v,y,w=(new e.Image).restorable(!1).fill("rgb(0,0,0)",0,0,n,r),C=1/i,A=1/s,b=d?o:a,n=w.width,r=w.height,E=w.getData(),R=E.length,I=n>>>1,M=r>>>1;if(h=h||1,f=f||.5,u=u||1,c=c||[[0,0]],t)for(p=0,m=0,v=0;R>v;v+=4,p++)p>=n&&(p=0,m++),_=p>I?n-1-p:p,g=m>M?r-1-m:m,p>_||m>g?(y=g*n+_<<2,E[v]=E[y],E[v+1]=E[y+1],E[v+2]=E[y+2]):(E[v]=~~(255*(.5*l(b,_,g,n,r,C,A,u,c,h,f)+.5)),E[v+1]=E[v],E[v+2]=E[v]);else for(p=0,m=0,v=0;R>v;v+=4,p++)p>=n&&(p=0,m++),E[v]=~~(255*(.5*l(b,_,g,n,r,C,A,u,c,h,f)+.5)),E[v+1]=E[v],E[v+2]=E[v];return w.setData(E),w}}}(FILTER),FILTER}); /** * * FILTER.js Codecs diff --git a/build/filter.js b/build/filter.js index b65fe45..8ba8b3a 100644 --- a/build/filter.js +++ b/build/filter.js @@ -2,7 +2,7 @@ * * FILTER.js * @version: 0.8.0 -* @built on 2016-07-19 20:00:58 +* @built on 2016-07-19 22:00:50 * @dependencies: Classy.js, Asynchronous.js * * JavaScript Image Processing Library @@ -26,7 +26,7 @@ else if ( !(name in root) ) /* Browser/WebWorker/.. */ * * FILTER.js * @version: 0.8.0 -* @built on 2016-07-19 20:00:58 +* @built on 2016-07-19 22:00:50 * @dependencies: Classy.js, Asynchronous.js * * JavaScript Image Processing Library @@ -3197,7 +3197,6 @@ XHR.create = FILTER.Browser.isNode if ( o.onStateChange ) o.onStateChange( xhr ); response.on('data', function( chunk ){ - xdata += chunk.toString( ); if ( !data_sent ) { data_sent = 1; @@ -3205,6 +3204,7 @@ XHR.create = FILTER.Browser.isNode if ( o.onStateChange ) o.onStateChange( xhr ); if ( o.onLoadStart ) o.onLoadStart( xhr ); } + xdata += chunk.toString( ); if ( o.onProgress ) o.onProgress( xhr ); }); @@ -3216,7 +3216,7 @@ XHR.create = FILTER.Browser.isNode if ( o.onStateChange ) o.onStateChange( xhr ); if ( o.onLoadEnd ) o.onLoadEnd( xhr ); - if ( (XHR.DONE === xhr.readyState) ) + if ( XHR.DONE === xhr.readyState ) { if ( 200 === xhr.status ) { @@ -3268,12 +3268,8 @@ XHR.create = FILTER.Browser.isNode }), update = function( xhr, $xhr$ ) { + //xhr.responseType = $xhr$.responseType; xhr.readyState = $xhr$.readyState; - xhr.responseType = $xhr$.responseType; - xhr.responseURL = $xhr$.responseURL; - xhr.response = $xhr$.response; - xhr.responseText = $xhr$.responseText; - xhr.responseXml = $xhr$.responseXml; xhr.status = $xhr$.status; xhr.statusText = $xhr$.statusText; return xhr; @@ -3288,7 +3284,7 @@ XHR.create = FILTER.Browser.isNode }; $xhr$.open( o.method||'GET', o.url, !o.sync ); - xhr.responseType = $xhr$.responseType = o.responseType || 'text'; + if ( o.responseType ) xhr.responseType = $xhr$.responseType = o.responseType; $xhr$.timeout = o.timeout || 30000; // 30 secs default timeout if ( o.onProgress ) @@ -3316,11 +3312,15 @@ XHR.create = FILTER.Browser.isNode }; } $xhr$.onload = function( ) { - update( xhr, $xhr$ ); - if ( (XHR.DONE === $xhr$.readyState) ) + if ( XHR.DONE === $xhr$.readyState ) { + update( xhr, $xhr$ ); if ( 200 === $xhr$.status ) { + xhr.responseURL = $xhr$.responseURL; + xhr.response = $xhr$.response; + //xhr.responseText = $xhr$.responseText; + //xhr.responseXml = $xhr$.responseXml; if ( o.onComplete ) o.onComplete( xhr ); } else @@ -3352,8 +3352,7 @@ var XHRLoader = FILTER.XHRLoader = Class(Loader, { constructor: function XHRLoader( ) { var self = this; - if ( !(self instanceof XHRLoader) ) - return new XHRLoader( ); + if ( !(self instanceof XHRLoader) ) return new XHRLoader( ); }, load: function ( url, onLoad, onError ) { @@ -3361,13 +3360,14 @@ var XHRLoader = FILTER.XHRLoader = Class(Loader, { XHR.create({ url: url, + responseType: self._responseType, onComplete: function( xhr ) { - if ( 'function' === typeof onLoad ) onLoad( 'arraybuffer' === self._responseType ? new Buffer(xhr.response) : xhr.response ); + if ( 'function' === typeof onLoad ) onLoad( xhr.response ); }, onError: function( xhr ) { if ( 'function' === typeof onError ) onError( xhr.statusText ); } - }); + }, null); /*if ( FILTER.Browser.isNode ) { // https://nodejs.org/api/http.html#http_http_request_options_callback @@ -3407,17 +3407,11 @@ var FileLoader = FILTER.FileLoader = Class(Loader, { constructor: function FileLoader( ) { var self = this; - if ( !(self instanceof FileLoader) ) - return new FileLoader( ); + if ( !(self instanceof FileLoader) ) return new FileLoader( ); }, load: function ( file, onLoad, onError ) { - var self = this, - options = { - // return raw buffer - encoding: 'arraybuffer' === self._responseType ? null : self._responseType, - flag: 'r' - }; + var self = this; // read file if ( FILTER.Browser.isNode ) { @@ -3448,7 +3442,7 @@ var FileLoader = FILTER.FileLoader = Class(Loader, { onError: function( xhr ) { if ( 'function' === typeof onError ) onError( xhr.statusText ); } - }); + }, null); } return self; } @@ -3540,9 +3534,7 @@ FILTER.HTMLImageLoader = FILTER.Class(FILTER.Loader, { if ( 'function' === typeof onError ) onError(image, loader); }; - if ( scope._crossOrigin ) loader.crossOrigin = scope._crossOrigin; - else loader.crossOrigin = ""; - + loader.crossOrigin = scope._crossOrigin || ""; loader.src = url; return image; diff --git a/build/filter.min.js b/build/filter.min.js index 969b83b..93e6c15 100644 --- a/build/filter.min.js +++ b/build/filter.min.js @@ -2,13 +2,13 @@ * * FILTER.js * @version: 0.8.0 -* @built on 2016-07-19 20:00:58 +* @built on 2016-07-19 22:00:50 * @dependencies: Classy.js, Asynchronous.js * * JavaScript Image Processing Library * https://github.com/foo123/FILTER.js * **/!function(e,t,n){"use strict";function r(e,t,n,r){return e?t.map(function(t,a){return(n?e[a]:e[t])||(r?r(t):null)}):[]}"object"==typeof module&&module.exports?(module.$deps=module.$deps||{})&&(module.exports=module.$deps[t]=n.apply(e,r(module.$deps,["Classy","Asynchronous"],!1,function(e){return require("./"+e.toLowerCase())}))):"function"==typeof define&&define.amd&&"function"==typeof require&&"function"==typeof require.specified&&require.specified(t)?define(t,["module"].concat(["Classy","Asynchronous"]),function(t){return n.moduleUri=t.uri,n.apply(e,r(Array.prototype.slice.call(arguments,1),["Classy","Asynchronous"],!0))}):t in e||(e[t]=n.apply(e,r(e,["Classy","Asynchronous"])))&&"function"==typeof define&&define.amd&&define(function(){return e[t]})}(this,"FILTER",function ModuleFactory__FILTER(Classy,Asynchronous){"use strict";var FILTER=Classy.Merge({Classy:Classy,Asynchronous:Asynchronous,Path:Asynchronous.path(ModuleFactory__FILTER.moduleUri)},Classy);return FILTER.VERSION="0.8.0",!function(e,t,n){var r,a="prototype",i=(Object[a],Function[a],Array[a]),s=t.Path,o=t.Merge,l=t.Asynchronous,u=l.isPlatform(l.Platform.NODE),c=l.isPlatform(l.Platform.BROWSER),h=l.supportsMultiThreading(),f=l.isThread(),d=navigator?navigator.userAgent:"",p=function(){return"[FILTER Plugin: "+this.name+"]"},m=function(e,t,n,r){return e},_=function(){},g=function(e){return function(){this.$super("constructor"),e.apply(this,arguments)}},v=(t.devicePixelRatio=e.devicePixelRatio||1,t._notSupportClamp="undefined"==typeof Uint8ClampedArray),y=("undefined"==typeof Int16Array||"function"!=typeof Int16Array[a].set,function(e,t){var n=e.length;for(t=t||0;--n>=0;)this[n+t]=e[n]}),w=i.slice,C=0,A=t.Browser={isNode:u,isBrowser:c,isWorker:f,supportsWorker:h,isPhantom:/PhantomJS/.test(d),isOpera:c&&/Opera|OPR\//.test(d),isFirefox:c&&/Firefox\//.test(d),isChrome:c&&/Chrome\//.test(d),isSafari:c&&/Apple Computer/.test(navigator.vendor),isKhtml:c&&/KHTML\//.test(d),isIE:c&&(/MSIE \d/.test(d)||/Trident\/\d/.test(d)),isGecko:c&&/gecko\/\d/i.test(d),isWebkit:c&&/WebKit\//.test(d),isMac_geLion:c&&/Mac OS X 1\d\D([7-9]|\d\d)\D/.test(d),isMac_geMountainLion:c&&/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(d),isMobile:!1,isIOS:/AppleWebKit/.test(d)&&/Mobile\/\w+/.test(d),isWin:/windows/i.test(navigator.platform),isMac:!1,isIE_lt8:!1,isIE_lt9:!1,isQtWebkit:!1};A.isMobile=A.isIOS||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(d),A.isMac=A.isIOS||/Mac/.test(navigator.platform),A.isIE_lt8=A.isIE&&!f&&(null==document.documentMode||document.documentMode<8),A.isIE_lt9=A.isIE&&!f&&(null==document.documentMode||document.documentMode<9),A.isQtWebkit=A.isWebkit&&/Qt\/\d+\.\d+/.test(d),t.getPath=l.path,t.uuid=function(e){return[e||"filter",(new Date).getTime(),++C].join("_")},t.Array=Array,t.Array32F="undefined"!=typeof Float32Array?Float32Array:Array,t.Array64F="undefined"!=typeof Float64Array?Float64Array:Array,t.Array8I="undefined"!=typeof Int8Array?Int8Array:Array,t.Array16I="undefined"!=typeof Int16Array?Int16Array:Array,t.Array32I="undefined"!=typeof Int32Array?Int32Array:Array,t.Array8U="undefined"!=typeof Uint8Array?Uint8Array:Array,t.Array16U="undefined"!=typeof Uint16Array?Uint16Array:Array,t.Array32U="undefined"!=typeof Uint32Array?Uint32Array:Array,t.Array32F[a].set||(t.Array32F[a].set=y,t.Array64F[a].set=y,t.Array8I[a].set=y,t.Array16I[a].set=y,t.Array32I[a].set=y,t.Array8U[a].set=y,t.Array16U[a].set=y,t.Array32U[a].set=y),t.Array32F[a].subarray||(t.Array32F[a].subarray=w,t.Array64F[a].subarray=w,t.Array8I[a].subarray=w,t.Array16I[a].subarray=w,t.Array32I[a].subarray=w,t.Array8U[a].subarray=w,t.Array16U[a].subarray=w,t.Array32U[a].subarray=w),t.ImArray=v?t.Array8U:Uint8ClampedArray,t.ImArrayCopy=A.isNode||A.isOpera?t.Array8U:t.ImArray,v&&"undefined"!=typeof CanvasPixelArray&&"function"!==CanvasPixelArray[a].set&&(CanvasPixelArray[a].set=y),v=t._notSupportClamp=v||A.isOpera||A.isNode,t.NotImplemented=function(e){return e=e||"",function(){throw new Error("Method "+e+" not Implemented!")}},t.useWebGL=!1,t.useWebGLSharedResources=!1,t.useWebGLIfAvailable=function(e){},t.useWebGLSharedResourcesIfAvailable=function(e){},t.CHANNEL={RED:0,GREEN:1,BLUE:2,ALPHA:3},t.MODE={IGNORE:0,WRAP:1,CLAMP:2,COLOR:4},t.LUMA=new t.Array32F([.212671,.71516,.072169]),t.FORMAT={IMAGE:1,DATA:4,PNG:8,JPG:16,GIF:32,BMP:64,TGA:128,RGBE:256},t.MIME={PNG:"image/png",JPG:"image/jpeg",GIF:"image/gif",BMP:"image/bmp"},t.FORMAT.JPEG=t.FORMAT.JPG,t.MIME.JPEG=t.MIME.JPG,t.Utils={},t.Codec={},t.Interpolation={},t.Transform={},t.MachineLearning=t.ML={},r=t.log=console&&console.log?function(e){console.log(e)}:function(e){},t.warning=function(e){r("WARNING: "+e)},t.error=function(e,t){if(r("ERROR: "+e),t)throw new Error(e)};var b=t.FilterThread=t.Class(l,{path:s,name:null,constructor:function(){var e=this,t=null;f&&e.initThread().listen("load",function(e){e&&e.filter&&(t&&(t.dispose(!0),t=null),t=l.load("FILTER."+e.filter))}).listen("import",function(e){e&&e["import"]&&e["import"].length&&importScripts(e["import"])}).listen("params",function(e){t&&t.unserialize(e)}).listen("apply",function(n){if(t&&n&&n.im){n.params&&t.unserialize(n.params),n.im[0].id=n.id;var r={im:t._apply(n.im[0],n.im[1],n.im[2])};t.hasMeta&&(r.meta=t.getMeta()),e.send("apply",r)}else e.send("apply",{im:null})}).listen("dispose",function(n){t&&(t.dispose(!0),t=null),e.dispose(!0),close()})},thread:function(e){var t=this;return arguments.length||(e=!0),e=!!e,e&&!t.$thread?(t.fork("FILTER.FilterThread",s.file!==t.path.file?[s.file,t.path.file]:t.path.file),t.send("load",{filter:t.name})):!e&&t.$thread&&t.unfork(),t},sources:function(){var e=i.slice.call(arguments);if(e.length){var t,n=[];for(t=0;tn?n:t>e?t:e}function r(e){return _(2,g(R(e)))}function a(e,t){var n=new p(2);return n[I]=e||0,n[M]=t||0,n}function i(e,t,n){var r=new p(3);return r[I]=e||0,r[M]=t||0,r[L]=n||0,r}function s(e,t,n){var r=1-n;return a(n*e[I]+r*t[I],n*e[M]+r*t[M])}function o(e,t,n){var r=1-n;return i(n*e[I]+r*t[I],n*e[M]+r*t[M],n*e[L]+r*t[L])}function l(e,t){return e[I]*t[M]-t[I]*e[M]}function u(e,t){var n;return 0>e&&(e=-e),0>t&&(t=-t),0==e?t:0==t?e:e>t?(n=t/e,e*m(1+n*n)):(n=e/t,t*m(1+n*n))}function c(e,t){var n,r,i,s,o;return n=a(e[I]-t[I],e[M]-t[M]),0===n[M]&&0===n[I]?null:(r=a(0,0),0===n[I]&&(r[I]=10),0===n[M]&&(r[M]=10),0!==n[M]&&0!==n[I]&&(i=n[M]/n[I],s=-n[I]/n[M],r[I]=10,r[M]=s*r[I]),o=u(r[I],r[M]),r[I]/=o,r[M]/=o,0>l(n,r)&&(r[I]=-r[I],r[M]=-r[M]),r)}function h(e,t,n,r){var a,i,s,o,l,u,c,h,f,d,m=t<<2,_=e.length,g=_>>2;for(d=!0!==r,a=new p(g),h=0,c=0,o=l=u=0,f=0;t>f;f++,c+=4,h++)o+=e[c],a[h]=o;for(c=m,f=0,h=0,o=l=u=0,c=m;_>c;c+=4,h++,f++)f>=t&&(f=0,o=l=u=0),o+=e[c],a[h+t]=a[h]+o;if(d){for(i=new p(g),s=new p(g),h=0,c=0,o=l=u=0,f=0;t>f;f++,c+=4,h++)l+=e[c+1],u+=e[c+2],i[h]=l,s[h]=u;for(c=m,f=0,h=0,o=l=u=0,c=m;_>c;c+=4,h++,f++)f>=t&&(f=0,o=l=u=0),l+=e[c+1],u+=e[c+2],i[h+t]=i[h]+l,s[h+t]=s[h]+u;return[a,i,s]}return[a,a,a]}function f(e,t,n,r){var a,i,s,o,l,u,c,h,f,d,m,_=e.length,g=0,v=0,y=0,w=255,C=255,A=255,b=1/(_>>2);for(m=!0!==r,a=new p(256),d=0;256>d;d+=8)a[d]=0,a[d+1]=0,a[d+2]=0,a[d+3]=0,a[d+4]=0,a[d+5]=0,a[d+6]=0,a[d+7]=0;for(d=0;_>d;d+=4)o=e[d],a[o]+=b,o>g?g=o:w>o&&(w=o);for(c=h=f=0,d=0;256>d;d+=8)c+=a[d],a[d]=c,c+=a[d+1],a[d+1]=c,c+=a[d+2],a[d+2]=c,c+=a[d+3],a[d+3]=c,c+=a[d+4],a[d+4]=c,c+=a[d+5],a[d+5]=c,c+=a[d+6],a[d+6]=c,c+=a[d+7],a[d+7]=c;if(m){for(i=new p(256),s=new p(256),d=0;256>d;d+=8)i[d]=0,s[d]=0,i[d+1]=0,s[d+1]=0,i[d+2]=0,s[d+2]=0,i[d+3]=0,s[d+3]=0,i[d+4]=0,s[d+4]=0,i[d+5]=0,s[d+5]=0,i[d+6]=0,s[d+6]=0,i[d+7]=0,s[d+7]=0;for(d=0;_>d;d+=4)l=e[d+1],u=e[d+2],i[l]+=b,s[u]+=b,l>v?v=l:C>l&&(C=l),u>y?y=u:A>u&&(A=u);for(c=h=f=0,d=0;256>d;d+=8)h+=i[d],i[d]=h,f+=s[d],s[d]=f,h+=i[d+1],i[d+1]=h,f+=s[d+1],s[d+1]=f,h+=i[d+2],i[d+2]=h,f+=s[d+2],s[d+2]=f,h+=i[d+3],i[d+3]=h,f+=s[d+3],s[d+3]=f,h+=i[d+4],i[d+4]=h,f+=s[d+4],s[d+4]=f,h+=i[d+5],i[d+5]=h,f+=s[d+5],s[d+5]=f,h+=i[d+6],i[d+6]=h,f+=s[d+6],s[d+6]=f,h+=i[d+7],i[d+7]=h,f+=s[d+7],s[d+7]=f;return[a,i,s]}return[a,a,a]}function d(e,t,n,r){return null}var p=(e.ImArray,e.Array32F),m=(e.Array64F,Math.sqrt),_=Math.pow,g=Math.ceil,v=Math.log,y=Math.PI,w=y+y,C=.5*y,A=Math.LN2,b=Math.SQRT2,E=function(e){return v(e)/A},R=Math.log2||E,I=0,M=1,L=2;e.CONSTANTS=e.CONST={PI:y,PI2:w,PI_2:C,SQRT2:b,LN2:A,toRad:y/180,toDeg:180/y,X:I,Y:M,Z:L},e.Geometry={Point2:a,Point3:i,enorm2:u,cross2:l,normal2:c,interpolate2:s,interpolate3:o},e.Math={clamp:n,closestPower2:r,integral:h,histogram:f,spectrum:d}}(FILTER),!function(e,t){var n=e.ImArray,r=Math.min;e.Interpolation.crop=function(e,t,a,i,s,o,l){o=r(o,t-1),l=r(l,a-1);var u,c,h,f,d=o-i+1,p=l-s+1,m=d*p<<2,_=new n(m),g=d<<2;for(u=s,c=s*t,h=0;l>=u;u++,c+=t,h+=g)f=c+i<<2,_.set(e.subarray(f,f+g),h);return _},e.Interpolation.pad=function(e,t,r,a,i,s,o){a=a||0,i=i||0,s=s||0,o=o||0;var l,u,c,h,f=t+s+a,d=r+o+i,p=f*d<<2,m=new n(p),_=t<<2,g=f<<2,v=o*g,y=s<<2;for(l=0,u=0,c=v;r>l;l++,u+=t,c+=g)h=u<<2,m.set(e.subarray(h,h+_),y+c);return m}}(FILTER),!function(e,t){var n=e.Math.clamp,r=e.ImArray;e.Interpolation.bilinear=function(e,t,a,i,s){var o,l,u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E,R,I=i*s<<2,M=new r(I),L=(t-1)/i,x=(a-1)/s,N=t<<2;for(m=0,_=0,g=0,v=0,w=0,b=0,R=0,A=0;I>A;A+=4,_++,g+=L)_>=i&&(_=0,g=0,m++,v+=x,w=~~v,R=v-w,b=w*t),y=~~g,E=g-y,h=(1-E)*(1-R),f=E*(1-R),d=R*(1-E),p=E*R,C=b+y<<2,o=e[C],l=e[C+4],u=e[C+N],c=e[C+N+4],M[A]=n(~~(o*h+l*f+u*d+c*p+.5),0,255),o=e[C+1],l=e[C+5],u=e[C+N+1],c=e[C+N+5],M[A+1]=n(~~(o*h+l*f+u*d+c*p+.5),0,255),o=e[C+2],l=e[C+6],u=e[C+N+2],c=e[C+N+6],M[A+2]=n(~~(o*h+l*f+u*d+c*p+.5),0,255),o=e[C+3],l=e[C+7],u=e[C+N+3],c=e[C+N+7],M[A+3]=n(~~(o*h+l*f+u*d+c*p+.5),0,255);return M}}(FILTER),!function(e,t){var n,r;r=e.Class({constructor:function(e){var t=this;t._cnv=e,t._transform={scale:[1,1],translate:[0,0],rotate:[0,0]},t._data=null},_cnv:null,_transform:null,_data:null,dispose:function(){var e=this;return e._cnv=null,e._data=null,e._transform=null,e},drawImage:function(){},scale:function(e,t){var n=this;return n._transform.scale[0]=e,n._transform.scale[1]=t,n},translate:function(e,t){var n=this;return n._transform.translate[0]=e,n._transform.translate[1]=t,n}}),n=e.FilterCanvas=e.Class({constructor:function(e,t){var n=this;n.width=e||0,n.height=t||0,n.style={},n._ctx=new r(n)},_ctx:null,width:null,height:null,style:null,dispose:function(){var e=this;return e.width=null,e.height=null,e.style=null,e._ctx.dispose(),e._ctx=null,e},getContext:function(e){return this._ctx},toDataURL:function(e){return""}}),e.Canvas=function(t,r){var a=e.Browser.isNode?new n:document.createElement("canvas");return t=t||0,r=r||0,a.style.width=t+"px",a.style.height=r+"px",a.width=t*devicePixelRatio,a.height=r*devicePixelRatio,a}}(FILTER),!function(e){var t=Math.sqrt,n=Math.round,r=(Math.floor,Math.min),a=Math.max,i=(Math.abs,e.Math.clamp),s=/([.*+?^${}()|\[\]\/\\\-])/g,o=function(e){return e.replace(s,"\\$1")},l=/^\s+|\s+$/g,u=String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(l,"")},c=1/255,h=100/255,f=2.55,d={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]},p=e.Color=e.Class({__static__:{clamp:i,clampPixel:function(e){return r(255,a(e,0))},toGray:function(t,n,r){var a=e.LUMA;return~~(a[0]*t+a[1]*n+a[2]*r)},distance:function(e,n){var r=e[0]-n[0],a=e[1]-n[1],i=e[2]-n[2];return t(r*r+a*a+i*i)},RGB2Color:function(e){return e[0]<<16|e[1]<<8|255&e[2]},RGBA2Color:function(e){return e[3]<<24|e[0]<<16|e[1]<<8|255&e[2]},Color2RGBA:function(e){return e=~~e,[e>>>16&255,e>>>8&255,255&e,e>>>24&255]},RGB2YCbCr:function(e){var t,n,r,a=e[0],i=e[1],s=e[2];return t=~~(0+.299*a+.587*i+.114*s),n=~~(128-.168736*a-.331264*i+.5*s),r=~~(128+.5*a-.418688*i-.081312*s),[t,n,r]},YCbCr2RGB:function(e){var t,n,r,a=e[0],i=e[1],s=e[2];return t=~~(a+1.402*(s-128)),n=~~(a-.34414*(i-128)-.71414*(s-128)),r=~~(a+1.772*(i-128)),[t,n,r]},RGB2HSV:function(e){var t,n,i,s,o,l,u,c,h;return s=e[0],o=e[1],l=e[2],t=r(s,o,l),n=a(s,o,l),i=n-t,h=n,0==n?(c=0,u=0,[u,c,h]):(c=i/n,u=s==n?(o-l)/i:o==n?2+(l-s)/i:4+(s-o)/i,u*=60,0>u&&(u+=360),[u,c,h])},HSV2RGB:function(e){var t,n,r,a,i,s,o,l,u,c,h;return u=e[0],c=e[1],h=e[2],0==c?(s=o=l=h,[s,o,l]):(u/=60,t=~~u,n=u-t,r=h*(1-c),a=h*(1-c*n),i=h*(1-c*(1-n)),0===t?(s=h,o=i,l=r):1===t?(s=a,o=h,l=r):2===t?(s=r,o=h,l=i):3===t?(s=r,o=a,l=h):4===t?(s=i,o=r,l=h):(s=h,o=r,l=a),[s,o,l])},toString:function(){return"[FILTER: "+this.name+"]"},C2F:c,C2P:h,P2C:f,Keywords:d,hexieRE:/^#([0-9a-fA-F]{8})\b/,hexRE:/^#([0-9a-fA-F]{3,6})\b/,rgbRE:/^(rgba?)\b\s*\(([^\)]*)\)/i,hslRE:/^(hsla?)\b\s*\(([^\)]*)\)/i,keywordRE:new RegExp("^("+Object.keys(d).map(o).join("|")+")\\b","i"),colorstopRE:/^\s+(\d+(\.\d+)?%?)/,col2per:function(e,t){return e*h+(t||"")},per2col:function(e){return e*f},rgb2cmyk:function(e,t,a,s){var o,l,u=0,h=0,d=0,p=0;return s&&(e=i(n(e*f),0,255),t=i(n(t*f),0,255),a=i(n(a*f),0,255)),0==e&&0==t&&0==a?(p=1,[0,0,0,1]):(u=1-e*c,h=1-t*c,d=1-a*c,o=r(u,h,d),l=1/(1-o),u=(u-o)*l,h=(h-o)*l,d=(d-o)*l,p=o,[u,h,d,p])},cmyk2rgb:function(e,t,r,a){var s,o,l=0,u=0,c=0;return 0==e&&0==t&&0==r?[0,0,0]:(s=a,o=1-s,e=e*o+s,t=t*o+s,r=r*o+s,l=255*(1-e),u=255*(1-t),c=255*(1-r),[i(n(l),0,255),i(n(u),0,255),i(n(c),0,255)])},rgb2hex:function(e,t,r,a,s){var o;return s&&(e=i(n(e*f),0,255),t=i(n(t*f),0,255),r=i(n(r*f),0,255)),e=16>e?"0"+e.toString(16):e.toString(16),t=16>t?"0"+t.toString(16):t.toString(16),r=16>r?"0"+r.toString(16):r.toString(16),o=a&&e[0]==e[1]&&t[0]==t[1]&&r[0]==r[1]?"#"+e[0]+t[0]+r[0]:"#"+e+t+r},rgb2hexIE:function(e,t,r,a,s){var o;return s&&(e=i(n(e*f),0,255),t=i(n(t*f),0,255),r=i(n(r*f),0,255),a=i(n(a*f),0,255)),e=16>e?"0"+e.toString(16):e.toString(16),t=16>t?"0"+t.toString(16):t.toString(16),r=16>r?"0"+r.toString(16):r.toString(16),a=16>a?"0"+a.toString(16):a.toString(16),o="#"+a+e+t+r},hex2rgb:function(e){return!e||3>e.length?[0,0,0]:6>e.length?[i(parseInt(e[0]+e[0],16),0,255),i(parseInt(e[1]+e[1],16),0,255),i(parseInt(e[2]+e[2],16),0,255)]:[i(parseInt(e[0]+e[1],16),0,255),i(parseInt(e[2]+e[3],16),0,255),i(parseInt(e[4]+e[5],16),0,255)]},hue2rgb:function(e,t,n){return 0>n&&(n+=1),n>1&&(n-=1),1/6>n?e+6*(t-e)*n:.5>n?t:2/3>n?e+(t-e)*(2/3-n)*6:e},hsl2rgb:function(e,t,r){var a,s,o,l,u;return e=(e+360)%360/360,t*=.01,r*=.01,0==t?(a=1,s=1,o=1):(u=.5>r?r*(1+t):r+t-r*t,l=2*r-u,a=p.hue2rgb(l,u,e+1/3),s=p.hue2rgb(l,u,e),o=p.hue2rgb(l,u,e-1/3)),[i(n(255*a),0,255),i(n(255*s),0,255),i(n(255*o),0,255)]},rgb2hsl:function(e,t,s,o){var l,u,h,f,d,p;return o?(e*=.01,t*=.01,s*=.01):(e*=c,t*=c,s*=c),u=a(e,t,s),l=r(e,t,s),d=.5*(u+l),u==l?h=f=0:(p=u-l,f=d>.5?p/(2-a-r):p/(a+r),h=u==e?(t-s)/p+(s>t?6:0):u==t?(s-e)/p+2:(e-t)/p+4,h/=6),[n(360*h)%360,i(100*f,0,100),i(100*d,0,100)]},parse:function(e,t,n,r){var a,i,s,o,l,c=0,f=0;if("hsl"==n||!n&&(a=e.match(p.hslRE))){if("hsl"==n){l="hsla"==e[0].toLowerCase();var d=e[1].split(",").map(u)}else{c=a[0].length,f=0,l="hsla"==a[1].toLowerCase();var d=a[2].split(",").map(u)}var m=d[0]?d[0]:"0",e=d[1]?d[1]:"0",_=d[2]?d[2]:"0",g=l&&null!=d[3]?d[3]:"1";return m=parseFloat(m,10),e="%"==e.slice(-1)?parseFloat(e,10):parseFloat(e,10)*h,_="%"==_.slice(-1)?parseFloat(_,10):parseFloat(_,10)*h,g=parseFloat(g,10),o=(new p).fromHSL([m,e,_,g]),t&&(s=e.substr(c),(i=s.match(p.colorstopRE))&&(o.colorStop(i[1]),f=i[0].length)),r?o:[o,0,c+f]}if("rgb"==n||!n&&(a=e.match(p.rgbRE))){if("rgb"==n){l="rgba"==e[0].toLowerCase();var d=e[1].split(",").map(u)}else{c=a[0].length,f=0,l="rgba"==a[1].toLowerCase();var d=a[2].split(",").map(u)}var v=d[0]?d[0]:"0",y=d[1]?d[1]:"0",w=d[2]?d[2]:"0",g=l&&null!=d[3]?d[3]:"1";return v="%"==v.slice(-1)?2.55*parseFloat(v,10):parseFloat(v,10),y="%"==y.slice(-1)?2.55*parseFloat(y,10):parseFloat(y,10),w="%"==w.slice(-1)?2.55*parseFloat(w,10):parseFloat(w,10),g=parseFloat(g,10),o=(new p).fromRGB([v,y,w,g]),t&&(s=e.substr(c),(i=s.match(p.colorstopRE))&&(o.colorStop(i[1]),f=i[0].length)),r?o:[o,0,c+f]}if("hex"==n||!n&&(a=e.match(p.hexRE))){if("hex"==n)var d=p.hex2rgb(e[0]);else{c=a[0].length,f=0;var d=p.hex2rgb(a[1])}var C=d[0]?d[0]:0,A=d[1]?d[1]:0,b=d[2]?d[2]:0,g=null!=d[3]?d[3]:255;return o=(new p).fromHEX([C,A,b,g]),t&&(s=e.substr(c),(i=s.match(p.colorstopRE))&&(o.colorStop(i[1]),f=i[0].length)),r?o:[o,0,c+f]}if("keyword"==n||!n&&(a=e.match(p.keywordRE))){if("keyword"==n)var d=e[0];else{c=a[0].length,f=0;var d=a[1]}return o=(new p).fromKeyword(d),t&&(s=e.substr(c),(i=s.match(p.colorstopRE))&&(o.colorStop(i[1]),f=i[0].length)),r?o:[o,0,c+f]}return null},fromString:function(e,t,n){return p.parse(e,t,n,1)},fromRGB:function(e){return(new p).fromRGB(e)},fromHSL:function(e){return(new p).fromHSL(e)},fromCMYK:function(e){return(new p).fromCMYK(e)},fromHEX:function(e){return(new p).fromHEX(e)},fromKeyword:function(e){return(new p).fromKeyword(e)},fromPixel:function(e){return(new p).fromPixel(e)}},constructor:function m(e,t){return this instanceof m?(this.reset(),void(e&&this.set(e,t))):new m(e,t)},name:"Color",col:null,cstop:null,kword:null,clone:function(){var e=new p;return e.col=this.col.slice(),e.cstop=this.cstop+"",e.kword=this.kword,e},reset:function(){return this.col=[0,0,0,1],this.cstop="",this.kword=null,this},set:function(e,t){return e&&(undef!==e[0]&&(this.col[0]=i(e[0],0,255)),undef!==e[1]&&(this.col[1]=i(e[1],0,255)),undef!==e[2]&&(this.col[2]=i(e[2],0,255)),undef!==e[3]?this.col[3]=i(e[3],0,1):this.col[3]=1,t&&(this.cstop=t),this.kword=null),this},colorStop:function(e){return this.cstop=e,this},isTransparent:function(){return 1>this.col[3]},isKeyword:function(){return!!this.kword},fromPixel:function(e){return e=e||0,this.col=[i(e>>16&255,0,255),i(e>>8&255,0,255),i(255&e,0,255),i((e>>24&255)*c,0,1)],this.kword=null,this},fromKeyword:function(e){return e=e.toLowerCase(),p.Keywords[e]&&(this.col=p.Keywords[e].slice(),this.kword=e),this},fromHEX:function(e){return this.col[0]=e[0]?i(parseInt(e[0],10),0,255):0,this.col[1]=e[1]?i(parseInt(e[1],10),0,255):0,this.col[2]=e[2]?i(parseInt(e[2],10),0,255):0,this.col[3]=undef!==e[3]?i(parseInt(e[3],10)*c,0,1):1,this.kword=null,this},fromRGB:function(e){return this.col[0]=e[0]?i(n(e[0]),0,255):0,this.col[1]=e[1]?i(n(e[1]),0,255):0,this.col[2]=e[2]?i(n(e[2]),0,255):0,this.col[3]=undef!==e[3]?i(e[3],0,1):1,this.kword=null,this},fromCMYK:function(e){var t=p.cmyk2rgb(e[0]||0,e[1]||0,e[2]||0,e[3]||0);return this.col[0]=t[0],this.col[1]=t[1],this.col[2]=t[2],this.col[3]=undef!==e[4]?i(e[4],0,1):1,this.kword=null,this},fromHSL:function(e){var t=p.hsl2rgb(e[0]||0,e[1]||0,e[2]||0);return this.col[0]=t[0],this.col[1]=t[1],this.col[2]=t[2],this.col[3]=undef!==e[3]?i(e[3],0,1):1,this.kword=null,this},toPixel:function(e){return e?i(255*this.col[3],0,255)<<24|this.col[0]<<16|this.col[1]<<8|255&this.col[2]:this.col[0]<<16|this.col[1]<<8|255&this.col[2]},toCMYK:function(e,t,n){var r=p.rgb2cmyk(this.col[0],this.col[1],this.col[2]);return n?r:r.concat(this.col[3])},toKeyword:function(e,t,n){return this.kword?this.kword:this.toHEX(1,t,n)},toHEX:function(e,t,r){return r?p.rgb2hexIE(this.col[0],this.col[1],this.col[2],i(n(255*this.col[3]),0,255)):p.rgb2hex(this.col[0],this.col[1],this.col[2],t)},toRGB:function(e,t,n){var r=this.col[3];return e?(t&&(r=1>r&&r>0?r.toString().slice(1):r),n||1==this.col[3]?"rgb("+this.col.slice(0,3).join(",")+")":"rgba("+this.col.slice(0,3).concat(r).join(",")+")"):n?this.col.slice(0,3):this.col.slice()},toHSL:function(e,t,n){var r=this.col[3],a=p.rgb2hsl(this.col[0],this.col[1],this.col[2]);return e?(t&&(a[1]=0==a[1]?a[1]:a[1]+"%",a[2]=0==a[2]?a[2]:a[2]+"%",r=1>r&&r>0?r.toString().slice(1):r),n||1==this.col[3]?"hsl("+[a[0],a[1],a[2]].join(",")+")":"hsla("+[a[0],a[1],a[2],r].join(",")+")"):n?a:a.concat(this.col[3])},toColorStop:function(e){var t=this.cstop;return e?(t=t.length?t+",":"",1>this.col[3]?"color-stop("+t+this.toRGB(1,1)+")":"color-stop("+t+this.toHEX(1,1)+")"):(t=t.length?" "+t:"",1>this.col[3]?this.toRGB(1,1)+t:this.toHEX(1,1)+t)},toString:function(e,t){return e=e?e.toLowerCase():"hex","rgb"==e||"rgba"==e?this.toRGB(1,!1!==t,"rgb"==e):"hsl"==e||"hsla"==e?this.toHSL(1,!1!==t,"hsl"==e):"keyword"==e?this.toKeyword(1):this.toHEX(1,!1!==t,"hexie"==e)}})}(FILTER),!function(e,t){function n(e){var t=e.width,n=e.height,r=c(t,n);return r.width=t*o,r.height=n*o,r}function r(e,t,n,r){return r=r||R,r&b&&(e.width=t,e.oCanvas.style.width=t+"px",e.oCanvas.width=t*o,e._restorable&&(e.iCanvas.style.width=e.oCanvas.style.width,e.iCanvas.width=e.oCanvas.width),e.tmpCanvas&&(e.tmpCanvas.style.width=e.oCanvas.style.width,e.tmpCanvas.width=e.oCanvas.width)),r&E&&(e.height=n,e.oCanvas.style.height=n+"px",e.oCanvas.height=n*o,e._restorable&&(e.iCanvas.style.height=e.oCanvas.style.height,e.iCanvas.height=e.oCanvas.height),e.tmpCanvas&&(e.tmpCanvas.style.height=e.oCanvas.style.height,e.tmpCanvas.height=e.oCanvas.height)),e}function a(e,t){var n=e.width,r=e.height;return t=t||255,e._restorable&&t&_&&e._needsRefresh&_&&(e.iData=e.ictx.getImageData(0,0,n,r),e._needsRefresh&=~_),t&g&&e._needsRefresh&g&&(e.oData=e.octx.getImageData(0,0,n,r),e._needsRefresh&=~g),e}function i(e,t){if(e.selection){var n=e.selection,r=e.width-1,a=e.height-1,i=f(n[0]*r),s=f(n[1]*a),o=f(n[2]*r)-i+1,l=f(n[3]*a)-s+1;t=t||255,e._restorable&&t&v&&e._needsRefresh&v&&(e.iDataSel=e.ictx.getImageData(i,s,o,l),e._needsRefresh&=~v),t&y&&e._needsRefresh&y&&(e.oDataSel=e.octx.getImageData(i,s,o,l),e._needsRefresh&=~y)}return e}var s="prototype",o=e.devicePixelRatio,l=e.ImArray,u=e.ImArrayCopy,c=(e.Array32F,e.Canvas),h=e.FilterCanvas,f=(e._notSupportTypedArrays,Math.min,Math.floor),d=e.FORMAT,p=e.MIME,m=0,_=1,g=2,v=4,y=8,w=16,C=32,A=64,b=2,E=4,R=b|E,I=v|y,M=_|g,L=~I,x=~w,N=~C,S=e.Image=e.Class({name:"Image",constructor:function O(e){var t=this,n=0,r=0;return t instanceof O?(t.id=++m,t.width=n,t.height=r,t.iData=null,t.iDataSel=null,t.oData=null,t.oDataSel=null,t.iCanvas=c(n,r),t.oCanvas=c(n,r),t.tmpCanvas=null,t.domElement=t.oCanvas,t.ictx=t.iCanvas.getContext("2d"),t.octx=t.oCanvas.getContext("2d"),t.webgl=null,t._histogram=null,t._integral=null,t._spectrum=null,t.selection=null,t._needsRefresh=0,t._restorable=!0,t._grayscale=!1,void(e&&t.image(e))):new O(e)},id:null,width:0,height:0,selection:null,iCanvas:null,oCanvas:null,tmpCanvas:null,ictx:null,octx:null,iData:null,iDataSel:null,oData:null,oDataSel:null,domElement:null,webgl:null,_histogram:null,_integral:null,_spectrum:null,_needsRefresh:0,_restorable:!0,_grayscale:!1,dispose:function(){var e=this;return e.id=null,e.width=null,e.height=null,e.selection=null,e.ictx=null,e.octx=null,e.iData=null,e.iDataSel=null,e.oData=null,e.oDataSel=null,e.iCanvas=null,e.oCanvas=null,e.tmpCanvas=null,e.domElement=null,e.webgl=null,e._histogram=null,e._integral=null,e._spectrum=null,e._needsRefresh=null,e._restorable=null,e._grayscale=null,e},clone:function(e){return new S(!0===e?this.iCanvas:this.oCanvas)},grayscale:function(e){var t=this;return arguments.length?(t._grayscale=!!e,t):t._grayscale},restorable:function(e){var t=this;return arguments.length||(e=!0),t._restorable=!!e,t},apply:function(e,t){return e.apply(this,this,t||null),this},apply2:function(e,t,n){return e.apply(this,t,n||null),this},select:function(e,t,n,r){var a=this,i=arguments.length;return 1>i&&(e=0),2>i&&(t=0),3>i&&(n=1),4>i&&(r=1),a.selection=[0>e?0:e>1?1:e,0>t?0:t>1?1:t,0>n?0:n>1?1:n,0>r?0:r>1?1:r],a._needsRefresh|=I,a},deselect:function(){var e=this;return e.selection=null,e.iDataSel=null,e.oDataSel=null,e._needsRefresh&=L,e},store:function(){var e=this;return e._restorable&&(e.ictx.drawImage(e.oCanvas,0,0),e._needsRefresh|=_,e.selection&&(e._needsRefresh|=v)),e},restore:function(){var e=this;return e._restorable&&(e.octx.drawImage(e.iCanvas,0,0),e._needsRefresh|=g|w|C|A,e.selection&&(e._needsRefresh|=y)),e},dimensions:function(e,t){var n=this;return r(n,e,t,R),n._needsRefresh|=M|w|C|A,n.selection&&(n._needsRefresh|=I),n},scale:function(e,t){var r=this;if(e=e||1,t=t||e,1==e&&1==t)return r;r.tmpCanvas=r.tmpCanvas||n(r);var a=r.tmpCanvas.getContext("2d"),i=r.width,s=r.height;return a.scale(e,t),i=r.width=~~(e*i+.5),s=r.height=~~(t*s+.5),a.drawImage(r.oCanvas,0,0),r.oCanvas.style.width=i+"px",r.oCanvas.style.height=s+"px",r.oCanvas.width=i*o,r.oCanvas.height=s*o,r.octx.drawImage(r.tmpCanvas,0,0),r._restorable&&(a.drawImage(r.iCanvas,0,0),r.iCanvas.style.width=r.oCanvas.style.width,r.iCanvas.style.height=r.oCanvas.style.height,r.iCanvas.width=r.oCanvas.width,r.iCanvas.height=r.oCanvas.height,r.ictx.drawImage(r.tmpCanvas,0,0)),r.tmpCanvas.width=r.oCanvas.width,r.tmpCanvas.height=r.oCanvas.height,r._needsRefresh|=M|w|C|A,r.selection&&(r._needsRefresh|=I),r},flipHorizontal:function(){var e=this;e.tmpCanvas=e.tmpCanvas||n(e);var t=e.tmpCanvas.getContext("2d");return t.translate(e.width,0),t.scale(-1,1),t.drawImage(e.oCanvas,0,0),e.octx.drawImage(e.tmpCanvas,0,0),e._restorable&&(t.drawImage(e.iCanvas,0,0),e.ictx.drawImage(e.tmpCanvas,0,0)),e._needsRefresh|=M|w|C|A,e.selection&&(e._needsRefresh|=I),e},flipVertical:function(){var e=this;e.tmpCanvas=e.tmpCanvas||n(e);var t=e.tmpCanvas.getContext("2d");return t.translate(0,e.height),t.scale(1,-1),t.drawImage(e.oCanvas,0,0),e.octx.drawImage(e.tmpCanvas,0,0),e._restorable&&(t.drawImage(e.iCanvas,0,0),e.ictx.drawImage(e.tmpCanvas,0,0)),e._needsRefresh|=M|w|C|A,e.selection&&(e._needsRefresh|=I),e},draw:function(e,t,n,r){return this},clear:function(){var e=this,t=e.width,n=e.height;return t&&n&&(e._restorable&&e.ictx.clearRect(0,0,t,n),e.octx.clearRect(0,0,t,n),e._needsRefresh|=M|w|C|A,e.selection&&(e._needsRefresh|=I)),e},crop:function(e,t,r,a){var i,s,l,u,c,h,d,p,m=this,_=m.selection,g=m.width,v=m.height;if(arguments.length)c=e,h=t,d=r-e+1,p=a-t+1;else{if(!_)return m;i=f(_[0]*(g-1)),s=f(_[1]*(v-1)),l=f(_[2]*(g-1))-i+1,u=f(_[3]*(v-1))-s+1,c=i,h=s,d=l,p=u,_[0]=0,_[1]=0,_[2]=1,_[3]=1}m.tmpCanvas=m.tmpCanvas||n(m);var y=m.tmpCanvas.getContext("2d");return y.drawImage(m.oCanvas,0,0,g,v,c,h,d,p),m.oCanvas.style.width=d+"px",m.oCanvas.style.height=p+"px",m.oCanvas.width=d*o,m.oCanvas.height=p*o,m.octx.drawImage(m.tmpCanvas,0,0),m._restorable&&(y.drawImage(m.iCanvas,0,0,g,v,c,h,d,p),m.iCanvas.style.width=m.oCanvas.style.width,m.iCanvas.style.height=m.oCanvas.style.height,m.iCanvas.width=m.oCanvas.width,m.iCanvas.height=m.oCanvas.height,m.ictx.drawImage(m.tmpCanvas,0,0)),m.tmpCanvas.width=m.oCanvas.width,m.tmpCanvas.height=m.oCanvas.height,m._needsRefresh|=M|w|C|A,_&&(m._needsRefresh|=I),m},fill:function(e,n,r,a,i){var s,o,l,u,c=this,h=c.selection,d=c.width,p=c.height;h?(s=f(h[0]*(d-1)),o=f(h[1]*(p-1)),l=f(h[2]*(d-1))-s+1,u=f(h[3]*(p-1))-o+1):(s=0,o=0,l=d,u=p),t===n&&(n=s),t===r&&(r=o),t===a&&(a=l), -t===i&&(i=u),a&&!d&&i&&!p&&c.createImageData(a,i);var m=c.ictx,_=c.octx;return e=e||0,c._restorable&&(m.fillStyle=e,m.fillRect(n,r,a,i)),_.fillStyle=e,_.fillRect(n,r,a,i),c._needsRefresh|=M|w|C|A,h&&(c._needsRefresh|=I),c},getData:function(){var e,t=this;return t._restorable?(t._needsRefresh&_&&a(t,_),e=t.iData):(t._needsRefresh&g&&a(t,g),e=t.oData),new u(e.data)},getSelectedData:function(){var e,t=this;return t.selection?t._restorable?(t._needsRefresh&v&&i(t,v),e=t.iDataSel):(t._needsRefresh&y&&i(t,y),e=t.oDataSel):t._restorable?(t._needsRefresh&_&&a(t,_),e=t.iData):(t._needsRefresh&g&&a(t,g),e=t.oData),[new u(e.data),e.width,e.height]},getProcessedData:function(){var e=this;return e._needsRefresh&g&&a(e,g),new u(e.oData.data)},getProcessedSelectedData:function(){var e,t=this;return t.selection?(t._needsRefresh&y&&i(t,y),e=t.oDataSel):(t._needsRefresh&g&&a(t,g),e=t.oData),[new u(e.data),e.width,e.height]},setData:function(e){var t=this;return t._needsRefresh&g&&a(t,g),t.oData.data.set(e),t.octx.putImageData(t.oData,0,0),t._needsRefresh|=w|C|A,t.selection&&(t._needsRefresh|=y),t},setSelectedData:function(e){var t=this;if(t.selection){var n=t.selection,r=t.width-1,s=t.height-1,o=f(n[0]*r),l=f(n[1]*s);t._needsRefresh&y&&i(t,y),t.oDataSel.data.set(e),t.octx.putImageData(t.oDataSel,o,l),t._needsRefresh|=g}else t._needsRefresh&g&&a(t,g),t.oData.data.set(e),t.octx.putImageData(t.oData,0,0);return t._needsRefresh|=w|C|A,t},createImageData:function(e,t){var n,a,i=this;return r(i,e,t,R),i._restorable&&(n=i.ictx=i.iCanvas.getContext("2d"),n.createImageData(e,t)),a=i.octx=i.oCanvas.getContext("2d"),a.createImageData(e,t),i._needsRefresh|=M,i.selection&&(i._needsRefresh|=I),i},image:function(e){if(!e)return this;var t,n,i,s,o,l,u,c=this;return e instanceof S&&(e=e.oCanvas),o=e instanceof HTMLVideoElement,l=e instanceof HTMLCanvasElement||e instanceof h,u=e instanceof Image,o?(i=e.videoWidth,s=e.videoHeight):(i=e.width,s=e.height),u||l||o?(r(c,i,s,R),c._restorable&&(t=c.ictx=c.iCanvas.getContext("2d"),t.drawImage(e,0,0)),n=c.octx=c.oCanvas.getContext("2d"),n.drawImage(e,0,0),c._needsRefresh|=M):(c.oData||(c.createImageData(i,s),a(c,M)),c._restorable&&(t=c.ictx=c.iCanvas.getContext("2d"),c.iData.data.set(e.data),t.putImageData(c.iData,0,0)),n=c.octx=c.oCanvas.getContext("2d"),c.oData.data.set(e.data),n.putImageData(c.oData,0,0)),c._needsRefresh|=w|C|A,c.selection&&(c._needsRefresh|=I),c},getPixel:function(e,t){var n=this;n._needsRefresh&g&&a(n,g);var r=~~(t*n.width+e+.5)<<2,i=n.oData.data;return{r:i[r],g:i[r+1],b:i[r+2],a:i[r+3]}},setPixel:function(e,t,n,r,a,i){var s=this;return s.octx.putImageData(new l([255&n,255&r,255&a,255&i]),e,t),s._needsRefresh|=g|w|C|A,s.selection&&(s._needsRefresh|=y),s},getPixelData:function(){return this._needsRefresh&g&&a(this,g),this.oData},setPixelData:function(e){var t=this;return t.octx.putImageData(e,0,0),t._needsRefresh|=g|w|C|A,t.selection&&(t._needsRefresh|=y),t},integral:function(){var e=this;return e._needsRefresh&C&&(e._integral=S.integral(e.getPixelData().data,e.width,e.height,e._grayscale),e._needsRefresh&=N),e._integral},histogram:function(){var e=this;return e._needsRefresh&w&&(e._histogram=S.histogram(e.getPixelData().data,e.width,e.height,e._grayscale),e._needsRefresh&=x),e._histogram},spectrum:function(){var e=this;return e._spectrum},toImage:function(e){var t,n=this.oCanvas,r=1;if(t=e&d.JPG?n.toDataURL(p.JPG,r):e&d.GIF?n.toDataURL(p.GIF,r):n.toDataURL(p.PNG,r),e&d.IMAGE){var a=new Image;return a.src=t,a}return t},toString:function(){return"[FILTER Image: "+this.name+"]"}});S[s].setImage=S[s].image,S[s].setDimensions=S[s].dimensions,S.scale=S.resize=e.Interpolation.bilinear,S.crop=e.Interpolation.crop,S.pad=e.Interpolation.pad,S.integral=e.Math.integral,S.histogram=e.Math.histogram,S.spectrum=e.Math.spectrum;var T=e.ScaledImage=e.Class(S,{name:"ScaledImage",constructor:function F(e,t,n){var r=this;return r instanceof F?(r.scaleX=e||1,r.scaleY=t||r.scaleX,void r.$super("constructor",n)):new F(e,t,n)},scaleX:1,scaleY:1,dispose:function(){var e=this;return e.scaleX=null,e.scaleY=null,e.$super("dispose"),e},clone:function(e){var t=this;return new T(t.scaleX,t.scaleY,!0===e?t.iCanvas:t.oCanvas)},setScale:function(e,t){var n=this,r=arguments.length;return r>0&&null!=e&&(n.scaleX=e,n.scaleY=e),r>1&&null!=t&&(n.scaleY=t),n},image:function(e){if(!e)return this;var t,n,a,i,s,o,l,u,c,f=this,d=f.scaleX,p=f.scaleY;return e instanceof S&&(e=e.oCanvas),l=e instanceof HTMLVideoElement,u=e instanceof HTMLCanvasElement||e instanceof h,c=e instanceof Image,l?(a=e.videoWidth,i=e.videoHeight):(a=e.width,i=e.height),(c||u||l)&&(s=~~(d*a+.5),o=~~(p*i+.5),r(f,s,o,R),f._restorable&&(t=f.ictx=f.iCanvas.getContext("2d"),t.drawImage(e,0,0,a,i,0,0,s,o)),n=f.octx=f.oCanvas.getContext("2d"),n.drawImage(e,0,0,a,i,0,0,s,o),f._needsRefresh|=M|w|C|A,f.selection&&(f._needsRefresh|=I)),f}});T[s].setImage=T[s].image}(FILTER),!function(e,t){function n(e,t,n){var r="";if(!e)return xhr?xhr:r;var a,l,u,c,h,f=s(e);if(n){for(l=0,u=f.length;u>l;l++)a=f[l],n.setHeader(a,e[a]);return n}if(t){for(l=0,u=f.length;u>l;l++)if(a=f[l],"[object Array]"===i.call(e[a]))for(c=0,h=e[a].length;h>c;c++)t.setRequestHeader(a,String(e[a][c]));else t.setRequestHeader(a,String(e[a]));return t}for(l=0,u=f.length;u>l;l++)if(a=f[l],"[object Array]"===i.call(e[a]))for(r.length&&(r+=o),r+=a+": "+String(e[a][0]),c=1,h=e[a].length;h>c;c++)r+=o+String(e[a][c]);else r.length&&(r+=o),r+=a+": "+String(e[a]);return r}function r(e,t){var n,r,i,s,l={},c=null;if(e)for(t=!0===t,e=e.split(o),r=0,i=e.length;i>r;r++)s=e[r],n=s.split(":"),n.length>1?(c=u(n.shift()),t&&(c=c.toLowerCase()),l[a](c)?("string"==typeof l[c]&&(l[c]=[l[c]]),l[c].push(u(n.join(":")))):l[c]=u(n.join(":"))):n[0].length&&c&&(l[c]=o+n[0]);return l}var a="hasOwnProperty",i=Object.prototype.toString,s=Object.keys,o="\r\n",l=/^\s+|\s+$/g,u=String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(l,"")},c=e.Image,h=e.Class,f=e.Loader=h({name:"Loader",__static__:{load:e.Method(function(e,t,n){return function(e,t,r){return(new n).load(e,t,r)}},e.LATE|e.STATIC)},constructor:function(){},_crossOrigin:null,_responseType:null,dispose:function(){var e=this;return e._crossOrigin=null,e._responseType=null,e},load:function(e,t,n){return null},responseType:function(e){var t=this;return arguments.length?(t._responseType=e,t):t._responseType},crossOrigin:function(e){var t=this;return arguments.length?(t._crossOrigin=e,t):t._crossOrigin}}),d=e.XHR=function m(e,t){var n=this,r=!1;n.readyState=m.UNSENT,n.status=null,n.statusText=null,n.responseType="text",n.responseURL=null,n.response=null,n.responseText=null,n.responseXml=null,n._rawHeaders=null,n._headers=null,n.send=function(t){return r||m.UNSENT!==n.readyState?n:(e&&e(t),n.readyState=m.OPENED,n)},n.abort=function(){return r?n:(r=!0,t&&t(),n)},n.getAllResponseHeaders=function(e){return m.DONE!==n.readyState?null:!0===e?n._headers:n._rawHeaders},n.getResponseHeader=function(e,t){if(null==e||m.DONE!==n.readyState)return null;var r=n._headers||{};return!1!==t&&(e=e.toLowerCase()),r[a](e)?r[e]:null},n.dispose=function(){return n.readyState=null,n.status=null,n.statusText=null,n.responseType=null,n.responseURL=null,n.response=null,n.responseText=null,n.responseXml=null,n._rawHeaders=null,n._headers=null,n.getAllResponseHeaders=null,n.getResponseHeader=null,n.send=null,n.abort=null,n}};d.UNSENT=0,d.OPENED=1,d.HEADERS_RECEIVED=2,d.LOADING=3,d.DONE=4,d.create=e.Browser.isNode?function(e,t){if(e=e||{},!e.url)return null;var r,a,s="[object Object]"===i.call(e.url)?e.url:require("url").parse(e.url),o={method:e.method||"GET",agent:!1,protocol:s.protocol,host:s.hostname,hostname:s.hostname,port:s.port||80,path:(s.pathname||"/")+(s.query?"?"+s.query:"")};return a=new d(function(e){null!=e&&(e=String(e),r.setHeader("Content-Length",String(e.length)),r.write(e)),r.end()},function(){r.abort()}),r=("https:"===o.protocol?require("https").request:require("http").request)(o,function(t){var n="",r=0;a.readyState=d.OPENED,e.onStateChange&&e.onStateChange(a),a.readyState=d.HEADERS_RECEIVED,a._rawHeaders=t.rawHeaders.join("\r\n"),a._headers=t.headers,a.responseURL=t.url||null,a.status=t.statusCode||null,a.statusText=t.statusMessage||null,e.onStateChange&&e.onStateChange(a),t.on("data",function(t){n+=t.toString(),r||(r=1,a.readyState=d.LOADING,e.onStateChange&&e.onStateChange(a),e.onLoadStart&&e.onLoadStart(a)),e.onProgress&&e.onProgress(a)}),t.on("end",function(){a.readyState=d.DONE,a.responseType="text",a.response=a.responseText=n,e.onStateChange&&e.onStateChange(a),e.onLoadEnd&&e.onLoadEnd(a),d.DONE===a.readyState&&(200===a.status?e.onComplete&&e.onComplete(a):e.onRequestError?e.onRequestError(a):e.onError&&e.onError(a))}),t.on("error",function(t){a.statusText=t.toString(),e.onError&&e.onError(a)})}),r.setTimeout(e.timeout||3e4,function(t){e.onTimeout&&e.onTimeout(a)}),r.on("abort",function(t){e.onAbort&&e.onAbort(a)}),r.on("error",function(t){a.statusText=t.toString(),e.onError&&e.onError(a)}),e.headers&&n(e.headers,null,r),arguments.length>1&&a.send(t),a}:function(e,t){if(e=e||{},!e.url)return null;var a="undefined"!=typeof XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),i=new d(function(e){a.send(e)},function(){a.abort()}),s=function(e,t){return e.readyState=t.readyState,e.responseType=t.responseType,e.responseURL=t.responseURL,e.response=t.response,e.responseText=t.responseText,e.responseXml=t.responseXml,e.status=t.status,e.statusText=t.statusText,e};return i.getAllResponseHeaders=function(e){var t=a.getAllResponseHeaders();return!0===e?r(t):t},i.getResponseHeader=function(e){return a.getResponseHeader(e)},a.open(e.method||"GET",e.url,!e.sync),i.responseType=a.responseType=e.responseType||"text",a.timeout=e.timeout||3e4,e.onProgress&&(a.onprogress=function(){e.onProgress(s(i,a))}),e.onLoadStart&&(a.onloadstart=function(){e.onLoadStart(s(i,a))}),e.onLoadEnd&&(a.onloadend=function(){e.onLoadEnd(s(i,a))}),!e.sync&&e.onStateChange&&(a.onreadystatechange=function(){e.onStateChange(s(i,a))}),a.onload=function(){s(i,a),d.DONE===a.readyState&&(200===a.status?e.onComplete&&e.onComplete(i):e.onRequestError?e.onRequestError(i):e.onError&&e.onError(i))},a.onabort=function(){e.onAbort&&e.onAbort(s(i,a))},a.onerror=function(){e.onError&&e.onError(s(i,a))},a.ontimeout=function(){e.onTimeout&&e.onTimeout(s(i,a))},e.headers&&n(e.headers,a),e.mimeType&&a.overrideMimeType(e.mimeType),arguments.length>1&&i.send(t),i};var p=(e.XHRLoader=h(f,{name:"XHRLoader",constructor:function _(){var e=this;return e instanceof _?void 0:new _},load:function(e,t,n){var r=this;return d.create({url:e,onComplete:function(e){"function"==typeof t&&t("arraybuffer"===r._responseType?new Buffer(e.response):e.response)},onError:function(e){"function"==typeof n&&n(e.statusText)}}),r}}),e.FileLoader=h(f,{name:"FileLoader",constructor:function g(){var e=this;return e instanceof g?void 0:new g},load:function(t,n,r){var a=this;({encoding:"arraybuffer"===a._responseType?null:a._responseType,flag:"r"});return e.Browser.isNode?require("fs").readFile(t,{encoding:"arraybuffer"===a._responseType?null:a._responseType,flag:"r"},function(e,t){e?"function"==typeof r&&r(e.toString()):"function"==typeof n&&n(t)}):d.create({url:t,responseType:a._responseType,onComplete:function(e){"function"==typeof n&&n(e.response)},onError:function(e){"function"==typeof r&&r(e.statusText)}}),a}}));e.BinaryLoader=h(f,{name:"BinaryLoader",constructor:function v(e){var t=this;return t instanceof v?void(t._decoder="function"==typeof e?e:null):new v(e)},_decoder:null,_encoder:null,dispose:function(){var e=this;return e._decoder=null,e._encoder=null,e.$super("dispose"),e},decoder:function(e){var t=this;return t._decoder="function"==typeof e?e:null,t},encoder:function(e){var t=this;return t._encoder="function"==typeof e?e:null,t},load:function(e,t,n){var r=this,a=new c,i=r._decoder;return"function"==typeof i&&(new p).responseType(r._responseType||"arraybuffer").load(e,function(e){var n={},r=i(e,n);r&&(a.image(r),"function"==typeof t&&t(a,n))},n),a}})}(FILTER),!function(e,t){var n=e.Image;e.HTMLImageLoader=e.Class(e.Loader,{name:"HTMLImageLoader",constructor:function r(){return this instanceof r?void this.$super("constructor"):new r},load:function(e,t,r){var a,i=this,s=new n;return a=new Image,a.onload=function(e){s.setImage(a),"function"==typeof t&&t(s,a)},a.onerror=function(e){"function"==typeof r&&r(s,a)},i._crossOrigin?a.crossOrigin=i._crossOrigin:a.crossOrigin="",a.src=e,s}})}(FILTER),!function(e,t){var n=(Object.prototype,Function.prototype,Array.prototype),r=n.slice,a=n.splice,i=n.concat,s=e.CompositeFilter=e.Class(e.Filter,{name:"CompositeFilter",constructor:function(e){var t=this;t.$super("constructor"),t._stack=e&&e.length?e.slice():[]},_stack:null,_meta:null,_stable:!0,dispose:function(e){var t,n=this,r=n._stack;if(n.$super("dispose"),!0===e)for(t=0;tn;n++)l[n]=l[n].unserialize(i[n]);else{for(n=0;a>n;n++)l[n]&&l[n].dispose(!0),l[n]=null;for(l=[],n=0;r>n;n++){if(s=i[n]&&i[n].filter?e[i[n].filter]:null,!s)throw new Error('Filter "'+i[n].filter+'" could not be created');l.push((new s).unserialize(i[n]))}}o._stack=l}return o},getMeta:function(){return this._meta},setMeta:function(e){var t,n,r=this,a=r._stack;if(e&&(n=e.length)&&a.length)for(t=0;n>t;t++)a[e[t][0]].setMeta(e[t][1]);return r},stable:function(e){return arguments.length||(e=!0),this._stable=!!e,this},filters:function(e){return arguments.length?(this._stack=e.slice(),this):this._stack.slice()},push:function(){var e=r.call(arguments),t=e.length;return t&&(this._stack=i.apply(this._stack,e)),this},pop:function(){return this._stack.pop()},shift:function(){return this._stack.shift()},unshift:function(){var e=r.call(arguments),t=e.length;return t&&a.apply(this._stack,[0,0].concat(e)),this},getAt:function(e){return this._stack.length>e?this._stack[e]:null},setAt:function(e,t){return this._stack.length>e?this._stack[e]=t:this._stack.push(t),this},insertAt:function(e){var t=r.call(arguments);t.length;return argslen>1&&(t.shift(),a.apply(this._stack,[e,0].concat(t))),this},removeAt:function(e){return this._stack.splice(e,1)},remove:function(e){for(var t=this._stack.length;--t>=0;)e===this._stack[t]&&this._stack.splice(t,1);return this},reset:function(){return this._stack.length=0,this},_apply:function(e,t,n,r){var a=this;if(a.hasMeta=!1,a._meta=[],a._isOn&&a._stack.length){var i,s,o=a._stack,l=o.length;for(i=0;l>i;i++)s=o[i],s&&s._isOn&&(e=s._apply(e,t,n,r),s.hasMeta&&a._meta.push([i,s.getMeta()]))}return a.hasMeta=a._meta.length>0,e},canRun:function(){return this._isOn&&this._stack.length},toString:function(){var e,t=arguments.length&&arguments[0].substr?arguments[0]:" ",n=t+t,r=this._stack,a=[],i=r.length;for(e=0;i>e;e++)a.push(r[e].toString(n));return["[FILTER: "+this.name+"]","["," "+a.join("\n "),"]",""].join("\n")}});s.prototype.empty=s.prototype.reset,s.prototype.concat=s.prototype.push}(FILTER),!function(e,t){var n="hasOwnProperty";e.InlineFilter=e.Class(e.Filter,{name:"InlineFilter",constructor:function(e){var t=this;t.$super("constructor"),t._handler=e&&"function"==typeof e?e:null,t._params={}},_handler:null,_params:null,dispose:function(){var e=this;return e.$super("dispose"),e._handler=null,e._params=null,e},params:function(e){var t=this;if(arguments.length){for(var r in e)e[n](r)&&(t._params[r]=e[r]);return t}return t._params},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_handler:e._handler?e._handler.toString():null,_params:e._params}}},unserialize:function(t){var n,r=this;return t&&r.name===t.filter&&(r._isOn=!!t._isOn,n=t.params,r._handler=null,n._handler&&(r._handler=new Function("FILTER",'"use strict"; return '+n._handler+";")(e)),r._params=n._params||{}),r},_apply:function(e,t,n,r){var a=this;return a._isOn&&a._handler?a._handler(a,e,t,n,r):e},canRun:function(){return this._isOn&&this._handler}});e.CustomFilter=e.InlineFilter}(FILTER),!function(e,t){function n(e,t){var n,r,a,i,o,l=new s(20);return n=t[0],r=t[1],a=t[2],i=t[3],o=t[4],l[0]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[1]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[2]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[3]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[4]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,n=t[5],r=t[6],a=t[7],i=t[8],o=t[9],l[5]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[6]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[7]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[8]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[9]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,n=t[10],r=t[11],a=t[12],i=t[13],o=t[14],l[10]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[11]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[12]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[13]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[14]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,n=t[15],r=t[16],a=t[17],i=t[18],o=t[19],l[15]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[16]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[17]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[18]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[19]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,l}function r(e,t,n){var r=1-n,a=new s(20);return a[0]=r*e[0]+n*t[0],a[1]=r*e[1]+n*t[1],a[2]=r*e[2]+n*t[2],a[3]=r*e[3]+n*t[3],a[4]=r*e[4]+n*t[4],a[5]=r*e[5]+n*t[5],a[6]=r*e[6]+n*t[6],a[7]=r*e[7]+n*t[7],a[8]=r*e[8]+n*t[8],a[9]=r*e[9]+n*t[9],a[10]=r*e[10]+n*t[10],a[11]=r*e[11]+n*t[11],a[12]=r*e[12]+n*t[12],a[13]=r*e[13]+n*t[13],a[14]=r*e[14]+n*t[14],a[15]=r*e[15]+n*t[15],a[16]=r*e[16]+n*t[16],a[17]=r*e[17]+n*t[17],a[18]=r*e[18]+n*t[18],a[19]=r*e[19]+n*t[19],a}var a=Math.sin,i=Math.cos,s=e.Array32F,o=e.CONST.toRad,l=(e.CONST.toDeg,e._notSupportClamp),u=e.ColorMatrixFilter=e.Class(e.Filter,{name:"ColorMatrixFilter",constructor:function(t){var n=this;n.$super("constructor"),t&&t.length?n._matrix=new s(t):n._matrix=null,e.useWebGL&&(n._webglInstance=e.WebGLColorMatrixFilterInstance||null)},_matrix:null,_webglInstance:null,dispose:function(){var e=this;return e.$super("dispose"),e._webglInstance=null,e._matrix=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_matrix:e._matrix}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n._matrix=t._matrix),n},channel:function(n,r){r=r===t?!1:r;var a=r?1:0;switch(n){case e.CHANNEL.ALPHA:return this.set([0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,255]);case e.CHANNEL.BLUE:return this.set([0,0,a,0,0,0,0,a,0,0,0,0,1,0,0,0,0,0,0,255]);case e.CHANNEL.GREEN:return this.set([0,a,0,0,0,0,1,0,0,0,0,a,0,0,0,0,0,0,0,255]);case e.CHANNEL.RED:default:return this.set([1,0,0,0,0,a,0,0,0,0,a,0,0,0,0,0,0,0,0,255])}},redChannel:function(t){return this.channel(e.CHANNEL.RED,t)},greenChannel:function(t){return this.channel(e.CHANNEL.GREEN,t)},blueChannel:function(t){return this.channel(e.CHANNEL.BLUE,t)},alphaChannel:function(t){return this.channel(e.CHANNEL.ALPHA,!0)},maskChannel:function(t){switch(t){case e.CHANNEL.ALPHA:return this;case e.CHANNEL.BLUE:return this.set([1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0]);case e.CHANNEL.GREEN:return this.set([1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0]);case e.CHANNEL.RED:default:return this.set([0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0])}},swapChannels:function(t,n){switch(t){case e.CHANNEL.ALPHA:switch(n){case e.CHANNEL.ALPHA:return this;case e.CHANNEL.BLUE:return this.set([1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0]);case e.CHANNEL.GREEN:return this.set([1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0]);case e.CHANNEL.RED:default:return this.set([0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0])}break;case e.CHANNEL.BLUE:switch(n){case e.CHANNEL.ALPHA:return this.set([1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0]);case e.CHANNEL.BLUE:return this;case e.CHANNEL.GREEN:return this.set([1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0]);case e.CHANNEL.RED:default:return this.set([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])}break;case e.CHANNEL.GREEN:switch(n){case e.CHANNEL.ALPHA:return this.set([1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0]);case e.CHANNEL.BLUE:return this.set([1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0]);case e.CHANNEL.GREEN:return this;case e.CHANNEL.RED:default:return this.set([0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0])}break;case e.CHANNEL.RED:default:switch(n){case e.CHANNEL.ALPHA:return this.set([0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0]);case e.CHANNEL.BLUE:return this.set([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0]);case e.CHANNEL.GREEN:return this.set([0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0]);case e.CHANNEL.RED:default:return this}}},desaturate:function(){return this.set([e.LUMA[0],e.LUMA[1],e.LUMA[2],0,0,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,0,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,0,0,0,0,1,0])},colorize:function(n,r){var a,i,s,o;return r===t&&(r=1),a=.00392156862745098*(n>>16&255),i=.00392156862745098*(n>>8&255),s=.00392156862745098*(255&n),o=1-r,this.set([o+r*a*e.LUMA[0],r*a*e.LUMA[1],r*a*e.LUMA[2],0,0,r*i*e.LUMA[0],o+r*i*e.LUMA[1],r*i*e.LUMA[2],0,0,r*s*e.LUMA[0],r*s*e.LUMA[1],o+r*s*e.LUMA[2],0,0,0,0,0,1,0])},invert:function(){return this.set([-1,0,0,0,255,0,-1,0,0,255,0,0,-1,0,255,0,0,0,1,0])},invertAlpha:function(){return this.set([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,-1,255])},saturate:function(t){var n,r,a,i;return n=1-t,r=n*e.LUMA[0],a=n*e.LUMA[1],i=n*e.LUMA[2],this.set([r+t,a,i,0,0,r,a+t,i,0,0,r,a,i+t,0,0,0,0,0,1,0])},contrast:function(e,n,r){return n===t&&(n=e),r===t&&(r=e),e+=1,n+=1,r+=1,this.set([e,0,0,0,128*(1-e),0,n,0,0,128*(1-n),0,0,r,0,128*(1-r),0,0,0,1,0])},brightness:function(e,n,r){return n===t&&(n=e),r===t&&(r=e),this.set([1,0,0,0,e,0,1,0,0,n,0,0,1,0,r,0,0,0,1,0])},adjustHue:function(t){t*=o;var n=i(t),r=a(t);return this.set([e.LUMA[0]+n*(1-e.LUMA[0])+r*-e.LUMA[0],e.LUMA[1]+n*-e.LUMA[1]+r*-e.LUMA[1],e.LUMA[2]+n*-e.LUMA[2]+r*(1-e.LUMA[2]),0,0,e.LUMA[0]+n*-e.LUMA[0]+.143*r,e.LUMA[1]+n*(1-e.LUMA[1])+.14*r,e.LUMA[2]+n*-e.LUMA[2]+r*-.283,0,0,e.LUMA[0]+n*-e.LUMA[0]+r*-(1-e.LUMA[0]),e.LUMA[1]+n*-e.LUMA[1]+r*e.LUMA[1],e.LUMA[2]+n*(1-e.LUMA[2])+r*e.LUMA[2],0,0,0,0,0,1,0])},average:function(e,n,r){return e===t&&(e=.3333),n===t&&(n=.3333),r===t&&(r=.3334),this.set([e,n,r,0,0,e,n,r,0,0,e,n,r,0,0,0,0,0,1,0])},quickContrastCorrection:function(e){return e===t&&(e=1.2),this.set([e,0,0,0,0,0,e,0,0,0,0,0,e,0,0,0,0,0,1,0])},sepia:function(e){return e===t&&(e=.5),e>1?e=1:0>e&&(e=0),this.set([1-.607*e,.769*e,.189*e,0,0,.349*e,1-.314*e,.168*e,0,0,.272*e,.534*e,1-.869*e,0,0,0,0,0,1,0])},sepia2:function(n){return n===t&&(n=10),n>100&&(n=100),n*=2.55,this.set([e.LUMA[0],e.LUMA[1],e.LUMA[2],0,40,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,20,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,-n,0,0,0,1,0])},threshold:function(n,r){return r===t&&(r=256),this.set([e.LUMA[0]*r,e.LUMA[1]*r,e.LUMA[2]*r,0,-(r-1)*n,e.LUMA[0]*r,e.LUMA[1]*r,e.LUMA[2]*r,0,-(r-1)*n,e.LUMA[0]*r,e.LUMA[1]*r,e.LUMA[2]*r,0,-(r-1)*n,0,0,0,1,0])},threshold_rgb:function(e,n){return n===t&&(n=256),this.set([n,0,0,0,-(n-1)*e,0,n,0,0,-(n-1)*e,0,0,n,0,-(n-1)*e,0,0,0,1,0])},threshold_alpha:function(e,n){return e===t&&(e=.5),n===t&&(n=256),this.set([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,n,-n*e])},RGB2YCbCr:function(){return this.set([.5,-.418688,-.081312,0,128,.299,.587,.114,0,0,-.168736,-.331264,.5,0,128,0,0,0,1,0])},YCbCr2RGB:function(){return this.set([1.402,1,0,0,-179.456,-.71414,1,-.34414,0,135.45984,0,1,1.772,0,-226.816,0,0,0,1,0])},blend:function(e,t){return this._matrix=this._matrix?r(this._matrix,e.getMatrix(),t):new s(e.getMatrix()),this},set:function(e){return this._matrix=this._matrix?n(this._matrix,new s(e)):new s(e),this},reset:function(){return this._matrix=null,this},combineWith:function(e){return this.set(e.getMatrix())},getMatrix:function(){return this._matrix},setMatrix:function(e){return this._matrix=new s(e),this},_apply:function(e,t,n){var r=this;if(r._isOn&&r._matrix){var a,i,s,o,l,u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E,R=e.length,I=r._matrix,M=(R>>2)%4;for(a=0;R>a;a+=16)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+4],A=e[a+5],b=e[a+6],E=e[a+7],u=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],c=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],h=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],f=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+8],A=e[a+9],b=e[a+10],E=e[a+11],d=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],p=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],m=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],_=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+12],A=e[a+13],b=e[a+14],E=e[a+15],g=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],v=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],y=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],w=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l,e[a+4]=~~u,e[a+5]=~~c,e[a+6]=~~h,e[a+7]=~~f,e[a+8]=~~d,e[a+9]=~~p,e[a+10]=~~m,e[a+11]=~~_,e[a+12]=~~g,e[a+13]=~~v,e[a+14]=~~y,e[a+15]=~~w;if(M)for(M<<=2,a=R-M;R>a;a+=4)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l}return e},canRun:function(){return this._isOn&&this._matrix}});u.prototype.grayscale=u.prototype.desaturate,u.prototype.rotateHue=u.prototype.adjustHue,u.prototype.thresholdRgb=u.prototype.threshold_rgb,u.prototype.thresholdAlpha=u.prototype.threshold_alpha,l&&(u.prototype._apply=function(e,t,n){var r=this;if(r._isOn&&r._matrix){var a,i,s,o,l,u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E,R=e.length,I=r._matrix,M=(R>>2)%4;for(a=0;R>a;a+=16)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+4],A=e[a+5],b=e[a+6],E=e[a+7],u=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],c=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],h=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],f=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+8],A=e[a+9],b=e[a+10],E=e[a+11],d=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],p=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],m=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],_=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+12],A=e[a+13],b=e[a+14],E=e[a+15],g=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],v=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],y=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],w=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s,o=0>o?0:o>255?255:o,l=0>l?0:l>255?255:l,u=0>u?0:u>255?255:u,c=0>c?0:c>255?255:c,h=0>h?0:h>255?255:h,f=0>f?0:f>255?255:f,d=0>d?0:d>255?255:d,p=0>p?0:p>255?255:p,m=0>m?0:m>255?255:m,_=0>_?0:_>255?255:_,g=0>g?0:g>255?255:g,v=0>v?0:v>255?255:v,y=0>y?0:y>255?255:y,w=0>w?0:w>255?255:w,e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l,e[a+4]=~~u,e[a+5]=~~c,e[a+6]=~~h,e[a+7]=~~f,e[a+8]=~~d,e[a+9]=~~p,e[a+10]=~~m,e[a+11]=~~_,e[a+12]=~~g,e[a+13]=~~v,e[a+14]=~~y,e[a+15]=~~w;if(M)for(M<<=2,a=R-M;R>a;a+=4)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s,o=0>o?0:o>255?255:o,l=0>l?0:l>255?255:l,e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l}return e})}(FILTER),!function(e,t){var n=e.ImArrayCopy,r=e.Color.clampPixel,a=function(){var e,t=new n(256);for(e=0;256>e;e++)t[e]=e;return t},i=function(){var e,t=new n(256);for(e=0;256>e;e++)t[e]=255-e;return t},s=function(e){var t,r=new n(256);for(t=0;256>t;t++)r[t]=e;return r},o=function(e){return e?new n(e):null},l=Math.pow,u=Math.exp,c=1/255,h=e.TableLookupFilter=e.Class(e.Filter,{name:"TableLookupFilter",constructor:function(e,t,n,r){var a=this;a.$super("constructor"),a._tableR=e||null,a._tableG=t||a._tableR,a._tableB=n||a._tableG,a._tableA=r||null},_tableR:null,_tableG:null,_tableB:null,_tableA:null,dispose:function(){var e=this;return e.$super("dispose"),e._tableR=null,e._tableG=null,e._tableB=null,e._tableA=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_tableR:e._tableR,_tableG:e._tableG,_tableB:e._tableB,_tableA:e._tableA}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n._tableR=t._tableR,n._tableG=t._tableG,n._tableB=t._tableB,n._tableA=t._tableA),n},thresholds:function(e,t,a){e.length||(e=[e]),t||(t=e),a||(a=t);var i,s,o=e.length,l=o+1,u=t.length,c=u+1,h=a.length,f=h+1,d=new n(256),p=new n(l),m=new n(256),_=new n(c),g=new n(256),v=new n(f),y=255/(l-1),w=255/(c-1),C=255/(f-1);for(i=0;l>i;)p[i]=~~(y*i),i++;for(e[0]=~~(255*e[0]),i=1;o>i;)e[i]=e[i-1]+~~(255*e[i]),i++;for(i=0;c>i;)_[i]=~~(w*i),i++;for(t[0]=~~(255*t[0]),i=1;u>i;)t[i]=t[i-1]+~~(255*t[i]),i++;for(i=0;f>i;)v[i]=~~(C*i),i++;for(a[0]=~~(255*a[0]),i=1;h>i;)a[i]=a[i-1]+~~(255*a[i]),i++;for(i=0;256>i;i++){for(s=0;o>s&&i>e[s];)s++;for(d[i]=r(p[s]),s=0;u>s&&i>t[s];)s++;for(m[i]=r(_[s]),s=0;h>s&&i>a[s];)s++;g[i]=r(v[s])}return this.set(d,m,g)},threshold:function(e,t,n){return e=e||.5,t=t||e,n=n||t,this.thresholds([e],[t],[n])},quantize:function(e){e===t&&(e=64),2>e&&(e=2);var a,i=new n(256),s=new n(e),o=255/(e-1),l=e/256;for(a=0;e>a;)s[a]=~~(o*a),a++;for(a=0;256>a;a++)i[a]=r(s[~~(l*a)]);return this.set(i)},binarize:function(){return this.quantize(2)},solarize:function(e){e===t&&(e=.5);var a,i,s=0,o=new n(256),l=2/255;for(s=0;256>s;s++)a=l*s,i=a>e?255-255*a:255*a-255,o[s]=~~r(i);return this.set(o)},solarize2:function(e){e===t&&(e=.5),e=1-e;var a,i,s=0,o=new n(256),l=2/255;for(s=0;256>s;s++)a=l*s,i=e>a?255-255*a:255*a-255,o[s]=~~r(i);return this.set(o)},solarizeInverse:function(e){e===t&&(e=.5),e*=256;var r=0,a=new n(256);for(r=0;256>r;r++)a[r]=r>e?255-r:r;return this.set(a)},invert:function(){return this.set(i())},mask:function(e){var t=0,a=e>>16&255,i=e>>8&255,s=255&e;for(tR=new n(256),tG=new n(256),tB=new n(256),t=0;256>t;t++)tR[t]=r(t&a),tG[t]=r(t&i),tB[t]=r(t&s);return this.set(tR,tG,tB)},replace:function(e,t){if(e==t)return this;var n=e>>16&255,r=e>>8&255,i=255&e,s=t>>16&255,o=t>>8&255,l=255&t,u=a(),c=a(),h=a();return u[n]=s,c[r]=o,h[i]=l,this.set(u,c,h)},extract:function(t,n,a){if(!n||!n.length)return this;a=a||0;var i,o,l=a>>16&255,u=a>>8&255,c=255&a,h=s(l),f=s(u),d=s(c);switch(t){case e.CHANNEL.BLUE:for(i=n[0],o=n[1];o>=i;)d[i]=r(i),i++;break;case e.CHANNEL.GREEN:for(i=n[0],o=n[1];o>=i;)f[i]=r(i),i++;break;case e.CHANNEL.RED:default:for(i=n[0],o=n[1];o>=i;)h[i]=r(i),i++}return this.set(h,f,d)},gammaCorrection:function(e,t,a){e=e||1,t=t||e,a=a||t,e=1/e,t=1/t,a=1/a;var i=new n(256),s=new n(256),o=new n(256),u=0;for(u=0;256>u;u++)i[u]=r(~~(255*l(c*u,e))),s[u]=r(~~(255*l(c*u,t))),o[u]=r(~~(255*l(c*u,a)));return this.set(i,s,o)},exposure:function(e){e===t&&(e=1);var a=0,i=new n(256);for(a=0;256>a;a++)i[a]=r(~~(255*(1-u(-e*a*c))));return this.set(i)},set:function(e,t,n,i){if(!e)return this;t=t||e,n=n||t;var s,l,u,c,h,f=this._tableR||a(),d=o(f);if(t&&n){for(s=this._tableG||o(f),l=this._tableB||o(s),u=o(s),c=o(l),h=0;256>h;h++)f[h]=r(e[r(d[h])]),s[h]=r(t[r(u[h])]),l[h]=r(n[r(c[h])]);this._tableR=f,this._tableG=s,this._tableB=l}else{for(h=0;256>h;h++)f[h]=r(e[r(d[h])]);this._tableR=f,this._tableG=this._tableR,this._tableB=this._tableR}return this},reset:function(){return this._tableR=this._tableG=this._tableB=this._tableA=null,this},combineWith:function(e){return this.set(e.getTable(0),e.getTable(1),e.getTable(2))},getTable:function(t){switch(t=t||e.CHANNEL.RED){case e.CHANNEL.ALPHA:return this._tableA;case e.CHANNEL.BLUE:return this._tableB;case e.CHANNEL.GREEN:return this._tableG;case e.CHANNEL.RED:default:return this._tableR}},setTable:function(t,n){switch(n=n||e.CHANNEL.RED){case e.CHANNEL.ALPHA:return this._tableA=t,this;case e.CHANNEL.BLUE:return this._tableB=t,this;case e.CHANNEL.GREEN:return this._tableG=t,this;case e.CHANNEL.RED:default:return this._tableR=t,this}},_apply:function(e,t,n){var r=this;if(!r._isOn||!r._tableR)return e;var a,i,s,o,l,u=e.length,c=(u>>2)%4,h=r._tableR,f=r._tableG,d=r._tableB,p=r._tableA; -if(p){for(a=0;u>a;a+=16)i=e[a],s=e[a+1],o=e[a+2],l=e[a+3],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o],e[a+3]=p[l],i=e[a+4],s=e[a+5],o=e[a+6],l=e[a+7],e[a+4]=h[i],e[a+5]=f[s],e[a+6]=d[o],e[a+7]=p[l],i=e[a+8],s=e[a+9],o=e[a+10],l=e[a+11],e[a+8]=h[i],e[a+9]=f[s],e[a+10]=d[o],e[a+11]=p[l],i=e[a+12],s=e[a+13],o=e[a+14],l=e[a+15],e[a+12]=h[i],e[a+13]=f[s],e[a+14]=d[o],e[a+15]=p[l];if(c)for(c<<=2,a=u-c;u>a;a+=4)i=e[a],s=e[a+1],o=e[a+2],l=e[a+3],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o],e[a+3]=p[l]}else{for(a=0;u>a;a+=16)i=e[a],s=e[a+1],o=e[a+2],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o],i=e[a+4],s=e[a+5],o=e[a+6],e[a+4]=h[i],e[a+5]=f[s],e[a+6]=d[o],i=e[a+8],s=e[a+9],o=e[a+10],e[a+8]=h[i],e[a+9]=f[s],e[a+10]=d[o],i=e[a+12],s=e[a+13],o=e[a+14],e[a+12]=h[i],e[a+13]=f[s],e[a+14]=d[o];if(c)for(c<<=2,a=u-c;u>a;a+=4)i=e[a],s=e[a+1],o=e[a+2],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o]}return e},canRun:function(){return this._isOn&&this._tableR}});h.prototype.posterize=h.prototype.levels=h.prototype.quantize}(FILTER),!function(e,t){var n=(e.ImArray,e.ImArrayCopy),r=e.Array16I,a=Math.min,i=(Math.max,Math.floor);e.DisplacementMapFilter=e.Class(e.Filter,{name:"DisplacementMapFilter",constructor:function(e){var t=this;t.$super("constructor"),e&&t.setMap(e)},_map:null,map:null,scaleX:1,scaleY:1,startX:0,startY:0,componentX:0,componentY:0,color:0,red:0,green:0,blue:0,alpha:0,mode:e.MODE.CLAMP,dispose:function(){var e=this;return e.$super("dispose"),e._map=null,e.map=null,e.scaleX=null,e.scaleY=null,e.startX=null,e.startY=null,e.componentX=null,e.componentY=null,e.color=null,e.red=null,e.green=null,e.blue=null,e.alpha=null,e.mode=null,e},serialize:function(){var e=this,t=e.map;return{filter:e.name,_isOn:!!e._isOn,params:{_map:e._map||(t?{data:t.getData(),width:t.width,height:t.height}:null),scaleX:e.scaleX,scaleY:e.scaleY,startX:e.startX,startY:e.startY,componentX:e.componentX,componentY:e.componentY,color:e.color,red:e.red,green:e.green,blue:e.blue,alpha:e.alpha,mode:e.mode}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n.map=null,n._map=t._map,n.scaleX=t.scaleX,n.scaleY=t.scaleY,n.startX=t.startX,n.startY=t.startY,n.componentX=t.componentX,n.componentY=t.componentY,n.color=t.color,n.red=t.red,n.green=t.green,n.blue=t.blue,n.alpha=t.alpha,n.mode=t.mode),n},reset:function(){var e=this;return e._map=null,e.map=null,e},getMap:function(){return this.map},setMap:function(e){var t=this;return e&&(t.map=e,t._map=null),t},setColor:function(e){var t=this;return t.color=e,t.alpha=e>>24&255,t.red=e>>16&255,t.green=e>>8&255,t.blue=255&e,t},_apply:function(t,s,o){var l=this;if(!l._isOn||!l.map&&!l._map)return t;var u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E,R,I,M,L,x,N,S,T,O,F,D,P,k,G,H,U=l.map,X=l._map||{data:U.getData(),width:U.width,height:U.height},B=.00390625*l.scaleX,Y=.00390625*l.scaleY,W=l.componentX,q=l.componentY,z=l.alpha,$=l.red,j=l.green,K=l.blue,J=l.mode,V=e.MODE.IGNORE,Q=(e.MODE.CLAMP,e.MODE.COLOR),Z=e.MODE.WRAP;for(u=X.data,c=X.width,h=X.height,f=u.length>>2,p=a(c,s),m=a(h,o),P=t.length,F=p*m<<2,D=P>>2,g=i(l.startX*(s-1)),_=i(l.startY*(o-1)),v=_*s,y=-g,w=-_,C=s-g-1,A=o-_-1,d=new r(f<<1),k=new n(t),E=0,R=0,I=0,M=0,b=0;f>b;b++,E+=2,R++)R>=c&&(R=0,I++,M+=c),S=R+M<<2,d[E]=i((u[S+W]-128)*B),d[E+1]=i((u[S+q]-128)*Y);for(R=0,I=0,M=0,L=0,b=0;F>b;b+=4,R++)if(R>=p&&(R=0,I++,M+=s,L+=c),!(w>I||I>A||y>R||R>C)){if(N=R+g,x=I+_,T=N+M+v<<2,E=R+L<<1,G=N+d[E],H=x+d[E+1],H>=o||0>H||G>=s||0>G){if(J==V)continue;if(J==Q){t[T]=$,t[T+1]=j,t[T+2]=K,t[T+3]=z;continue}J==Z?(H>A?H-=o:0>H&&(H+=o),G>C?G-=s:0>G&&(G+=s)):(H>A?H=A:0>H&&(H=0),G>C?G=C:0>G&&(G=0))}O=G+H*s<<2,t[T]=k[O],t[T+1]=k[O+1],t[T+2]=k[O+2],t[T+3]=k[O+3]}return t},canRun:function(){return this._isOn&&(this._map||this.map)}})}(FILTER),!function(FILTER,undef){var IMG=FILTER.ImArray,IMGcopy=FILTER.ImArrayCopy,PI=FILTER.CONST.PI,DoublePI=FILTER.CONST.PI2,HalfPI=FILTER.CONST.PI_2,ThreePI2=1.5*PI,Sqrt=Math.sqrt,Atan2=Math.atan2,Atan=Math.atan,Sin=Math.sin,Cos=Math.cos,Floor=Math.floor,Round=Math.round,Asin=Math.asin,Tan=Math.tan,Abs=Math.abs,Max=Math.max,toRad=FILTER.CONST.toRad,Maps,GeometricMapFilter=FILTER.GeometricMapFilter=FILTER.Class(FILTER.Filter,{name:"GeometricMapFilter",constructor:function(e){var t=this;t.$super("constructor"),e&&t.generic(e)},_map:null,_mapName:null,inverseTransform:null,matrix:null,centerX:0,centerY:0,dx:0,dy:0,angle:0,radius:0,wavelength:0,amplitude:0,phase:0,xAmplitude:0,yAmplitude:0,xWavelength:0,yWavelength:0,mode:FILTER.MODE.CLAMP,dispose:function(){var e=this;return e.$super("dispose"),e._map=null,e._mapName=null,e.inverseTransform=null,e.matrix=null,e.centerX=null,e.centerY=null,e.dx=null,e.dy=null,e.angle=null,e.radius=null,e.wavelength=null,e.amplitude=null,e.phase=null,e.xAmplitude=null,e.yAmplitude=null,e.xWavelength=null,e.yWavelength=null,e.mode=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_mapName:e._mapName,inverseTransform:e.inverseTransform?e.inverseTransform.toString():null,matrix:e.matrix,centerX:e.centerX,centerY:e.centerY,dx:e.dx,dy:e.dy,angle:e.angle,radius:e.radius,wavelength:e.wavelength,amplitude:e.amplitude,phase:e.phase,xAmplitude:e.xAmplitude,yAmplitude:e.yAmplitude,xWavelength:e.xWavelength,yWavelength:e.yWavelength,mode:e.mode}}},unserialize:function(json){var self=this,params;return json&&self.name===json.filter&&(self._isOn=!!json._isOn,params=json.params,self.inverseTransform=null,self.matrix=params.matrix,self.centerX=params.centerX,self.centerY=params.centerY,self.dx=params.dx,self.dy=params.dy,self.angle=params.angle,self.radius=params.radius,self.wavelength=params.wavelength,self.amplitude=params.amplitude,self.phase=params.phase,self.xAmplitude=params.xAmplitude,self.yAmplitude=params.yAmplitude,self.xWavelength=params.xWavelength,self.yWavelength=params.yWavelength,self.mode=params.mode,params.inverseTransform&&(self.inverseTransform=eval('(function(){ "use strict"; return '+params.inverseTransform+"})();")),self._mapName=params._mapName,self._map=null,self._mapName&&Maps[self._mapName]&&(self._map=Maps[self._mapName])),self},generic:function(e){var t=this;return e&&(t.inverseTransform=e,t._mapName="generic",t._map=Maps.generic),t},affine:function(e){var t=this;return e&&(t.matrix=e,t._mapName="affine",t._map=Maps.affine),t},flipX:function(){var e=this;return e._mapName="flipX",e._map=Maps.flipX,e},flipY:function(){var e=this;return e._mapName="flipY",e._map=Maps.flipY,e},flipXY:function(){var e=this;return e._mapName="flipXY",e._map=Maps.flipXY,e},rotateCW:function(){var e=this;return e._mapName="rotateCW",e._map=Maps.rotateCW,e},rotateCCW:function(){var e=this;return e._mapName="rotateCCW",e._map=Maps.rotateCCW,e},polar:function(e,t){var n=this;return n.centerX=e||0,n.centerY=t||0,n._mapName="polar",n._map=Maps.polar,n},cartesian:function(e,t){var n=this;return n.centerX=e||0,n.centerY=t||0,n._mapName="cartesian",n._map=Maps.cartesian,n},twirl:function(e,t,n,r){var a=this;return a.angle=e||0,a.radius=t||0,a.centerX=n||0,a.centerY=r||0,a._mapName="twirl",a._map=Maps.twirl,a},sphere:function(e,t,n){var r=this;return r.radius=e||0,r.centerX=t||0,r.centerY=n||0,r._mapName="sphere",r._map=Maps.sphere,r},ripple:function(e,t,n,r,a,i){var s=this;return s.radius=e!==undef?e:50,s.centerX=a||0,s.centerY=i||0,s.wavelength=t!==undef?t:16,s.amplitude=n!==undef?n:10,s.phase=r||0,s._mapName="ripple",s._map=Maps.ripple,s},shift:function(e,t){var n=this;return n.dx=e!==undef?e:0,n.dy=t!==undef?t:n.dx,n._mapName="shift",n._map=Maps.shift,n},reset:function(){var e=this;return e._mapName=null,e._map=null,e},getMap:function(){return this._map},setMap:function(e){var t=this;return t._mapName=null,t._map=e,t},_apply:function(e,t,n,r){var a=this;return a._isOn&&a._map?a._map(a,e,t,n,r):e},canRun:function(){return this._isOn&&this._map}});GeometricMapFilter.prototype.translate=GeometricMapFilter.prototype.shift,Maps={generic:function(e,t,n,r){var a,i,s,o,l,u,c,h=t.length,f=new IMG(h),d=e.inverseTransform,p=e.mode,m=FILTER.MODE.CLAMP,_=FILTER.MODE.WRAP;for(a=0,i=0,s=0;h>s;s+=4,a++){if(a>=n&&(a=0,i++),l=d([a,i],n,r),u=~~l[0],c=~~l[1],0>u||u>=n||0>c||c>=r)switch(p){case _:c>=r?c-=r:0>c&&(c+=r),u>=n?u-=n:0>u&&(u+=n);break;case m:default:c>=r?c=r-1:0>c&&(c=0),u>=n?u=n-1:0>u&&(u=0)}o=u+c*n<<2,f[s]=t[o],f[s+1]=t[o+1],f[s+2]=t[o+2],f[s+3]=t[o+3]}return f},affine:function(e,t,n,r){var a,i,s,o,l,u,c,h,f,d=t.length,p=d>>2,m=new IMG(d),_=e.matrix,g=_[0],v=_[1],y=_[3],w=_[4],C=_[2],A=_[5],b=e.mode,E=FILTER.MODE.CLAMP,R=FILTER.MODE.WRAP,I=n-1,M=p-n;for(a=0,i=0,l=A*n,u=y*n,c=w*n,s=0;d>s;s+=4,a++){if(a>=n&&(a=0,i++),h=~~(g*a+v*i+C),f=~~(u*a+c*i+l),0>h||h>I||0>f||f>M)switch(b){case R:f>M?f-=p:0>f&&(f+=p),h>=n?h-=n:0>h&&(h+=n);break;case E:default:f>M?f=M:0>f&&(f=0),h>I?h=I:0>h&&(h=0)}o=h+f<<2,m[s]=t[o],m[s+1]=t[o+1],m[s+2]=t[o+2],m[s+3]=t[o+3]}return m},shift:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u),h=-e.dx,f=-e.dy;for(0>h&&(h+=n),0>f&&(f+=r),a=0,i=0,s=0,o=0;u>o;o+=4,a++)a>=n&&(a=0,i++,s+=n),l=(a+h)%n+(i+f)%r*n<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},flipX:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u);for(a=0,i=0,s=0,o=0;u>o;o+=4,a++)a>=n&&(a=0,i++,s+=n),l=n-1-a+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},flipY:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u);for(a=0,i=0,s=(r-1)*n,o=0;u>o;o+=4,a++)a>=n&&(a=0,i++,s-=n),l=a+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},flipXY:function(e,t,n,r){var a,i,s,o,l,u,c=t.length,h=new IMG(c);for(a=0,i=0,o=(r-1)*n,l=0;c>l;l+=4,a++)a>=n&&(a=0,i++,s+=n,o-=n),u=n-1-a+o<<2,h[l]=t[u],h[l+1]=t[u+1],h[l+2]=t[u+2],h[l+3]=t[u+3];return h},rotateCW:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u),h=u>>2;for(a=0,i=0,s=h-1,o=0;u>o;o+=4,a++,s-=n)a>=n&&(a=0,s=h-1,i++),l=i+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},rotateCCW:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u);for(a=0,i=0,s=0,o=0;u>o;o+=4,a++,s+=n)a>=n&&(a=0,s=0,i++),l=n-1-i+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},twirl:function(e,t,n,r){if(0>=e.radius)return t;var a,i,s,o,l,u,c,h,f=t.length,d=new IMGcopy(t),p=e.centerX,m=e.centerY,_=e.angle,g=e.radius,v=e.mode,y=FILTER.MODE.CLAMP,w=FILTER.MODE.WRAP,C=_/g,A=n-1,b=r-1;for(p=Floor(p*(n-1)),m=Floor(m*(r-1)),a=0,i=0,s=0;f>s;s+=4,a++)if(a>=n&&(a=0,i++),u=a-p,c=i-m,l=Sqrt(u*u+c*c),g>l){if(h=Atan2(c,u)+C*(g-l),u=~~(p+l*Cos(h)),c=~~(m+l*Sin(h)),0>u||u>A||0>c||c>b)switch(v){case w:c>b?c-=r:0>c&&(c+=r),u>A?u-=n:0>u&&(u+=n);break;case y:default:c>b?c=b:0>c&&(c=0),u>A?u=A:0>u&&(u=0)}o=u+c*n<<2,t[s]=d[o],t[s+1]=d[o+1],t[s+2]=d[o+2],t[s+3]=d[o+3]}return t},sphere:function(e,t,n,r){if(0>=e.radius)return t;var a,i,s,o,l,u,c,h,f,d,p,m,_,g=t.length,v=new IMGcopy(t),y=e.centerX,w=e.centerY,C=e.radius,A=e.mode,b=FILTER.MODE.CLAMP,E=FILTER.MODE.WRAP,R=C*C,I=.555556,M=1-I,L=n-1,x=r-1;for(y=Floor(y*(n-1)),w=Floor(w*(r-1)),a=0,i=0,s=0;g>s;s+=4,a++)if(a>=n&&(a=0,i++),l=a-y,u=i-w,m=l*l,_=u*u,c=m+_,R>c){if(d=R-c,p=Sqrt(d),h=Asin(l/Sqrt(m+d))*M,f=Asin(u/Sqrt(_+d))*M,l=~~(a-p*Tan(h)),u=~~(i-p*Tan(f)),0>l||l>L||0>u||u>x)switch(A){case E:u>x?u-=r:0>u&&(u+=r),l>L?l-=n:0>l&&(l+=n);break;case b:default:u>x?u=x:0>u&&(u=0),l>L?l=L:0>l&&(l=0)}o=l+u*n<<2,t[s]=v[o],t[s+1]=v[o+1],t[s+2]=v[o+2],t[s+3]=v[o+3]}return t},ripple:function(e,t,n,r){if(0>=e.radius)return t;var a,i,s,o,l,u,c,h,f,d,p,m=t.length,_=new IMGcopy(t),g=FILTER.MODE.CLAMP,v=FILTER.MODE.WRAP,y=n-1,w=r-1,C=e.centerX,A=e.centerY,b=e.radius,E=e.mode,R=b*b,I=e.wavelength,M=e.amplitude,L=e.phase;for(C=Floor(C*(n-1)),A=Floor(A*(r-1)),a=0,i=0,s=0;m>s;s+=4,a++)if(a>=n&&(a=0,i++),u=a-C,c=i-A,d=u*u,p=c*c,f=d+p,R>f){if(l=Sqrt(f),h=M*Sin(l/I*Math.PI*2-L),h*=(b-l)/b,l&&(h*=I/l),u=~~(a+u*h),c=~~(i+c*h),0>u||u>y||0>c||c>w)switch(E){case v:c>w?c-=r:0>c&&(c+=r),u>y?u-=n:0>u&&(u+=n);break;case g:default:c>w?c=w:0>c&&(c=0),u>y?u=y:0>u&&(u=0)}o=u+c*n<<2,t[s]=_[o],t[s+1]=_[o+1],t[s+2]=_[o+2],t[s+3]=_[o+3]}return t},polar:function(e,t,n,r){var a,i,s,o,l,u,c,h,f,d,p,m,_=t.length,g=new IMGcopy(t),v=FILTER.MODE.CLAMP,y=FILTER.MODE.WRAP,w=n-1,C=r-1,A=0,b=e.mode;for(p=~~(.5*n+.5),m=~~(.5*r+.5),d=Max(m,p),a=0,i=0,s=0;_>s;s+=4,a++){if(a>=n&&(a=0,i++),o=a-p,l=i-m,f=0,o>=0?l>0?(f=PI-Atan(o/l),A=Sqrt(o*o+l*l)):0>l?(f=Atan(o/l),A=Sqrt(o*o+l*l)):(f=HalfPI,A=o):0>o&&(0>l?(f=DoublePI-Atan(o/l),A=Sqrt(o*o+l*l)):l>0?(f=PI+Atan(o/l),A=Sqrt(o*o+l*l)):(f=ThreePI2,A=-o)),u=n-1-(n-1)/DoublePI*f,c=r*A/d,u=Round(u),c=Round(c),0>u||u>w||0>c||c>C)switch(b){case y:c>C?c-=r:0>c&&(c+=r),u>w?u-=n:0>u&&(u+=n);break;case v:default:c>C?c=C:0>c&&(c=0),u>w?u=w:0>u&&(u=0)}h=u+c*n<<2,t[s]=g[h],t[s+1]=g[h+1],t[s+2]=g[h+2],t[s+3]=g[h+3]}return t},cartesian:function(e,t,n,r){var a,i,s,o,l,u,c,h,f,d,p,m,_,g=t.length,v=new IMGcopy(t),y=FILTER.MODE.CLAMP,w=FILTER.MODE.WRAP,C=n-1,A=r-1,b=0,E=e.mode;for(m=~~(.5*n+.5),_=~~(.5*r+.5),p=Max(_,m),a=0,i=0,s=0;g>s;s+=4,a++){if(a>=n&&(a=0,i++),f=a/n*DoublePI,d=f>=ThreePI2?DoublePI-f:f>=PI?f-PI:f>=HalfPI?PI-f:f,b=p*(i/r),c=-b*Sin(d),h=b*Cos(d),f>=ThreePI2?(o=m-c,l=_-h):f>=PI?(o=m-c,l=_+h):f>=HalfPI?(o=m+c,l=_+h):(o=m+c,l=_-h),o=Round(o),l=Round(l),0>o||o>C||0>l||l>A)switch(E){case w:l>A?l-=r:0>l&&(l+=r),o>C?o-=n:0>o&&(o+=n);break;case y:default:l>A?l=A:0>l&&(l=0),o>C?o=C:0>o&&(o=0)}u=o+l*n<<2,t[s]=v[u],t[s+1]=v[u+1],t[s+2]=v[u+2],t[s+3]=v[u+3]}return t}}}(FILTER),!function(e,t){function n(e,t,n,r){var a,i=e.length,s=new w(e.length);for(n=n||1,r=r||1,a=0;i>a;)s[a]=n*e[a]+r*t[a],a++;return s}function r(e,t){var n,r,a,i=e.length,s=[],o=0;for(n=0;i>n;n++)for(r=0;i>r;r++)a=e[n]*t[r],o+=a,s.push(a);return{kernel:s,sum:o}}function a(e){var t,n=new Array(e);for(t=0;e>t;)n[t]=1,t++;return n}function i(e){var t,n,r,a,i=R.length;if(e--,i>e)t=new w(R[e]);else for(t=new w(R[i-1]);e>=i;){for(n=t,t=new w(n.length+1),t[0]=1,r=0,a=n.length-1;a>r;r++)t[r+1]=n[r]+n[r+1];t[n.length]=1,40>i&&R.push(new Array(t)),i++}return t}function s(e){var t,n=e>>1,r=-n,a=new Array(e);for(t=0;e>t;)a[t]=r,r++,t++;return a}function o(e){var t=i(e);return r(t,t)}function l(e,t){var n=i(e),a=s(e);return 1==t?r(a.reverse(),n):r(n,a)}function u(e,t){var n=a(e),i=s(e);return 1==t?r(i.reverse(),n):r(n,i)}function c(e,t,n){t=t||1,n=n||t;var r,a=e*e,i=a>>1,s=new w(a);for(r=0;a>r;)s[r]=t,r++;return s[i]=n,s}function h(e,t,n,r){var a,i,s,o,l,u=e*e,c=e>>1,h=u>>1,f=new w(u);for(o=0,a=0;c>=a;a++){for(i=0,l=0,s=0;c>=s;s++)f[h+a+i]=o+l,f[h-a-i]=-o-l,f[h-a+i]=-o+l,f[h+a-i]=o-l,i+=e,l+=n;o+=t}return f[h]=r||1,f}function f(e,t,n,r){var a,i,s,o,l,u,c=e*e,h=e>>1,f=c>>1,d=new w(c),p=new w(c),m=1/e,g=1e-8;for(_(t)>g?(l=1,u=n/t):(l=t/n,u=1),a=0,s=0,o=0,i=u*e;h>=a;)p[f+a]=~~(f+s+o+.5),p[f-a]=~~(f-s-o+.5),a++,s+=l,o+=i;for(a=0;h>=a;)d[p[f+a]]=d[p[f-a]]=m,a++;return d[f]=r||1,d}function d(e,t,n,r,a,i,s,o,l,u){var c,h,f,d,p,m,_,g,v,y,w,b,R,I,M,L,x,N,S,T,O,F,D,P,k,G,H,U,X,B,Y,W,q,z,$,j,K,J,V,Q,Z,ee,te,ne,re,ae,ie,se=e.length,oe=se>>2,le=i,ue=s;if(g=le*ue,m=le>>1,_=t*(ue>>1),w=-m-1,R=-_-t,b=m,I=_,B=0,W=t-1,Y=0,q=oe-t,h=(oe<<1)+oe,y=(t<<1)+t,u=u||1,ie=0,a)for(T=r[0],O=r[g>>1],F=O-T,D=a[0],P=a[g>>1],k=P-D;u>ie;){for(v=new C(se),c=new A(h),M=0,L=0,f=d=p=0,x=0;t>x;x++,M+=4,L+=3)f+=e[M],d+=e[M+1],p+=e[M+2],c[L]=f,c[L+1]=d,c[L+2]=p;for(L=0,x=0,f=d=p=0,M=y+t;se>M;M+=4,L+=3,x++)x>=t&&(x=0,f=d=p=0),f+=e[M],d+=e[M+1],p+=e[M+2],c[L+y]=c[L]+f,c[L+y+1]=c[L+1]+d,c[L+y+2]=c[L+2]+p;for(x=0,N=0,S=0,M=0;se>M;M+=4,x++)x>=t&&(x=0,N++,S+=t),G=x+w,H=S+R,U=x+b,X=S+I,G=B>G?B:G,U=U>W?W:U,H=Y>H?Y:H,X=X>q?q:X,z=G+H,K=U+X,$=U+H,j=G+X,z=(z<<1)+z,$=($<<1)+$,j=(j<<1)+j,K=(K<<1)+K,Z=T*(c[K]-c[$]-c[j]+c[z])+F*e[M],ee=T*(c[K+1]-c[$+1]-c[j+1]+c[z+1])+F*e[M+1],te=T*(c[K+2]-c[$+2]-c[j+2]+c[z+2])+F*e[M+2],ne=D*(c[K]-c[$]-c[j]+c[z])+k*e[M],re=D*(c[K+1]-c[$+1]-c[j+1]+c[z+1])+k*e[M+1],ae=D*(c[K+2]-c[$+2]-c[j+2]+c[z+2])+k*e[M+2],J=o*Z+l*ne,V=o*ee+l*re,Q=o*te+l*ae,E&&(J=0>J?0:J>255?255:J,V=0>V?0:V>255?255:V,Q=0>Q?0:Q>255?255:Q),v[M]=~~J,v[M+1]=~~V,v[M+2]=~~Q,v[M+3]=e[M+3];e=v,ie++}else for(T=r[0],O=r[g>>1],F=O-T;u>ie;){for(v=new C(se),c=new A(h),M=0,L=0,f=d=p=0,x=0;t>x;x++,M+=4,L+=3)f+=e[M],d+=e[M+1],p+=e[M+2],c[L]=f,c[L+1]=d,c[L+2]=p;for(L=0,x=0,f=d=p=0,M=y+t;se>M;M+=4,L+=3,x++)x>=t&&(x=0,f=d=p=0),f+=e[M],d+=e[M+1],p+=e[M+2],c[L+y]=c[L]+f,c[L+y+1]=c[L+1]+d,c[L+y+2]=c[L+2]+p;for(x=0,N=0,S=0,M=0;se>M;M+=4,x++)x>=t&&(x=0,N++,S+=t),G=x+w,H=S+R,U=x+b,X=S+I,G=B>G?B:G,U=U>W?W:U,H=Y>H?Y:H,X=X>q?q:X,z=G+H,K=U+X,$=U+H,j=G+X,z=(z<<1)+z,$=($<<1)+$,j=(j<<1)+j,K=(K<<1)+K,Z=T*(c[K]-c[$]-c[j]+c[z])+F*e[M],ee=T*(c[K+1]-c[$+1]-c[j+1]+c[z+1])+F*e[M+1],te=T*(c[K+2]-c[$+2]-c[j+2]+c[z+2])+F*e[M+2],J=o*Z+l,V=o*ee+l,Q=o*te+l,E&&(J=0>J?0:J>255?255:J,V=0>V?0:V>255?255:V,Q=0>Q?0:Q>255?255:Q),v[M]=~~J,v[M+1]=~~V,v[M+2]=~~Q,v[M+3]=e[M+3];e=v,ie++}return v}function p(e,t,n,r,a,i,s,o,l){var u,c,h,f,d,p,m,_,g,v,y,w,A,R,I,M,L,x,N,S,T,O,F,D,P,k,G,H=e.length,U=H>>2;for(u=[a,r],c=[s,i],P=[l,o],M=t-1,L=U-t,G=2;G--;){for(m=new C(H),f=u[G],d=c[G],h=f.length,p=d.length,k=P[G],_=new b(d),y=0;p>y;y+=2)_[y+1]*=t;if(E)for(w=0,A=0,g=0;H>g;g+=4,w++){for(w>=t&&(w=0,A+=t),O=0,F=0,D=0,y=0,v=0;h>y;y++,v+=2)R=w+_[v],I=A+_[v+1],R>=0&&M>=R&&I>=0&&L>=I&&(srcOff=R+I<<2,T=f[y],O+=e[srcOff]*T,F+=e[srcOff+1]*T,D+=e[srcOff+2]*T);x=k*O,N=k*F,S=k*D,x=0>x?0:x>255?255:x,N=0>N?0:N>255?255:N,S=0>S?0:S>255?255:S,m[g]=~~x,m[g+1]=~~N,m[g+2]=~~S,m[g+3]=e[g+3]}else for(w=0,A=0,g=0;H>g;g+=4,w++){for(w>=t&&(w=0,A+=t),O=0,F=0,D=0,y=0,v=0;h>y;y++,v+=2)R=w+_[v],I=A+_[v+1],R>=0&&M>=R&&I>=0&&L>=I&&(srcOff=R+I<<2,T=f[y],O+=e[srcOff]*T,F+=e[srcOff+1]*T,D+=e[srcOff+2]*T);x=k*O,N=k*F,S=k*D,m[g]=~~x,m[g+1]=~~N,m[g+2]=~~S,m[g+3]=e[g+3]}e=m}return m}var m=(e.CONST.SQRT2,e.CONST.toRad),_=(e.CONST.toDeg,Math.abs),g=Math.sqrt,v=Math.sin,y=Math.cos,w=e.Array32F,C=e.ImArray,A=e.Array32F,b=e.Array16I,E=(e.Array8U,e._notSupportClamp),R=[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1],[1,5,10,10,5,1],[1,6,15,20,15,6,1],[1,7,21,35,35,21,7,1],[1,8,28,56,70,56,28,8,1]],I=e.ConvolutionMatrixFilter=e.Class(e.Filter,{name:"ConvolutionMatrixFilter",constructor:function(t,n,r){var a=this;a.$super("constructor"),a._coeff=new w([1,0]),t&&t.length?a.set(t,~~(g(t.length)+.5),n||1,r||0):(a._matrix=null,a._dim=0),a._matrix2=null,a._dim2=0,a._isGrad=!1,a._doIntegral=0,a._doSeparable=!1,e.useWebGL&&(a._webglInstance=e.WebGLConvolutionMatrixFilterInstance||null)},_dim:0,_dim2:0,_matrix:null,_matrix2:null,_mat:null,_mat2:null,_coeff:null,_isGrad:!1,_doIntegral:0,_doSeparable:!1,_indices:null,_indices2:null,_indicesf:null,_indicesf2:null,_webglInstance:null,dispose:function(){var e=this;return e.$super("dispose"),e._webglInstance=null,e._dim=null,e._dim2=null,e._matrix=null,e._matrix2=null,e._mat=null,e._mat2=null,e._coeff=null,e._isGrad=null,e._doIntegral=null,e._doSeparable=null,e._indices=null,e._indices2=null,e._indicesf=null,e._indicesf2=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_dim:e._dim,_dim2:e._dim2,_matrix:e._matrix,_matrix2:e._matrix2,_mat:e._mat,_mat2:e._mat2,_coeff:e._coeff,_isGrad:e._isGrad,_doIntegral:e._doIntegral,_doSeparable:e._doSeparable,_indices:e._indices,_indices2:e._indices2,_indicesf:e._indicesf,_indicesf2:e._indicesf2}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n._dim=t._dim,n._dim2=t._dim2,n._matrix=t._matrix,n._matrix2=t._matrix2,n._mat=t._mat,n._mat2=t._mat2,n._coeff=t._coeff,n._isGrad=t._isGrad,n._doIntegral=t._doIntegral,n._doSeparable=t._doSeparable,n._indices=t._indices,n._indices2=t._indices2,n._indicesf=t._indicesf,n._indicesf2=t._indicesf2),n},lowPass:function(e){return e=e===t?3:e%2?e:e+1,this.set(c(e),e,1/(e*e),0),this._doIntegral=1,this},highPass:function(e,n){e=e===t?3:e%2?e:e+1,n=n===t?1:n;var r=e*e,a=-n/r,i=c(e,a,1+a);return this.set(i,e,1,0),this._doIntegral=1,this},glow:function(e,n){return e=e===t?.5:e,this.highPass(n,-e)},sharpen:function(e,n){return e=e===t?.5:e,this.highPass(n,e)},verticalBlur:function(e){return e=e===t?3:e%2?e:e+1,this.set(a(e),1,1/e,0),this._dim2=e,this._doIntegral=1,this},horizontalBlur:function(e){return e=e===t?3:e%2?e:e+1,this.set(a(e),e,1/e,0),this._dim2=1,this._doIntegral=1,this},directionalBlur:function(e,n){n=n===t?3:n%2?n:n+1,e*=m;var r=y(e),a=-v(e),i=f(n,r,a,1/n);return this.set(i,n,1,0)},fastGauss:function(e,n){return n=n===t?3:n%2?n:n+1,e=~~(e||1),1>e?e=1:e>3&&(e=3),this.set(c(n),n,1/(n*n),0),this._doIntegral=e,this},binomialLowPass:function(e){e=e===t?3:e%2?e:e+1;var n=i(e),r=1<>1;for(r=0,a=0,n=0;l>n;)s.push(r-c),s.push(a-c),e[n]&&(i.push(r-c),i.push(a-c),o.push(e[n])),n++,r++,r>=u&&(r=0,a++);return[new b(i),new b(s),new w(o)]},reset:function(){var e=this;return e._matrix=e._matrix2=null,e._mat=e._mat2=null,e._dim=e._dim2=0,e._indices=e._indices2=e._indicesf=e._indicesf2=null,e._isGrad=!1,e._doIntegral=0,e._doSeparable=!1,e},combineWith:function(e){return this},getMatrix:function(){return this._matrix},setMatrix:function(e,t){return this.set(e,t)},_apply:function(e,t,n){var r=this;if(!r._isOn||!r._matrix)return e;if(r._doIntegral)return r._matrix2?d(e,t,n,r._matrix,r._matrix2,r._dim,r._dim2,r._coeff[0],r._coeff[1],r._doIntegral):d(e,t,n,r._matrix,null,r._dim,r._dim,r._coeff[0],r._coeff[1],r._doIntegral);if(r._doSeparable)return p(e,t,n,r._mat,r._mat2,r._indices,r._indices2,r._coeff[0],r._coeff[1]);var a,i,s,o,l,u,c,h,f,m,g,v,y,w,A,R,I,M,L,x,N,S,T=e.length,O=T>>2,F=new C(T),D=t-1,P=O-t,k=r._coeff[0],G=r._coeff[1],H=r._matrix,U=r._matrix2,X=r._isGrad;if(U){for(x=r._indicesf.length,S=new b(r._indicesf),u=0;x>u;u+=2)S[u+1]*=t;for(N=H.length,c=0,h=0,o=0;T>o;o+=4,c++){for(c>=t&&(c=0,h+=t),v=0,y=0,w=0,A=0,R=0,I=0,u=0,l=0;N>u;u++,l+=2)f=c+S[l],m=h+S[l+1],f>=0&&D>=f&&m>=0&&P>=m&&(g=f+m<<2,M=H[u],v+=e[g]*M,y+=e[g+1]*M,w+=e[g+2]*M,L=U[u],A+=e[g]*L,R+=e[g+1]*L,I+=e[g+2]*L);X?(a=_(v)+_(A),i=_(y)+_(R),s=_(w)+_(I)):(a=k*v+G*A,i=k*y+G*R,s=k*w+G*I),E&&(a=0>a?0:a>255?255:a,i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s),F[o]=~~a,F[o+1]=~~i,F[o+2]=~~s,F[o+3]=e[o+3]}}else{for(x=r._indices.length,S=new b(r._indices),u=0;x>u;u+=2)S[u+1]*=t;for(H=r._mat,N=H.length,c=0,h=0,o=0;T>o;o+=4,c++){for(c>=t&&(c=0,h+=t),v=0,y=0,w=0,u=0,l=0;N>u;u++,l+=2)f=c+S[l],m=h+S[l+1],f>=0&&D>=f&&m>=0&&P>=m&&(g=f+m<<2,M=H[u],v+=e[g]*M,y+=e[g+1]*M,w+=e[g+2]*M);a=k*v+G,i=k*y+G,s=k*w+G,E&&(a=0>a?0:a>255?255:a,i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s),F[o]=~~a,F[o+1]=~~i,F[o+2]=~~s,F[o+3]=e[o+3]}}return F},canRun:function(){return this._isOn&&this._matrix}});I.prototype.bump=I.prototype.emboss,I.prototype.boxBlur=I.prototype.lowPass,I.prototype.gaussBlur=I.prototype.binomialLowPass,I.prototype.gradX=I.prototype.prewittX,I.prototype.gradY=I.prototype.prewittY,I.prototype.gradDirectional=I.prototype.prewittDirectional,I.prototype.grad=I.prototype.prewitt}(FILTER),!function(e,t){var n,r=e.ImArray,a=e.Array8U,i=e.Array32I,s=Math.sqrt,o=function(e){var t,n=e*e,r=new a(n);for(t=0;n>t;t++)r[t]=1;return r},l=o(3);e.MorphologicalFilter=e.Class(e.Filter,{name:"MorphologicalFilter",constructor:function(){var e=this;e.$super("constructor"),e._filterName=null,e._filter=null,e._dim=0,e._structureElement=null,e._indices=null},_filterName:null,_filter:null,_dim:0,_structureElement:null,_indices:null,dispose:function(){var e=this;return e.$super("dispose"),e._filterName=null,e._filter=null,e._dim=null,e._structureElement=null,e._indices=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_filterName:e._filterName,_dim:e._dim,_structureElement:e._structureElement,_indices:e._indices}}},unserialize:function(e){var t,r=this;return e&&r.name===e.filter&&(r._isOn=!!e._isOn,t=e.params,r._dim=t._dim,r._structureElement=t._structureElement,r._indices=t._indices,r._filterName=t._filterName,r._filterName&&n[r._filterName]&&(r._filter=n[r._filterName])),r},erode:function(e){return this.set(e,"erode")},dilate:function(e){return this.set(e,"dilate")},opening:function(e){return this.set(e,"open")},closing:function(e){return this.set(e,"close")},set:function(e,t){var r=this;r._filterName=t,r._filter=n[t],e&&e.length?(r._structureElement=new a(e),r._dim=~~(s(r._structureElement.length)+.5)):e&&e===e-0?(r._structureElement=o(e),r._dim=e):(r._structureElement=l,r._dim=3);var u,c,h,f=[],e=r._structureElement,d=e.length,p=r._dim,m=p>>1;for(c=0,h=0,u=0;d>u;)e[u]&&(f.push(c-m),f.push(h-m)),u++,c++,c>=p&&(c=0,h++);return r._indices=new i(f),r},reset:function(){var e=this;return e._filterName=null,e._filter=null,e._dim=0,e._structureElement=null,e._indices=null,e},_apply:function(e,t,n){var r=this;return r._isOn&&r._dim&&r._filter?r._filter(r,e,t,n):e},canRun:function(){return this._isOn&&this._dim&&this._filter}});n={dilate:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=0,v=0,y=0,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],p>g&&(g=p),m>v&&(v=m),_>y&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E},erode:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E},open:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}for(t=E,E=new r(A),u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E},close:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}for(t=E,E=new r(A),u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E}}}(FILTER),!function(e,t){var n,r=e.ImArray,a=e.Array32I,i=(Math.min,Math.max,e.StatisticalFilter=e.Class(e.Filter,{name:"StatisticalFilter",constructor:function(){var e=this;e.$super("constructor"),e._dim=0,e._indices=null,e._filterName=null,e._filter=null},_dim:0,_indices:null,_filter:null,_filterName:null,dispose:function(){var e=this;return e.$super("dispose"),e._dim=null,e._indices=null,e._filter=null,e._filterName=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_filterName:e._filterName,_dim:e._dim,_indices:e._indices}}},unserialize:function(e){var t,r=this;return e&&r.name===e.filter&&(r._isOn=!!e._isOn,t=e.params,r._dim=t._dim,r._indices=t._indices,r._filterName=t._filterName,r._filterName&&n[r._filterName]&&(r._filter=n[r._filterName])),r},median:function(e){return e=e===t?3:e%2?e:e+1,this.set(e,"median")},minimum:function(e){return e=e===t?3:e%2?e:e+1,this.set(e,"minimum")},maximum:function(e){return e=e===t?3:e%2?e:e+1,this.set(e,"maximum")},set:function(e,t){var r=this;r._filterName=t,r._filter=n[t],r._dim=e;var i,s,o,l=[],u=e*e,c=e,h=c>>1;for(s=0,o=0,i=0;u>i;)l.push(s-h),l.push(o-h),i++,s++,s>=c&&(s=0,o++);return r._indices=new a(l),r},reset:function(){var e=this;return e._filterName=null,e._filter=null,e._dim=0,e._indices=null,e},_apply:function(e,t,n){var r=this;return r._isOn&&r._dim?r._filter(r,e,t,n):e},canRun:function(){return this._isOn&&this._dim}}));i.prototype.erode=i.prototype.minimum,i.prototype.dilate=i.prototype.maximum,n={median:function(e,t,n,i){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E=e._dim,R=E*E,I=new a(e._indices),M=t.length,L=M>>2,x=new r(M),N=R<<1,S=n-1,T=L-n;for(d=[],p=[],m=[],o=0;N>o;o+=2)I[o+1]*=n;for(s=0,l=0,u=0;M>s;){for(d.length=0,p.length=0,m.length=0,o=0;N>o;)c=l+I[o],h=u+I[o+1],c>=0&&S>=c&&h>=0&&T>=h&&(f=c+h<<2,_=t[f],g=t[f+1],v=t[f+2],d.push(_),p.push(g),m.push(v)),o+=2;d.sort(),p.sort(),m.sort(),A=d.length,b=A>>1,y=A%2?d[b+1]:~~(.5*(d[b]+d[b+1])),A=p.length,b=A>>1,w=A%2?p[b+1]:~~(.5*(p[b]+p[b+1])),A=m.length,b=A>>1,C=A%2?m[b+1]:~~(.5*(m[b]+m[b+1])),x[s]=y,x[s+1]=w,x[s+2]=C,x[s+3]=t[s+3],s+=4,l++,l>=n&&(l=0,u+=n)}return x},maximum:function(e,t,n,i){var s,o,l,u,c,h,f,d,p,m,_,g,v,y=e._dim,w=y*y,C=new a(e._indices),A=t.length,b=A>>2,E=new r(A),R=w<<1,I=n-1,M=b-n;for(o=0;R>o;o+=2)C[o+1]*=n;for(s=0,l=0,u=0;A>s;){for(_=0,g=0,v=0,o=0;R>o;)c=l+C[o],h=u+C[o+1],c>=0&&I>=c&&h>=0&&M>=h&&(f=c+h<<2,d=t[f],p=t[f+1],m=t[f+2],d>_&&(_=d),p>g&&(g=p),m>v&&(v=m)),o+=2;E[s]=_,E[s+1]=g,E[s+2]=v,E[s+3]=t[s+3],s+=4,l++,l>=n&&(l=0,u+=n)}return E},minimum:function(e,t,n,i){var s,o,l,u,c,h,f,d,p,m,_,g,v,y=e._dim,w=y*y,C=new a(e._indices),A=t.length,b=A>>2,E=new r(A),R=w<<1,I=n-1,M=b-n;for(o=0;R>o;o+=2)C[o+1]*=n;for(s=0,l=0,u=0;A>s;){for(_=255,g=255,v=255,o=0;R>o;)c=l+C[o],h=u+C[o+1],c>=0&&I>=c&&h>=0&&M>=h&&(f=c+h<<2,d=t[f],p=t[f+1],m=t[f+2],_>d&&(_=d),g>p&&(g=p),v>m&&(v=m)),o+=2;E[s]=_,E[s+1]=g,E[s+2]=v,E[s+3]=t[s+3],s+=4,l++,l>=n&&(l=0,u+=n)}return E}}}(FILTER),!function(e,t){function n(e){var t,n;for(e>0&&1>e&&(e*=65536),e=u(e),256>e&&(e|=e<<8),n=0;256>n;n++)t=1&n?h[n]^255&e:h[n]^e>>8&255, -f[n]=f[n+256]=t}function r(e,t,n){var r=7&e,a=4>r?t:n,i=4>r?n:t;return(1&r?-a:a)+(2&r?-2*i:2*i)}function a(e,t){var n,a,i,s,o,l=.366025403,c=.211324865,h=(e+t)*l,d=e+h,p=t+h,m=u(d),_=u(p),g=(m+_)*c,v=m-g,y=_-g,w=e-v,C=t-y;w>C?(s=1,o=0):(s=0,o=1);var A=w-s+c,b=C-o+c,E=w-1+2*c,R=C-1+2*c,I=255&m,M=255&_,L=.5-w*w-C*C;0>L?n=0:(L*=L,n=L*L*r(f[I+f[M]],w,C));var x=.5-A*A-b*b;0>x?a=0:(x*=x,a=x*x*r(f[I+s+f[M+o]],A,b));var N=.5-E*E-R*R;return 0>N?i=0:(N*=N,i=N*N*r(f[I+1+f[M+1]],E,R)),40*(n+a+i)}function i(e){return e*e*e*(e*(6*e-15)+10)}function s(e,t,n){return t+e*(n-t)}function o(e,t){var n,a,o,l,c,h,d,p,m,_,g,v,y,w;return n=u(e),a=u(t),c=e-n,h=t-a,d=c-1,p=h-1,o=n+1&255,l=a+1&255,n=255&n,a=255&a,_=i(h),m=i(c),g=r(f[n+f[a]],c,h),v=r(f[n+f[l]],c,p),y=s(_,g,v),g=r(f[o+f[a]],d,h),v=r(f[o+f[l]],d,p),w=s(_,g,v),.507*s(m,y,w)}function l(e,t,n,r,a,i,s,o,l,u,c){var h,f,d,p=0,m=u,_=1,g=0;for(h=0;o>h;h++)f=(t+l[h][0])%r,d=(n+l[h][1])%a,p+=e(m*f*i,m*d*s)*_,m*=2,g+=_,_*=c;return p/g}var u=Math.floor,c=(Math.sin,Math.cos,e.CONST.PI2,e.Array8U),h=new c([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,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 c(h);e.PerlinNoise={seed:n,Image:function(t,n,r,i,s,u,c,h,f,d){var p,m,_,g,v,y,w=(new e.Image).restorable(!1).fill("rgb(0,0,0)",0,0,n,r),C=1/i,A=1/s,b=d?o:a,n=w.width,r=w.height,E=w.getData(),R=E.length,I=n>>>1,M=r>>>1;if(h=h||1,f=f||.5,u=u||1,c=c||[[0,0]],t)for(p=0,m=0,v=0;R>v;v+=4,p++)p>=n&&(p=0,m++),_=p>I?n-1-p:p,g=m>M?r-1-m:m,p>_||m>g?(y=g*n+_<<2,E[v]=E[y],E[v+1]=E[y+1],E[v+2]=E[y+2]):(E[v]=~~(255*(.5*l(b,_,g,n,r,C,A,u,c,h,f)+.5)),E[v+1]=E[v],E[v+2]=E[v]);else for(p=0,m=0,v=0;R>v;v+=4,p++)p>=n&&(p=0,m++),E[v]=~~(255*(.5*l(b,_,g,n,r,C,A,u,c,h,f)+.5)),E[v+1]=E[v],E[v+2]=E[v];return w.setData(E),w}}}(FILTER),FILTER}); \ No newline at end of file +t===i&&(i=u),a&&!d&&i&&!p&&c.createImageData(a,i);var m=c.ictx,_=c.octx;return e=e||0,c._restorable&&(m.fillStyle=e,m.fillRect(n,r,a,i)),_.fillStyle=e,_.fillRect(n,r,a,i),c._needsRefresh|=M|w|C|A,h&&(c._needsRefresh|=I),c},getData:function(){var e,t=this;return t._restorable?(t._needsRefresh&_&&a(t,_),e=t.iData):(t._needsRefresh&g&&a(t,g),e=t.oData),new u(e.data)},getSelectedData:function(){var e,t=this;return t.selection?t._restorable?(t._needsRefresh&v&&i(t,v),e=t.iDataSel):(t._needsRefresh&y&&i(t,y),e=t.oDataSel):t._restorable?(t._needsRefresh&_&&a(t,_),e=t.iData):(t._needsRefresh&g&&a(t,g),e=t.oData),[new u(e.data),e.width,e.height]},getProcessedData:function(){var e=this;return e._needsRefresh&g&&a(e,g),new u(e.oData.data)},getProcessedSelectedData:function(){var e,t=this;return t.selection?(t._needsRefresh&y&&i(t,y),e=t.oDataSel):(t._needsRefresh&g&&a(t,g),e=t.oData),[new u(e.data),e.width,e.height]},setData:function(e){var t=this;return t._needsRefresh&g&&a(t,g),t.oData.data.set(e),t.octx.putImageData(t.oData,0,0),t._needsRefresh|=w|C|A,t.selection&&(t._needsRefresh|=y),t},setSelectedData:function(e){var t=this;if(t.selection){var n=t.selection,r=t.width-1,s=t.height-1,o=f(n[0]*r),l=f(n[1]*s);t._needsRefresh&y&&i(t,y),t.oDataSel.data.set(e),t.octx.putImageData(t.oDataSel,o,l),t._needsRefresh|=g}else t._needsRefresh&g&&a(t,g),t.oData.data.set(e),t.octx.putImageData(t.oData,0,0);return t._needsRefresh|=w|C|A,t},createImageData:function(e,t){var n,a,i=this;return r(i,e,t,R),i._restorable&&(n=i.ictx=i.iCanvas.getContext("2d"),n.createImageData(e,t)),a=i.octx=i.oCanvas.getContext("2d"),a.createImageData(e,t),i._needsRefresh|=M,i.selection&&(i._needsRefresh|=I),i},image:function(e){if(!e)return this;var t,n,i,s,o,l,u,c=this;return e instanceof S&&(e=e.oCanvas),o=e instanceof HTMLVideoElement,l=e instanceof HTMLCanvasElement||e instanceof h,u=e instanceof Image,o?(i=e.videoWidth,s=e.videoHeight):(i=e.width,s=e.height),u||l||o?(r(c,i,s,R),c._restorable&&(t=c.ictx=c.iCanvas.getContext("2d"),t.drawImage(e,0,0)),n=c.octx=c.oCanvas.getContext("2d"),n.drawImage(e,0,0),c._needsRefresh|=M):(c.oData||(c.createImageData(i,s),a(c,M)),c._restorable&&(t=c.ictx=c.iCanvas.getContext("2d"),c.iData.data.set(e.data),t.putImageData(c.iData,0,0)),n=c.octx=c.oCanvas.getContext("2d"),c.oData.data.set(e.data),n.putImageData(c.oData,0,0)),c._needsRefresh|=w|C|A,c.selection&&(c._needsRefresh|=I),c},getPixel:function(e,t){var n=this;n._needsRefresh&g&&a(n,g);var r=~~(t*n.width+e+.5)<<2,i=n.oData.data;return{r:i[r],g:i[r+1],b:i[r+2],a:i[r+3]}},setPixel:function(e,t,n,r,a,i){var s=this;return s.octx.putImageData(new l([255&n,255&r,255&a,255&i]),e,t),s._needsRefresh|=g|w|C|A,s.selection&&(s._needsRefresh|=y),s},getPixelData:function(){return this._needsRefresh&g&&a(this,g),this.oData},setPixelData:function(e){var t=this;return t.octx.putImageData(e,0,0),t._needsRefresh|=g|w|C|A,t.selection&&(t._needsRefresh|=y),t},integral:function(){var e=this;return e._needsRefresh&C&&(e._integral=S.integral(e.getPixelData().data,e.width,e.height,e._grayscale),e._needsRefresh&=N),e._integral},histogram:function(){var e=this;return e._needsRefresh&w&&(e._histogram=S.histogram(e.getPixelData().data,e.width,e.height,e._grayscale),e._needsRefresh&=x),e._histogram},spectrum:function(){var e=this;return e._spectrum},toImage:function(e){var t,n=this.oCanvas,r=1;if(t=e&d.JPG?n.toDataURL(p.JPG,r):e&d.GIF?n.toDataURL(p.GIF,r):n.toDataURL(p.PNG,r),e&d.IMAGE){var a=new Image;return a.src=t,a}return t},toString:function(){return"[FILTER Image: "+this.name+"]"}});S[s].setImage=S[s].image,S[s].setDimensions=S[s].dimensions,S.scale=S.resize=e.Interpolation.bilinear,S.crop=e.Interpolation.crop,S.pad=e.Interpolation.pad,S.integral=e.Math.integral,S.histogram=e.Math.histogram,S.spectrum=e.Math.spectrum;var T=e.ScaledImage=e.Class(S,{name:"ScaledImage",constructor:function F(e,t,n){var r=this;return r instanceof F?(r.scaleX=e||1,r.scaleY=t||r.scaleX,void r.$super("constructor",n)):new F(e,t,n)},scaleX:1,scaleY:1,dispose:function(){var e=this;return e.scaleX=null,e.scaleY=null,e.$super("dispose"),e},clone:function(e){var t=this;return new T(t.scaleX,t.scaleY,!0===e?t.iCanvas:t.oCanvas)},setScale:function(e,t){var n=this,r=arguments.length;return r>0&&null!=e&&(n.scaleX=e,n.scaleY=e),r>1&&null!=t&&(n.scaleY=t),n},image:function(e){if(!e)return this;var t,n,a,i,s,o,l,u,c,f=this,d=f.scaleX,p=f.scaleY;return e instanceof S&&(e=e.oCanvas),l=e instanceof HTMLVideoElement,u=e instanceof HTMLCanvasElement||e instanceof h,c=e instanceof Image,l?(a=e.videoWidth,i=e.videoHeight):(a=e.width,i=e.height),(c||u||l)&&(s=~~(d*a+.5),o=~~(p*i+.5),r(f,s,o,R),f._restorable&&(t=f.ictx=f.iCanvas.getContext("2d"),t.drawImage(e,0,0,a,i,0,0,s,o)),n=f.octx=f.oCanvas.getContext("2d"),n.drawImage(e,0,0,a,i,0,0,s,o),f._needsRefresh|=M|w|C|A,f.selection&&(f._needsRefresh|=I)),f}});T[s].setImage=T[s].image}(FILTER),!function(e,t){function n(e,t,n){var r="";if(!e)return xhr?xhr:r;var a,l,u,c,h,f=s(e);if(n){for(l=0,u=f.length;u>l;l++)a=f[l],n.setHeader(a,e[a]);return n}if(t){for(l=0,u=f.length;u>l;l++)if(a=f[l],"[object Array]"===i.call(e[a]))for(c=0,h=e[a].length;h>c;c++)t.setRequestHeader(a,String(e[a][c]));else t.setRequestHeader(a,String(e[a]));return t}for(l=0,u=f.length;u>l;l++)if(a=f[l],"[object Array]"===i.call(e[a]))for(r.length&&(r+=o),r+=a+": "+String(e[a][0]),c=1,h=e[a].length;h>c;c++)r+=o+String(e[a][c]);else r.length&&(r+=o),r+=a+": "+String(e[a]);return r}function r(e,t){var n,r,i,s,l={},c=null;if(e)for(t=!0===t,e=e.split(o),r=0,i=e.length;i>r;r++)s=e[r],n=s.split(":"),n.length>1?(c=u(n.shift()),t&&(c=c.toLowerCase()),l[a](c)?("string"==typeof l[c]&&(l[c]=[l[c]]),l[c].push(u(n.join(":")))):l[c]=u(n.join(":"))):n[0].length&&c&&(l[c]=o+n[0]);return l}var a="hasOwnProperty",i=Object.prototype.toString,s=Object.keys,o="\r\n",l=/^\s+|\s+$/g,u=String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(l,"")},c=e.Image,h=e.Class,f=e.Loader=h({name:"Loader",__static__:{load:e.Method(function(e,t,n){return function(e,t,r){return(new n).load(e,t,r)}},e.LATE|e.STATIC)},constructor:function(){},_crossOrigin:null,_responseType:null,dispose:function(){var e=this;return e._crossOrigin=null,e._responseType=null,e},load:function(e,t,n){return null},responseType:function(e){var t=this;return arguments.length?(t._responseType=e,t):t._responseType},crossOrigin:function(e){var t=this;return arguments.length?(t._crossOrigin=e,t):t._crossOrigin}}),d=e.XHR=function m(e,t){var n=this,r=!1;n.readyState=m.UNSENT,n.status=null,n.statusText=null,n.responseType="text",n.responseURL=null,n.response=null,n.responseText=null,n.responseXml=null,n._rawHeaders=null,n._headers=null,n.send=function(t){return r||m.UNSENT!==n.readyState?n:(e&&e(t),n.readyState=m.OPENED,n)},n.abort=function(){return r?n:(r=!0,t&&t(),n)},n.getAllResponseHeaders=function(e){return m.DONE!==n.readyState?null:!0===e?n._headers:n._rawHeaders},n.getResponseHeader=function(e,t){if(null==e||m.DONE!==n.readyState)return null;var r=n._headers||{};return!1!==t&&(e=e.toLowerCase()),r[a](e)?r[e]:null},n.dispose=function(){return n.readyState=null,n.status=null,n.statusText=null,n.responseType=null,n.responseURL=null,n.response=null,n.responseText=null,n.responseXml=null,n._rawHeaders=null,n._headers=null,n.getAllResponseHeaders=null,n.getResponseHeader=null,n.send=null,n.abort=null,n}};d.UNSENT=0,d.OPENED=1,d.HEADERS_RECEIVED=2,d.LOADING=3,d.DONE=4,d.create=e.Browser.isNode?function(e,t){if(e=e||{},!e.url)return null;var r,a,s="[object Object]"===i.call(e.url)?e.url:require("url").parse(e.url),o={method:e.method||"GET",agent:!1,protocol:s.protocol,host:s.hostname,hostname:s.hostname,port:s.port||80,path:(s.pathname||"/")+(s.query?"?"+s.query:"")};return a=new d(function(e){null!=e&&(e=String(e),r.setHeader("Content-Length",String(e.length)),r.write(e)),r.end()},function(){r.abort()}),r=("https:"===o.protocol?require("https").request:require("http").request)(o,function(t){var n="",r=0;a.readyState=d.OPENED,e.onStateChange&&e.onStateChange(a),a.readyState=d.HEADERS_RECEIVED,a._rawHeaders=t.rawHeaders.join("\r\n"),a._headers=t.headers,a.responseURL=t.url||null,a.status=t.statusCode||null,a.statusText=t.statusMessage||null,e.onStateChange&&e.onStateChange(a),t.on("data",function(t){r||(r=1,a.readyState=d.LOADING,e.onStateChange&&e.onStateChange(a),e.onLoadStart&&e.onLoadStart(a)),n+=t.toString(),e.onProgress&&e.onProgress(a)}),t.on("end",function(){a.readyState=d.DONE,a.responseType="text",a.response=a.responseText=n,e.onStateChange&&e.onStateChange(a),e.onLoadEnd&&e.onLoadEnd(a),d.DONE===a.readyState&&(200===a.status?e.onComplete&&e.onComplete(a):e.onRequestError?e.onRequestError(a):e.onError&&e.onError(a))}),t.on("error",function(t){a.statusText=t.toString(),e.onError&&e.onError(a)})}),r.setTimeout(e.timeout||3e4,function(t){e.onTimeout&&e.onTimeout(a)}),r.on("abort",function(t){e.onAbort&&e.onAbort(a)}),r.on("error",function(t){a.statusText=t.toString(),e.onError&&e.onError(a)}),e.headers&&n(e.headers,null,r),arguments.length>1&&a.send(t),a}:function(e,t){if(e=e||{},!e.url)return null;var a="undefined"!=typeof XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),i=new d(function(e){a.send(e)},function(){a.abort()}),s=function(e,t){return e.readyState=t.readyState,e.status=t.status,e.statusText=t.statusText,e};return i.getAllResponseHeaders=function(e){var t=a.getAllResponseHeaders();return!0===e?r(t):t},i.getResponseHeader=function(e){return a.getResponseHeader(e)},a.open(e.method||"GET",e.url,!e.sync),e.responseType&&(i.responseType=a.responseType=e.responseType),a.timeout=e.timeout||3e4,e.onProgress&&(a.onprogress=function(){e.onProgress(s(i,a))}),e.onLoadStart&&(a.onloadstart=function(){e.onLoadStart(s(i,a))}),e.onLoadEnd&&(a.onloadend=function(){e.onLoadEnd(s(i,a))}),!e.sync&&e.onStateChange&&(a.onreadystatechange=function(){e.onStateChange(s(i,a))}),a.onload=function(){d.DONE===a.readyState&&(s(i,a),200===a.status?(i.responseURL=a.responseURL,i.response=a.response,e.onComplete&&e.onComplete(i)):e.onRequestError?e.onRequestError(i):e.onError&&e.onError(i))},a.onabort=function(){e.onAbort&&e.onAbort(s(i,a))},a.onerror=function(){e.onError&&e.onError(s(i,a))},a.ontimeout=function(){e.onTimeout&&e.onTimeout(s(i,a))},e.headers&&n(e.headers,a),e.mimeType&&a.overrideMimeType(e.mimeType),arguments.length>1&&i.send(t),i};var p=(e.XHRLoader=h(f,{name:"XHRLoader",constructor:function _(){var e=this;return e instanceof _?void 0:new _},load:function(e,t,n){var r=this;return d.create({url:e,responseType:r._responseType,onComplete:function(e){"function"==typeof t&&t(e.response)},onError:function(e){"function"==typeof n&&n(e.statusText)}},null),r}}),e.FileLoader=h(f,{name:"FileLoader",constructor:function g(){var e=this;return e instanceof g?void 0:new g},load:function(t,n,r){var a=this;return e.Browser.isNode?require("fs").readFile(t,{encoding:"arraybuffer"===a._responseType?null:a._responseType,flag:"r"},function(e,t){e?"function"==typeof r&&r(e.toString()):"function"==typeof n&&n(t)}):d.create({url:t,responseType:a._responseType,onComplete:function(e){"function"==typeof n&&n(e.response)},onError:function(e){"function"==typeof r&&r(e.statusText)}},null),a}}));e.BinaryLoader=h(f,{name:"BinaryLoader",constructor:function v(e){var t=this;return t instanceof v?void(t._decoder="function"==typeof e?e:null):new v(e)},_decoder:null,_encoder:null,dispose:function(){var e=this;return e._decoder=null,e._encoder=null,e.$super("dispose"),e},decoder:function(e){var t=this;return t._decoder="function"==typeof e?e:null,t},encoder:function(e){var t=this;return t._encoder="function"==typeof e?e:null,t},load:function(e,t,n){var r=this,a=new c,i=r._decoder;return"function"==typeof i&&(new p).responseType(r._responseType||"arraybuffer").load(e,function(e){var n={},r=i(e,n);r&&(a.image(r),"function"==typeof t&&t(a,n))},n),a}})}(FILTER),!function(e,t){var n=e.Image;e.HTMLImageLoader=e.Class(e.Loader,{name:"HTMLImageLoader",constructor:function r(){return this instanceof r?void this.$super("constructor"):new r},load:function(e,t,r){var a,i=this,s=new n;return a=new Image,a.onload=function(e){s.setImage(a),"function"==typeof t&&t(s,a)},a.onerror=function(e){"function"==typeof r&&r(s,a)},a.crossOrigin=i._crossOrigin||"",a.src=e,s}})}(FILTER),!function(e,t){var n=(Object.prototype,Function.prototype,Array.prototype),r=n.slice,a=n.splice,i=n.concat,s=e.CompositeFilter=e.Class(e.Filter,{name:"CompositeFilter",constructor:function(e){var t=this;t.$super("constructor"),t._stack=e&&e.length?e.slice():[]},_stack:null,_meta:null,_stable:!0,dispose:function(e){var t,n=this,r=n._stack;if(n.$super("dispose"),!0===e)for(t=0;tn;n++)l[n]=l[n].unserialize(i[n]);else{for(n=0;a>n;n++)l[n]&&l[n].dispose(!0),l[n]=null;for(l=[],n=0;r>n;n++){if(s=i[n]&&i[n].filter?e[i[n].filter]:null,!s)throw new Error('Filter "'+i[n].filter+'" could not be created');l.push((new s).unserialize(i[n]))}}o._stack=l}return o},getMeta:function(){return this._meta},setMeta:function(e){var t,n,r=this,a=r._stack;if(e&&(n=e.length)&&a.length)for(t=0;n>t;t++)a[e[t][0]].setMeta(e[t][1]);return r},stable:function(e){return arguments.length||(e=!0),this._stable=!!e,this},filters:function(e){return arguments.length?(this._stack=e.slice(),this):this._stack.slice()},push:function(){var e=r.call(arguments),t=e.length;return t&&(this._stack=i.apply(this._stack,e)),this},pop:function(){return this._stack.pop()},shift:function(){return this._stack.shift()},unshift:function(){var e=r.call(arguments),t=e.length;return t&&a.apply(this._stack,[0,0].concat(e)),this},getAt:function(e){return this._stack.length>e?this._stack[e]:null},setAt:function(e,t){return this._stack.length>e?this._stack[e]=t:this._stack.push(t),this},insertAt:function(e){var t=r.call(arguments);t.length;return argslen>1&&(t.shift(),a.apply(this._stack,[e,0].concat(t))),this},removeAt:function(e){return this._stack.splice(e,1)},remove:function(e){for(var t=this._stack.length;--t>=0;)e===this._stack[t]&&this._stack.splice(t,1);return this},reset:function(){return this._stack.length=0,this},_apply:function(e,t,n,r){var a=this;if(a.hasMeta=!1,a._meta=[],a._isOn&&a._stack.length){var i,s,o=a._stack,l=o.length;for(i=0;l>i;i++)s=o[i],s&&s._isOn&&(e=s._apply(e,t,n,r),s.hasMeta&&a._meta.push([i,s.getMeta()]))}return a.hasMeta=a._meta.length>0,e},canRun:function(){return this._isOn&&this._stack.length},toString:function(){var e,t=arguments.length&&arguments[0].substr?arguments[0]:" ",n=t+t,r=this._stack,a=[],i=r.length;for(e=0;i>e;e++)a.push(r[e].toString(n));return["[FILTER: "+this.name+"]","["," "+a.join("\n "),"]",""].join("\n")}});s.prototype.empty=s.prototype.reset,s.prototype.concat=s.prototype.push}(FILTER),!function(e,t){var n="hasOwnProperty";e.InlineFilter=e.Class(e.Filter,{name:"InlineFilter",constructor:function(e){var t=this;t.$super("constructor"),t._handler=e&&"function"==typeof e?e:null,t._params={}},_handler:null,_params:null,dispose:function(){var e=this;return e.$super("dispose"),e._handler=null,e._params=null,e},params:function(e){var t=this;if(arguments.length){for(var r in e)e[n](r)&&(t._params[r]=e[r]);return t}return t._params},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_handler:e._handler?e._handler.toString():null,_params:e._params}}},unserialize:function(t){var n,r=this;return t&&r.name===t.filter&&(r._isOn=!!t._isOn,n=t.params,r._handler=null,n._handler&&(r._handler=new Function("FILTER",'"use strict"; return '+n._handler+";")(e)),r._params=n._params||{}),r},_apply:function(e,t,n,r){var a=this;return a._isOn&&a._handler?a._handler(a,e,t,n,r):e},canRun:function(){return this._isOn&&this._handler}});e.CustomFilter=e.InlineFilter}(FILTER),!function(e,t){function n(e,t){var n,r,a,i,o,l=new s(20);return n=t[0],r=t[1],a=t[2],i=t[3],o=t[4],l[0]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[1]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[2]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[3]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[4]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,n=t[5],r=t[6],a=t[7],i=t[8],o=t[9],l[5]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[6]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[7]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[8]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[9]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,n=t[10],r=t[11],a=t[12],i=t[13],o=t[14],l[10]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[11]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[12]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[13]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[14]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,n=t[15],r=t[16],a=t[17],i=t[18],o=t[19],l[15]=n*e[0]+r*e[5]+a*e[10]+i*e[15],l[16]=n*e[1]+r*e[6]+a*e[11]+i*e[16],l[17]=n*e[2]+r*e[7]+a*e[12]+i*e[17],l[18]=n*e[3]+r*e[8]+a*e[13]+i*e[18],l[19]=n*e[4]+r*e[9]+a*e[14]+i*e[19]+o,l}function r(e,t,n){var r=1-n,a=new s(20);return a[0]=r*e[0]+n*t[0],a[1]=r*e[1]+n*t[1],a[2]=r*e[2]+n*t[2],a[3]=r*e[3]+n*t[3],a[4]=r*e[4]+n*t[4],a[5]=r*e[5]+n*t[5],a[6]=r*e[6]+n*t[6],a[7]=r*e[7]+n*t[7],a[8]=r*e[8]+n*t[8],a[9]=r*e[9]+n*t[9],a[10]=r*e[10]+n*t[10],a[11]=r*e[11]+n*t[11],a[12]=r*e[12]+n*t[12],a[13]=r*e[13]+n*t[13],a[14]=r*e[14]+n*t[14],a[15]=r*e[15]+n*t[15],a[16]=r*e[16]+n*t[16],a[17]=r*e[17]+n*t[17],a[18]=r*e[18]+n*t[18],a[19]=r*e[19]+n*t[19],a}var a=Math.sin,i=Math.cos,s=e.Array32F,o=e.CONST.toRad,l=(e.CONST.toDeg,e._notSupportClamp),u=e.ColorMatrixFilter=e.Class(e.Filter,{name:"ColorMatrixFilter",constructor:function(t){var n=this;n.$super("constructor"),t&&t.length?n._matrix=new s(t):n._matrix=null,e.useWebGL&&(n._webglInstance=e.WebGLColorMatrixFilterInstance||null)},_matrix:null,_webglInstance:null,dispose:function(){var e=this;return e.$super("dispose"),e._webglInstance=null,e._matrix=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_matrix:e._matrix}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n._matrix=t._matrix),n},channel:function(n,r){r=r===t?!1:r;var a=r?1:0;switch(n){case e.CHANNEL.ALPHA:return this.set([0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,255]);case e.CHANNEL.BLUE:return this.set([0,0,a,0,0,0,0,a,0,0,0,0,1,0,0,0,0,0,0,255]);case e.CHANNEL.GREEN:return this.set([0,a,0,0,0,0,1,0,0,0,0,a,0,0,0,0,0,0,0,255]);case e.CHANNEL.RED:default:return this.set([1,0,0,0,0,a,0,0,0,0,a,0,0,0,0,0,0,0,0,255])}},redChannel:function(t){return this.channel(e.CHANNEL.RED,t)},greenChannel:function(t){return this.channel(e.CHANNEL.GREEN,t)},blueChannel:function(t){return this.channel(e.CHANNEL.BLUE,t)},alphaChannel:function(t){return this.channel(e.CHANNEL.ALPHA,!0)},maskChannel:function(t){switch(t){case e.CHANNEL.ALPHA:return this;case e.CHANNEL.BLUE:return this.set([1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0]);case e.CHANNEL.GREEN:return this.set([1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0]);case e.CHANNEL.RED:default:return this.set([0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0])}},swapChannels:function(t,n){switch(t){case e.CHANNEL.ALPHA:switch(n){case e.CHANNEL.ALPHA:return this;case e.CHANNEL.BLUE:return this.set([1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0]);case e.CHANNEL.GREEN:return this.set([1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0]);case e.CHANNEL.RED:default:return this.set([0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0])}break;case e.CHANNEL.BLUE:switch(n){case e.CHANNEL.ALPHA:return this.set([1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0]);case e.CHANNEL.BLUE:return this;case e.CHANNEL.GREEN:return this.set([1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0]);case e.CHANNEL.RED:default:return this.set([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])}break;case e.CHANNEL.GREEN:switch(n){case e.CHANNEL.ALPHA:return this.set([1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0]);case e.CHANNEL.BLUE:return this.set([1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0]);case e.CHANNEL.GREEN:return this;case e.CHANNEL.RED:default:return this.set([0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0])}break;case e.CHANNEL.RED:default:switch(n){case e.CHANNEL.ALPHA:return this.set([0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0]);case e.CHANNEL.BLUE:return this.set([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0]);case e.CHANNEL.GREEN:return this.set([0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0]);case e.CHANNEL.RED:default:return this}}},desaturate:function(){return this.set([e.LUMA[0],e.LUMA[1],e.LUMA[2],0,0,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,0,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,0,0,0,0,1,0])},colorize:function(n,r){var a,i,s,o;return r===t&&(r=1),a=.00392156862745098*(n>>16&255),i=.00392156862745098*(n>>8&255),s=.00392156862745098*(255&n),o=1-r,this.set([o+r*a*e.LUMA[0],r*a*e.LUMA[1],r*a*e.LUMA[2],0,0,r*i*e.LUMA[0],o+r*i*e.LUMA[1],r*i*e.LUMA[2],0,0,r*s*e.LUMA[0],r*s*e.LUMA[1],o+r*s*e.LUMA[2],0,0,0,0,0,1,0])},invert:function(){return this.set([-1,0,0,0,255,0,-1,0,0,255,0,0,-1,0,255,0,0,0,1,0])},invertAlpha:function(){return this.set([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,-1,255])},saturate:function(t){var n,r,a,i;return n=1-t,r=n*e.LUMA[0],a=n*e.LUMA[1],i=n*e.LUMA[2],this.set([r+t,a,i,0,0,r,a+t,i,0,0,r,a,i+t,0,0,0,0,0,1,0])},contrast:function(e,n,r){return n===t&&(n=e),r===t&&(r=e),e+=1,n+=1,r+=1,this.set([e,0,0,0,128*(1-e),0,n,0,0,128*(1-n),0,0,r,0,128*(1-r),0,0,0,1,0])},brightness:function(e,n,r){return n===t&&(n=e),r===t&&(r=e),this.set([1,0,0,0,e,0,1,0,0,n,0,0,1,0,r,0,0,0,1,0])},adjustHue:function(t){t*=o;var n=i(t),r=a(t);return this.set([e.LUMA[0]+n*(1-e.LUMA[0])+r*-e.LUMA[0],e.LUMA[1]+n*-e.LUMA[1]+r*-e.LUMA[1],e.LUMA[2]+n*-e.LUMA[2]+r*(1-e.LUMA[2]),0,0,e.LUMA[0]+n*-e.LUMA[0]+.143*r,e.LUMA[1]+n*(1-e.LUMA[1])+.14*r,e.LUMA[2]+n*-e.LUMA[2]+r*-.283,0,0,e.LUMA[0]+n*-e.LUMA[0]+r*-(1-e.LUMA[0]),e.LUMA[1]+n*-e.LUMA[1]+r*e.LUMA[1],e.LUMA[2]+n*(1-e.LUMA[2])+r*e.LUMA[2],0,0,0,0,0,1,0])},average:function(e,n,r){return e===t&&(e=.3333),n===t&&(n=.3333),r===t&&(r=.3334),this.set([e,n,r,0,0,e,n,r,0,0,e,n,r,0,0,0,0,0,1,0])},quickContrastCorrection:function(e){return e===t&&(e=1.2),this.set([e,0,0,0,0,0,e,0,0,0,0,0,e,0,0,0,0,0,1,0])},sepia:function(e){return e===t&&(e=.5),e>1?e=1:0>e&&(e=0),this.set([1-.607*e,.769*e,.189*e,0,0,.349*e,1-.314*e,.168*e,0,0,.272*e,.534*e,1-.869*e,0,0,0,0,0,1,0])},sepia2:function(n){return n===t&&(n=10),n>100&&(n=100),n*=2.55,this.set([e.LUMA[0],e.LUMA[1],e.LUMA[2],0,40,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,20,e.LUMA[0],e.LUMA[1],e.LUMA[2],0,-n,0,0,0,1,0])},threshold:function(n,r){return r===t&&(r=256),this.set([e.LUMA[0]*r,e.LUMA[1]*r,e.LUMA[2]*r,0,-(r-1)*n,e.LUMA[0]*r,e.LUMA[1]*r,e.LUMA[2]*r,0,-(r-1)*n,e.LUMA[0]*r,e.LUMA[1]*r,e.LUMA[2]*r,0,-(r-1)*n,0,0,0,1,0])},threshold_rgb:function(e,n){return n===t&&(n=256),this.set([n,0,0,0,-(n-1)*e,0,n,0,0,-(n-1)*e,0,0,n,0,-(n-1)*e,0,0,0,1,0])},threshold_alpha:function(e,n){return e===t&&(e=.5),n===t&&(n=256),this.set([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,n,-n*e])},RGB2YCbCr:function(){return this.set([.5,-.418688,-.081312,0,128,.299,.587,.114,0,0,-.168736,-.331264,.5,0,128,0,0,0,1,0])},YCbCr2RGB:function(){return this.set([1.402,1,0,0,-179.456,-.71414,1,-.34414,0,135.45984,0,1,1.772,0,-226.816,0,0,0,1,0])},blend:function(e,t){return this._matrix=this._matrix?r(this._matrix,e.getMatrix(),t):new s(e.getMatrix()),this},set:function(e){return this._matrix=this._matrix?n(this._matrix,new s(e)):new s(e),this},reset:function(){return this._matrix=null,this},combineWith:function(e){return this.set(e.getMatrix())},getMatrix:function(){return this._matrix},setMatrix:function(e){return this._matrix=new s(e),this},_apply:function(e,t,n){var r=this;if(r._isOn&&r._matrix){var a,i,s,o,l,u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E,R=e.length,I=r._matrix,M=(R>>2)%4;for(a=0;R>a;a+=16)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+4],A=e[a+5],b=e[a+6],E=e[a+7],u=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],c=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],h=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],f=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+8],A=e[a+9],b=e[a+10],E=e[a+11],d=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],p=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],m=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],_=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+12],A=e[a+13],b=e[a+14],E=e[a+15],g=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],v=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],y=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],w=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l,e[a+4]=~~u,e[a+5]=~~c,e[a+6]=~~h,e[a+7]=~~f,e[a+8]=~~d,e[a+9]=~~p,e[a+10]=~~m,e[a+11]=~~_,e[a+12]=~~g,e[a+13]=~~v,e[a+14]=~~y,e[a+15]=~~w;if(M)for(M<<=2,a=R-M;R>a;a+=4)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l}return e},canRun:function(){return this._isOn&&this._matrix}});u.prototype.grayscale=u.prototype.desaturate,u.prototype.rotateHue=u.prototype.adjustHue,u.prototype.thresholdRgb=u.prototype.threshold_rgb,u.prototype.thresholdAlpha=u.prototype.threshold_alpha,l&&(u.prototype._apply=function(e,t,n){var r=this;if(r._isOn&&r._matrix){var a,i,s,o,l,u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E,R=e.length,I=r._matrix,M=(R>>2)%4;for(a=0;R>a;a+=16)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+4],A=e[a+5],b=e[a+6],E=e[a+7],u=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],c=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],h=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],f=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+8],A=e[a+9],b=e[a+10],E=e[a+11],d=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],p=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],m=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],_=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],C=e[a+12],A=e[a+13],b=e[a+14],E=e[a+15],g=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],v=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],y=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],w=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s,o=0>o?0:o>255?255:o,l=0>l?0:l>255?255:l,u=0>u?0:u>255?255:u,c=0>c?0:c>255?255:c,h=0>h?0:h>255?255:h,f=0>f?0:f>255?255:f,d=0>d?0:d>255?255:d,p=0>p?0:p>255?255:p,m=0>m?0:m>255?255:m,_=0>_?0:_>255?255:_,g=0>g?0:g>255?255:g,v=0>v?0:v>255?255:v,y=0>y?0:y>255?255:y,w=0>w?0:w>255?255:w,e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l,e[a+4]=~~u,e[a+5]=~~c,e[a+6]=~~h,e[a+7]=~~f,e[a+8]=~~d,e[a+9]=~~p,e[a+10]=~~m,e[a+11]=~~_,e[a+12]=~~g,e[a+13]=~~v,e[a+14]=~~y,e[a+15]=~~w;if(M)for(M<<=2,a=R-M;R>a;a+=4)C=e[a],A=e[a+1],b=e[a+2],E=e[a+3],i=I[0]*C+I[1]*A+I[2]*b+I[3]*E+I[4],s=I[5]*C+I[6]*A+I[7]*b+I[8]*E+I[9],o=I[10]*C+I[11]*A+I[12]*b+I[13]*E+I[14],l=I[15]*C+I[16]*A+I[17]*b+I[18]*E+I[19],i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s,o=0>o?0:o>255?255:o,l=0>l?0:l>255?255:l,e[a]=~~i,e[a+1]=~~s,e[a+2]=~~o,e[a+3]=~~l}return e})}(FILTER),!function(e,t){var n=e.ImArrayCopy,r=e.Color.clampPixel,a=function(){var e,t=new n(256);for(e=0;256>e;e++)t[e]=e;return t},i=function(){var e,t=new n(256);for(e=0;256>e;e++)t[e]=255-e;return t},s=function(e){var t,r=new n(256);for(t=0;256>t;t++)r[t]=e;return r},o=function(e){return e?new n(e):null},l=Math.pow,u=Math.exp,c=1/255,h=e.TableLookupFilter=e.Class(e.Filter,{name:"TableLookupFilter",constructor:function(e,t,n,r){var a=this;a.$super("constructor"),a._tableR=e||null,a._tableG=t||a._tableR,a._tableB=n||a._tableG,a._tableA=r||null},_tableR:null,_tableG:null,_tableB:null,_tableA:null,dispose:function(){var e=this;return e.$super("dispose"),e._tableR=null,e._tableG=null,e._tableB=null,e._tableA=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_tableR:e._tableR,_tableG:e._tableG,_tableB:e._tableB,_tableA:e._tableA}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n._tableR=t._tableR,n._tableG=t._tableG,n._tableB=t._tableB,n._tableA=t._tableA),n},thresholds:function(e,t,a){e.length||(e=[e]),t||(t=e),a||(a=t);var i,s,o=e.length,l=o+1,u=t.length,c=u+1,h=a.length,f=h+1,d=new n(256),p=new n(l),m=new n(256),_=new n(c),g=new n(256),v=new n(f),y=255/(l-1),w=255/(c-1),C=255/(f-1);for(i=0;l>i;)p[i]=~~(y*i),i++;for(e[0]=~~(255*e[0]),i=1;o>i;)e[i]=e[i-1]+~~(255*e[i]),i++;for(i=0;c>i;)_[i]=~~(w*i),i++;for(t[0]=~~(255*t[0]),i=1;u>i;)t[i]=t[i-1]+~~(255*t[i]),i++;for(i=0;f>i;)v[i]=~~(C*i),i++;for(a[0]=~~(255*a[0]),i=1;h>i;)a[i]=a[i-1]+~~(255*a[i]),i++;for(i=0;256>i;i++){for(s=0;o>s&&i>e[s];)s++;for(d[i]=r(p[s]),s=0;u>s&&i>t[s];)s++;for(m[i]=r(_[s]),s=0;h>s&&i>a[s];)s++;g[i]=r(v[s])}return this.set(d,m,g)},threshold:function(e,t,n){return e=e||.5,t=t||e,n=n||t,this.thresholds([e],[t],[n])},quantize:function(e){e===t&&(e=64),2>e&&(e=2);var a,i=new n(256),s=new n(e),o=255/(e-1),l=e/256;for(a=0;e>a;)s[a]=~~(o*a),a++;for(a=0;256>a;a++)i[a]=r(s[~~(l*a)]);return this.set(i)},binarize:function(){return this.quantize(2)},solarize:function(e){e===t&&(e=.5);var a,i,s=0,o=new n(256),l=2/255;for(s=0;256>s;s++)a=l*s,i=a>e?255-255*a:255*a-255,o[s]=~~r(i);return this.set(o)},solarize2:function(e){e===t&&(e=.5),e=1-e;var a,i,s=0,o=new n(256),l=2/255;for(s=0;256>s;s++)a=l*s,i=e>a?255-255*a:255*a-255,o[s]=~~r(i);return this.set(o)},solarizeInverse:function(e){e===t&&(e=.5),e*=256;var r=0,a=new n(256);for(r=0;256>r;r++)a[r]=r>e?255-r:r;return this.set(a)},invert:function(){return this.set(i())},mask:function(e){var t=0,a=e>>16&255,i=e>>8&255,s=255&e;for(tR=new n(256),tG=new n(256),tB=new n(256),t=0;256>t;t++)tR[t]=r(t&a),tG[t]=r(t&i),tB[t]=r(t&s);return this.set(tR,tG,tB)},replace:function(e,t){if(e==t)return this;var n=e>>16&255,r=e>>8&255,i=255&e,s=t>>16&255,o=t>>8&255,l=255&t,u=a(),c=a(),h=a();return u[n]=s,c[r]=o,h[i]=l,this.set(u,c,h)},extract:function(t,n,a){if(!n||!n.length)return this;a=a||0;var i,o,l=a>>16&255,u=a>>8&255,c=255&a,h=s(l),f=s(u),d=s(c);switch(t){case e.CHANNEL.BLUE:for(i=n[0],o=n[1];o>=i;)d[i]=r(i),i++;break;case e.CHANNEL.GREEN:for(i=n[0],o=n[1];o>=i;)f[i]=r(i),i++;break;case e.CHANNEL.RED:default:for(i=n[0],o=n[1];o>=i;)h[i]=r(i),i++}return this.set(h,f,d)},gammaCorrection:function(e,t,a){e=e||1,t=t||e,a=a||t,e=1/e,t=1/t,a=1/a;var i=new n(256),s=new n(256),o=new n(256),u=0;for(u=0;256>u;u++)i[u]=r(~~(255*l(c*u,e))),s[u]=r(~~(255*l(c*u,t))),o[u]=r(~~(255*l(c*u,a)));return this.set(i,s,o)},exposure:function(e){e===t&&(e=1);var a=0,i=new n(256);for(a=0;256>a;a++)i[a]=r(~~(255*(1-u(-e*a*c))));return this.set(i)},set:function(e,t,n,i){if(!e)return this;t=t||e,n=n||t;var s,l,u,c,h,f=this._tableR||a(),d=o(f);if(t&&n){for(s=this._tableG||o(f),l=this._tableB||o(s),u=o(s),c=o(l),h=0;256>h;h++)f[h]=r(e[r(d[h])]),s[h]=r(t[r(u[h])]),l[h]=r(n[r(c[h])]);this._tableR=f,this._tableG=s,this._tableB=l}else{for(h=0;256>h;h++)f[h]=r(e[r(d[h])]);this._tableR=f,this._tableG=this._tableR,this._tableB=this._tableR}return this},reset:function(){return this._tableR=this._tableG=this._tableB=this._tableA=null,this},combineWith:function(e){return this.set(e.getTable(0),e.getTable(1),e.getTable(2))},getTable:function(t){switch(t=t||e.CHANNEL.RED){case e.CHANNEL.ALPHA:return this._tableA;case e.CHANNEL.BLUE:return this._tableB;case e.CHANNEL.GREEN:return this._tableG;case e.CHANNEL.RED:default:return this._tableR}},setTable:function(t,n){switch(n=n||e.CHANNEL.RED){case e.CHANNEL.ALPHA:return this._tableA=t,this;case e.CHANNEL.BLUE:return this._tableB=t,this;case e.CHANNEL.GREEN:return this._tableG=t,this;case e.CHANNEL.RED:default:return this._tableR=t,this}},_apply:function(e,t,n){var r=this;if(!r._isOn||!r._tableR)return e;var a,i,s,o,l,u=e.length,c=(u>>2)%4,h=r._tableR,f=r._tableG,d=r._tableB,p=r._tableA;if(p){for(a=0;u>a;a+=16)i=e[a],s=e[a+1],o=e[a+2],l=e[a+3],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o],e[a+3]=p[l],i=e[a+4],s=e[a+5],o=e[a+6],l=e[a+7],e[a+4]=h[i],e[a+5]=f[s],e[a+6]=d[o],e[a+7]=p[l], +i=e[a+8],s=e[a+9],o=e[a+10],l=e[a+11],e[a+8]=h[i],e[a+9]=f[s],e[a+10]=d[o],e[a+11]=p[l],i=e[a+12],s=e[a+13],o=e[a+14],l=e[a+15],e[a+12]=h[i],e[a+13]=f[s],e[a+14]=d[o],e[a+15]=p[l];if(c)for(c<<=2,a=u-c;u>a;a+=4)i=e[a],s=e[a+1],o=e[a+2],l=e[a+3],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o],e[a+3]=p[l]}else{for(a=0;u>a;a+=16)i=e[a],s=e[a+1],o=e[a+2],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o],i=e[a+4],s=e[a+5],o=e[a+6],e[a+4]=h[i],e[a+5]=f[s],e[a+6]=d[o],i=e[a+8],s=e[a+9],o=e[a+10],e[a+8]=h[i],e[a+9]=f[s],e[a+10]=d[o],i=e[a+12],s=e[a+13],o=e[a+14],e[a+12]=h[i],e[a+13]=f[s],e[a+14]=d[o];if(c)for(c<<=2,a=u-c;u>a;a+=4)i=e[a],s=e[a+1],o=e[a+2],e[a]=h[i],e[a+1]=f[s],e[a+2]=d[o]}return e},canRun:function(){return this._isOn&&this._tableR}});h.prototype.posterize=h.prototype.levels=h.prototype.quantize}(FILTER),!function(e,t){var n=(e.ImArray,e.ImArrayCopy),r=e.Array16I,a=Math.min,i=(Math.max,Math.floor);e.DisplacementMapFilter=e.Class(e.Filter,{name:"DisplacementMapFilter",constructor:function(e){var t=this;t.$super("constructor"),e&&t.setMap(e)},_map:null,map:null,scaleX:1,scaleY:1,startX:0,startY:0,componentX:0,componentY:0,color:0,red:0,green:0,blue:0,alpha:0,mode:e.MODE.CLAMP,dispose:function(){var e=this;return e.$super("dispose"),e._map=null,e.map=null,e.scaleX=null,e.scaleY=null,e.startX=null,e.startY=null,e.componentX=null,e.componentY=null,e.color=null,e.red=null,e.green=null,e.blue=null,e.alpha=null,e.mode=null,e},serialize:function(){var e=this,t=e.map;return{filter:e.name,_isOn:!!e._isOn,params:{_map:e._map||(t?{data:t.getData(),width:t.width,height:t.height}:null),scaleX:e.scaleX,scaleY:e.scaleY,startX:e.startX,startY:e.startY,componentX:e.componentX,componentY:e.componentY,color:e.color,red:e.red,green:e.green,blue:e.blue,alpha:e.alpha,mode:e.mode}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n.map=null,n._map=t._map,n.scaleX=t.scaleX,n.scaleY=t.scaleY,n.startX=t.startX,n.startY=t.startY,n.componentX=t.componentX,n.componentY=t.componentY,n.color=t.color,n.red=t.red,n.green=t.green,n.blue=t.blue,n.alpha=t.alpha,n.mode=t.mode),n},reset:function(){var e=this;return e._map=null,e.map=null,e},getMap:function(){return this.map},setMap:function(e){var t=this;return e&&(t.map=e,t._map=null),t},setColor:function(e){var t=this;return t.color=e,t.alpha=e>>24&255,t.red=e>>16&255,t.green=e>>8&255,t.blue=255&e,t},_apply:function(t,s,o){var l=this;if(!l._isOn||!l.map&&!l._map)return t;var u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E,R,I,M,L,x,N,S,T,O,F,D,P,k,G,H,U=l.map,X=l._map||{data:U.getData(),width:U.width,height:U.height},B=.00390625*l.scaleX,Y=.00390625*l.scaleY,W=l.componentX,q=l.componentY,z=l.alpha,$=l.red,j=l.green,K=l.blue,J=l.mode,V=e.MODE.IGNORE,Q=(e.MODE.CLAMP,e.MODE.COLOR),Z=e.MODE.WRAP;for(u=X.data,c=X.width,h=X.height,f=u.length>>2,p=a(c,s),m=a(h,o),P=t.length,F=p*m<<2,D=P>>2,g=i(l.startX*(s-1)),_=i(l.startY*(o-1)),v=_*s,y=-g,w=-_,C=s-g-1,A=o-_-1,d=new r(f<<1),k=new n(t),E=0,R=0,I=0,M=0,b=0;f>b;b++,E+=2,R++)R>=c&&(R=0,I++,M+=c),S=R+M<<2,d[E]=i((u[S+W]-128)*B),d[E+1]=i((u[S+q]-128)*Y);for(R=0,I=0,M=0,L=0,b=0;F>b;b+=4,R++)if(R>=p&&(R=0,I++,M+=s,L+=c),!(w>I||I>A||y>R||R>C)){if(N=R+g,x=I+_,T=N+M+v<<2,E=R+L<<1,G=N+d[E],H=x+d[E+1],H>=o||0>H||G>=s||0>G){if(J==V)continue;if(J==Q){t[T]=$,t[T+1]=j,t[T+2]=K,t[T+3]=z;continue}J==Z?(H>A?H-=o:0>H&&(H+=o),G>C?G-=s:0>G&&(G+=s)):(H>A?H=A:0>H&&(H=0),G>C?G=C:0>G&&(G=0))}O=G+H*s<<2,t[T]=k[O],t[T+1]=k[O+1],t[T+2]=k[O+2],t[T+3]=k[O+3]}return t},canRun:function(){return this._isOn&&(this._map||this.map)}})}(FILTER),!function(FILTER,undef){var IMG=FILTER.ImArray,IMGcopy=FILTER.ImArrayCopy,PI=FILTER.CONST.PI,DoublePI=FILTER.CONST.PI2,HalfPI=FILTER.CONST.PI_2,ThreePI2=1.5*PI,Sqrt=Math.sqrt,Atan2=Math.atan2,Atan=Math.atan,Sin=Math.sin,Cos=Math.cos,Floor=Math.floor,Round=Math.round,Asin=Math.asin,Tan=Math.tan,Abs=Math.abs,Max=Math.max,toRad=FILTER.CONST.toRad,Maps,GeometricMapFilter=FILTER.GeometricMapFilter=FILTER.Class(FILTER.Filter,{name:"GeometricMapFilter",constructor:function(e){var t=this;t.$super("constructor"),e&&t.generic(e)},_map:null,_mapName:null,inverseTransform:null,matrix:null,centerX:0,centerY:0,dx:0,dy:0,angle:0,radius:0,wavelength:0,amplitude:0,phase:0,xAmplitude:0,yAmplitude:0,xWavelength:0,yWavelength:0,mode:FILTER.MODE.CLAMP,dispose:function(){var e=this;return e.$super("dispose"),e._map=null,e._mapName=null,e.inverseTransform=null,e.matrix=null,e.centerX=null,e.centerY=null,e.dx=null,e.dy=null,e.angle=null,e.radius=null,e.wavelength=null,e.amplitude=null,e.phase=null,e.xAmplitude=null,e.yAmplitude=null,e.xWavelength=null,e.yWavelength=null,e.mode=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_mapName:e._mapName,inverseTransform:e.inverseTransform?e.inverseTransform.toString():null,matrix:e.matrix,centerX:e.centerX,centerY:e.centerY,dx:e.dx,dy:e.dy,angle:e.angle,radius:e.radius,wavelength:e.wavelength,amplitude:e.amplitude,phase:e.phase,xAmplitude:e.xAmplitude,yAmplitude:e.yAmplitude,xWavelength:e.xWavelength,yWavelength:e.yWavelength,mode:e.mode}}},unserialize:function(json){var self=this,params;return json&&self.name===json.filter&&(self._isOn=!!json._isOn,params=json.params,self.inverseTransform=null,self.matrix=params.matrix,self.centerX=params.centerX,self.centerY=params.centerY,self.dx=params.dx,self.dy=params.dy,self.angle=params.angle,self.radius=params.radius,self.wavelength=params.wavelength,self.amplitude=params.amplitude,self.phase=params.phase,self.xAmplitude=params.xAmplitude,self.yAmplitude=params.yAmplitude,self.xWavelength=params.xWavelength,self.yWavelength=params.yWavelength,self.mode=params.mode,params.inverseTransform&&(self.inverseTransform=eval('(function(){ "use strict"; return '+params.inverseTransform+"})();")),self._mapName=params._mapName,self._map=null,self._mapName&&Maps[self._mapName]&&(self._map=Maps[self._mapName])),self},generic:function(e){var t=this;return e&&(t.inverseTransform=e,t._mapName="generic",t._map=Maps.generic),t},affine:function(e){var t=this;return e&&(t.matrix=e,t._mapName="affine",t._map=Maps.affine),t},flipX:function(){var e=this;return e._mapName="flipX",e._map=Maps.flipX,e},flipY:function(){var e=this;return e._mapName="flipY",e._map=Maps.flipY,e},flipXY:function(){var e=this;return e._mapName="flipXY",e._map=Maps.flipXY,e},rotateCW:function(){var e=this;return e._mapName="rotateCW",e._map=Maps.rotateCW,e},rotateCCW:function(){var e=this;return e._mapName="rotateCCW",e._map=Maps.rotateCCW,e},polar:function(e,t){var n=this;return n.centerX=e||0,n.centerY=t||0,n._mapName="polar",n._map=Maps.polar,n},cartesian:function(e,t){var n=this;return n.centerX=e||0,n.centerY=t||0,n._mapName="cartesian",n._map=Maps.cartesian,n},twirl:function(e,t,n,r){var a=this;return a.angle=e||0,a.radius=t||0,a.centerX=n||0,a.centerY=r||0,a._mapName="twirl",a._map=Maps.twirl,a},sphere:function(e,t,n){var r=this;return r.radius=e||0,r.centerX=t||0,r.centerY=n||0,r._mapName="sphere",r._map=Maps.sphere,r},ripple:function(e,t,n,r,a,i){var s=this;return s.radius=e!==undef?e:50,s.centerX=a||0,s.centerY=i||0,s.wavelength=t!==undef?t:16,s.amplitude=n!==undef?n:10,s.phase=r||0,s._mapName="ripple",s._map=Maps.ripple,s},shift:function(e,t){var n=this;return n.dx=e!==undef?e:0,n.dy=t!==undef?t:n.dx,n._mapName="shift",n._map=Maps.shift,n},reset:function(){var e=this;return e._mapName=null,e._map=null,e},getMap:function(){return this._map},setMap:function(e){var t=this;return t._mapName=null,t._map=e,t},_apply:function(e,t,n,r){var a=this;return a._isOn&&a._map?a._map(a,e,t,n,r):e},canRun:function(){return this._isOn&&this._map}});GeometricMapFilter.prototype.translate=GeometricMapFilter.prototype.shift,Maps={generic:function(e,t,n,r){var a,i,s,o,l,u,c,h=t.length,f=new IMG(h),d=e.inverseTransform,p=e.mode,m=FILTER.MODE.CLAMP,_=FILTER.MODE.WRAP;for(a=0,i=0,s=0;h>s;s+=4,a++){if(a>=n&&(a=0,i++),l=d([a,i],n,r),u=~~l[0],c=~~l[1],0>u||u>=n||0>c||c>=r)switch(p){case _:c>=r?c-=r:0>c&&(c+=r),u>=n?u-=n:0>u&&(u+=n);break;case m:default:c>=r?c=r-1:0>c&&(c=0),u>=n?u=n-1:0>u&&(u=0)}o=u+c*n<<2,f[s]=t[o],f[s+1]=t[o+1],f[s+2]=t[o+2],f[s+3]=t[o+3]}return f},affine:function(e,t,n,r){var a,i,s,o,l,u,c,h,f,d=t.length,p=d>>2,m=new IMG(d),_=e.matrix,g=_[0],v=_[1],y=_[3],w=_[4],C=_[2],A=_[5],b=e.mode,E=FILTER.MODE.CLAMP,R=FILTER.MODE.WRAP,I=n-1,M=p-n;for(a=0,i=0,l=A*n,u=y*n,c=w*n,s=0;d>s;s+=4,a++){if(a>=n&&(a=0,i++),h=~~(g*a+v*i+C),f=~~(u*a+c*i+l),0>h||h>I||0>f||f>M)switch(b){case R:f>M?f-=p:0>f&&(f+=p),h>=n?h-=n:0>h&&(h+=n);break;case E:default:f>M?f=M:0>f&&(f=0),h>I?h=I:0>h&&(h=0)}o=h+f<<2,m[s]=t[o],m[s+1]=t[o+1],m[s+2]=t[o+2],m[s+3]=t[o+3]}return m},shift:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u),h=-e.dx,f=-e.dy;for(0>h&&(h+=n),0>f&&(f+=r),a=0,i=0,s=0,o=0;u>o;o+=4,a++)a>=n&&(a=0,i++,s+=n),l=(a+h)%n+(i+f)%r*n<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},flipX:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u);for(a=0,i=0,s=0,o=0;u>o;o+=4,a++)a>=n&&(a=0,i++,s+=n),l=n-1-a+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},flipY:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u);for(a=0,i=0,s=(r-1)*n,o=0;u>o;o+=4,a++)a>=n&&(a=0,i++,s-=n),l=a+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},flipXY:function(e,t,n,r){var a,i,s,o,l,u,c=t.length,h=new IMG(c);for(a=0,i=0,o=(r-1)*n,l=0;c>l;l+=4,a++)a>=n&&(a=0,i++,s+=n,o-=n),u=n-1-a+o<<2,h[l]=t[u],h[l+1]=t[u+1],h[l+2]=t[u+2],h[l+3]=t[u+3];return h},rotateCW:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u),h=u>>2;for(a=0,i=0,s=h-1,o=0;u>o;o+=4,a++,s-=n)a>=n&&(a=0,s=h-1,i++),l=i+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},rotateCCW:function(e,t,n,r){var a,i,s,o,l,u=t.length,c=new IMG(u);for(a=0,i=0,s=0,o=0;u>o;o+=4,a++,s+=n)a>=n&&(a=0,s=0,i++),l=n-1-i+s<<2,c[o]=t[l],c[o+1]=t[l+1],c[o+2]=t[l+2],c[o+3]=t[l+3];return c},twirl:function(e,t,n,r){if(0>=e.radius)return t;var a,i,s,o,l,u,c,h,f=t.length,d=new IMGcopy(t),p=e.centerX,m=e.centerY,_=e.angle,g=e.radius,v=e.mode,y=FILTER.MODE.CLAMP,w=FILTER.MODE.WRAP,C=_/g,A=n-1,b=r-1;for(p=Floor(p*(n-1)),m=Floor(m*(r-1)),a=0,i=0,s=0;f>s;s+=4,a++)if(a>=n&&(a=0,i++),u=a-p,c=i-m,l=Sqrt(u*u+c*c),g>l){if(h=Atan2(c,u)+C*(g-l),u=~~(p+l*Cos(h)),c=~~(m+l*Sin(h)),0>u||u>A||0>c||c>b)switch(v){case w:c>b?c-=r:0>c&&(c+=r),u>A?u-=n:0>u&&(u+=n);break;case y:default:c>b?c=b:0>c&&(c=0),u>A?u=A:0>u&&(u=0)}o=u+c*n<<2,t[s]=d[o],t[s+1]=d[o+1],t[s+2]=d[o+2],t[s+3]=d[o+3]}return t},sphere:function(e,t,n,r){if(0>=e.radius)return t;var a,i,s,o,l,u,c,h,f,d,p,m,_,g=t.length,v=new IMGcopy(t),y=e.centerX,w=e.centerY,C=e.radius,A=e.mode,b=FILTER.MODE.CLAMP,E=FILTER.MODE.WRAP,R=C*C,I=.555556,M=1-I,L=n-1,x=r-1;for(y=Floor(y*(n-1)),w=Floor(w*(r-1)),a=0,i=0,s=0;g>s;s+=4,a++)if(a>=n&&(a=0,i++),l=a-y,u=i-w,m=l*l,_=u*u,c=m+_,R>c){if(d=R-c,p=Sqrt(d),h=Asin(l/Sqrt(m+d))*M,f=Asin(u/Sqrt(_+d))*M,l=~~(a-p*Tan(h)),u=~~(i-p*Tan(f)),0>l||l>L||0>u||u>x)switch(A){case E:u>x?u-=r:0>u&&(u+=r),l>L?l-=n:0>l&&(l+=n);break;case b:default:u>x?u=x:0>u&&(u=0),l>L?l=L:0>l&&(l=0)}o=l+u*n<<2,t[s]=v[o],t[s+1]=v[o+1],t[s+2]=v[o+2],t[s+3]=v[o+3]}return t},ripple:function(e,t,n,r){if(0>=e.radius)return t;var a,i,s,o,l,u,c,h,f,d,p,m=t.length,_=new IMGcopy(t),g=FILTER.MODE.CLAMP,v=FILTER.MODE.WRAP,y=n-1,w=r-1,C=e.centerX,A=e.centerY,b=e.radius,E=e.mode,R=b*b,I=e.wavelength,M=e.amplitude,L=e.phase;for(C=Floor(C*(n-1)),A=Floor(A*(r-1)),a=0,i=0,s=0;m>s;s+=4,a++)if(a>=n&&(a=0,i++),u=a-C,c=i-A,d=u*u,p=c*c,f=d+p,R>f){if(l=Sqrt(f),h=M*Sin(l/I*Math.PI*2-L),h*=(b-l)/b,l&&(h*=I/l),u=~~(a+u*h),c=~~(i+c*h),0>u||u>y||0>c||c>w)switch(E){case v:c>w?c-=r:0>c&&(c+=r),u>y?u-=n:0>u&&(u+=n);break;case g:default:c>w?c=w:0>c&&(c=0),u>y?u=y:0>u&&(u=0)}o=u+c*n<<2,t[s]=_[o],t[s+1]=_[o+1],t[s+2]=_[o+2],t[s+3]=_[o+3]}return t},polar:function(e,t,n,r){var a,i,s,o,l,u,c,h,f,d,p,m,_=t.length,g=new IMGcopy(t),v=FILTER.MODE.CLAMP,y=FILTER.MODE.WRAP,w=n-1,C=r-1,A=0,b=e.mode;for(p=~~(.5*n+.5),m=~~(.5*r+.5),d=Max(m,p),a=0,i=0,s=0;_>s;s+=4,a++){if(a>=n&&(a=0,i++),o=a-p,l=i-m,f=0,o>=0?l>0?(f=PI-Atan(o/l),A=Sqrt(o*o+l*l)):0>l?(f=Atan(o/l),A=Sqrt(o*o+l*l)):(f=HalfPI,A=o):0>o&&(0>l?(f=DoublePI-Atan(o/l),A=Sqrt(o*o+l*l)):l>0?(f=PI+Atan(o/l),A=Sqrt(o*o+l*l)):(f=ThreePI2,A=-o)),u=n-1-(n-1)/DoublePI*f,c=r*A/d,u=Round(u),c=Round(c),0>u||u>w||0>c||c>C)switch(b){case y:c>C?c-=r:0>c&&(c+=r),u>w?u-=n:0>u&&(u+=n);break;case v:default:c>C?c=C:0>c&&(c=0),u>w?u=w:0>u&&(u=0)}h=u+c*n<<2,t[s]=g[h],t[s+1]=g[h+1],t[s+2]=g[h+2],t[s+3]=g[h+3]}return t},cartesian:function(e,t,n,r){var a,i,s,o,l,u,c,h,f,d,p,m,_,g=t.length,v=new IMGcopy(t),y=FILTER.MODE.CLAMP,w=FILTER.MODE.WRAP,C=n-1,A=r-1,b=0,E=e.mode;for(m=~~(.5*n+.5),_=~~(.5*r+.5),p=Max(_,m),a=0,i=0,s=0;g>s;s+=4,a++){if(a>=n&&(a=0,i++),f=a/n*DoublePI,d=f>=ThreePI2?DoublePI-f:f>=PI?f-PI:f>=HalfPI?PI-f:f,b=p*(i/r),c=-b*Sin(d),h=b*Cos(d),f>=ThreePI2?(o=m-c,l=_-h):f>=PI?(o=m-c,l=_+h):f>=HalfPI?(o=m+c,l=_+h):(o=m+c,l=_-h),o=Round(o),l=Round(l),0>o||o>C||0>l||l>A)switch(E){case w:l>A?l-=r:0>l&&(l+=r),o>C?o-=n:0>o&&(o+=n);break;case y:default:l>A?l=A:0>l&&(l=0),o>C?o=C:0>o&&(o=0)}u=o+l*n<<2,t[s]=v[u],t[s+1]=v[u+1],t[s+2]=v[u+2],t[s+3]=v[u+3]}return t}}}(FILTER),!function(e,t){function n(e,t,n,r){var a,i=e.length,s=new w(e.length);for(n=n||1,r=r||1,a=0;i>a;)s[a]=n*e[a]+r*t[a],a++;return s}function r(e,t){var n,r,a,i=e.length,s=[],o=0;for(n=0;i>n;n++)for(r=0;i>r;r++)a=e[n]*t[r],o+=a,s.push(a);return{kernel:s,sum:o}}function a(e){var t,n=new Array(e);for(t=0;e>t;)n[t]=1,t++;return n}function i(e){var t,n,r,a,i=R.length;if(e--,i>e)t=new w(R[e]);else for(t=new w(R[i-1]);e>=i;){for(n=t,t=new w(n.length+1),t[0]=1,r=0,a=n.length-1;a>r;r++)t[r+1]=n[r]+n[r+1];t[n.length]=1,40>i&&R.push(new Array(t)),i++}return t}function s(e){var t,n=e>>1,r=-n,a=new Array(e);for(t=0;e>t;)a[t]=r,r++,t++;return a}function o(e){var t=i(e);return r(t,t)}function l(e,t){var n=i(e),a=s(e);return 1==t?r(a.reverse(),n):r(n,a)}function u(e,t){var n=a(e),i=s(e);return 1==t?r(i.reverse(),n):r(n,i)}function c(e,t,n){t=t||1,n=n||t;var r,a=e*e,i=a>>1,s=new w(a);for(r=0;a>r;)s[r]=t,r++;return s[i]=n,s}function h(e,t,n,r){var a,i,s,o,l,u=e*e,c=e>>1,h=u>>1,f=new w(u);for(o=0,a=0;c>=a;a++){for(i=0,l=0,s=0;c>=s;s++)f[h+a+i]=o+l,f[h-a-i]=-o-l,f[h-a+i]=-o+l,f[h+a-i]=o-l,i+=e,l+=n;o+=t}return f[h]=r||1,f}function f(e,t,n,r){var a,i,s,o,l,u,c=e*e,h=e>>1,f=c>>1,d=new w(c),p=new w(c),m=1/e,g=1e-8;for(_(t)>g?(l=1,u=n/t):(l=t/n,u=1),a=0,s=0,o=0,i=u*e;h>=a;)p[f+a]=~~(f+s+o+.5),p[f-a]=~~(f-s-o+.5),a++,s+=l,o+=i;for(a=0;h>=a;)d[p[f+a]]=d[p[f-a]]=m,a++;return d[f]=r||1,d}function d(e,t,n,r,a,i,s,o,l,u){var c,h,f,d,p,m,_,g,v,y,w,b,R,I,M,L,x,N,S,T,O,F,D,P,k,G,H,U,X,B,Y,W,q,z,$,j,K,J,V,Q,Z,ee,te,ne,re,ae,ie,se=e.length,oe=se>>2,le=i,ue=s;if(g=le*ue,m=le>>1,_=t*(ue>>1),w=-m-1,R=-_-t,b=m,I=_,B=0,W=t-1,Y=0,q=oe-t,h=(oe<<1)+oe,y=(t<<1)+t,u=u||1,ie=0,a)for(T=r[0],O=r[g>>1],F=O-T,D=a[0],P=a[g>>1],k=P-D;u>ie;){for(v=new C(se),c=new A(h),M=0,L=0,f=d=p=0,x=0;t>x;x++,M+=4,L+=3)f+=e[M],d+=e[M+1],p+=e[M+2],c[L]=f,c[L+1]=d,c[L+2]=p;for(L=0,x=0,f=d=p=0,M=y+t;se>M;M+=4,L+=3,x++)x>=t&&(x=0,f=d=p=0),f+=e[M],d+=e[M+1],p+=e[M+2],c[L+y]=c[L]+f,c[L+y+1]=c[L+1]+d,c[L+y+2]=c[L+2]+p;for(x=0,N=0,S=0,M=0;se>M;M+=4,x++)x>=t&&(x=0,N++,S+=t),G=x+w,H=S+R,U=x+b,X=S+I,G=B>G?B:G,U=U>W?W:U,H=Y>H?Y:H,X=X>q?q:X,z=G+H,K=U+X,$=U+H,j=G+X,z=(z<<1)+z,$=($<<1)+$,j=(j<<1)+j,K=(K<<1)+K,Z=T*(c[K]-c[$]-c[j]+c[z])+F*e[M],ee=T*(c[K+1]-c[$+1]-c[j+1]+c[z+1])+F*e[M+1],te=T*(c[K+2]-c[$+2]-c[j+2]+c[z+2])+F*e[M+2],ne=D*(c[K]-c[$]-c[j]+c[z])+k*e[M],re=D*(c[K+1]-c[$+1]-c[j+1]+c[z+1])+k*e[M+1],ae=D*(c[K+2]-c[$+2]-c[j+2]+c[z+2])+k*e[M+2],J=o*Z+l*ne,V=o*ee+l*re,Q=o*te+l*ae,E&&(J=0>J?0:J>255?255:J,V=0>V?0:V>255?255:V,Q=0>Q?0:Q>255?255:Q),v[M]=~~J,v[M+1]=~~V,v[M+2]=~~Q,v[M+3]=e[M+3];e=v,ie++}else for(T=r[0],O=r[g>>1],F=O-T;u>ie;){for(v=new C(se),c=new A(h),M=0,L=0,f=d=p=0,x=0;t>x;x++,M+=4,L+=3)f+=e[M],d+=e[M+1],p+=e[M+2],c[L]=f,c[L+1]=d,c[L+2]=p;for(L=0,x=0,f=d=p=0,M=y+t;se>M;M+=4,L+=3,x++)x>=t&&(x=0,f=d=p=0),f+=e[M],d+=e[M+1],p+=e[M+2],c[L+y]=c[L]+f,c[L+y+1]=c[L+1]+d,c[L+y+2]=c[L+2]+p;for(x=0,N=0,S=0,M=0;se>M;M+=4,x++)x>=t&&(x=0,N++,S+=t),G=x+w,H=S+R,U=x+b,X=S+I,G=B>G?B:G,U=U>W?W:U,H=Y>H?Y:H,X=X>q?q:X,z=G+H,K=U+X,$=U+H,j=G+X,z=(z<<1)+z,$=($<<1)+$,j=(j<<1)+j,K=(K<<1)+K,Z=T*(c[K]-c[$]-c[j]+c[z])+F*e[M],ee=T*(c[K+1]-c[$+1]-c[j+1]+c[z+1])+F*e[M+1],te=T*(c[K+2]-c[$+2]-c[j+2]+c[z+2])+F*e[M+2],J=o*Z+l,V=o*ee+l,Q=o*te+l,E&&(J=0>J?0:J>255?255:J,V=0>V?0:V>255?255:V,Q=0>Q?0:Q>255?255:Q),v[M]=~~J,v[M+1]=~~V,v[M+2]=~~Q,v[M+3]=e[M+3];e=v,ie++}return v}function p(e,t,n,r,a,i,s,o,l){var u,c,h,f,d,p,m,_,g,v,y,w,A,R,I,M,L,x,N,S,T,O,F,D,P,k,G,H=e.length,U=H>>2;for(u=[a,r],c=[s,i],P=[l,o],M=t-1,L=U-t,G=2;G--;){for(m=new C(H),f=u[G],d=c[G],h=f.length,p=d.length,k=P[G],_=new b(d),y=0;p>y;y+=2)_[y+1]*=t;if(E)for(w=0,A=0,g=0;H>g;g+=4,w++){for(w>=t&&(w=0,A+=t),O=0,F=0,D=0,y=0,v=0;h>y;y++,v+=2)R=w+_[v],I=A+_[v+1],R>=0&&M>=R&&I>=0&&L>=I&&(srcOff=R+I<<2,T=f[y],O+=e[srcOff]*T,F+=e[srcOff+1]*T,D+=e[srcOff+2]*T);x=k*O,N=k*F,S=k*D,x=0>x?0:x>255?255:x,N=0>N?0:N>255?255:N,S=0>S?0:S>255?255:S,m[g]=~~x,m[g+1]=~~N,m[g+2]=~~S,m[g+3]=e[g+3]}else for(w=0,A=0,g=0;H>g;g+=4,w++){for(w>=t&&(w=0,A+=t),O=0,F=0,D=0,y=0,v=0;h>y;y++,v+=2)R=w+_[v],I=A+_[v+1],R>=0&&M>=R&&I>=0&&L>=I&&(srcOff=R+I<<2,T=f[y],O+=e[srcOff]*T,F+=e[srcOff+1]*T,D+=e[srcOff+2]*T);x=k*O,N=k*F,S=k*D,m[g]=~~x,m[g+1]=~~N,m[g+2]=~~S,m[g+3]=e[g+3]}e=m}return m}var m=(e.CONST.SQRT2,e.CONST.toRad),_=(e.CONST.toDeg,Math.abs),g=Math.sqrt,v=Math.sin,y=Math.cos,w=e.Array32F,C=e.ImArray,A=e.Array32F,b=e.Array16I,E=(e.Array8U,e._notSupportClamp),R=[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1],[1,5,10,10,5,1],[1,6,15,20,15,6,1],[1,7,21,35,35,21,7,1],[1,8,28,56,70,56,28,8,1]],I=e.ConvolutionMatrixFilter=e.Class(e.Filter,{name:"ConvolutionMatrixFilter",constructor:function(t,n,r){var a=this;a.$super("constructor"),a._coeff=new w([1,0]),t&&t.length?a.set(t,~~(g(t.length)+.5),n||1,r||0):(a._matrix=null,a._dim=0),a._matrix2=null,a._dim2=0,a._isGrad=!1,a._doIntegral=0,a._doSeparable=!1,e.useWebGL&&(a._webglInstance=e.WebGLConvolutionMatrixFilterInstance||null)},_dim:0,_dim2:0,_matrix:null,_matrix2:null,_mat:null,_mat2:null,_coeff:null,_isGrad:!1,_doIntegral:0,_doSeparable:!1,_indices:null,_indices2:null,_indicesf:null,_indicesf2:null,_webglInstance:null,dispose:function(){var e=this;return e.$super("dispose"),e._webglInstance=null,e._dim=null,e._dim2=null,e._matrix=null,e._matrix2=null,e._mat=null,e._mat2=null,e._coeff=null,e._isGrad=null,e._doIntegral=null,e._doSeparable=null,e._indices=null,e._indices2=null,e._indicesf=null,e._indicesf2=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_dim:e._dim,_dim2:e._dim2,_matrix:e._matrix,_matrix2:e._matrix2,_mat:e._mat,_mat2:e._mat2,_coeff:e._coeff,_isGrad:e._isGrad,_doIntegral:e._doIntegral,_doSeparable:e._doSeparable,_indices:e._indices,_indices2:e._indices2,_indicesf:e._indicesf,_indicesf2:e._indicesf2}}},unserialize:function(e){var t,n=this;return e&&n.name===e.filter&&(n._isOn=!!e._isOn,t=e.params,n._dim=t._dim,n._dim2=t._dim2,n._matrix=t._matrix,n._matrix2=t._matrix2,n._mat=t._mat,n._mat2=t._mat2,n._coeff=t._coeff,n._isGrad=t._isGrad,n._doIntegral=t._doIntegral,n._doSeparable=t._doSeparable,n._indices=t._indices,n._indices2=t._indices2,n._indicesf=t._indicesf,n._indicesf2=t._indicesf2),n},lowPass:function(e){return e=e===t?3:e%2?e:e+1,this.set(c(e),e,1/(e*e),0),this._doIntegral=1,this},highPass:function(e,n){e=e===t?3:e%2?e:e+1,n=n===t?1:n;var r=e*e,a=-n/r,i=c(e,a,1+a);return this.set(i,e,1,0),this._doIntegral=1,this},glow:function(e,n){return e=e===t?.5:e,this.highPass(n,-e)},sharpen:function(e,n){return e=e===t?.5:e,this.highPass(n,e)},verticalBlur:function(e){return e=e===t?3:e%2?e:e+1,this.set(a(e),1,1/e,0),this._dim2=e,this._doIntegral=1,this},horizontalBlur:function(e){return e=e===t?3:e%2?e:e+1,this.set(a(e),e,1/e,0),this._dim2=1,this._doIntegral=1,this},directionalBlur:function(e,n){n=n===t?3:n%2?n:n+1,e*=m;var r=y(e),a=-v(e),i=f(n,r,a,1/n);return this.set(i,n,1,0)},fastGauss:function(e,n){return n=n===t?3:n%2?n:n+1,e=~~(e||1),1>e?e=1:e>3&&(e=3),this.set(c(n),n,1/(n*n),0),this._doIntegral=e,this},binomialLowPass:function(e){e=e===t?3:e%2?e:e+1;var n=i(e),r=1<>1;for(r=0,a=0,n=0;l>n;)s.push(r-c),s.push(a-c),e[n]&&(i.push(r-c),i.push(a-c),o.push(e[n])),n++,r++,r>=u&&(r=0,a++);return[new b(i),new b(s),new w(o)]},reset:function(){var e=this;return e._matrix=e._matrix2=null,e._mat=e._mat2=null,e._dim=e._dim2=0,e._indices=e._indices2=e._indicesf=e._indicesf2=null,e._isGrad=!1,e._doIntegral=0,e._doSeparable=!1,e},combineWith:function(e){return this},getMatrix:function(){return this._matrix},setMatrix:function(e,t){return this.set(e,t)},_apply:function(e,t,n){var r=this;if(!r._isOn||!r._matrix)return e;if(r._doIntegral)return r._matrix2?d(e,t,n,r._matrix,r._matrix2,r._dim,r._dim2,r._coeff[0],r._coeff[1],r._doIntegral):d(e,t,n,r._matrix,null,r._dim,r._dim,r._coeff[0],r._coeff[1],r._doIntegral);if(r._doSeparable)return p(e,t,n,r._mat,r._mat2,r._indices,r._indices2,r._coeff[0],r._coeff[1]);var a,i,s,o,l,u,c,h,f,m,g,v,y,w,A,R,I,M,L,x,N,S,T=e.length,O=T>>2,F=new C(T),D=t-1,P=O-t,k=r._coeff[0],G=r._coeff[1],H=r._matrix,U=r._matrix2,X=r._isGrad;if(U){for(x=r._indicesf.length,S=new b(r._indicesf),u=0;x>u;u+=2)S[u+1]*=t;for(N=H.length,c=0,h=0,o=0;T>o;o+=4,c++){for(c>=t&&(c=0,h+=t),v=0,y=0,w=0,A=0,R=0,I=0,u=0,l=0;N>u;u++,l+=2)f=c+S[l],m=h+S[l+1],f>=0&&D>=f&&m>=0&&P>=m&&(g=f+m<<2,M=H[u],v+=e[g]*M,y+=e[g+1]*M,w+=e[g+2]*M,L=U[u],A+=e[g]*L,R+=e[g+1]*L,I+=e[g+2]*L);X?(a=_(v)+_(A),i=_(y)+_(R),s=_(w)+_(I)):(a=k*v+G*A,i=k*y+G*R,s=k*w+G*I),E&&(a=0>a?0:a>255?255:a,i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s),F[o]=~~a,F[o+1]=~~i,F[o+2]=~~s,F[o+3]=e[o+3]}}else{for(x=r._indices.length,S=new b(r._indices),u=0;x>u;u+=2)S[u+1]*=t;for(H=r._mat,N=H.length,c=0,h=0,o=0;T>o;o+=4,c++){for(c>=t&&(c=0,h+=t),v=0,y=0,w=0,u=0,l=0;N>u;u++,l+=2)f=c+S[l],m=h+S[l+1],f>=0&&D>=f&&m>=0&&P>=m&&(g=f+m<<2,M=H[u],v+=e[g]*M,y+=e[g+1]*M,w+=e[g+2]*M);a=k*v+G,i=k*y+G,s=k*w+G,E&&(a=0>a?0:a>255?255:a,i=0>i?0:i>255?255:i,s=0>s?0:s>255?255:s),F[o]=~~a,F[o+1]=~~i,F[o+2]=~~s,F[o+3]=e[o+3]}}return F},canRun:function(){return this._isOn&&this._matrix}});I.prototype.bump=I.prototype.emboss,I.prototype.boxBlur=I.prototype.lowPass,I.prototype.gaussBlur=I.prototype.binomialLowPass,I.prototype.gradX=I.prototype.prewittX,I.prototype.gradY=I.prototype.prewittY,I.prototype.gradDirectional=I.prototype.prewittDirectional,I.prototype.grad=I.prototype.prewitt}(FILTER),!function(e,t){var n,r=e.ImArray,a=e.Array8U,i=e.Array32I,s=Math.sqrt,o=function(e){var t,n=e*e,r=new a(n);for(t=0;n>t;t++)r[t]=1;return r},l=o(3);e.MorphologicalFilter=e.Class(e.Filter,{name:"MorphologicalFilter",constructor:function(){var e=this;e.$super("constructor"),e._filterName=null,e._filter=null,e._dim=0,e._structureElement=null,e._indices=null},_filterName:null,_filter:null,_dim:0,_structureElement:null,_indices:null,dispose:function(){var e=this;return e.$super("dispose"),e._filterName=null,e._filter=null,e._dim=null,e._structureElement=null,e._indices=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_filterName:e._filterName,_dim:e._dim,_structureElement:e._structureElement,_indices:e._indices}}},unserialize:function(e){var t,r=this;return e&&r.name===e.filter&&(r._isOn=!!e._isOn,t=e.params,r._dim=t._dim,r._structureElement=t._structureElement,r._indices=t._indices,r._filterName=t._filterName,r._filterName&&n[r._filterName]&&(r._filter=n[r._filterName])),r},erode:function(e){return this.set(e,"erode")},dilate:function(e){return this.set(e,"dilate")},opening:function(e){return this.set(e,"open")},closing:function(e){return this.set(e,"close")},set:function(e,t){var r=this;r._filterName=t,r._filter=n[t],e&&e.length?(r._structureElement=new a(e),r._dim=~~(s(r._structureElement.length)+.5)):e&&e===e-0?(r._structureElement=o(e),r._dim=e):(r._structureElement=l,r._dim=3);var u,c,h,f=[],e=r._structureElement,d=e.length,p=r._dim,m=p>>1;for(c=0,h=0,u=0;d>u;)e[u]&&(f.push(c-m),f.push(h-m)),u++,c++,c>=p&&(c=0,h++);return r._indices=new i(f),r},reset:function(){var e=this;return e._filterName=null,e._filter=null,e._dim=0,e._structureElement=null,e._indices=null,e},_apply:function(e,t,n){var r=this;return r._isOn&&r._dim&&r._filter?r._filter(r,e,t,n):e},canRun:function(){return this._isOn&&this._dim&&this._filter}});n={dilate:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=0,v=0,y=0,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],p>g&&(g=p),m>v&&(v=m),_>y&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E},erode:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E},open:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}for(t=E,E=new r(A),u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E},close:function(e,t,n,a){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w=e._structureElement,C=(w.length,e._dim,new i(e._indices)),A=t.length,b=A>>2,E=new r(A),R=C.length,I=R>>1,M=n-1,L=b-n;for(l=0;R>l;l+=2)C[l+1]*=n;for(u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}for(t=E,E=new r(A),u=0,c=0,s=0;A>s;s+=4,u++){for(u>=n&&(u=0,c+=n),g=255,v=255,y=255,o=0;I>o;o+=2)h=u+C[o],f=c+C[o+1],h>=0&&M>=h&&f>=0&&L>=f&&(d=h+f<<2,p=t[d],m=t[d+1],_=t[d+2],g>p&&(g=p),v>m&&(v=m),y>_&&(y=_));E[s]=g,E[s+1]=v,E[s+2]=y,E[s+3]=t[s+3]}return E}}}(FILTER),!function(e,t){var n,r=e.ImArray,a=e.Array32I,i=(Math.min,Math.max,e.StatisticalFilter=e.Class(e.Filter,{name:"StatisticalFilter",constructor:function(){var e=this;e.$super("constructor"),e._dim=0,e._indices=null,e._filterName=null,e._filter=null},_dim:0,_indices:null,_filter:null,_filterName:null,dispose:function(){var e=this;return e.$super("dispose"),e._dim=null,e._indices=null,e._filter=null,e._filterName=null,e},serialize:function(){var e=this;return{filter:e.name,_isOn:!!e._isOn,params:{_filterName:e._filterName,_dim:e._dim,_indices:e._indices}}},unserialize:function(e){var t,r=this;return e&&r.name===e.filter&&(r._isOn=!!e._isOn,t=e.params,r._dim=t._dim,r._indices=t._indices,r._filterName=t._filterName,r._filterName&&n[r._filterName]&&(r._filter=n[r._filterName])),r},median:function(e){return e=e===t?3:e%2?e:e+1,this.set(e,"median")},minimum:function(e){return e=e===t?3:e%2?e:e+1,this.set(e,"minimum")},maximum:function(e){return e=e===t?3:e%2?e:e+1,this.set(e,"maximum")},set:function(e,t){var r=this;r._filterName=t,r._filter=n[t],r._dim=e;var i,s,o,l=[],u=e*e,c=e,h=c>>1;for(s=0,o=0,i=0;u>i;)l.push(s-h),l.push(o-h),i++,s++,s>=c&&(s=0,o++);return r._indices=new a(l),r},reset:function(){var e=this;return e._filterName=null,e._filter=null,e._dim=0,e._indices=null,e},_apply:function(e,t,n){var r=this;return r._isOn&&r._dim?r._filter(r,e,t,n):e},canRun:function(){return this._isOn&&this._dim}}));i.prototype.erode=i.prototype.minimum,i.prototype.dilate=i.prototype.maximum,n={median:function(e,t,n,i){var s,o,l,u,c,h,f,d,p,m,_,g,v,y,w,C,A,b,E=e._dim,R=E*E,I=new a(e._indices),M=t.length,L=M>>2,x=new r(M),N=R<<1,S=n-1,T=L-n;for(d=[],p=[],m=[],o=0;N>o;o+=2)I[o+1]*=n;for(s=0,l=0,u=0;M>s;){for(d.length=0,p.length=0,m.length=0,o=0;N>o;)c=l+I[o],h=u+I[o+1],c>=0&&S>=c&&h>=0&&T>=h&&(f=c+h<<2,_=t[f],g=t[f+1],v=t[f+2],d.push(_),p.push(g),m.push(v)),o+=2;d.sort(),p.sort(),m.sort(),A=d.length,b=A>>1,y=A%2?d[b+1]:~~(.5*(d[b]+d[b+1])),A=p.length,b=A>>1,w=A%2?p[b+1]:~~(.5*(p[b]+p[b+1])),A=m.length,b=A>>1,C=A%2?m[b+1]:~~(.5*(m[b]+m[b+1])),x[s]=y,x[s+1]=w,x[s+2]=C,x[s+3]=t[s+3],s+=4,l++,l>=n&&(l=0,u+=n)}return x},maximum:function(e,t,n,i){var s,o,l,u,c,h,f,d,p,m,_,g,v,y=e._dim,w=y*y,C=new a(e._indices),A=t.length,b=A>>2,E=new r(A),R=w<<1,I=n-1,M=b-n;for(o=0;R>o;o+=2)C[o+1]*=n;for(s=0,l=0,u=0;A>s;){for(_=0,g=0,v=0,o=0;R>o;)c=l+C[o],h=u+C[o+1],c>=0&&I>=c&&h>=0&&M>=h&&(f=c+h<<2,d=t[f],p=t[f+1],m=t[f+2],d>_&&(_=d),p>g&&(g=p),m>v&&(v=m)),o+=2;E[s]=_,E[s+1]=g,E[s+2]=v,E[s+3]=t[s+3],s+=4,l++,l>=n&&(l=0,u+=n)}return E},minimum:function(e,t,n,i){var s,o,l,u,c,h,f,d,p,m,_,g,v,y=e._dim,w=y*y,C=new a(e._indices),A=t.length,b=A>>2,E=new r(A),R=w<<1,I=n-1,M=b-n;for(o=0;R>o;o+=2)C[o+1]*=n;for(s=0,l=0,u=0;A>s;){for(_=255,g=255,v=255,o=0;R>o;)c=l+C[o],h=u+C[o+1],c>=0&&I>=c&&h>=0&&M>=h&&(f=c+h<<2,d=t[f],p=t[f+1],m=t[f+2],_>d&&(_=d),g>p&&(g=p),v>m&&(v=m)),o+=2;E[s]=_,E[s+1]=g,E[s+2]=v,E[s+3]=t[s+3],s+=4,l++,l>=n&&(l=0,u+=n)}return E}}}(FILTER),!function(e,t){function n(e){var t,n;for(e>0&&1>e&&(e*=65536),e=u(e),256>e&&(e|=e<<8),n=0;256>n;n++)t=1&n?h[n]^255&e:h[n]^e>>8&255,f[n]=f[n+256]=t}function r(e,t,n){var r=7&e,a=4>r?t:n,i=4>r?n:t;return(1&r?-a:a)+(2&r?-2*i:2*i)}function a(e,t){var n,a,i,s,o,l=.366025403,c=.211324865,h=(e+t)*l,d=e+h,p=t+h,m=u(d),_=u(p),g=(m+_)*c,v=m-g,y=_-g,w=e-v,C=t-y; +w>C?(s=1,o=0):(s=0,o=1);var A=w-s+c,b=C-o+c,E=w-1+2*c,R=C-1+2*c,I=255&m,M=255&_,L=.5-w*w-C*C;0>L?n=0:(L*=L,n=L*L*r(f[I+f[M]],w,C));var x=.5-A*A-b*b;0>x?a=0:(x*=x,a=x*x*r(f[I+s+f[M+o]],A,b));var N=.5-E*E-R*R;return 0>N?i=0:(N*=N,i=N*N*r(f[I+1+f[M+1]],E,R)),40*(n+a+i)}function i(e){return e*e*e*(e*(6*e-15)+10)}function s(e,t,n){return t+e*(n-t)}function o(e,t){var n,a,o,l,c,h,d,p,m,_,g,v,y,w;return n=u(e),a=u(t),c=e-n,h=t-a,d=c-1,p=h-1,o=n+1&255,l=a+1&255,n=255&n,a=255&a,_=i(h),m=i(c),g=r(f[n+f[a]],c,h),v=r(f[n+f[l]],c,p),y=s(_,g,v),g=r(f[o+f[a]],d,h),v=r(f[o+f[l]],d,p),w=s(_,g,v),.507*s(m,y,w)}function l(e,t,n,r,a,i,s,o,l,u,c){var h,f,d,p=0,m=u,_=1,g=0;for(h=0;o>h;h++)f=(t+l[h][0])%r,d=(n+l[h][1])%a,p+=e(m*f*i,m*d*s)*_,m*=2,g+=_,_*=c;return p/g}var u=Math.floor,c=(Math.sin,Math.cos,e.CONST.PI2,e.Array8U),h=new c([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,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 c(h);e.PerlinNoise={seed:n,Image:function(t,n,r,i,s,u,c,h,f,d){var p,m,_,g,v,y,w=(new e.Image).restorable(!1).fill("rgb(0,0,0)",0,0,n,r),C=1/i,A=1/s,b=d?o:a,n=w.width,r=w.height,E=w.getData(),R=E.length,I=n>>>1,M=r>>>1;if(h=h||1,f=f||.5,u=u||1,c=c||[[0,0]],t)for(p=0,m=0,v=0;R>v;v+=4,p++)p>=n&&(p=0,m++),_=p>I?n-1-p:p,g=m>M?r-1-m:m,p>_||m>g?(y=g*n+_<<2,E[v]=E[y],E[v+1]=E[y+1],E[v+2]=E[y+2]):(E[v]=~~(255*(.5*l(b,_,g,n,r,C,A,u,c,h,f)+.5)),E[v+1]=E[v],E[v+2]=E[v]);else for(p=0,m=0,v=0;R>v;v+=4,p++)p>=n&&(p=0,m++),E[v]=~~(255*(.5*l(b,_,g,n,r,C,A,u,c,h,f)+.5)),E[v+1]=E[v],E[v+2]=E[v];return w.setData(E),w}}}(FILTER),FILTER}); \ No newline at end of file diff --git a/screenshots/filters-image-process.png b/screenshots/filters-image-process.png index 7c0e25e..effbdbc 100644 Binary files a/screenshots/filters-image-process.png and b/screenshots/filters-image-process.png differ diff --git a/src/core/Loader.js b/src/core/Loader.js index 8ead3fa..50939e2 100644 --- a/src/core/Loader.js +++ b/src/core/Loader.js @@ -269,7 +269,6 @@ XHR.create = FILTER.Browser.isNode if ( o.onStateChange ) o.onStateChange( xhr ); response.on('data', function( chunk ){ - xdata += chunk.toString( ); if ( !data_sent ) { data_sent = 1; @@ -277,6 +276,7 @@ XHR.create = FILTER.Browser.isNode if ( o.onStateChange ) o.onStateChange( xhr ); if ( o.onLoadStart ) o.onLoadStart( xhr ); } + xdata += chunk.toString( ); if ( o.onProgress ) o.onProgress( xhr ); }); @@ -288,7 +288,7 @@ XHR.create = FILTER.Browser.isNode if ( o.onStateChange ) o.onStateChange( xhr ); if ( o.onLoadEnd ) o.onLoadEnd( xhr ); - if ( (XHR.DONE === xhr.readyState) ) + if ( XHR.DONE === xhr.readyState ) { if ( 200 === xhr.status ) { @@ -340,12 +340,8 @@ XHR.create = FILTER.Browser.isNode }), update = function( xhr, $xhr$ ) { + //xhr.responseType = $xhr$.responseType; xhr.readyState = $xhr$.readyState; - xhr.responseType = $xhr$.responseType; - xhr.responseURL = $xhr$.responseURL; - xhr.response = $xhr$.response; - xhr.responseText = $xhr$.responseText; - xhr.responseXml = $xhr$.responseXml; xhr.status = $xhr$.status; xhr.statusText = $xhr$.statusText; return xhr; @@ -360,7 +356,7 @@ XHR.create = FILTER.Browser.isNode }; $xhr$.open( o.method||'GET', o.url, !o.sync ); - xhr.responseType = $xhr$.responseType = o.responseType || 'text'; + if ( o.responseType ) xhr.responseType = $xhr$.responseType = o.responseType; $xhr$.timeout = o.timeout || 30000; // 30 secs default timeout if ( o.onProgress ) @@ -388,11 +384,15 @@ XHR.create = FILTER.Browser.isNode }; } $xhr$.onload = function( ) { - update( xhr, $xhr$ ); - if ( (XHR.DONE === $xhr$.readyState) ) + if ( XHR.DONE === $xhr$.readyState ) { + update( xhr, $xhr$ ); if ( 200 === $xhr$.status ) { + xhr.responseURL = $xhr$.responseURL; + xhr.response = $xhr$.response; + //xhr.responseText = $xhr$.responseText; + //xhr.responseXml = $xhr$.responseXml; if ( o.onComplete ) o.onComplete( xhr ); } else @@ -424,8 +424,7 @@ var XHRLoader = FILTER.XHRLoader = Class(Loader, { constructor: function XHRLoader( ) { var self = this; - if ( !(self instanceof XHRLoader) ) - return new XHRLoader( ); + if ( !(self instanceof XHRLoader) ) return new XHRLoader( ); }, load: function ( url, onLoad, onError ) { @@ -433,13 +432,14 @@ var XHRLoader = FILTER.XHRLoader = Class(Loader, { XHR.create({ url: url, + responseType: self._responseType, onComplete: function( xhr ) { - if ( 'function' === typeof onLoad ) onLoad( 'arraybuffer' === self._responseType ? new Buffer(xhr.response) : xhr.response ); + if ( 'function' === typeof onLoad ) onLoad( xhr.response ); }, onError: function( xhr ) { if ( 'function' === typeof onError ) onError( xhr.statusText ); } - }); + }, null); /*if ( FILTER.Browser.isNode ) { // https://nodejs.org/api/http.html#http_http_request_options_callback @@ -479,17 +479,11 @@ var FileLoader = FILTER.FileLoader = Class(Loader, { constructor: function FileLoader( ) { var self = this; - if ( !(self instanceof FileLoader) ) - return new FileLoader( ); + if ( !(self instanceof FileLoader) ) return new FileLoader( ); }, load: function ( file, onLoad, onError ) { - var self = this, - options = { - // return raw buffer - encoding: 'arraybuffer' === self._responseType ? null : self._responseType, - flag: 'r' - }; + var self = this; // read file if ( FILTER.Browser.isNode ) { @@ -520,7 +514,7 @@ var FileLoader = FILTER.FileLoader = Class(Loader, { onError: function( xhr ) { if ( 'function' === typeof onError ) onError( xhr.statusText ); } - }); + }, null); } return self; } diff --git a/src/loaders/HTMLImageLoader.js b/src/loaders/HTMLImageLoader.js index ffc9a82..229f288 100644 --- a/src/loaders/HTMLImageLoader.js +++ b/src/loaders/HTMLImageLoader.js @@ -33,9 +33,7 @@ FILTER.HTMLImageLoader = FILTER.Class(FILTER.Loader, { if ( 'function' === typeof onError ) onError(image, loader); }; - if ( scope._crossOrigin ) loader.crossOrigin = scope._crossOrigin; - else loader.crossOrigin = ""; - + loader.crossOrigin = scope._crossOrigin || ""; loader.src = url; return image;