/*
 * Canvas2Image v0.1
 * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk
 * MIT License [http://www.opensource.org/licenses/mit-license.php]
 *
 * Modified by Aviary to AV namespace; no public vars 
 */typeof AV=="undefined"&&(AV={}),AV.toBitmapURL=function(e){var t=function(t){var n="";if(typeof t=="string")n=t;else{var r=t;for(var i=0;i<r.length;i++)n+=String.fromCharCode(r[i])}return e.btoa(n)},n=function(e){var n=[],r=e.width,i=e.height;n.push(66),n.push(77);var s=r*i*3+54;n.push(s%256),s=Math.floor(s/256),n.push(s%256),s=Math.floor(s/256),n.push(s%256),s=Math.floor(s/256),n.push(s%256),n.push(0),n.push(0),n.push(0),n.push(0),n.push(54),n.push(0),n.push(0),n.push(0);var o=[];o.push(40),o.push(0),o.push(0),o.push(0);var u=r;o.push(u%256),u=Math.floor(u/256),o.push(u%256),u=Math.floor(u/256),o.push(u%256),u=Math.floor(u/256),o.push(u%256);var a=i;o.push(a%256),a=Math.floor(a/256),o.push(a%256),a=Math.floor(a/256),o.push(a%256),a=Math.floor(a/256),o.push(a%256),o.push(1),o.push(0),o.push(24),o.push(0),o.push(0),o.push(0),o.push(0),o.push(0);var f=r*i*3;o.push(f%256),f=Math.floor(f/256),o.push(f%256),f=Math.floor(f/256),o.push(f%256),f=Math.floor(f/256),o.push(f%256);for(var l=0;l<16;l++)o.push(0);var c=(4-r*3%4)%4,h=e.data,p="",d=i;do{var v=r*(d-1)*4,m="";for(var g=0;g<r;g++){var y=4*g;m+=String.fromCharCode(h[v+y+2]),m+=String.fromCharCode(h[v+y+1]),m+=String.fromCharCode(h[v+y])}for(var b=0;b<c;b++)m+=String.fromCharCode(0);p+=m}while(--d);var w=t(n.concat(o))+t(p);return w};return function(e){var t=e.width,r=e.height;return n(e.getContext("2d").getImageData(0,0,t,r))}}(window);/*
 * Copyright 2012 Small Batch, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
/**
 * Global Aviary namespace object
 */
if (typeof AV == 'undefined') {
	AV = {};
}
;(function(window,document,undefined){
var h=void 0,j=!0,l=null,o=!1;function p(a){return function(){return this[a]}}var q;function r(a,c,b){var d=2<arguments.length?Array.prototype.slice.call(arguments,2):[];return function(){d.push.apply(d,arguments);return c.apply(a,d)}};function s(a){this.F=a;this.U=h}s.prototype.createElement=function(a,c,b){a=this.F.createElement(a);if(c)for(var d in c)c.hasOwnProperty(d)&&("style"==d?u(this,a,c[d]):a.setAttribute(d,c[d]));b&&a.appendChild(this.F.createTextNode(b));return a};function v(a,c,b){a=a.F.getElementsByTagName(c)[0];a||(a=document.documentElement);a&&a.lastChild&&a.insertBefore(b,a.lastChild)}function aa(a){function c(){document.body?a():setTimeout(c,0)}c()}function w(a){a.parentNode&&a.parentNode.removeChild(a)}
function x(a,c){return a.createElement("link",{rel:"stylesheet",href:c})}function y(a,c){return a.createElement("script",{src:c})}function z(a,c){for(var b=a.className.split(/\s+/),d=0,e=b.length;d<e;d++)if(b[d]==c)return;b.push(c);a.className=b.join(" ").replace(/^\s+/,"")}function A(a,c){for(var b=a.className.split(/\s+/),d=[],e=0,g=b.length;e<g;e++)b[e]!=c&&d.push(b[e]);a.className=d.join(" ").replace(/^\s+/,"").replace(/\s+$/,"")}
function ba(a,c){for(var b=a.className.split(/\s+/),d=0,e=b.length;d<e;d++)if(b[d]==c)return j;return o}function u(a,c,b){if(a.U===h){var d=a.F.createElement("p");d.innerHTML='<a style="top:1px;">w</a>';a.U=/top/.test(d.getElementsByTagName("a")[0].getAttribute("style"))}a.U?c.setAttribute("style",b):c.style.cssText=b};function B(a,c,b,d,e,g,f,i){this.za=a;this.Fa=c;this.na=b;this.ma=d;this.Ca=e;this.Ba=g;this.la=f;this.Ga=i}q=B.prototype;q.getName=p("za");q.va=p("Fa");q.X=p("na");q.sa=p("ma");q.ta=p("Ca");q.ua=p("Ba");q.ra=p("la");q.w=p("Ga");function C(a,c){this.a=a;this.j=c}var ca=new B("Unknown","Unknown","Unknown","Unknown","Unknown","Unknown",h,o);
C.prototype.parse=function(){var a;if(-1!=this.a.indexOf("MSIE"))if(a=D(this.a,/(MSIE [\d\w\.]+)/,1),""!=a){var c=a.split(" ");a=c[0];c=c[1];a=new B(a,c,a,c,F(this),G(this),H(this.j),6<=I(c))}else a=new B("MSIE","Unknown","MSIE","Unknown",F(this),G(this),H(this.j),o);else if(-1!=this.a.indexOf("Opera"))a:{var c=a="Unknown",b=D(this.a,/(Presto\/[\d\w\.]+)/,1);""!=b?(c=b.split("/"),a=c[0],c=c[1]):(-1!=this.a.indexOf("Gecko")&&(a="Gecko"),b=D(this.a,/rv:([^\)]+)/,1),""!=b&&(c=b));if(-1!=this.a.indexOf("Opera Mini/"))b=
D(this.a,/Opera Mini\/([\d\.]+)/,1),""==b&&(b="Unknown"),a=new B("OperaMini",b,a,c,F(this),G(this),H(this.j),o);else{if(-1!=this.a.indexOf("Version/")&&(b=D(this.a,/Version\/([\d\.]+)/,1),""!=b)){a=new B("Opera",b,a,c,F(this),G(this),H(this.j),10<=I(b));break a}b=D(this.a,/Opera[\/ ]([\d\.]+)/,1);a=""!=b?new B("Opera",b,a,c,F(this),G(this),H(this.j),10<=I(b)):new B("Opera","Unknown",a,c,F(this),G(this),H(this.j),o)}}else if(-1!=this.a.indexOf("AppleWebKit")){a=F(this);c=G(this);b=D(this.a,/AppleWebKit\/([\d\.\+]+)/,
1);""==b&&(b="Unknown");var d="Unknown";-1!=this.a.indexOf("Chrome")||-1!=this.a.indexOf("CrMo")||-1!=this.a.indexOf("CriOS")?d="Chrome":-1!=this.a.indexOf("Safari")?d="Safari":-1!=this.a.indexOf("AdobeAIR")&&(d="AdobeAIR");var e="Unknown";-1!=this.a.indexOf("Version/")?e=D(this.a,/Version\/([\d\.\w]+)/,1):"Chrome"==d?e=D(this.a,/(Chrome|CrMo|CriOS)\/([\d\.]+)/,2):"AdobeAIR"==d&&(e=D(this.a,/AdobeAIR\/([\d\.]+)/,1));var g=o;"AdobeAIR"==d?(g=D(e,/\d+\.(\d+)/,1),g=2<I(e)||2==I(e)&&5<=parseInt(g,10)):
(g=D(b,/\d+\.(\d+)/,1),g=526<=I(b)||525<=I(b)&&13<=parseInt(g,10));a=new B(d,e,"AppleWebKit",b,a,c,H(this.j),g)}else-1!=this.a.indexOf("Gecko")?(c=a="Unknown",d=o,-1!=this.a.indexOf("Firefox")?(a="Firefox",b=D(this.a,/Firefox\/([\d\w\.]+)/,1),""!=b&&(d=D(b,/\d+\.(\d+)/,1),c=b,d=""!=b&&3<=I(b)&&5<=parseInt(d,10))):-1!=this.a.indexOf("Mozilla")&&(a="Mozilla"),b=D(this.a,/rv:([^\)]+)/,1),""==b?b="Unknown":d||(d=I(b),e=parseInt(D(b,/\d+\.(\d+)/,1),10),g=parseInt(D(b,/\d+\.\d+\.(\d+)/,1),10),d=1<d||1==
d&&9<e||1==d&&9==e&&2<=g||b.match(/1\.9\.1b[123]/)!=l||b.match(/1\.9\.1\.[\d\.]+/)!=l),a=new B(a,c,"Gecko",b,F(this),G(this),H(this.j),d)):a=ca;return a};function F(a){var c=D(a.a,/(iPod|iPad|iPhone|Android)/,1);if(""!=c)return c;a=D(a.a,/(Linux|Mac_PowerPC|Macintosh|Windows|CrOS)/,1);return""!=a?("Mac_PowerPC"==a&&(a="Macintosh"),a):"Unknown"}
function G(a){var c=D(a.a,/(OS X|Windows NT|Android|CrOS) ([^;)]+)/,2);if(c||(c=D(a.a,/(iPhone )?OS ([\d_]+)/,2)))return c;return(a=D(a.a,/Linux ([i\d]+)/,1))?a:"Unknown"}function I(a){a=D(a,/(\d+)/,1);return""!=a?parseInt(a,10):-1}function D(a,c,b){return(a=a.match(c))&&a[b]?a[b]:""}function H(a){if(a.documentMode)return a.documentMode};function da(a,c,b){this.c=a;this.g=c;this.V=b;this.k="wf";this.h=new fa("-")}function ga(a){z(a.g,a.h.e(a.k,"loading"));J(a,"loading")}function K(a){A(a.g,a.h.e(a.k,"loading"));ba(a.g,a.h.e(a.k,"active"))||z(a.g,a.h.e(a.k,"inactive"));J(a,"inactive")}function J(a,c,b,d){if(a.V[c])a.V[c](b,d)};function ha(){this.ea={}}function ia(a,c){var b=[],d;for(d in c)if(c.hasOwnProperty(d)){var e=a.ea[d];e&&b.push(e(c[d]))}return b};function L(a,c,b,d,e){this.c=a;this.A=c;this.n=b;this.u=d;this.D=e;this.L=0;this.ia=this.da=o}L.prototype.watch=function(a,c,b,d,e){for(var g=a.length,f=0;f<g;f++){var i=a[f];c[i]||(c[i]=["n4"]);this.L+=c[i].length}e&&(this.da=e);for(f=0;f<g;f++)for(var i=a[f],e=c[i],m=b[i],k=0,n=e.length;k<n;k++){var E=e[k],t=this.A,P=i,ea=E;z(t.g,t.h.e(t.k,P,ea,"loading"));J(t,"fontloading",P,ea);t=r(this,this.oa);P=r(this,this.pa);(new d(t,P,this.c,this.n,this.u,this.D,i,E,m)).start()}};
L.prototype.oa=function(a,c){var b=this.A;A(b.g,b.h.e(b.k,a,c,"loading"));A(b.g,b.h.e(b.k,a,c,"inactive"));z(b.g,b.h.e(b.k,a,c,"active"));J(b,"fontactive",a,c);this.ia=j;ja(this)};L.prototype.pa=function(a,c){var b=this.A;A(b.g,b.h.e(b.k,a,c,"loading"));ba(b.g,b.h.e(b.k,a,c,"active"))||z(b.g,b.h.e(b.k,a,c,"inactive"));J(b,"fontinactive",a,c);ja(this)};
function ja(a){0==--a.L&&a.da&&(a.ia?(a=a.A,A(a.g,a.h.e(a.k,"loading")),A(a.g,a.h.e(a.k,"inactive")),z(a.g,a.h.e(a.k,"active")),J(a,"active")):K(a.A))};function M(a,c,b,d,e,g,f,i,m){this.I=a;this.Z=c;this.c=b;this.n=d;this.u=e;this.D=g;this.ya=new ka;this.v=new N;this.M=f;this.B=i;this.qa=m||"BESbswy";this.P=la(this,"arial,'URW Gothic L',sans-serif");this.Q=la(this,"Georgia,'Century Schoolbook L',serif");this.ba=this.P;this.ca=this.Q;this.R=O(this,"arial,'URW Gothic L',sans-serif");this.S=O(this,"Georgia,'Century Schoolbook L',serif")}M.prototype.start=function(){this.ha=this.D();this.K()};
M.prototype.K=function(){var a=this.n.p(this.R),c=this.n.p(this.S);(this.P!=a||this.Q!=c)&&this.ba==a&&this.ca==c?Q(this,this.I):5E3<=this.D()-this.ha?Q(this,this.Z):(this.ba=a,this.ca=c,ma(this))};function ma(a){a.u(function(a,b){return function(){b.call(a)}}(a,a.K),25)}function Q(a,c){w(a.R);w(a.S);c(a.M,a.B)}function la(a,c){var b=O(a,c,j),d=a.n.p(b);w(b);return d}function O(a,c,b){c=a.c.createElement("span",{style:R(a,c,a.B,b)},a.qa);v(a.c,"body",c);return c}
function R(a,c,b,d){b=a.v.expand(b);return"position:absolute;top:-999px;left:-999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;font-family:"+(d?"":a.ya.quote(a.M)+",")+c+";"+b};function S(a,c,b,d,e){this.c=a;this.W=c;this.g=b;this.u=d;this.a=e;this.N=this.O=0}S.prototype.q=function(a,c){this.W.ea[a]=c};S.prototype.load=function(a){var c=new da(this.c,this.g,a);this.a.w()?na(this,c,a):K(c)};S.prototype.wa=function(a,c,b,d){var e=a.Y?a.Y():M;d?a.load(r(this,this.Aa,c,b,e)):(a=0==--this.O,this.N--,a&&(0==this.N?K(c):ga(c)),b.watch([],{},{},e,a))};
S.prototype.Aa=function(a,c,b,d,e,g){var f=0==--this.O;f&&ga(a);this.u(r(this,function(a,b,c,d,e,g){a.watch(b,c||{},d||{},e,g)},c,d,e,g,b,f))};function na(a,c,b){b=ia(a.W,b);a.N=a.O=b.length;for(var d=new L(a.c,c,{p:function(a){return a.offsetWidth}},a.u,function(){return(new Date).getTime()}),e=0,g=b.length;e<g;e++){var f=b[e];f.z(a.a,r(a,a.wa,f,c,d))}};function fa(a){this.xa=a||"-"}fa.prototype.e=function(a){for(var c=[],b=0;b<arguments.length;b++)c.push(arguments[b].replace(/[\W_]+/g,"").toLowerCase());return c.join(this.xa)};function ka(){this.ga="'"}ka.prototype.quote=function(a){for(var c=[],a=a.split(/,\s*/),b=0;b<a.length;b++){var d=a[b].replace(/['"]/g,"");-1==d.indexOf(" ")?c.push(d):c.push(this.ga+d+this.ga)}return c.join(",")};function N(){this.H=oa;this.o=pa}var oa=["font-style","font-weight"],pa={"font-style":[["n","normal"],["i","italic"],["o","oblique"]],"font-weight":[["1","100"],["2","200"],["3","300"],["4","400"],["5","500"],["6","600"],["7","700"],["8","800"],["9","900"],["4","normal"],["7","bold"]]};function T(a,c,b){this.$=a;this.Da=c;this.o=b}T.prototype.compact=function(a,c){for(var b=0;b<this.o.length;b++)if(c==this.o[b][1]){a[this.$]=this.o[b][0];break}};
T.prototype.expand=function(a,c){for(var b=0;b<this.o.length;b++)if(c==this.o[b][0]){a[this.$]=this.Da+":"+this.o[b][1];break}};N.prototype.compact=function(a){for(var c=["n","4"],a=a.split(";"),b=0,d=a.length;b<d;b++){var e=a[b].replace(/\s+/g,"").split(":");if(2==e.length){var g=e[1];a:{for(var e=e[0],f=0;f<this.H.length;f++)if(e==this.H[f]){e=new T(f,e,this.o[e]);break a}e=l}e&&e.compact(c,g)}}return c.join("")};
N.prototype.expand=function(a){if(2!=a.length)return l;for(var c=[l,l],b=0,d=this.H.length;b<d;b++){var e=this.H[b];(new T(b,e,this.o[e])).expand(c,a.substr(b,1))}return c[0]&&c[1]?c.join(";")+";":l};var U=window.AV.WebFont=function(){var a=(new C(navigator.userAgent,document)).parse();return new S(new s(document),new ha,document.documentElement,function(a,b){setTimeout(a,b)},a)}();U.load=U.load;U.addModule=U.q;B.prototype.getName=B.prototype.getName;B.prototype.getVersion=B.prototype.va;B.prototype.getEngine=B.prototype.X;B.prototype.getEngineVersion=B.prototype.sa;B.prototype.getPlatform=B.prototype.ta;B.prototype.getPlatformVersion=B.prototype.ua;B.prototype.getDocumentMode=B.prototype.ra;
B.prototype.isSupportingWebFont=B.prototype.w;function V(a,c,b){this.m=a;this.c=c;this.d=b;this.f=[];this.s={};this.v=new N}V.prototype.C=function(a){return("https:"==this.m.location.protocol?"https:":"http:")+(this.d.api||"//f.fontdeck.com/s/css/js/")+this.m.document.location.hostname+"/"+a+".js"};
V.prototype.z=function(a,c){var b=this.d.id,d=this;b?(this.m.__webfontfontdeckmodule__||(this.m.__webfontfontdeckmodule__={}),this.m.__webfontfontdeckmodule__[b]=function(a,b){for(var f=0,i=b.fonts.length;f<i;++f){var m=b.fonts[f];d.f.push(m.name);d.s[m.name]=[d.v.compact("font-weight:"+m.weight+";font-style:"+m.style)]}c(a)},v(this.c,"head",y(this.c,this.C(b)))):c(j)};V.prototype.load=function(a){a(this.f,this.s)};U.q("fontdeck",function(a){return new V(window,new s(document),a)});function W(a,c){this.c=a;this.d=c}var qa={regular:"n4",bold:"n7",italic:"i4",bolditalic:"i7",r:"n4",b:"n7",i:"i4",bi:"i7"};W.prototype.z=function(a,c){return c(a.w())};
W.prototype.load=function(a){var c,b;v(this.c,"head",x(this.c,("https:"==document.location.protocol?"https:":"http:")+"//webfonts.fontslive.com/css/"+this.d.key+".css"));var d=this.d.families,e,g;e=[];g={};for(var f=0,i=d.length;f<i;f++){b=b=c=h;b=d[f].split(":");c=b[0];if(b[1]){b=b[1].split(",");for(var m=[],k=0,n=b.length;k<n;k++){var E=b[k];if(E){var t=qa[E];m.push(t?t:E)}}b=m}else b=["n4"];e.push(c);g[c]=b}a(e,g)};U.q("ascender",function(a){return new W(new s(document),a)});function ra(a,c){this.c=a;this.d=c}ra.prototype.load=function(a){for(var c=this.d.urls||[],b=this.d.families||[],d=0,e=c.length;d<e;d++)v(this.c,"head",x(this.c,c[d]));a(b)};ra.prototype.z=function(a,c){return c(a.w())};U.q("custom",function(a){return new ra(new s(document),a)});function X(a,c,b,d,e){this.m=a;this.a=c;this.c=b;this.j=d;this.d=e;this.f=[];this.s={}}X.prototype.z=function(a,c){var b=this,d=b.d.projectId;if(d){var e=y(b.c,b.C(d));e.id="__MonotypeAPIScript__"+d;e.onreadystatechange=function(a){if("loaded"===e.readyState||"complete"===e.readyState)e.onreadystatechange=l,e.onload(a)};e.onload=function(){if(b.m["__mti_fntLst"+d]){var e=b.m["__mti_fntLst"+d]();if(e&&e.length){var f;for(f=0;f<e.length;f++)b.f.push(e[f].fontfamily)}}c(a.w())};v(this.c,"head",e)}else c(j)};
X.prototype.C=function(a){var c=this.protocol(),b=(this.d.api||"fast.fonts.com/jsapi").replace(/^.*http(s?):(\/\/)?/,"");return c+"//"+b+"/"+a+".js"};X.prototype.load=function(a){a(this.f,this.s)};X.prototype.protocol=function(){var a=["http:","https:"],c=a[0];if(this.j&&this.j.location&&this.j.location.protocol)for(var b=0,b=0;b<a.length;b++)if(this.j.location.protocol===a[b])return this.j.location.protocol;return c};
U.q("monotype",function(a){var c=(new C(navigator.userAgent,document)).parse();return new X(window,c,new s(document),document,a)});function Y(a,c,b){this.m=a;this.c=c;this.d=b;this.f=[];this.s={}}Y.prototype.C=function(a){var c="https:"==window.location.protocol?"https:":"http:";return(this.d.api||c+"//use.typekit.com")+"/"+a+".js"};Y.prototype.z=function(a,c){var b=this.d.id,d=this.d,e=this;b?(this.m.__webfonttypekitmodule__||(this.m.__webfonttypekitmodule__={}),this.m.__webfonttypekitmodule__[b]=function(b){b(a,d,function(a,b,d){e.f=b;e.s=d;c(a)})},v(this.c,"head",y(this.c,this.C(b)))):c(j)};
Y.prototype.load=function(a){a(this.f,this.s)};U.q("typekit",function(a){return new Y(window,new s(document),a)});function Z(a,c,b,d,e,g,f,i,m){Z.Ea.call(this,a,c,b,d,e,g,f,i,m);a=["Times New Roman","Arial","Times","Sans","Serif"];c=a.length;b={};d=O(this,a[0],j);b[this.n.p(d)]=j;for(e=1;e<c;e++)g=a[e],u(this.c,d,R(this,g,this.B,j)),b[this.n.p(d)]=j,"4"!=this.B[1]&&(u(this.c,d,R(this,g,this.B[0]+"4",j)),b[this.n.p(d)]=j);w(d);this.t=b;this.ka=o}(function(a,c){function b(){}b.prototype=a.prototype;c.prototype=new b;c.Ea=a;c.Ha=a.prototype})(M,Z);var sa={Arimo:j,Cousine:j,Tinos:j};
Z.prototype.K=function(){var a=this.n.p(this.R),c=this.n.p(this.S);!this.ka&&a==c&&this.t[a]&&(this.t={},this.ka=this.t[a]=j);(this.P!=a||this.Q!=c)&&!this.t[a]&&!this.t[c]?Q(this,this.I):5E3<=this.D()-this.ha?this.t[a]&&this.t[c]&&sa[this.M]?Q(this,this.I):Q(this,this.Z):ma(this)};function ta(a){this.J=a?a:("https:"==window.location.protocol?"https:":"http:")+ua;this.f=[];this.T=[]}var ua="//fonts.googleapis.com/css";ta.prototype.e=function(){if(0==this.f.length)throw Error("No fonts to load !");if(-1!=this.J.indexOf("kit="))return this.J;for(var a=this.f.length,c=[],b=0;b<a;b++)c.push(this.f[b].replace(/ /g,"+"));a=this.J+"?family="+c.join("%7C");0<this.T.length&&(a+="&subset="+this.T.join(","));return a};function va(a){this.f=a;this.fa=[];this.ja={};this.G={};this.v=new N}var wa={ultralight:"n2",light:"n3",regular:"n4",bold:"n7",italic:"i4",bolditalic:"i7",ul:"n2",l:"n3",r:"n4",b:"n7",i:"i4",bi:"i7"},xa={latin:"BESbswy",cyrillic:"&#1081;&#1103;&#1046;",greek:"&#945;&#946;&#931;",khmer:"&#x1780;&#x1781;&#x1782;",Hanuman:"&#x1780;&#x1781;&#x1782;"};
va.prototype.parse=function(){for(var a=this.f.length,c=0;c<a;c++){var b=this.f[c].split(":"),d=b[0].replace(/\+/g," "),e=["n4"];if(2<=b.length){var g;var f=b[1];g=[];if(f)for(var f=f.split(","),i=f.length,m=0;m<i;m++){var k;k=f[m];if(k.match(/^[\w ]+$/)){var n=wa[k];n?k=n:(n=k.match(/^(\d*)(\w*)$/),k=n[1],n=n[2],k=(k=this.v.expand([n?n:"n",k?k.substr(0,1):"4"].join("")))?this.v.compact(k):l)}else k="";k&&g.push(k)}0<g.length&&(e=g);3==b.length&&(b=b[2],g=[],b=!b?g:b.split(","),0<b.length&&(b=xa[b[0]])&&
(this.G[d]=b))}this.G[d]||(b=xa[d])&&(this.G[d]=b);this.fa.push(d);this.ja[d]=e}};function $(a,c,b){this.a=a;this.c=c;this.d=b}$.prototype.z=function(a,c){c(a.w())};$.prototype.Y=function(){return"AppleWebKit"==this.a.X()?Z:M};$.prototype.load=function(a){"MSIE"==this.a.getName()&&this.d.blocking!=j?aa(r(this,this.aa,a)):this.aa(a)};
$.prototype.aa=function(a){for(var c=this.c,b=new ta(this.d.api),d=this.d.families,e=d.length,g=0;g<e;g++){var f=d[g].split(":");3==f.length&&b.T.push(f.pop());var i="";2==f.length&&""!=f[1]&&(i=":");b.f.push(f.join(i))}d=new va(d);d.parse();v(c,"head",x(c,b.e()));a(d.fa,d.ja,d.G)};U.q("google",function(a){var c=(new C(navigator.userAgent,document)).parse();return new $(c,new s(document),a)});window.WebFontConfig&&U.load(window.WebFontConfig);
})(this,document);
(function(){(function(){var C=function(q,B){var e=C.resolve(q,B||"/"),o=C.modules[e];if(!o)throw Error("Failed to resolve module "+q+", tried "+e);return(e=C.cache[e])?e.exports:o()};C.paths=[];C.modules={};C.cache={};C.extensions=[".js",".coffee",".json"];C._core={assert:!0,events:!0,fs:!0,path:!0,vm:!0};C.resolve=function(q,B){function e(a){a=h.normalize(a);if(C.modules[a])return a;for(var d=0;d<C.extensions.length;d++){var j=C.extensions[d];if(C.modules[a+j])return a+j}}function o(a){var a=a.replace(/\/+$/,
""),d=h.normalize(a+"/package.json");if(C.modules[d]){var d=C.modules[d](),j=d.browserify;if("object"===typeof j&&j.main){if(d=e(h.resolve(a,j.main)))return d}else if("string"===typeof j){if(d=e(h.resolve(a,j)))return d}else if(d.main&&(d=e(h.resolve(a,d.main))))return d}return e(a+"/index")}B||(B="/");if(C._core[q])return q;var h=C.modules.path(),a=(B=h.resolve("/",B))||"/";if(q.match(/^(?:\.\.?\/|\/)/)){var j=e(h.resolve(a,q))||o(h.resolve(a,q));if(j)return j}a:{for(var j="/"===a?[""]:h.normalize(a).split("/"),
a=[],f=j.length-1;0<=f;f--)if("node_modules"!==j[f]){var n=j.slice(0,f+1).join("/")+"/node_modules";a.push(n)}for(j=0;j<a.length;j++){f=a[j];if(n=e(f+"/"+q)){a=n;break a}if(f=o(f+"/"+q)){a=f;break a}}a=(n=e(q))?n:void 0}if(a)return a;throw Error("Cannot find module '"+q+"'");};C.alias=function(q,B){var e=C.modules.path(),o=null;try{o=C.resolve(q+"/package.json","/")}catch(h){o=C.resolve(q,"/")}for(var e=e.dirname(o),o=(Object.keys||function(a){var j=[],i;for(i in a)j.push(i);return j})(C.modules),
a=0;a<o.length;a++){var j=o[a];j.slice(0,e.length+1)===e+"/"?(j=j.slice(e.length),C.modules[B+j]=C.modules[e+j]):j===e&&(C.modules[B]=C.modules[e])}};var ba={},da="undefined"!==typeof window?window:{},ca=!1;C.define=function(q,B){!ca&&C.modules.__browserify_process&&(ba=C.modules.__browserify_process(),ca=!0);var e=C._core[q]?"":C.modules.path().dirname(q),o=function(a){var j=C(a,e);if((a=C.cache[C.resolve(a,e)])&&a.parent===null)a.parent=h;return j};o.resolve=function(a){return C.resolve(a,e)};o.modules=
C.modules;o.define=C.define;o.cache=C.cache;var h={id:q,filename:q,exports:{},loaded:!1,parent:null};C.modules[q]=function(){C.cache[q]=h;B.call(h.exports,o,h,h.exports,e,q,ba,da);h.loaded=true;return h.exports}};C.define("path",function(q,B,e,o,h,a){function j(a,d){for(var j=[],f=0;f<a.length;f++)d(a[f],f,a)&&j.push(a[f]);return j}function f(a,d){for(var j=0,f=a.length;0<=f;f--){var g=a[f];"."==g?a.splice(f,1):".."===g?(a.splice(f,1),j++):j&&(a.splice(f,1),j--)}if(d)for(;j--;j)a.unshift("..");return a}
var n=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;e.resolve=function(){for(var i="",d=!1,n=arguments.length;-1<=n&&!d;n--){var e=0<=n?arguments[n]:a.cwd();"string"===typeof e&&e&&(i=e+"/"+i,d="/"===e.charAt(0))}i=f(j(i.split("/"),function(a){return!!a}),!d).join("/");return(d?"/":"")+i||"."};e.normalize=function(a){var d="/"===a.charAt(0),n="/"===a.slice(-1),a=f(j(a.split("/"),function(a){return!!a}),!d).join("/");!a&&!d&&(a=".");a&&n&&(a+="/");return(d?"/":"")+a};e.join=function(){var a=Array.prototype.slice.call(arguments,
0);return e.normalize(j(a,function(a){return a&&"string"===typeof a}).join("/"))};e.dirname=function(a){return(a=n.exec(a)[1]||"")?1===a.length?a:a.substring(0,a.length-1):"."};e.basename=function(a,d){var j=n.exec(a)[2]||"";d&&j.substr(-1*d.length)===d&&(j=j.substr(0,j.length-d.length));return j};e.extname=function(a){return n.exec(a)[3]||""}});C.define("__browserify_process",function(q,B,e,o,h,a){a=B.exports={};a.nextTick=function(){if("undefined"!==typeof window&&window.setImmediate)return function(a){return window.setImmediate(a)};
if("undefined"!==typeof window&&window.postMessage&&window.addEventListener){var a=[];window.addEventListener("message",function(j){j.source===window&&"browserify-tick"===j.data&&(j.stopPropagation(),0<a.length&&a.shift()())},!0);return function(j){a.push(j);window.postMessage("browserify-tick","*")}}return function(a){setTimeout(a,0)}}();a.title="browser";a.browser=!0;a.env={};a.argv=[];a.binding=function(a){if("evals"===a)return q("vm");throw Error("No such module. (Possibly not yet loaded)");};
var j="/",f;a.cwd=function(){return j};a.chdir=function(a){f||(f=q("path"));j=f.resolve(a,j)}});C.define("/src/js/webgl/moaGL_bundle.js",function(q,B){var e=q("../filters/colorConversion.js"),o=function(b){return"normal"==b?0:"sharp"==b?1:"mediumSharp"==b?2:"ultraSharp"==b?3:-1},h=function(b){if("none"==b)return 0;if("halftone"==b)return 1;if("lines"==b)return 2;if("smooth"==b)return 3;if("shadow"==b)return 4;if("fade"==b)return 5;if("rough"==b)return 6;if("bulge"==b)return 7;if("torn"==b)return 8;
if("torn2"==b)return 9;if("rect"==b)return 10;if("round"==b)return 11;if("flickr"==b)return 12;if("hardrand"==b)return 13;if("instant"==b)return 14;if("vignette"==b)return 15;if("viewfinder"==b)return 16};B.exports={MoaGL:function(){this.glBuffers={};this.glBuffers={};this.glPrograms={};this.glRenderingObjects={};this.glImageData={};this.renderingMode=1;this.freeTextures=[];this.currentVertices=[];this.currentTexCoords=[];this.currentIndeces=[];this.currentBlendMode=0;this.freeTextures=[];this.stateOK=
!0;var b,m=this;this.setup=function(c){b=c;m.glImageData.pixelFormat=b.RGBA;m.createFramebuffer();m.setupVBOs();b.clearColor(0,0,0,1);m.glPrograms.bitmapIdentityProgram=D(m.glPrograms.bitmapIdentityProgram,f,a.VertexShader,a.BitmapIdentityFragmentShader,!1,b)};this.getGL=function(){return b};this.willAcceptImageOfSize=function(b,a){var c=m.maxImageDim();return b<=c&&0<b&&a<=c&&0<a};this.maxImageDim=function(){return b.getParameter(b.MAX_TEXTURE_SIZE)};this.deleteAllShaders=function(){};var j=function(m,
a,c,l){b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,a);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,m);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,c);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,l)};this.setImage=function(a){b.activeTexture(b.TEXTURE0);"undefined"===typeof m.glImageData.texID?(m.glImageData.texID=b.createTexture(),b.bindTexture(b.TEXTURE_2D,m.glImageData.texID),j(b.NEAREST,b.NEAREST,b.CLAMP_TO_EDGE,b.CLAMP_TO_EDGE)):b.bindTexture(b.TEXTURE_2D,m.glImageData.texID);b.texImage2D(b.TEXTURE_2D,
0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,a);if(m.glImageData.width!=a.width||m.glImageData.height!=a.height){m.glImageData.width=a.width;m.glImageData.height=a.height;var c=a.width,a=a.height;"undefined"===typeof m.glRenderingObjects.processedTexture1?(m.glRenderingObjects.processedTexture1=b.createTexture(),b.bindTexture(b.TEXTURE_2D,m.glRenderingObjects.processedTexture1),j(b.NEAREST,b.NEAREST,b.CLAMP_TO_EDGE,b.CLAMP_TO_EDGE)):b.bindTexture(b.TEXTURE_2D,m.glRenderingObjects.processedTexture1);b.texImage2D(b.TEXTURE_2D,
0,b.RGBA,c,a,0,b.RGBA,b.UNSIGNED_BYTE,null);"undefined"===typeof m.glRenderingObjects.processedTexture2?(m.glRenderingObjects.processedTexture2=b.createTexture(),b.bindTexture(b.TEXTURE_2D,m.glRenderingObjects.processedTexture2),j(b.NEAREST,b.NEAREST,b.CLAMP_TO_EDGE,b.CLAMP_TO_EDGE)):b.bindTexture(b.TEXTURE_2D,m.glRenderingObjects.processedTexture2);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,c,a,0,b.RGBA,b.UNSIGNED_BYTE,null)}};this.createFramebuffer=function(){"undefined"===typeof m.glRenderingObjects.offscreenFramebuffer&&
(m.glRenderingObjects.offscreenFramebuffer=b.createFramebuffer(),b.bindFramebuffer(b.FRAMEBUFFER,m.glRenderingObjects.offscreenFramebuffer))};this.setupVBOs=function(){m.glBuffers.positionBuffer=b.createBuffer();m.glBuffers.texCoordBuffer=b.createBuffer();m.resetVertexBufferVertices();var a=[0,1,2,2,3,0];m.currentIndeces=a;m.glBuffers.currentIndexBuffer=b.createBuffer();b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,m.glBuffers.currentIndexBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,new Uint16Array(a),b.STATIC_DRAW)};
this.resetVertexBufferVertices=function(){var a=[1,-1,0,1,1,0,-1,1,0,-1,-1,0],c=[1,0,1,1,0,1,0,0];m.currentVertices=a;m.currentTexCoords=c;b.bindBuffer(b.ARRAY_BUFFER,m.glBuffers.positionBuffer);b.bufferData(b.ARRAY_BUFFER,new Float32Array(a),b.STATIC_DRAW);b.bindBuffer(b.ARRAY_BUFFER,m.glBuffers.texCoordBuffer);b.bufferData(b.ARRAY_BUFFER,new Float32Array(c),b.STATIC_DRAW)};this.configureVertexArraysForDraw=function(a){b.enableVertexAttribArray(a.positionSlot);b.enableVertexAttribArray(a.texCoordSlot);
b.bindBuffer(b.ARRAY_BUFFER,m.glBuffers.positionBuffer);b.vertexAttribPointer(a.positionSlot,3,b.FLOAT,!1,0,0);b.bindBuffer(b.ARRAY_BUFFER,m.glBuffers.texCoordBuffer);b.vertexAttribPointer(a.texCoordSlot,2,b.FLOAT,!1,0,0)};this.createEffect=function(){m.resetFreeTextures();b.bindFramebuffer(b.FRAMEBUFFER,m.glRenderingObjects.offscreenFramebuffer);b.activeTexture(b.TEXTURE0);3!=m.renderingMode&&4!=m.renderingMode&&(m.glRenderingObjects.readTexture=m.glImageData.texID,m.glRenderingObjects.writeTexture=
m.glRenderingObjects.processedTexture1);b.bindTexture(b.TEXTURE_2D,m.glImageData.texID);j(b.NEAREST,b.NEAREST,b.CLAMP_TO_EDGE,b.CLAMP_TO_EDGE)};this.finalizeEffect=function(){if(1==m.renderingMode||4==m.renderingMode)b.bindFramebuffer(b.FRAMEBUFFER,null),b.activeTexture(b.TEXTURE0),b.bindTexture(b.TEXTURE_2D,m.glRenderingObjects.readTexture),b.useProgram(m.glPrograms.bitmapIdentityProgram),b.clear(b.COLOR_BUFFER_BIT),b.viewport(0,0,m.glImageData.width,m.glImageData.height),b.bindBuffer(b.ARRAY_BUFFER,
m.glBuffers.texCoordBuffer),b.bufferData(b.ARRAY_BUFFER,new Float32Array([1,1,1,0,0,0,0,1]),b.STATIC_DRAW),m.configureVertexArraysForDraw(m.glPrograms.bitmapIdentityProgram),b.uniform1i(m.glPrograms.bitmapIdentityProgram.samplerSlot,0),b.drawElements(b.TRIANGLES,m.currentIndeces.length,b.UNSIGNED_SHORT,0),m.resetVertexBufferVertices();else if(0==m.renderingMode){var a=m.glRenderingObjects.readTexture;if(a!=m.glImageData.texID){var c=m.glImageData.texID,l=m.glRenderingObjects.writeTexture;m.glImageData.texID=
a;m.glRenderingObjects.processedTexture2=l;m.glRenderingObjects.processedTexture1=c}}};this.startRender=function(a,c){m.currentBlendMode=c;0!=c&&6!=c?(m.glRenderingObjects.readTexture==m.glImageData.texID&&(this.renderIdentity(),m.currentBlendMode=c,b.useProgram(a)),b.enable(b.BLEND),1==c?b.blendFuncSeparate(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA,b.ZERO,b.ONE):2==c?b.blendFuncSeparate(b.DST_COLOR,b.SRC_ALPHA,b.ZERO,b.ONE):3==c?b.blendFuncSeparate(b.ONE,b.ONE_MINUS_SRC_ALPHA,b.ZERO,b.ONE):4==c?b.blendFunc(b.SRC_ALPHA,
b.SRC_ALPHA):5==c&&b.blendFunc(b.ONE_MINUS_DST_ALPHA,b.DST_ALPHA),b.blendEquation(b.FUNC_ADD)):(b.disable(b.BLEND),b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,m.glRenderingObjects.writeTexture,0),b.activeTexture(b.TEXTURE0),b.bindTexture(b.TEXTURE_2D,m.glRenderingObjects.readTexture),6!=c&&b.clear(b.COLOR_BUFFER_BIT));b.viewport(0,0,m.glImageData.width,m.glImageData.height);m.configureVertexArraysForDraw(a);b.uniform1i(a.samplerSlot,0)};this.finishRender=function(a){b.drawElements(b.TRIANGLES,
m.currentIndeces.length,b.UNSIGNED_SHORT,0);a&&m.swapTextures()};this.swapTextures=function(){m.glRenderingObjects.writeTexture=m.glRenderingObjects.writeTexture==m.glRenderingObjects.processedTexture2?m.glRenderingObjects.processedTexture1:m.glRenderingObjects.processedTexture2;m.glRenderingObjects.readTexture=m.glRenderingObjects.writeTexture==m.glRenderingObjects.processedTexture2?m.glRenderingObjects.processedTexture1:m.glRenderingObjects.processedTexture2};this.commit=function(){var b=m.glImageData.texID;
m.glImageData.texID=m.glRenderingObjects.readTexture;m.glRenderingObjects.readTexture==m.glRenderingObjects.processedTexture2?m.glRenderingObjects.processedTexture2=b:m.glRenderingObjects.processedTexture1=b;m.glRenderingObjects.readTexture=b};this.getImageData=function(){var a=new Uint8Array(Array(4*m.glImageData.width*m.glImageData.height));b.readPixels(0,0,m.glImageData.width,m.glImageData.height,b.RGBA,b.UNSIGNED_BYTE,a);return a};this.resetFreeTextures=function(){m.freeTextures[0]=!0;for(var b=
1;16>b;b++)m.freeTextures[b]=!1};this.claimFreeTexture=function(){for(var b=0;16>b;b++)if(!m.freeTextures[b])return m.freeTextures[b]=!0,b;return-1};this.getTextureForIndex=function(a){return[b.TEXTURE0,b.TEXTURE1,b.TEXTURE2,b.TEXTURE3,b.TEXTURE4,b.TEXTURE5,b.TEXTURE6,b.TEXTURE7][a]};this.resetTextureToFree=function(b){this.freeTextures[b]=!1};this.displayOriginal=function(){m.createEffect();this.renderIdentity();this.renderIdentity();m.finalizeEffect()};this.renderIdentity=function(){m.glPrograms.bitmapIdentityProgram=
D(m.glPrograms.bitmapIdentityProgram,f,a.VertexShader,a.BitmapIdentityFragmentShader,!1,b);b.useProgram(m.glPrograms.bitmapIdentityProgram);m.startRender(m.glPrograms.bitmapIdentityProgram,0);m.finishRender(!0)};this.renderBlendWithOriginal=function(c,l){m.glPrograms.bitmapBlendProgram=D(m.glPrograms.bitmapBlendProgram,A,a.VertexShader,a.BitmapBlendFragmentShader,!1,b);var p=m.glPrograms.bitmapBlendProgram;b.useProgram(p);m.startRender(p,0);texIndex=m.claimFreeTexture();m.glRenderingObjects.readTexture!=
m.glImageData.texID?(b.activeTexture(m.getTextureForIndex(texIndex)),b.bindTexture(b.TEXTURE_2D,m.glImageData.texID)):texIndex=0;b.uniform1i(p.srcSamplerSlot,texIndex);b.uniform1f(p.srcAmountSlot,l);b.uniform1f(p.dstAmountSlot,c);m.finishRender(!0);0!=texIndex&&(b.activeTexture(m.getTextureForIndex(texIndex)),b.bindTexture(b.TEXTURE_2D,null));this.resetTextureToFree(texIndex)};this.renderBlendWithOriginalOverlayReverse=function(c){m.glPrograms.bitmapBlendOverlayReverseProgram=D(m.glPrograms.bitmapBlendOverlayReverseProgram,
k,a.VertexShader,a.BitmapBlendOverlayReverseFragmentShader,!1,b);var l=m.glPrograms.bitmapBlendOverlayReverseProgram;b.useProgram(l);m.startRender(l,0);texIndex=m.claimFreeTexture();m.glRenderingObjects.readTexture!=m.glImageData.texID?(b.activeTexture(m.getTextureForIndex(texIndex)),b.bindTexture(b.TEXTURE_2D,m.glImageData.texID)):texIndex=0;b.uniform1i(l.srcSamplerSlot,texIndex);b.uniform1f(l.factorSlot,c);m.finishRender(!0);0!=texIndex&&(b.activeTexture(m.getTextureForIndex(texIndex)),b.bindTexture(b.TEXTURE_2D,
null));this.resetTextureToFree(texIndex)};var q=function(b,a,m){a[0]=b[0];a[1]=b[4];a[2]=b[8];a[3]=b[1];a[4]=b[5];a[5]=b[9];a[6]=b[2];a[7]=b[6];a[8]=b[10];m[0]=b[3]/255;m[1]=b[7]/255;m[2]=b[11]/255};this.renderColorMatrixTransform=function(c){m.glPrograms.colorTransformProgram=D(m.glPrograms.colorTransformProgram,n,a.VertexShader,a.ColorTransformFragmentShader,!1,b);var l=m.glPrograms.colorTransformProgram,p=[],g=[];q(c,p,g);b.useProgram(l);m.startRender(l,0);b.uniform3fv(l.colorTransSlot,new Float32Array(g));
b.uniformMatrix3fv(l.colorMatSlot,!1,new Float32Array(p));m.finishRender(!0)};this.renderColorMatrixTransformAndOverlayWithOriginal=function(c,l){m.glPrograms.colorTransformAndOverlayWithOriginalProgram=D(m.glPrograms.colorTransformAndOverlayWithOriginalProgram,O,a.VertexShader,a.ColorTransformAndOverlayWithOriginalFragmentShader,!1,b);var p=m.glPrograms.colorTransformAndOverlayWithOriginalProgram,g=[],d=[];q(c,g,d);b.useProgram(p);m.startRender(p,0);b.uniform3fv(p.colorTransSlot,new Float32Array(d));
b.uniformMatrix3fv(p.colorMatSlot,!1,new Float32Array(g));b.uniform1f(m.glPrograms.colorTransformAndOverlayWithOriginalProgram.overlayAmountSlot,l);m.finishRender(!0)};var B=function(a,c,l,p){var g,d=[];b.activeTexture(m.getTextureForIndex(p));p=b.createTexture();b.bindTexture(b.TEXTURE_2D,p);for(g=0;256>g;g++)d[4*g]=a[g],d[4*g+1]=c[g],d[4*g+2]=l[g],d[4*g+3]=0;b.texImage2D(b.TEXTURE_2D,0,b.RGBA,1,256,0,b.RGBA,b.UNSIGNED_BYTE,new Uint8Array(d));j(b.NEAREST,b.NEAREST,b.CLAMP_TO_EDGE,b.CLAMP_TO_EDGE);
return p};this.renderColorMap=function(c){var l;m.glPrograms.colorMapProgram=D(m.glPrograms.colorMapProgram,i,a.VertexShader,a.ColorMapFragmentShader,!1,b);var p=m.glPrograms.colorMapProgram;b.useProgram(p);this.startRender(p,0);l=m.claimFreeTexture();c=B(c.r,c.g,c.b,l);b.uniform1i(p.colorMapSamplerSlot,l);this.finishRender(!0);b.activeTexture(m.getTextureForIndex(l));b.bindTexture(b.TEXTURE_2D,null);b.deleteTexture(c);m.resetTextureToFree(l)};this.renderIntensityMap=function(c,l,p){var g;if("multiply"==
l)m.glPrograms.intensityMapMultiplyProgram=D(m.glPrograms.intensityMapMultiplyProgram,t,a.VertexShader,a.IntensityMapMultiplyFragmentShader,!1,b),g=m.glPrograms.intensityMapMultiplyProgram;else if("overlay"==l)m.glPrograms.intensityMapOverlayProgram=D(m.glPrograms.intensityMapOverlayProgram,t,a.VertexShader,a.IntensityMapOverlayFragmentShader,!1,b),g=m.glPrograms.intensityMapOverlayProgram;else if("normal"==l)m.glPrograms.intensityMapProgram=D(m.glPrograms.intensityMapProgram,t,a.VertexShader,a.IntensityMapFragmentShader,
!1,b),g=m.glPrograms.intensityMapProgram;else{console.log("The blend mode you're trying to use isn't implemented in GL yet in MoaGL.renderIntensityMap");return}b.useProgram(g);this.startRender(g,0);l=m.claimFreeTexture();c=B(c.r,c.g,c.b,l);b.uniform1i(g.colorMapSamplerSlot,l);b.uniform1f(g.intensitySlot,p);this.finishRender(!0);b.activeTexture(m.getTextureForIndex(l));b.bindTexture(b.TEXTURE_2D,null);b.deleteTexture(c);m.resetTextureToFree(l)};var J=function(b,a){b[0]=a.r/255;b[1]=a.g/255;b[2]=a.b/
255;b[3]=a.a/255};this.renderFlare=function(c,l,p,g,j,s,f,r){var y=[],i=[];J(i,g);y[0]=(1+j)/2;y[1]=(1+s)/2;g=Math.log(1/(255*g.a));f=1/p/0.5/f;r=1/p/0.5/r;"sinc"==l&&(r=f=2/p);p=i[3];"blob"==l&&("overlay"==c||"normal"==c)?"overlay"==c?(m.glPrograms.flareBlobOverlayProgram=D(m.glPrograms.flareBlobOverlayProgram,d,a.VertexShader,a.FlareBlobOverlayFragmentShader,!1,b),j=m.glPrograms.flareBlobOverlayProgram):(m.glPrograms.flareBlobProgram=D(m.glPrograms.flareBlobProgram,d,a.VertexShader,a.FlareBlobFragmentShader,
!1,b),j=m.glPrograms.flareBlobProgram):"angleGaussian"==l&&"normal"==c?(m.glPrograms.flareAngleGaussianProgram=D(m.glPrograms.flareAngleGaussianProgram,d,a.VertexShader,a.FlareAngleGaussianFragmentShader,!1,b),j=m.glPrograms.flareAngleGaussianProgram):"gaussianThing"==l&&"normal"==c?(m.glPrograms.flareGaussianThingProgram=D(m.glPrograms.flareGaussianThingProgram,d,a.VertexShader,a.FlareGaussianThingFragmentShader,!1,b),j=m.glPrograms.flareGaussianThingProgram):"gaussianThing2"==l&&"normal"==c?(m.glPrograms.flareGaussianThing2Program=
D(m.glPrograms.flareGaussianThing2Program,d,a.VertexShader,a.FlareGaussianThing2FragmentShader,!1,b),j=m.glPrograms.flareGaussianThing2Program):"blob2"==l&&("normal"==c||"overlay"==c)?"overlay"==c?(m.glPrograms.flareBlob2OverlayProgram=D(m.glPrograms.flareBlob2OverlayProgram,d,a.VertexShader,a.FlareBlob2OverlayFragmentShader,!1,b),j=m.glPrograms.flareBlob2OverlayProgram):(m.glPrograms.flareBlob2Program=D(m.glPrograms.flareBlob2Program,d,a.VertexShader,a.FlareBlob2FragmentShader,!1,b),j=m.glPrograms.flareBlob2Program):
"cornerFlares"==l&&("normal"==c||"overlay"==c)?"overlay"==c?(m.glPrograms.flareCornerflaresOverlayProgram=D(m.glPrograms.flareCornerflaresOverlayProgram,d,a.VertexShader,a.FlareCornerflaresOverlayFragmentShader,!1,b),j=m.glPrograms.flareCornerflaresOverlayProgram):(m.glPrograms.flareCornerflaresProgram=D(m.glPrograms.flareCornerflaresProgram,d,a.VertexShader,a.FlareCornerflaresFragmentShader,!1,b),j=m.glPrograms.flareCornerflaresProgram):"gaussianThing3"==l&&"normal"==c?(m.glPrograms.flareGaussianThing3OverlayProgram=
D(m.glPrograms.flareGaussianThing3OverlayProgram,d,a.VertexShader,a.FlareGaussianThing3OverlayFragmentShader,!1,b),j=m.glPrograms.flareGaussianThing3OverlayProgram):(m.glPrograms.flareFallbackProgram=D(m.glPrograms.flareFallbackProgram,d,a.VertexShader,a.FlareFragmentShader,!1,b),j=m.glPrograms.flareFallbackProgram);b.useProgram(j);"normal"!=c||j==m.glPrograms.flareFallbackProgram?m.startRender(j,0):m.startRender(j,1);j==m.glPrograms.flareFallbackProgram&&(b.uniform1i(j.flareTypeSlot,"sinc"==l?0:
"gaussianThing"==l?1:"gaussianThing2"==l?2:"gaussianThing3"==l?3:"gaussianThing4"==l?4:"angleGaussian"==l?5:"stardom"==l?6:"lobes"==l?7:"lensFlare"==l?8:"stripe"==l?9:"stripe2"==l?10:"dimondFlare"==l?11:"crossFlare"==l?12:"cornerFlares"==l?13:"fingerFlare"==l?14:"blobFlare"==l?15:"blah"==l?16:"blob"==l?17:"blob2"==l?18:-1),b.uniform1i(j.blendModeSlot,"normal"==c?0:"overlay"==c?1:"color"==c?2:"screen"==c?3:"darken"==c?4:"multiply"==c?5:-1));b.uniform1f(j.scaleDiffxSlot,f);b.uniform1f(j.scaleDiffySlot,
r);b.uniform2fv(j.onePlusDxTimesCenterCoordSlot,new Float32Array(y));b.uniform4fv(j.flareColorSlot,new Float32Array(i));b.uniform1f(j.minEXPSlot,g);b.uniform1f(j.maxEXPSlot,0);b.uniform1f(j.aFSlot,p);"normal"!=c||j==m.glPrograms.flareFallbackProgram?m.finishRender(!0):m.finishRender(!1)};var V=function(c,l){var p=[];if(!(2>c)){for(var g=!1,j=0,d=c;!g;)if(d=c+j,j*=-1,0>=j&&j--,!(3>d)){var g=!0,s=[3,5,7];p[0]=0;p[1]=0;for(var f=p[2]=0,r=0;1<d;)if(0==d%s[f]?(p[f]++,r++,d=d/s[f]|0):f++,3<=f){g=!1;break}}j=
1/("horizontal"==l?m.glImageData.width:m.glImageData.height);"horizontal"==l?(m.glPrograms.horizontalBoxBlur3Program=D(m.glPrograms.horizontalBoxBlur3Program,F,a.ConvolutionHorizontalBoxBlur3VertexShader,a.ConvolutionBoxBlur3FragmentShader,!1,b),m.glPrograms.horizontalBoxBlur5Program=D(m.glPrograms.horizontalBoxBlur5Program,F,a.ConvolutionHorizontalBoxBlur5VertexShader,a.ConvolutionBoxBlur5FragmentShader,!1,b),m.glPrograms.horizontalBoxBlur7Program=D(m.glPrograms.horizontalBoxBlur7Program,F,a.ConvolutionHorizontalBoxBlur7VertexShader,
a.ConvolutionBoxBlur7FragmentShader,!1,b)):(m.glPrograms.verticalBoxBlur3Program=D(m.glPrograms.verticalBoxBlur3Program,F,a.ConvolutionVerticalBoxBlur3VertexShader,a.ConvolutionBoxBlur3FragmentShader,!1,b),m.glPrograms.verticalBoxBlur5Program=D(m.glPrograms.verticalBoxBlur5Program,F,a.ConvolutionVerticalBoxBlur5VertexShader,a.ConvolutionBoxBlur5FragmentShader,!1,b),m.glPrograms.verticalBoxBlur7Program=D(m.glPrograms.verticalBoxBlur7Program,F,a.ConvolutionVerticalBoxBlur7VertexShader,a.ConvolutionBoxBlur7FragmentShader,
!1,b));g=p[0]+p[1]+p[2];s=d=j;for(j=0;j<g;j++)j<p[0]?(f="horizontal"==l?m.glPrograms.horizontalBoxBlur3Program:m.glPrograms.verticalBoxBlur3Program,s*=3):j<p[0]+p[1]?(f="horizontal"==l?m.glPrograms.horizontalBoxBlur5Program:m.glPrograms.verticalBoxBlur5Program,s*=5):(f="horizontal"==l?m.glPrograms.horizontalBoxBlur7Program:m.glPrograms.verticalBoxBlur7Program,s*=7),b.useProgram(f),b.uniform1f(f.texelStrideSlot,d),m.startRender(f,0),b.activeTexture(b.TEXTURE0),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,
b.LINEAR),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR),m.finishRender(!0),d=s;b.activeTexture(b.TEXTURE0);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST)}};this.renderConvolution=function(c,l,p){1<l&&V(l,p);l=1/("horizonal"==p?m.glImageData.width:m.glImageData.height)*(l?l:1);"horizontal"==p?(m.glPrograms.gaussianBlurHorizontalProgram=D(m.glPrograms.gaussianBlurHorizontalProgram,K,a.ConvolutionHorizontalGaussian9VertexShader,
a.ConvolutionGaussian9FragmentShader,!1,b),p=m.glPrograms.gaussianBlurHorizontalProgram):(m.glPrograms.gaussianBlurVerticalProgram=D(m.glPrograms.gaussianBlurVerticalProgram,K,a.ConvolutionVerticalGaussian9VertexShader,a.ConvolutionGaussian9FragmentShader,!1,b),p=m.glPrograms.gaussianBlurVerticalProgram);b.useProgram(p);m.startRender(p,0);b.uniform1f(p.texelStrideSlot,l);b.uniform1f(p.weight0Slot,c[4]);b.uniform1f(p.weight1Slot,c[3]);b.uniform1f(p.weight2Slot,c[2]);b.uniform1f(p.weight3Slot,c[1]);
b.uniform1f(p.weight4Slot,c[0]);b.activeTexture(b.TEXTURE0);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR);m.finishRender(!0);b.activeTexture(b.TEXTURE0);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST)};m.renderAutoEnhance=function(c,l,p,g,d,s,f,r){var y=Number.MAX_VALUE,i=0,n,w,A;m.glPrograms.autoEnhanceProgram=D(m.glPrograms.autoEnhanceProgram,u,a.VertexShader,
a.AutoEnhanceFragmentShader,!1,b);n=m.glPrograms.autoEnhanceProgram;for(w=0;256>w;w++)A=r[w],A<y&&(y=A),A>i&&(i=A);d/=255;s/=255;f/=255;b.useProgram(n);m.startRender(n,0);i=1/(i-y);w=m.claimFreeTexture();var e,k;b.activeTexture(m.getTextureForIndex(w));A=b.createTexture();b.bindTexture(b.TEXTURE_2D,A);e=[];for(k=0;256>k;k++){var h=i*(r[k]-y),z=16777216*h-Math.floor(16777216*h),v=65536*h-Math.floor(65536*h)-z/256,x=256*h-Math.floor(256*h)-v/256,h=h-x/256;e[4*k]=255*z|0;e[4*k+1]=255*v|0;e[4*k+2]=255*
x|0;e[4*k+3]=255*h|0}b.texImage2D(b.TEXTURE_2D,0,b.RGBA,256,1,0,b.RGBA,b.UNSIGNED_BYTE,new Uint8Array(e));j(b.NEAREST,b.NEAREST,b.CLAMP_TO_EDGE,b.CLAMP_TO_EDGE);b.uniform1i(n.mapFactorSamplerSlot,w);b.uniform1f(n.gainSlot,c);b.uniform1f(n.rMinSlot,d);b.uniform1f(n.gMinSlot,s);b.uniform1f(n.bMinSlot,f);b.uniform1f(n.rScaleSlot,l);b.uniform1f(n.gScaleSlot,p);b.uniform1f(n.bScaleSlot,g);b.uniform1f(n.floatMultSlot,i);b.uniform1f(n.floatTransSlot,y);m.finishRender(!0);b.activeTexture(m.getTextureForIndex(w));
b.bindTexture(b.TEXTURE_2D,null);b.deleteTexture(A);m.resetTextureToFree(w)};m.renderConvertLABToRGB=function(c,l){var p;m.glPrograms.labToRgbProgram=D(m.glPrograms.labToRgbProgram,v,a.VertexShader,a.LABToRGBFragmentShader,!1,b);p=m.glPrograms.labToRgbProgram;b.useProgram(p);m.startRender(p,0);b.uniform1f(p.scaleASlot,c);b.uniform1f(p.scaleBSlot,l);m.finishRender(!0)};m.renderConvertRGBToLAB=function(){var c;m.glPrograms.rgbToLabProgram=D(m.glPrograms.rgbToLabProgram,z,a.VertexShader,a.RGBToLABFragmentShader,
!1,b);c=m.glPrograms.rgbToLabProgram;b.useProgram(c);m.startRender(c,0);m.finishRender(!0)};this.renderGradient=function(c,l,p,g,d,s,f){var r,y;if("overlay"==p){if("linearVignette"==c.shapeMode){console.log("Overlay linear vignette not implemented");return}m.glPrograms.gradientOverlayProgram=D(m.glPrograms.gradientOverlayProgram,W,a.VertexShader,a.GradientOverlayFragmentShader,!1,b);y=m.glPrograms.gradientOverlayProgram}else{if("normal"!=p){console.log("Blend mode not implemented yet in renderGradient");
return}"linearVignette"==c.shapeMode?(m.glPrograms.gradientLinearVignetteProgram=D(m.glPrograms.gradientLinearVignetteProgram,W,a.VertexShader,a.GradientLinearVignetteFragmentShader,!1,b),y=m.glPrograms.gradientLinearVignetteProgram):(m.glPrograms.gradientProgram=D(m.glPrograms.gradientProgram,W,a.VertexShader,a.GradientFragmentShader,!1,b),y=m.glPrograms.gradientProgram)}r=m.claimFreeTexture();var i;b.activeTexture(m.getTextureForIndex(r));i=b.createTexture();b.bindTexture(b.TEXTURE_2D,i);b.texImage2D(b.TEXTURE_2D,
0,b.RGBA,1,l.length/4,0,b.RGBA,b.UNSIGNED_BYTE,new Uint8Array(l));j(b.LINEAR,b.LINEAR,b.CLAMP_TO_EDGE,b.CLAMP_TO_EDGE);b.useProgram(y);"overlay"==p?m.startRender(y,0):("normal"!=p&&console.log("\nWarning: The MoaBlendMode you are trying to use in MoaGLAddBorderVignette isn't implemented yet. Using MoaBlendModeNormal."),m.startRender(y,1));b.uniform1f(y.widthSlot,m.glImageData.width);b.uniform1f(y.heightSlot,m.glImageData.height);b.uniform1f(y.scaleSlot,c.scale);b.uniform1f(y.xCenterSlot,c.xCenter);
b.uniform1f(y.yCenterSlot,c.yCenter);b.uniform1f(y.dx_2Slot,c.dx/2);b.uniform1f(y.dy_2Slot,c.dy/2);b.uniform1f(y.denomISlot,f);b.uniform1f(y.alphaBlendSlot,g);b.uniform1f(y.angleCosSlot,s);b.uniform1f(y.angleSinSlot,d);b.uniform1i(y.shapeModeSlot,"linear"==c.shapeMode?0:"radial"==c.shapeMode?1:"linearVignette"==c.shapeMode?2:-1);b.uniform1i(y.vignetteShapeSlot,o(c.vignetteShape));b.uniform1i(y.gradientMapSlot,r);"overlay"==p?m.finishRender(!0):m.finishRender(!1);b.activeTexture(m.getTextureForIndex(r));
b.bindTexture(b.TEXTURE_2D,null);b.deleteTexture(i);m.resetTextureToFree(r)};this.renderVignette=function(c){var l,p=[];J(p,c.color);"overlay"==c.blendMode?(m.glPrograms.borderVignetteOverlayProgram=D(m.glPrograms.borderVignetteOverlayProgram,g,a.VertexShader,a.BordersVignetteOverlayFragmentShader,!1,b),l=m.glPrograms.borderVignetteOverlayProgram):"multiply"==c.blendMode?(m.glPrograms.borderVignetteMultiplyProgram=D(m.glPrograms.borderVignetteMultiplyProgram,g,a.VertexShader,a.BordersVignetteMultiplyFragmentShader,
!1,b),l=m.glPrograms.borderVignetteMultiplyProgram):(m.glPrograms.borderVignetteProgram=D(m.glPrograms.borderVignetteProgram,g,a.VertexShader,a.BordersVignetteFragmentShader,!1,b),l=m.glPrograms.borderVignetteProgram);b.useProgram(l);"overlay"==c.blendMode||"multiply"==c.blendMode?m.startRender(l,0):("normal"!=c.blendMode&&console.log("\nWarning: The MoaBlendMode you are trying to use in MoaGLAddBorderVignette isn't implemented yet. Using MoaBlendModeNormal."),m.startRender(l,1));b.uniform1f(l.widthSlot,
m.glImageData.width);b.uniform1f(l.heightSlot,m.glImageData.height);b.uniform1f(l.vignetteScaleSlot,c.vignetteScale);b.uniform1f(l.dx_2Slot,c.dx/2);b.uniform1f(l.dy_2Slot,c.dy/2);b.uniform4fv(l.vignetteColorSlot,p);b.uniform1i(l.shouldStrecthSlot,c.stretch?1:0);b.uniform1i(l.shapeModeSlot,o(c.shapeMode));"overlay"==c.blendMode||"multiply"==c.blendMode?m.finishRender(!0):m.finishRender(!1)};this.renderColorBlendColor=function(c,l,p){var g;m.glPrograms.colorBlendColorProgram=D(m.glPrograms.colorBlendColorProgram,
aa,a.VertexShader,a.BitmapColorBlendColorFragmentShader,!1,b);g=m.glPrograms.colorBlendColorProgram;b.useProgram(g);m.startRender(g,0);b.uniform3fv(g.blendColorSlot,new Float32Array(c));b.uniform1f(g.blendAmountSlot,p);b.uniform1f(g.blendColorAlphaSlot,l);m.finishRender(!0)};this.renderNoise=function(c,l){var p;m.glPrograms.noiseProgram=D(m.glPrograms.noiseProgram,r,a.VertexShader,a.NoiseFragmentShader,!1,b);p=m.glPrograms.noiseProgram;0==l&&(l=1);b.useProgram(p);m.startRender(p,0);b.uniform1f(p.randomSeedSlot,
l);b.uniform1f(p.intensitySlot,c);m.finishRender(!0)};var Q=function(a,c,l){b.activeTexture(m.getTextureForIndex(a));a=b.createTexture();b.bindTexture(b.TEXTURE_2D,a);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,c,l,0,b.RGBA,b.UNSIGNED_BYTE,null);j(b.LINEAR,b.LINEAR,b.CLAMP_TO_EDGE,b.CLAMP_TO_EDGE);return a},T=function(b,a,c,l){m.glRenderingObjects.readTexture=b;m.glRenderingObjects.writeTexture=a;m.renderIdentity();m.glRenderingObjects.readTexture=a;m.glRenderingObjects.writeTexture=c;m.glRenderingObjects.processedTexture1=
a;m.glRenderingObjects.processedTexture2=c;V(2*l+1,"horizontal");V(2*l+1,"vertical");m.renderColorMatrixTransform([0.213,0.715,0.072,0,0.213,0.715,0.072,0,0.213,0.715,0.072,0])};this.renderClarity=function(c,l,p,g){var d,j,s,f,y,r,i,n;m.glPrograms.twitterClarityProgram=D(m.glPrograms.twitterClarityProgram,E,a.VertexShader,a.TwitterClarityFragmentShader,!1,b);n=m.glPrograms.twitterClarityProgram;f=m.glRenderingObjects.readTexture;y=m.glRenderingObjects.writeTexture;r=m.glRenderingObjects.processedTexture1;
i=m.glRenderingObjects.processedTexture2;m.renderColorMap(c);c=m.claimFreeTexture();j=Q(c,m.glImageData.width,m.glImageData.height);d=m.claimFreeTexture();s=Q(d,m.glImageData.width,m.glImageData.height);T(y,s,j,l);T(f,y,s,l);m.glRenderingObjects.readTexture=f;m.glRenderingObjects.writeTexture=y;m.glRenderingObjects.processedTexture1=r;m.glRenderingObjects.processedTexture2=i;b.useProgram(n);m.startRender(n,0);b.activeTexture(m.getTextureForIndex(d));b.bindTexture(b.TEXTURE_2D,s);b.activeTexture(m.getTextureForIndex(c));
b.bindTexture(b.TEXTURE_2D,j);b.uniform1i(n.avgImgSamplerSlot,d);b.uniform1i(n.effectedAvgImgSamplerSlot,c);b.uniform1f(n.gainSlot,p);b.uniform1f(n.sharpenAmountSlot,g);m.finishRender(!0);b.deleteTexture(s);b.deleteTexture(j);m.resetTextureToFree(d);m.resetTextureToFree(c)};this.renderBasicDots=function(c,l,g,d,s){var f;m.glPrograms.basicDotsProgram=D(m.glPrograms.basicDotsProgram,p,a.BasicDotsVertexShader,a.DotMatrixFragmentShader,!1,b);f=m.glPrograms.basicDotsProgram;J([],c);b.useProgram(f);b.enable(b.BLEND);
b.blendFuncSeparate(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA,b.ZERO,b.ONE);b.blendEquation(b.FUNC_ADD);b.enableVertexAttribArray(f.positionSlot);b.enableVertexAttribArray(f.pointSizeSlot);var y=b.createBuffer(),r=b.createBuffer();b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,null);b.bindBuffer(b.ARRAY_BUFFER,y);b.bufferData(b.ARRAY_BUFFER,new Float32Array(l),b.STATIC_DRAW);b.vertexAttribPointer(f.positionSlot,2,b.FLOAT,!1,0,0);b.bindBuffer(b.ARRAY_BUFFER,r);b.bufferData(b.ARRAY_BUFFER,new Float32Array(g),b.STATIC_DRAW);
b.vertexAttribPointer(f.pointSizeSlot,1,b.FLOAT,!1,0,0);var l=m.claimFreeTexture(),i,n,w,A,e,k,u,h,z,v,x,I,o,d=1.5,s=2*d;b.activeTexture(m.getTextureForIndex(l));i=b.createTexture();b.bindTexture(b.TEXTURE_2D,i);n=Math.ceil(2*(d+s));k=d*d;u=Math.pow(d+s,2);h=c.a/255;o=[];for(w=0;w<n;w++){z=4*n*w;for(A=0;A<n;A++)e=z+4*A,o[e]=c.r,o[e+1]=c.g,o[e+2]=c.b,v=w+0.5,x=A+0.5,I=n/2,v=(v-I)*(v-I)+(x-I)*(x-I),v=v>u?0:v>k?1-(1-h+h*(Math.sqrt(v)-d)/s):h,o[e+3]=255*v}b.texImage2D(b.TEXTURE_2D,0,b.RGBA,n,n,0,b.RGBA,
b.UNSIGNED_BYTE,new Uint8Array(o));j(b.LINEAR,b.LINEAR,b.CLAMP_TO_EDGE,b.CLAMP_TO_EDGE);b.uniform1i(f.dotSamplerSlot,l);b.drawArrays(b.POINTS,0,g.length);b.disable(b.BLEND);b.deleteTexture(i);b.deleteBuffer(y);b.deleteBuffer(r);m.resetTextureToFree(l);b.bindFramebuffer(b.FRAMEBUFFER,m.glRenderingObjects.offscreenFramebuffer);b.bindBuffer(b.ARRAY_BUFFER,m.glBuffers.vertexBufferFlipped);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,m.glBuffers.currentIndexBuffer)};this.renderDotMatrix=function(l,p,g){var d,s;
m.glPrograms.dotMatrixProgram=D(m.glPrograms.dotMatrixProgram,c,a.DotMatrixVertexShader,a.DotMatrixFragmentShader,!1,b);d=m.glPrograms.dotMatrixProgram;J([],l);b.useProgram(d);b.enable(b.BLEND);b.blendFuncSeparate(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA,b.ZERO,b.ONE);b.blendEquation(b.FUNC_ADD);b.enableVertexAttribArray(d.positionSlot);var f=b.createBuffer();b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,null);b.bindBuffer(b.ARRAY_BUFFER,f);b.bufferData(b.ARRAY_BUFFER,new Float32Array(p),b.STATIC_DRAW);b.vertexAttribPointer(d.positionSlot,
2,b.FLOAT,!1,0,0);s=g*m.glImageData.width/2;b.uniform1f(d.pointSizeSlot,10*s);var g=m.claimFreeTexture(),y,r,i,n,w,A,e,k,u,h,z,v;3.3>s&&(s=3.3);0==Math.ceil(10*s)%2&&(s=(Math.ceil(10*s)+1)/10);b.activeTexture(m.getTextureForIndex(g));w=b.createTexture();b.bindTexture(b.TEXTURE_2D,w);i=Math.ceil(10*s);A=Math.PI/(2*s*s);e=l.a/255;v=[];for(y=0;y<i;y++){z=4*i*y;for(r=0;r<i;r++)n=z+4*r,v[n]=l.r,v[n+1]=l.g,v[n+2]=l.b,k=y+0.5,u=r+0.5,h=i/2,k=(k-h)*(k-h)+(u-h)*(u-h),k>5*s*s?k=0:(k*=A,k=2.25>k?e*Math.max(Math.cos(k),
Math.cos(Math.sqrt(k)/1.8)/2):e*Math.cos(Math.sqrt(k)/1.8)/2,0>k?k=0:1<k&&(k=1)),v[n+3]=255*k}b.texImage2D(b.TEXTURE_2D,0,b.RGBA,i,i,0,b.RGBA,b.UNSIGNED_BYTE,new Uint8Array(v));j(b.LINEAR,b.LINEAR,b.CLAMP_TO_EDGE,b.CLAMP_TO_EDGE);b.uniform1i(d.dotSamplerSlot,g);b.drawArrays(b.POINTS,0,p.length/2);b.disable(b.BLEND);b.deleteTexture(w);b.deleteBuffer(f);m.resetTextureToFree(g);b.bindFramebuffer(b.FRAMEBUFFER,m.glRenderingObjects.offscreenFramebuffer);b.bindBuffer(b.ARRAY_BUFFER,m.glBuffers.vertexBufferFlipped);
b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,m.glBuffers.currentIndexBuffer)};this.renderLine=function(c,l,p,g,d,j,f,y,r,i,n,w,A,e,k,u,h){var z,v=[],x=[],I=[];m.glPrograms.lineProgram=D(m.glPrograms.lineProgram,s,a.LineVertexShader,a.LineFragmentShader,!1,b);z=m.glPrograms.lineProgram;J(I,c);b.useProgram(z);b.enableVertexAttribArray(z.positionSlot);b.enableVertexAttribArray(z.imagePosSlot);var c=b.createBuffer(),o=b.createBuffer();b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,null);var t=2*(e/(m.glImageData.width-1))-
1,O=2*(k/(m.glImageData.height-1))-1,E=2*(u/(m.glImageData.width-1))-1,q=2*(h/(m.glImageData.height-1))-1;v[0]=t;v[1]=O;x[0]=e;x[1]=k;v[2]=E;v[3]=O;x[2]=u;x[3]=k;v[4]=t;v[5]=q;x[4]=e;x[5]=h;v[6]=E;v[7]=q;x[6]=u;x[7]=h;b.bindBuffer(b.ARRAY_BUFFER,c);b.bufferData(b.ARRAY_BUFFER,new Float32Array(v),b.STATIC_DRAW);b.vertexAttribPointer(z.positionSlot,2,b.FLOAT,!1,0,0);b.bindBuffer(b.ARRAY_BUFFER,o);b.bufferData(b.ARRAY_BUFFER,new Float32Array(x),b.STATIC_DRAW);b.vertexAttribPointer(z.imagePosSlot,2,b.FLOAT,
!1,0,0);b.enable(b.BLEND);b.blendFuncSeparate(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA,b.ZERO,b.ONE);b.blendEquation(b.FUNC_ADD);b.uniform1f(z.nHatxSlot,l);b.uniform1f(z.nHatySlot,p);b.uniform1f(z.x1Slot,g);b.uniform1f(z.y1Slot,j);b.uniform1f(z.x2Slot,d);b.uniform1f(z.y2Slot,f);b.uniform1f(z.rSlot,y);b.uniform1f(z.r2Slot,r);b.uniform1f(z.dAASlot,i);b.uniform1f(z.bASlot,n);b.uniform1f(z.r2AASlot,w);b.uniform4fv(z.colorSlot,I);b.uniform1f(z.vLength2Slot,A);b.drawArrays(b.TRIANGLE_STRIP,0,4);b.disable(b.BLEND);
b.deleteBuffer(c);b.deleteBuffer(o);b.bindFramebuffer(b.FRAMEBUFFER,m.glRenderingObjects.offscreenFramebuffer);b.bindBuffer(b.ARRAY_BUFFER,m.glBuffers.vertexBufferFlipped);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,m.glBuffers.currentIndexBuffer)};this.renderRingFlare=function(c,l,p,g,d,j,s,f){var r,i=[];m.glPrograms.ringFlareProgram=D(m.glPrograms.ringFlareProgram,y,a.VertexShader,a.RingFlareFragmentShader,!1,b);r=m.glPrograms.ringFlareProgram;J(i,c);b.useProgram(r);m.startRender(r,1);b.uniform1f(r.dr22Slot,
g);b.uniform1f(r.dr12Slot,d);b.uniform1f(r.daaSlot,j);b.uniform1f(r.avgDSlot,s);b.uniform1f(r.bASlot,f);b.uniform1f(r.widthSlot,m.glImageData.width);b.uniform1f(r.heightSlot,m.glImageData.height);b.uniform1f(r.xCenterSlot,l);b.uniform1f(r.yCenterSlot,p);b.uniform4fv(r.colorSlot,i);m.finishRender(!1)};this.renderThetaBorder=function(c,p,g,d,j,s,f,r,y,i){var n,w=[];m.glPrograms.borderThetaProgram=D(m.glPrograms.borderThetaProgram,l,a.VertexShader,a.BordersThetaFragmentShader,!1,b);n=m.glPrograms.borderThetaProgram;
J(w,c);b.useProgram(n);m.startRender(n,1);b.uniform1f(n.dwSlot,g);b.uniform1f(n.rFactorSlot,d);b.uniform1f(n.widthSlot,m.glImageData.width);b.uniform1f(n.heightSlot,m.glImageData.height);b.uniform1i(n.borderStyleSlot,h(p));b.uniform4fv(n.borderColorSlot,w);b.uniform1f(n.offsetLSlot,j);b.uniform1f(n.offsetRSlot,s);b.uniform1f(n.offsetTSlot,f);b.uniform1f(n.offsetBSlot,r);b.uniform1f(n.offsetXSlot,y);b.uniform1f(n.offsetYSlot,i);m.finishRender(!1)};this.renderHardRandBorder=function(c,l,p,g,d,s,f,r,
y,n,i){var A,e=[],k;m.glPrograms.hardRandProgram=D(m.glPrograms.hardRandProgram,w,a.VertexShader,a.BordersHardRandFragmentShader,!1,b);k=m.glPrograms.hardRandProgram;0==d&&(d=1);J(e,c);b.useProgram(k);m.startRender(k,1);var c=Math.max(m.glImageData.width,m.glImageData.height),u=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],h=[0,0,0,0],z,v;for(A=0;A<m.glImageData.width;A++)z=n[A],v=i[A],z>h[2]&&(h[2]=z),v>h[3]&&(h[3]=v),z<u[2]&&(u[2]=z),v<u[3]&&(u[3]=v);for(A=0;A<m.glImageData.height;A++)z=
r[A],v=y[A],z>h[0]&&(h[0]=z),v>h[1]&&(h[1]=v),z<u[0]&&(u[0]=z),v<u[1]&&(u[1]=v);A=Math.max(Math.max(h[0],h[1]),Math.max(h[2],h[3]));u=Math.min(Math.min(u[0],u[1]),Math.min(u[2],u[3]));A=1/(A-u);h=m.claimFreeTexture();z=m.glImageData.width;v=m.glImageData.height;var x,I,o,t,O,E,q;b.activeTexture(m.getTextureForIndex(h));o=b.createTexture();b.bindTexture(b.TEXTURE_2D,o);I=[];for(x=0;x<v;x++)t=A*(r[x]-u),O=16777216*t-Math.floor(16777216*t),E=65536*t-Math.floor(65536*t)-O/256,q=256*t-Math.floor(256*t)-
E/256,t-=q/256,I[4*x]=255*O,I[4*x+1]=255*E,I[4*x+2]=255*q,I[4*x+3]=255*t;r=4*c;for(x=0;x<v;x++)t=A*(y[x]-u),O=16777216*t-Math.floor(16777216*t),E=65536*t-Math.floor(65536*t)-O/256,q=256*t-Math.floor(256*t)-E/256,t-=q/256,I[r+4*x]=255*O,I[r+4*x+1]=255*E,I[r+4*x+2]=255*q,I[r+4*x+3]=255*t;r=8*c;for(x=0;x<z;x++)t=A*(n[x]-u),O=16777216*t-Math.floor(16777216*t),E=65536*t-Math.floor(65536*t)-O/256,q=256*t-Math.floor(256*t)-E/256,t-=q/256,I[r+4*x]=255*O,I[r+4*x+1]=255*E,I[r+4*x+2]=255*q,I[r+4*x+3]=255*t;
r=12*c;for(x=0;x<z;x++)t=A*(i[x]-u),O=16777216*t-Math.floor(16777216*t),E=65536*t-Math.floor(65536*t)-O/256,q=256*t-Math.floor(256*t)-E/256,t-=q/256,I[r+4*x]=255*O,I[r+4*x+1]=255*E,I[r+4*x+2]=255*q,I[r+4*x+3]=255*t;b.texImage2D(b.TEXTURE_2D,0,b.RGBA,c,4,0,b.RGBA,b.UNSIGNED_BYTE,new Uint8Array(I));j(b.NEAREST,b.NEAREST,b.CLAMP_TO_EDGE,b.CLAMP_TO_EDGE);b.uniform1i(k.linesSamplerSlot,h);b.uniform1f(k.heightSlot,m.glImageData.height);b.uniform1f(k.widthSlot,m.glImageData.width);b.uniform1f(k.widthTexCoordMultSlot,
1/c);b.uniform1f(k.heightTexCoordMultSlot,1/c);b.uniform1f(k.h2Slot,f);b.uniform1f(k.w2Slot,s);b.uniform1f(k.offsetSlot,g);b.uniform1f(k.dwSlot,l);b.uniform4fv(k.colorSlot,e);b.uniform1f(k.scaleSlot,p);b.uniform1f(k.floatMultSlot,A);b.uniform1f(k.floatTransSlot,u);b.uniform1f(k.randomSeedSlot,d);m.finishRender(!1);b.deleteTexture(o);m.resetTextureToFree(h)};this.renderWhiten=function(){m.glPrograms.whitenProgram=D(m.glPrograms.whitenProgram,x,a.VertexShader,a.WhitenFragmentShader,!1,b);program=m.glPrograms.whitenProgram;
b.useProgram(program);m.startRender(program,0);m.finishRender(!0)};this.renderRedeye=function(){m.glPrograms.redeyeProgram=D(m.glPrograms.redeyeProgram,I,a.VertexShader,a.RedeyeFragmentShader,!1,b);program=m.glPrograms.redeyeProgram;b.useProgram(program);m.startRender(program,0);m.finishRender(!0)};this.createMask=function(c,a){if(!m.willAcceptImageOfSize(c,a))return null;var l=m.claimFreeTexture();b.activeTexture(m.getTextureForIndex(l));var p=b.createTexture();b.bindTexture(b.TEXTURE_2D,p);m.setTextureParams(b.NEAREST,
b.NEAREST,b.CLAMP_TO_EDGE,b.CLAMP_TO_EDGE);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,c,a,0,b.RGBA,b.UNSIGNED_BYTE,null);m.resetTextureToFree(l);return p};this.destroyMask=function(c){c&&b.deleteTexture(c)};this.maskFillRadial=function(c,l,p,g,d,j){m.glPrograms.maskRadialProgram=D(m.glPrograms.maskRadialProgram,L,a.VertexShader,a.MaskRadialFragmentShader,!1,b);program=m.glPrograms.maskRadialProgram;var r,s,f;r=m.glRenderingObjects.writeTexture;s=m.glImageData.width;f=m.glImageData.height;m.glRenderingObjects.writeTexture=
c;m.glImageData.width=l;m.glImageData.height=p;b.useProgram(program);m.startRender(program,0);b.uniform2fv(program.centerPointSlot,1,new Float32Array([g,d]));b.uniform1f(program.sigmaR2Slot,j*j);b.uniform1f(program.widthSlot,l);b.uniform1f(program.heightSlot,p);b.clearColor(0,0,0,0);b.clear(b.COLOR_BUFFER_BIT);b.clearColor(0,0,0,1);m.finishRender(!0);m.glRenderingObjects.writeTexture=r;m.glImageData.width=s;m.glImageData.height=f};this.maskFillLinear=function(c,l,p,g,d,j,r){m.glPrograms.maskLinearProgram=
D(m.glPrograms.maskLinearProgram,C,a.VertexShader,a.MaskLinearFragmentShader,!1,b);program=m.glPrograms.maskLinearProgram;var s,f,y;s=m.glRenderingObjects.writeTexture;f=m.glImageData.width;y=m.glImageData.height;m.glRenderingObjects.writeTexture=c;m.glImageData.width=l;m.glImageData.height=p;b.useProgram(program);m.startRender(program,0);c=[g,d];g=-Math.sin(r);r=Math.cos(r);b.uniform2fv(program.centerPointSlot,1,new Float32Array(c));b.uniform1f(program.sigmaR2Slot,j*j);b.uniform1f(program.widthSlot,
l);b.uniform1f(program.heightSlot,p);b.uniform1f(program.normXSlot,g);b.uniform1f(program.normYSlot,r);b.ClearColor(0,0,0,0);b.Clear(b.COLOR_BUFFER_BIT);b.ClearColor(0,0,0,1);m.finishRender(!0);m.glRenderingObjects.writeTexture=s;m.glImageData.width=f;m.glImageData.height=y};this.maskAddPoints=function(c,l,p,g,d,j,r,s,f,y){var n=g.length,i,w,A;i=m.glRenderingObjects.writeTexture;w=m.glImageData.width;A=m.glImageData.height;m.glRenderingObjects.writeTexture=c;m.glImageData.width=l;m.glImageData.height=
p;if("normal"==s)m.glPrograms.maskDotsProgram=D(m.glPrograms.maskDotsProgram,G,a.MaskDotsVertexShader,a.MaskDotFragmentShader,!1,b),c=m.glPrograms.maskDotsProgram;else if("splash"==s)m.glPrograms.colorSplashAutoProgram=D(m.glPrograms.colorSplashAutoProgram,H,a.MaskDotsVertexShader,a.ColorSplashAutoFragmentShader,!1,b),c=m.glPrograms.colorSplashAutoProgram;else throw"Error, invalid GL Mask Type";b.useProgram(c);m.startRender(c,6);b.enable(b.BLEND);b.blendEquation(b.FUNC_ADD);b.blendFunc(y?b.ZERO:b.ONE,
b.ONE_MINUS_SRC_ALPHA);b.bindBuffer(b.ARRAY_BUFFER,0);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,0);for(y=0;y<n/2;y++)g[2*y]=2*g[2*y]-1,g[2*y+1]=2*g[2*y+1]-1;b.enableVertexAttribArray(c.positionSlot);b.vertexAttribPointer(c.positionSlot,2,b.FLOAT,b.FALSE,0,new Float32Array(g));g=0.5*d;y=Math.pow(d+g*(1-Math.sqrt(5/255)),2);y=Math.sqrt(y);b.uniform1f(c.pointSizeSlot,Math.ceil(2*y));b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,m.glImageData.texID);b.uniform1f(c.radiusSlot,d);b.uniform1f(c.widthSlot,
l);b.uniform1f(c.heightSlot,p);b.uniform1f(c.alphaSlot,r);b.uniform1f(c.dEdgeSlot,g);"splash"==s&&(l=e.rgb2labwithcbrtmapping(f),b.uniform1f(c.lSlot,l[0]),b.uniform1f(c.aSlot,l[1]),b.uniform1f(c.bSlot,l[2]),b.uniform1f(c.sigmaCSlot,j));b.drawArrays(b.POINTS,0,n/2);b.finish();m.swapTextures();m.glRenderingObjects.writeTexture=i;m.glImageData.width=w;m.glImageData.height=A;b.disable(b.BLEND);b.bindFramebuffer(b.FRAMEBUFFER,m.glRenderingObjects.offscreenFramebuffer);b.bindBuffer(b.ARRAY_BUFFER,m.glBuffers.vertexBufferFlipped);
b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,m.glBuffers.indexBuffer)};this.redrawBitmapWithGLMask=function(c,l,p){m.glPrograms.redrawWithMaskProgram=D(m.glPrograms.redrawWithMaskProgram,M,a.VertexShader,a.BitmapRedrawWithMaskFragmentShader,!1,b);program=m.glPrograms.redrawWithMaskProgram;b.useProgram(program);m.startRender(program,0);c=m.claimFreeTexture();b.activeTexture(m.getTextureForIndex(c));b.bindTexture(b.TEXTURE_2D,maskID);l=m.claimFreeTexture();b.activeTexture(m.getTextureForIndex(l));b.bindTexture(b.TEXTURE_2D,
srcTexture);p?(b.uniform1i(program.sharedUnisAndAttribs.samplerSlot,l),b.uniform1i(program.sourceSamplerSlot,0)):b.uniform1i(program.sourceSamplerSlot,l);glUniform1i(program.maskSamplerSlot,c);m.finishRender(!0);b.activeTexture(c);b.bindTexture(b.TEXTURE_2D,null);m.resetTextureToFree(c);b.activeTexture(l);b.bindTexture(b.TEXTURE_2D,null);m.resetTextureToFree(l)};this.drawExistingProcessedTextureWithMaskTexture=function(b,c,a){var l=0;b==m.glRenderingObjects.processedTexture1?l=m.glRenderingObjects.processedTexture2:
b==m.glRenderingObjects.processedTexture2&&(l=m.glRenderingObjects.processedTexture1);m.glRenderingObjects.readTexture=m.glImageData.texID;m.glRenderingObjects.writeTexture=l;m.redrawBitmapWithGLMask(b,c,a);m.finalizeEffect()}}};var a={AutoEnhanceFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform lowp sampler2D u_mapFactorSampler;\nuniform float u_gain;\nuniform float u_rScale;\nuniform float u_gScale;\nuniform float u_bScale;\nuniform float u_rMin;\nuniform float u_gMin;\nuniform float u_bMin;\nuniform float u_floatMult;\nuniform float u_floatTrans;\n\nhighp float unpackFloatFromVec4i(const vec4 value)\n{\nconst vec4 bitSh = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\nfloat rawVal = dot(value, bitSh);\nreturn ((rawVal / u_floatMult) + u_floatTrans);\n}\n\nvoid main(void) {\nlowp vec4 color = texture2D(u_sampler, v_texCoord);\n\nfloat r = color.r;\nfloat g = color.g;\nfloat b = color.b;\n\nfloat lum = 0.213*r+0.715*g+0.072*b;\n\nfloat factor = unpackFloatFromVec4i(texture2D(u_mapFactorSampler, vec2(lum, 0)));\n\nfloat gNew = factor*g;\n\nr = (r+(r*factor-r)*u_gain + (gNew - g)*(1.0-u_gain)-u_rMin)*u_rScale;\nb = (b+(b*factor-b)*u_gain + (gNew - g)*(1.0-u_gain)-u_bMin)*u_bScale;\ng = (gNew-u_gMin)*u_gScale;\n\ncolor.r = r;\ncolor.g = g;\ncolor.b = b;\n\ngl_FragColor = color;\n}",
LABToRGBFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform float u_scaleA;\nuniform float u_scaleB;\n\nvoid main(void) {\nhighp vec4 color = texture2D(u_sampler, v_texCoord);\n\nfloat lab0 = color.r * 255.0;\nfloat lab1 = color.g * u_scaleA * 255.0;\nfloat lab2 = color.b * u_scaleB * 255.0;\n\nfloat Y = ( lab0/2.55 + 16.0) / 116.0;\nfloat X = (lab1-127.0) / 500.0 + Y;\nfloat Z = Y - (lab2-127.0) / 200.0;\n\nfloat Y3 = Y*Y*Y;\nfloat X3 = X*X*X;\nfloat Z3 = Z*Z*Z;\n\nif ( Y3 > 0.008856 ){ Y = Y3;}else{Y = ( Y - 16.0 / 116.0 ) / 7.787;}\n\nif ( X3 > 0.008856 ){ X = X3;}else{X = ( X - 16.0 / 116.0 ) / 7.787;}\n\nif ( Z3 > 0.008856 ){ Z = Z3;}else{Z = ( Z - 16.0 / 116.0 ) / 7.787;}\n\nX = .95047  * X;\nY = 1.00000 * Y;\nZ = 1.08883 * Z;\n\nfloat R = X *  3.2406 + Y * -1.5372 + Z * -0.4986;\nfloat G = X * -0.9689 + Y *  1.8758 + Z *  0.0415;\nfloat B = X *  0.0557 + Y * -0.2040 + Z *  1.0570;\n\nif ( R > 0.0031308 ) {R = 1.055 * ( pow(R , ( 0.41666666666667 )) ) - 0.055;}else{ R = 12.92 * R;}\nif ( G > 0.0031308 ) {G = 1.055 * ( pow(G , ( 0.41666666666667 )) ) - 0.055;}else{ G = 12.92 * G;}\nif ( B > 0.0031308 ) {B = 1.055 * ( pow(B , ( 0.41666666666667 )) ) - 0.055;}else{ B = 12.92 * B;}\n\n\ncolor.r = R; color.g = G; color.b = B;\ngl_FragColor = color;\n}",
RGBToLABFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\n\nvoid main(void) {\nhighp vec4 color = texture2D(u_sampler, v_texCoord);\n\nfloat R = color.r * 255.0;\nfloat G = color.g * 255.0;\nfloat B = color.b * 255.0;\n\nfloat l1;\nfloat a1;\nfloat b1;\nfloat r;\nfloat g;\nfloat b;\nfloat x;\nfloat y;\nfloat z;\n\nif(R/255.0 <= 0.04045){r = 100.0 *R/255.0/12.92;} else{ r = 100.0*pow((R/255.0+0.055)/1.055,2.40);}\nif(G/255.0 <= 0.04045){g = 100.0 *G/255.0/12.92;} else{ g = 100.0*pow((G/255.0+0.055)/1.055,2.40);}\nif(B/255.0 <= 0.04045){b = 100.0 *B/255.0/12.92;} else{ b = 100.0*pow((B/255.0+0.055)/1.055,2.40);}\n\nx = 0.00433891*r  + 0.00376234915*g + 0.0018990604648*b;\ny = 0.002126*r    + 0.007152*g      + 0.000722*b;\nz = 0.000177255*r + 0.00109475308*g + 0.0087295537*b;\n\nif(x > 0.008856){x = pow(x,1.0/3.0);}else{x = 7.787*x+16.0/116.0;}\nif(y > 0.008856){y = pow(y,1.0/3.0);}else{y = 7.787*y+16.0/116.0;}\nif(z > 0.008856){z = pow(z,1.0/3.0);}else{z = 7.787*z+16.0/116.0;}\n\nl1 = 116.0*y-16.0;\na1 = 500.0*(x-y);\nb1 = 200.0*(y-z);\n\ncolor.r = l1 * 2.55 / 255.0; color.g = (a1+127.0) / 255.0; color.b = (b1+127.0) / 255.0;\ngl_FragColor = color;\n}",
BitmapIdentityFragmentShader:"precision mediump float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nvoid main(void) {\ngl_FragColor = texture2D(u_sampler, v_texCoord);\n}",BitmapBlendFragmentShader:"precision mediump float;\n\nuniform lowp sampler2D u_sampler;\nuniform lowp sampler2D u_srcSampler;\nuniform float u_dstAmount;\nuniform float u_srcAmount;\nvarying highp vec2 v_texCoord;\n\nvoid main(void) {\nvec4 color = texture2D(u_srcSampler, v_texCoord);\nvec4 originalColor = texture2D(u_sampler, v_texCoord);\ngl_FragColor = color * u_srcAmount + originalColor * u_dstAmount;\ngl_FragColor.a = 1.0;\n}",
BitmapBlendOverlayFragmentShader:"precision mediump float;\n\nuniform lowp sampler2D u_sampler;\nuniform lowp sampler2D u_srcSampler;\nuniform float u_factor;\nvarying highp vec2 v_texCoord;\n\nvoid main(void) {\nlowp vec4 src = texture2D(u_srcSampler, v_texCoord);\nlowp vec4 dst = texture2D(u_sampler, v_texCoord);\n\nlowp vec4 color = vec4(0,0,0,0);\n\nfloat factorI = 1.0 - u_factor;\n\nif (dst.r <= 0.5) {\ncolor.r = factorI * dst.r + u_factor * 2.0 * dst.r * src.r;\n} else {\ncolor.r = factorI * dst.r + u_factor * (1.0 - (1.0 - dst.r) * (1.0 - src.r) / 0.5);\n}\nif (dst.g <= 0.5) {\ncolor.g = factorI * dst.g + u_factor * 2.0 * dst.g * src.g;\n} else {\ncolor.g = factorI * dst.g + u_factor * (1.0 - (1.0 - dst.g) * (1.0 - src.g) / 0.5);\n}\nif (dst.b <= 0.5) {\ncolor.b = factorI * dst.b + u_factor * 2.0 * dst.b * src.b;\n} else {\ncolor.b = factorI * dst.b + u_factor * (1.0 - (1.0 - dst.b) * (1.0 - src.b) / 0.5);\n}\n\ncolor.a = 1.0;\ngl_FragColor = color;\n\n}",
BitmapBlendOverlayReverseFragmentShader:"precision mediump float;\n\nuniform lowp sampler2D u_sampler;\nuniform lowp sampler2D u_srcSampler;\nuniform float u_factor;\nvarying highp vec2 v_texCoord;\n\nvoid main(void) {\nlowp vec4 dst = texture2D(u_srcSampler, v_texCoord);\nlowp vec4 src = texture2D(u_sampler, v_texCoord);\n\nlowp vec4 color = vec4(0,0,0,0);\n\nfloat factorI = 1.0 - u_factor;\n\nif (dst.r <= 0.5) {\ncolor.r = factorI * dst.r + u_factor * 2.0 * dst.r * src.r;\n} else {\ncolor.r = factorI * dst.r + u_factor * (1.0 - (1.0 - dst.r) * (1.0 - src.r) / 0.5);\n}\nif (dst.g <= 0.5) {\ncolor.g = factorI * dst.g + u_factor * 2.0 * dst.g * src.g;\n} else {\ncolor.g = factorI * dst.g + u_factor * (1.0 - (1.0 - dst.g) * (1.0 - src.g) / 0.5);\n}\nif (dst.b <= 0.5) {\ncolor.b = factorI * dst.b + u_factor * 2.0 * dst.b * src.b;\n} else {\ncolor.b = factorI * dst.b + u_factor * (1.0 - (1.0 - dst.b) * (1.0 - src.b) / 0.5);\n}\n\ncolor.a = 1.0;\ngl_FragColor = color;\n\n}",
BitmapDrawWithMaskFragmentShader:"precision mediump float;\n\nuniform lowp sampler2D u_sampler;\nuniform lowp sampler2D u_maskSampler;\nvarying highp vec2 v_texCoord;\n\nvoid main(void) {\nvec4 maskAmount = texture2D(u_maskSampler, v_texCoord);\nvec4 originalColor = texture2D(u_sampler, v_texCoord);\noriginalColor.a = 1.0 - maskAmount.a;\n//                                                      originalColor.a = maskAmount.a;\ngl_FragColor = originalColor;\n//                                                      gl_FragColor =  maskAmount;\n}",
BitmapRedrawWithMaskFragmentShader:"precision mediump float;\n\nuniform lowp sampler2D u_sampler;\nuniform lowp sampler2D u_maskSampler;\nuniform lowp sampler2D u_sourceSampler;\nvarying highp vec2 v_texCoord;\n\nvoid main(void) {\nvec4 maskAmount = texture2D(u_maskSampler, v_texCoord);\nvec4 originalColor = texture2D(u_sampler, v_texCoord);\nvec4 sourceColor = texture2D(u_sourceSampler, v_texCoord);\ngl_FragColor = mix(originalColor, sourceColor, maskAmount.a);\n//                                                             gl_FragColor =  maskAmount;\n//                                                             gl_FragColor = vec4(1,0,0,1);\n\n}",
BitmapColorBlendColorFragmentShader:"precision highp float;\n\nuniform highp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform highp vec3 u_blendColor;\nuniform highp float u_blendAmount;\nuniform highp float u_blendColorAlpha;\n\nvoid main(void) {\nhighp vec4 color = texture2D(u_sampler, v_texCoord);\n\n// RBG -> HSL\nfloat r = color.r;\nfloat g = color.g;\nfloat b = color.b;\nfloat h = u_blendColor.x;\nfloat s = u_blendColor.y;\nfloat l = u_blendColor.z;\n\n// Blend\ns *= u_blendColorAlpha; //Hack hack hack\nl  = (0.212671*r + 0.71516*g + 0.072169*b);\n\n// End Blend\n\n// HSL -> RGB\nfloat hPrime;\nfloat C;\nfloat X;\nfloat m;\nfloat hPrimeMod2;\n\nhPrime = h * 6.0;\nC = l > 0.5 ? 2.0 * s * (1.0 - l) : 2.0 * s * l;\nhPrimeMod2 = hPrime;\n\nhPrimeMod2 = mod(hPrimeMod2, 2.0);\n\nX = C * (1.0 - abs(hPrimeMod2 - 1.0));\n\nm = l - 0.5*C;\n\nif(hPrime < 1.0){\nr = C; g = X; b = 0.0;\n}else if(hPrime < 2.0){\nr = X; g = C; b = 0.0;\n}else if(hPrime < 3.0){\nr = 0.0; g = C; b = X;\n}else if(hPrime < 4.0){\nr = 0.0; g = X; b = C;\n}else if(hPrime < 5.0){\nr = X; g = 0.0; b = C;\n}else if(hPrime < 6.0){\nr = C; g = 0.0; b = X;\n}\n// End HSL -> RGB\n\nvec4 blendedColor = vec4(r+m,g+m,b+m,1.0);\ncolor = mix(color, blendedColor, u_blendAmount);\ncolor.a = 1.0; //Just to make sure\n\ngl_FragColor = color;\n}",
BordersVignetteFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform float u_width;\nuniform float u_height;\nuniform float u_vignetteScale;\nuniform lowp vec4 u_vignetteColor;\nuniform int u_shouldStretch;\nuniform int u_shapeMode;\nuniform float u_dx_2;\nuniform float u_dy_2;\n\nconst float cutoff = 1.15;\nconst float c4 = 5.0 / 3.0;\nconst float c6 = 34.0 / 45.0;\nconst float c8 = 13.0 / 63.0;\nconst float c10 = 514.0 / 14175.0;\n\nvoid main(void) {\nlowp vec4 color = u_vignetteColor;\n\nfloat xDist = u_width * (v_texCoord.x - 0.5 - u_dx_2);\nfloat yDist = u_height * (v_texCoord.y - 0.5 - u_dy_2);\n\nfloat denomI = cutoff / (u_vignetteScale * u_vignetteScale);\n\nfloat theta = 0.0;\n\nif(u_shouldStretch == 0){\ntheta = (xDist * xDist + yDist * yDist) * denomI;\n}else{\ntheta = (xDist * xDist / u_width / u_width + yDist * yDist / u_height / u_height) * denomI;\n}\n\nif(u_shapeMode == 1){theta *= theta;}\nelse if(u_shapeMode == 3){theta *= theta; theta *= theta;}\nelse if(u_shapeMode == 2){theta = pow(theta,1.5);}\n\nif(theta < 0.04){\ncolor.a = 0.0;\n}else if(theta <= cutoff){\nfloat t2 = theta * theta;\nfloat t4 = t2 * t2;\nfloat t6 = t4 * t2;\nfloat t8 = t6 * t2;\nfloat factor = 1.0 - 2.0 * t2 + c4 * t4 - c6 * t6 + c8 * t8 - c10 * t8 * t2;\n\ncolor.a *= 1.0 - factor;\n}\n\ngl_FragColor = color;\n}",
BordersVignetteMultiplyFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform float u_width;\nuniform float u_height;\nuniform float u_vignetteScale;\nuniform lowp vec4 u_vignetteColor;\nuniform int u_shouldStretch;\nuniform int u_shapeMode;\nuniform float u_dx_2;\nuniform float u_dy_2;\n\n\nconst float cutoff = 1.15;\nconst float c4 = 5.0 / 3.0;\nconst float c6 = 34.0 / 45.0;\nconst float c8 = 13.0 / 63.0;\nconst float c10 = 514.0 / 14175.0;\n\nvoid main(void) {\nlowp vec4 dst = texture2D(u_sampler, v_texCoord);\nlowp vec4 color = vec4(0,0,0,0);\n\nfloat xDist = u_width * (v_texCoord.x - 0.5 - u_dx_2);\nfloat yDist = u_height * (v_texCoord.y - 0.5 - u_dy_2);\n\nfloat denomI = cutoff / (u_vignetteScale * u_vignetteScale);\n\nfloat theta = 0.0;\n\nif(u_shouldStretch == 0){\ntheta = (xDist * xDist + yDist * yDist) * denomI;\n}else{\ntheta = (xDist * xDist / u_width / u_width + yDist * yDist / u_height / u_height) * denomI;\n}\n\nif(u_shapeMode == 1){theta *= theta;}\nelse if(u_shapeMode == 3){theta *= theta; theta *= theta;}\nelse if(u_shapeMode == 2){theta = pow(theta,1.5);}\n\nfloat factor = u_vignetteColor.a;\nfloat factorI = 0.0;\n\nif(theta < 0.04){\nfactor = 0.0;\n}else if(theta <= cutoff){\nfloat t2 = theta * theta;\nfloat t4 = t2 * t2;\nfloat t6 = t4 * t2;\nfloat t8 = t6 * t2;\nfloat tFactor = 1.0 - 2.0 * t2 + c4 * t4 - c6 * t6 + c8 * t8 - c10 * t8 * t2;\n\nfactor = u_vignetteColor.a * (1.0 - tFactor);\n}\n\nfactor = clamp(factor,0.0,1.0);\nfactorI = 1.0 - factor;\n\ndst.rgb = factorI * dst.rgb + factor * (u_vignetteColor.rgb * dst.rgb);\ndst.a = 1.0;\n\ngl_FragColor = dst;\n}",
BordersVignetteOverlayFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform float u_width;\nuniform float u_height;\nuniform float u_vignetteScale;\nuniform lowp vec4 u_vignetteColor;\nuniform int u_shouldStretch;\nuniform int u_shapeMode;\nuniform float u_dx_2;\nuniform float u_dy_2;\n\nconst float cutoff = 1.15;\nconst float c4 = 5.0 / 3.0;\nconst float c6 = 34.0 / 45.0;\nconst float c8 = 13.0 / 63.0;\nconst float c10 = 514.0 / 14175.0;\n\nvoid main(void) {\nlowp vec4 dst = texture2D(u_sampler, v_texCoord);\nlowp vec4 color = vec4(0,0,0,0);\n\nfloat xDist = u_width * (v_texCoord.x - 0.5 - u_dx_2);\nfloat yDist = u_height * (v_texCoord.y - 0.5 - u_dy_2);\n\nfloat denomI = cutoff / (u_vignetteScale * u_vignetteScale);\n\nfloat theta = 0.0;\n\nif(u_shouldStretch == 0){\ntheta = (xDist * xDist + yDist * yDist) * denomI;\n}else{\ntheta = (xDist * xDist / u_width / u_width + yDist * yDist / u_height / u_height) * denomI;\n}\n\nif(u_shapeMode == 1){theta *= theta;}\nelse if(u_shapeMode == 3){theta *= theta; theta *= theta;}\nelse if(u_shapeMode == 2){theta = pow(theta,1.5);}\n\nfloat factor = u_vignetteColor.a;\nfloat factorI = 0.0;\n\nif(theta < 0.04){\nfactor = 0.0;\n}else if(theta <= cutoff){\nfloat t2 = theta * theta;\nfloat t4 = t2 * t2;\nfloat t6 = t4 * t2;\nfloat t8 = t6 * t2;\nfloat tFactor = 1.0 - 2.0 * t2 + c4 * t4 - c6 * t6 + c8 * t8 - c10 * t8 * t2;\n\nfactor = u_vignetteColor.a * (1.0 - tFactor);\n}\n\nfactor = clamp(factor,0.0,1.0);\nfactorI = 1.0 - factor;\n\nif (dst.r <= 0.5) {\ncolor.r = factorI * dst.r + factor * 2.0 * dst.r * u_vignetteColor.r;\n} else {\ncolor.r = factorI * dst.r + factor * (1.0 - (1.0 - dst.r) * (1.0 - u_vignetteColor.r) / 0.5);\n}\nif (dst.g <= 0.5) {\ncolor.g = factorI * dst.g + factor * 2.0 * dst.g * u_vignetteColor.g;\n} else {\ncolor.g = factorI * dst.g + factor * (1.0 - (1.0 - dst.g) * (1.0 - u_vignetteColor.g) / 0.5);\n}\nif (dst.b <= 0.5) {\ncolor.b = factorI * dst.b + factor * 2.0 * dst.b * u_vignetteColor.b;\n} else {\ncolor.b = factorI * dst.b + factor * (1.0 - (1.0 - dst.b) * (1.0 - u_vignetteColor.b) / 0.5);\n}\n\ncolor.a = 1.0;\n// color = vec4(factorI, 0, 0, 1);\n\ngl_FragColor = color;\n}\n\n\n",
BordersThetaFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform float u_dw;\nuniform float u_rFactor;\nuniform float u_width;\nuniform float u_height;\nuniform int u_borderStyle;\nuniform lowp vec4 u_borderColor;\nuniform float u_linesScale;\n\nuniform float u_dotScale;\nuniform float u_offsetL;\nuniform float u_offsetR;\nuniform float u_offsetT;\nuniform float u_offsetB;\n\nuniform float u_offsetX;\nuniform float u_offsetY;\n\nfloat rand(vec2 n)\n{\nreturn fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453);\n}\n\nvoid main(void) {\nlowp vec4 color = u_borderColor;\n\nfloat xComp = (v_texCoord.x < 0.5) ? v_texCoord.x * u_width - u_offsetL : u_width - 1.0 - v_texCoord.x * u_width - u_offsetR;\nfloat yComp = (v_texCoord.y < 0.5) ? v_texCoord.y * u_height - u_offsetT : u_height - 1.0 - v_texCoord.y * u_height - u_offsetB;\n\nfloat theta = 0.0;\nfloat factor = 0.0;\nfloat dots = 0.0;\nfloat xCompS = 0.0;\nfloat yCompS = 0.0;\n\nif (yComp < 1.414213562373 * u_dw * u_rFactor && xComp < 1.414213562373 * u_dw * u_rFactor) {\ntheta = 1.414213562373*u_dw*u_rFactor - sqrt((yComp - 1.414213562373 * u_dw * u_rFactor) * (yComp - 1.414213562373 * u_dw * u_rFactor) + (xComp - 1.414213562373 * u_dw * u_rFactor) * (xComp - 1.414213562373 * u_dw * u_rFactor));\n} else {\nif (yComp < xComp) { theta = yComp; } else { theta = xComp; }\n}\n\nif (yComp < 0.0 || xComp < 0.0) {\n// In this area set to pure border color\n} else if (theta < u_dw) {\n// If within effect scale distance\nif (u_borderStyle == 5) {\ntheta = theta < 0.0 ? 0.0 : theta;\nfactor = pow(theta / u_dw, 2.0);\n} else if (u_borderStyle == 6) {\nfactor = 1.0 - (0.4 * rand(v_texCoord) + 0.6) * 2.0 * pow((1.0 - theta / u_dw), 4.0);\n} else if (u_borderStyle == 16) {\nfactor = 1.0 - (0.4 * rand(v_texCoord) + 0.6) * 2.0 * pow((1.0 - theta / u_dw), 4.0);\n} else if (u_borderStyle == 3) {\nfactor = 1.0 - 2.0 * pow((1.0 - theta / u_dw), 4.0);\n}\nfactor = clamp(factor, 0.0, 1.0);\ncolor.a = (1.0 - factor);\n}else{\ncolor.a = 0.0;\n}\n\ngl_FragColor = color;\n}",
BorderSideVertexShader:"attribute highp vec2 a_position;\nattribute float a_alpha;\nvarying highp vec2 v_position;\nvarying float v_alpha;\n\nvoid main()\n{\nv_alpha = a_alpha;\ngl_Position = vec4(a_position.x, a_position.y, 0.0, 1.0);\n}\n\n",BorderSideFragmentShader:"precision highp float;\n\nuniform vec4 u_borderColor;\n\nvarying float v_alpha;\n\nvoid main()\n{\nvec4 color = u_borderColor;\nfloat alpha = v_alpha;\nalpha = clamp(alpha, 0.0, 0.9999);\ncolor.a = color.a * alpha;\ngl_FragColor = color;\n}",
BordersHardRandFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform sampler2D u_linesSampler;\nuniform float u_height;\nuniform float u_width;\nuniform float u_widthTexCoordMult;\nuniform float u_heightTexCoordMult;\nuniform float u_h2;\nuniform float u_w2;\nuniform float u_offset;\nuniform float u_dw;\nuniform vec4 u_color;\nuniform float u_scale;\nuniform float u_floatMult;\nuniform float u_floatTrans;\nuniform float u_randomSeed;\n\n\nfloat rand(in vec2 n)\n{\n//                                                   n *= u_randomSeed;\nreturn fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453);\n}\n\nhighp float unpackFloatFromVec4i(const vec4 value)\n{\nconst vec4 bitSh = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\nfloat rawVal = dot(value, bitSh);\nreturn ((rawVal / u_floatMult) + u_floatTrans);\n}\n\nvoid main(void) {\nfloat x = v_texCoord.x * u_width;\nfloat y = v_texCoord.y * u_height;\n\n// Y tex coords for given lines\nfloat lineL = 0.125;\nfloat lineR = 0.375;\nfloat lineT = 0.625;\nfloat lineB = 0.875;\n\nfloat xComp;\nfloat yComp;\nfloat theta;\nfloat factor;\n\nif (y < u_h2) {\nvec2 samplingCoord = vec2(x * u_widthTexCoordMult, lineT);\nvec4 sampledValue = texture2D(u_linesSampler, samplingCoord);\nyComp = y - u_offset - unpackFloatFromVec4i(sampledValue);\n}\n\nelse {\nvec2 samplingCoord = vec2(x * u_widthTexCoordMult, lineB);\nyComp = u_height - 1.0 - y - u_offset - unpackFloatFromVec4i(texture2D(u_linesSampler, samplingCoord));\n}\nif (x < u_w2) {\nvec2 samplingCoord = vec2(y * u_heightTexCoordMult, lineL);\nxComp = x - u_offset - unpackFloatFromVec4i(texture2D(u_linesSampler, samplingCoord));\n}else {\nvec2 samplingCoord = vec2(y * u_heightTexCoordMult, lineR);\nxComp = u_width - 1.0 - x - u_offset - unpackFloatFromVec4i(texture2D(u_linesSampler, samplingCoord));\n}\n\n// Set theta to distance to edge with case for rounded edges\nif (yComp < 1.414213562373 * u_dw && xComp < 1.414213562373 * u_dw) {\ntheta = 1.414213562373*u_dw - sqrt((yComp - 1.414213562373 * u_dw) * (yComp - 1.414213562373 * u_dw) + (xComp - 1.414213562373 * u_dw) * (xComp - 1.414213562373 * u_dw));\n} else {\nif (yComp < xComp) { theta = yComp; } else { theta = xComp; }\n}\n\nvec4 finalColor = u_color;\nif (yComp < 0.0 || xComp < 0.0) {\n\n}\nelse if (theta < u_dw) {\n// If within effect scale distance\nfactor = 1.0-(0.4*rand(vec2(x,y))+0.6) * 2.0 * pow(1.0 - theta / u_dw, 4.0*u_scale);\nfactor = clamp(factor, 0.0, 1.0);\nfinalColor.a *= 1.0 - factor;\n}else{\nfinalColor.a = 0.0;\n}\ngl_FragColor = finalColor;\n}",
ColorMapFragmentShader:"precision mediump float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\nuniform lowp sampler2D u_colorMapSampler;\n\nvoid main(void) {\nlowp vec4 color = texture2D(u_sampler, v_texCoord);\n\nlowp vec2 redVec = vec2(0,color.r);\nlowp vec2 greenVec = vec2(0,color.g);\nlowp vec2 blueVec = vec2(0,color.b);\n\nlowp vec4 rColor = texture2D(u_colorMapSampler, redVec);\nlowp vec4 gColor = texture2D(u_colorMapSampler, greenVec);\nlowp vec4 bColor = texture2D(u_colorMapSampler, blueVec);\n\ncolor.r = rColor.r;\ncolor.g = gColor.g;\ncolor.b = bColor.b;\n\ngl_FragColor = color;\n}",
IntensityMapOverlayFragmentShader:"precision mediump float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\nuniform lowp sampler2D u_colorMapSampler;\nuniform float u_intensity;\n\nvoid main(void) {\nlowp vec4 dst = texture2D(u_sampler, v_texCoord);\nlowp vec4 src;\n\nfloat intensity = 0.212671*dst.r + 0.71516*dst.g + 0.072169*dst.b;\n\nlowp vec2 intensityVec = vec2(0,intensity);\n\nsrc = texture2D(u_colorMapSampler, intensityVec);\n\nfloat factor = u_intensity;\nfloat factorI = 1.0 - factor;\n\nif (dst.r <= 0.5) {\ndst.r = factorI * dst.r + factor * 2.0 * dst.r * src.r;\n} else {\ndst.r = factorI * dst.r + factor * (1.0 - (1.0 - dst.r) * (1.0 - src.r) / 0.5);\n}\nif (dst.g <= 0.5) {\ndst.g = factorI * dst.g + factor * 2.0 * dst.g * src.g;\n} else {\ndst.g = factorI * dst.g + factor * (1.0 - (1.0 - dst.g) * (1.0 - src.g) / 0.5);\n}\nif (dst.b <= 0.5) {\ndst.b = factorI * dst.b + factor * 2.0 * dst.b * src.b;\n} else {\ndst.b = factorI * dst.b + factor * (1.0 - (1.0 - dst.b) * (1.0 - src.b) / 0.5);\n}\n\ndst.a = 1.0;\n\n\ngl_FragColor = dst;\n}",
IntensityMapMultiplyFragmentShader:"precision mediump float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\nuniform lowp sampler2D u_colorMapSampler;\nuniform float u_intensity;\n\nvoid main(void) {\nlowp vec4 dst = texture2D(u_sampler, v_texCoord);\nlowp vec4 src;\n\nfloat intensity = 0.212671*dst.r + 0.71516*dst.g + 0.072169*dst.b;\n\nlowp vec2 intensityVec = vec2(0,intensity);\n\nsrc = texture2D(u_colorMapSampler, intensityVec);\n\n// Could use a blend mode here, but we've already gone to the trouble of sampling the source\nfloat factor = u_intensity;\nfloat factorI = 1.0 - factor;\n\ndst.rgb = factorI * dst.rgb + factor * (src.rgb * dst.rgb);\n\ndst.a = 1.0;\n\ngl_FragColor = dst;\n}",
IntensityMapFragmentShader:"precision mediump float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\nuniform lowp sampler2D u_colorMapSampler;\nuniform float u_intensity;\n\nvoid main(void) {\nlowp vec4 dst = texture2D(u_sampler, v_texCoord);\nlowp vec4 src;\n\nfloat intensity = 0.212671*dst.r + 0.71516*dst.g + 0.072169*dst.b;\n\nlowp vec2 intensityVec = vec2(0,intensity);\n\nsrc = texture2D(u_colorMapSampler, intensityVec);\n\n// Could use a blend mode here, but we've already gone to the trouble of sampling the source\n//                                                               float factor = u_intensity;\n//                                                               float factorI = 1.0 - factor;\ndst = mix(dst, src, u_intensity);\n//                                                               dst.rgb = factorI * dst.rgb + factor * src.rgb;\n\ndst.a = 1.0;\n\ngl_FragColor = dst;\n//                                                               gl_FragColor = vec4(1,0,0,1);\n\n}",
ColorTransformFragmentShader:"precision mediump float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\nuniform mat3 u_colorMat;\nuniform vec3 u_colorTrans;\n\nvoid main(void) {\nlowp vec4 color = texture2D(u_sampler, v_texCoord);\n\ncolor.rgb = u_colorMat * color.rgb + u_colorTrans;\n\ngl_FragColor = color;\n}",ColorTransformAndOverlayWithOriginalFragmentShader:"\nprecision mediump float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\nuniform mat3 u_colorMat;\nuniform vec3 u_colorTrans;\nuniform float u_overlayAmount;\n\nvoid main(void) {\nlowp vec4 color = texture2D(u_sampler, v_texCoord);\nlowp vec4 originalColor = color;\n\ncolor.rgb = u_colorMat * color.rgb + u_colorTrans;\n\n// Overlay with amount\n\nfloat factor = clamp(u_overlayAmount, 0.0, 1.0);\nfloat factorI = 1.0-factor;\n\nif (originalColor.r <= 0.5) {\ncolor.r = factorI * originalColor.r + factor * 2.0 * originalColor.r * color.r;\n} else {\ncolor.r = factorI * originalColor.r + factor * (1.0 - (1.0 - originalColor.r) * (1.0 - color.r) / 0.5);\n}\nif (originalColor.g <= 0.5) {\ncolor.g = factorI * originalColor.g + factor * 2.0 * originalColor.g * color.g;\n} else {\ncolor.g = factorI * originalColor.g + factor * (1.0 - (1.0 - originalColor.g) * (1.0 - color.g) / 0.5);\n}\nif (originalColor.b <= 0.5) {\ncolor.b = factorI * originalColor.b + factor * 2.0 * originalColor.b * color.b;\n} else {\ncolor.b = factorI * originalColor.b + factor * (1.0 - (1.0 - originalColor.b) * (1.0 - color.b) / 0.5);\n}\n\n\ngl_FragColor = color;\n}",
ConvolutionHorizontalBoxBlur3VertexShader:"attribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying highp vec2 v_texCoord;\n\nvarying highp vec2 v_texCoordMinus1;\nvarying highp vec2 v_texCoordPlus1;\n\n\nuniform highp float u_texelStride;\n\nvoid main(void) {\nv_texCoord = a_texCoord;\nv_texCoordMinus1 = a_texCoord;\nv_texCoordPlus1 = a_texCoord;\nv_texCoordMinus1.x = a_texCoord.x - u_texelStride;\nv_texCoordPlus1.x = a_texCoord.x + u_texelStride;\n\ngl_Position = a_position;\n}",ConvolutionVerticalBoxBlur3VertexShader:"attribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying highp vec2 v_texCoord;\n\nvarying highp vec2 v_texCoordMinus1;\nvarying highp vec2 v_texCoordPlus1;\n\n\nuniform highp float u_texelStride;\n\nvoid main(void) {\nv_texCoord = a_texCoord;\nv_texCoordMinus1 = a_texCoord;\nv_texCoordPlus1 = a_texCoord;\nv_texCoordMinus1.y = a_texCoord.y - u_texelStride;\nv_texCoordPlus1.y = a_texCoord.y + u_texelStride;\n\ngl_Position = a_position;\n}",
ConvolutionBoxBlur3FragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nvarying highp vec2 v_texCoordMinus1;\nvarying highp vec2 v_texCoordPlus1;\n\nvoid main(void) {\nhighp vec4 resultColor = texture2D(u_sampler, v_texCoord);\nresultColor += texture2D(u_sampler, v_texCoordPlus1);\nresultColor += texture2D(u_sampler, v_texCoordMinus1);\ngl_FragColor = resultColor / 3.0;\n}",ConvolutionHorizontalBoxBlur5VertexShader:"attribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying highp vec2 v_texCoord;\n\nvarying highp vec2 v_texCoordMinus1;\nvarying highp vec2 v_texCoordPlus1;\nvarying highp vec2 v_texCoordMinus2;\nvarying highp vec2 v_texCoordPlus2;\n\n\nuniform highp float u_texelStride;\n\nvoid main(void) {\nv_texCoord = a_texCoord;\nv_texCoordMinus1 = a_texCoord;\nv_texCoordPlus1 = a_texCoord;\nv_texCoordMinus2 = a_texCoord;\nv_texCoordPlus2 = a_texCoord;\nv_texCoordMinus1.x = a_texCoord.x - u_texelStride;\nv_texCoordPlus1.x = a_texCoord.x + u_texelStride;\nv_texCoordMinus2.x = a_texCoord.x - u_texelStride * 2.0;\nv_texCoordPlus2.x = a_texCoord.x + u_texelStride * 2.0;\n\ngl_Position = a_position;\n}",
ConvolutionVerticalBoxBlur5VertexShader:"attribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying highp vec2 v_texCoord;\n\nvarying highp vec2 v_texCoordMinus1;\nvarying highp vec2 v_texCoordPlus1;\nvarying highp vec2 v_texCoordMinus2;\nvarying highp vec2 v_texCoordPlus2;\n\nuniform highp float u_texelStride;\n\nvoid main(void) {\nv_texCoord = a_texCoord;\nv_texCoordMinus1 = a_texCoord;\nv_texCoordPlus1 = a_texCoord;\nv_texCoordMinus2 = a_texCoord;\nv_texCoordPlus2 = a_texCoord;\nv_texCoordMinus1.y = a_texCoord.y - u_texelStride;\nv_texCoordPlus1.y = a_texCoord.y + u_texelStride;\nv_texCoordMinus2.y = a_texCoord.y - u_texelStride * 2.0;\nv_texCoordPlus2.y = a_texCoord.y + u_texelStride * 2.0;\n\ngl_Position = a_position;\n}",
ConvolutionBoxBlur5FragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nvarying highp vec2 v_texCoordMinus1;\nvarying highp vec2 v_texCoordPlus1;\nvarying highp vec2 v_texCoordMinus2;\nvarying highp vec2 v_texCoordPlus2;\n\nvoid main(void) {\nhighp vec4 resultColor = texture2D(u_sampler, v_texCoord);\nresultColor += texture2D(u_sampler, v_texCoordPlus1);\nresultColor += texture2D(u_sampler, v_texCoordMinus1);\nresultColor += texture2D(u_sampler, v_texCoordPlus2);\nresultColor += texture2D(u_sampler, v_texCoordMinus2);\ngl_FragColor = resultColor / 5.0;\n}",
ConvolutionHorizontalBoxBlur7VertexShader:"attribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying highp vec2 v_texCoord;\n\nvarying highp vec2 v_texCoordMinus1;\nvarying highp vec2 v_texCoordPlus1;\nvarying highp vec2 v_texCoordMinus2;\nvarying highp vec2 v_texCoordPlus2;\nvarying highp vec2 v_texCoordMinus3;\nvarying highp vec2 v_texCoordPlus3;\n\nuniform highp float u_texelStride;\n\nvoid main(void) {\nv_texCoord = a_texCoord;\nv_texCoordMinus1 = a_texCoord;\nv_texCoordPlus1 = a_texCoord;\nv_texCoordMinus2 = a_texCoord;\nv_texCoordPlus2 = a_texCoord;\nv_texCoordMinus3 = a_texCoord;\nv_texCoordPlus3 = a_texCoord;\nv_texCoordMinus1.x = a_texCoord.x - u_texelStride;\nv_texCoordPlus1.x = a_texCoord.x + u_texelStride;\nv_texCoordMinus2.x = a_texCoord.x - u_texelStride * 2.0;\nv_texCoordPlus2.x = a_texCoord.x + u_texelStride * 2.0;\nv_texCoordMinus3.x = a_texCoord.x - u_texelStride * 3.0;\nv_texCoordPlus3.x = a_texCoord.x + u_texelStride * 3.0;\n\ngl_Position = a_position;\n}",
ConvolutionVerticalBoxBlur7VertexShader:"attribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying highp vec2 v_texCoord;\n\nvarying highp vec2 v_texCoordMinus1;\nvarying highp vec2 v_texCoordPlus1;\nvarying highp vec2 v_texCoordMinus2;\nvarying highp vec2 v_texCoordPlus2;\nvarying highp vec2 v_texCoordMinus3;\nvarying highp vec2 v_texCoordPlus3;\n\nuniform highp float u_texelStride;\n\nvoid main(void) {\nv_texCoord = a_texCoord;\nv_texCoordMinus1 = a_texCoord;\nv_texCoordPlus1 = a_texCoord;\nv_texCoordMinus2 = a_texCoord;\nv_texCoordPlus2 = a_texCoord;\nv_texCoordMinus3 = a_texCoord;\nv_texCoordPlus3 = a_texCoord;\nv_texCoordMinus1.y = a_texCoord.y - u_texelStride;\nv_texCoordPlus1.y = a_texCoord.y + u_texelStride;\nv_texCoordMinus2.y = a_texCoord.y - u_texelStride * 2.0;\nv_texCoordPlus2.y = a_texCoord.y + u_texelStride * 2.0;\nv_texCoordMinus3.y = a_texCoord.y - u_texelStride * 3.0;\nv_texCoordPlus3.y = a_texCoord.y + u_texelStride * 3.0;\n\ngl_Position = a_position;\n}",
ConvolutionBoxBlur7FragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nvarying highp vec2 v_texCoordMinus1;\nvarying highp vec2 v_texCoordPlus1;\nvarying highp vec2 v_texCoordMinus2;\nvarying highp vec2 v_texCoordPlus2;\nvarying highp vec2 v_texCoordMinus3;\nvarying highp vec2 v_texCoordPlus3;\n\nvoid main(void) {\nhighp vec4 resultColor = texture2D(u_sampler, v_texCoord);\nresultColor += texture2D(u_sampler, v_texCoordPlus1);\nresultColor += texture2D(u_sampler, v_texCoordMinus1);\nresultColor += texture2D(u_sampler, v_texCoordPlus2);\nresultColor += texture2D(u_sampler, v_texCoordMinus2);\nresultColor += texture2D(u_sampler, v_texCoordPlus3);\nresultColor += texture2D(u_sampler, v_texCoordMinus3);\ngl_FragColor = resultColor / 7.0;\n}",
ConvolutionHorizontalGaussian9VertexShader:"attribute vec4 a_position;\nattribute vec2 a_texCoord;\n\nvarying highp vec2 v_texCoord;\nvarying highp vec2 v_texCoordMinus1;\nvarying highp vec2 v_texCoordPlus1;\nvarying highp vec2 v_texCoordMinus2;\nvarying highp vec2 v_texCoordPlus2;\nvarying highp vec2 v_texCoordMinus3;\nvarying highp vec2 v_texCoordPlus3;\nvarying highp vec2 v_texCoordMinus4;\nvarying highp vec2 v_texCoordPlus4;\n\nuniform highp float u_texelStride;\n\nvoid main(void) {\nv_texCoord = a_texCoord;\nv_texCoordMinus1 = a_texCoord;\nv_texCoordPlus1 = a_texCoord;\nv_texCoordMinus2 = a_texCoord;\nv_texCoordPlus2 = a_texCoord;\nv_texCoordMinus3 = a_texCoord;\nv_texCoordPlus3 = a_texCoord;\nv_texCoordMinus4 = a_texCoord;\nv_texCoordPlus4 = a_texCoord;\n\nv_texCoordMinus1.x = a_texCoord.x - u_texelStride;\nv_texCoordPlus1.x = a_texCoord.x + u_texelStride;\nv_texCoordMinus2.x = a_texCoord.x - u_texelStride * 2.0;\nv_texCoordPlus2.x = a_texCoord.x + u_texelStride * 2.0;\nv_texCoordMinus3.x = a_texCoord.x - u_texelStride * 3.0;\nv_texCoordPlus3.x = a_texCoord.x + u_texelStride * 3.0;\nv_texCoordMinus4.x = a_texCoord.x - u_texelStride * 4.0;\nv_texCoordPlus4.x = a_texCoord.x + u_texelStride * 4.0;\n\ngl_Position = a_position;\n}",
ConvolutionVerticalGaussian9VertexShader:"attribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying highp vec2 v_texCoord;\n\nvarying highp vec2 v_texCoordMinus1;\nvarying highp vec2 v_texCoordPlus1;\nvarying highp vec2 v_texCoordMinus2;\nvarying highp vec2 v_texCoordPlus2;\nvarying highp vec2 v_texCoordMinus3;\nvarying highp vec2 v_texCoordPlus3;\nvarying highp vec2 v_texCoordMinus4;\nvarying highp vec2 v_texCoordPlus4;\n\nuniform highp float u_texelStride;\n\nvoid main(void) {\nv_texCoord = a_texCoord;\nv_texCoordMinus1 = a_texCoord;\nv_texCoordPlus1 = a_texCoord;\nv_texCoordMinus2 = a_texCoord;\nv_texCoordPlus2 = a_texCoord;\nv_texCoordMinus3 = a_texCoord;\nv_texCoordPlus3 = a_texCoord;\nv_texCoordMinus4 = a_texCoord;\nv_texCoordPlus4 = a_texCoord;\n\nv_texCoordMinus1.y = a_texCoord.y - u_texelStride;\nv_texCoordPlus1.y = a_texCoord.y + u_texelStride;\nv_texCoordMinus2.y = a_texCoord.y - u_texelStride * 2.0;\nv_texCoordPlus2.y = a_texCoord.y + u_texelStride * 2.0;\nv_texCoordMinus3.y = a_texCoord.y - u_texelStride * 3.0;\nv_texCoordPlus3.y = a_texCoord.y + u_texelStride * 3.0;\nv_texCoordMinus4.y = a_texCoord.y - u_texelStride * 4.0;\nv_texCoordPlus4.y = a_texCoord.y + u_texelStride * 4.0;\n\ngl_Position = a_position;\n}",
ConvolutionGaussian9FragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nvarying highp vec2 v_texCoordMinus1;\nvarying highp vec2 v_texCoordPlus1;\nvarying highp vec2 v_texCoordMinus2;\nvarying highp vec2 v_texCoordPlus2;\nvarying highp vec2 v_texCoordMinus3;\nvarying highp vec2 v_texCoordPlus3;\nvarying highp vec2 v_texCoordMinus4;\nvarying highp vec2 v_texCoordPlus4;\n\nuniform highp float u_weight0;\nuniform highp float u_weight1;\nuniform highp float u_weight2;\nuniform highp float u_weight3;\nuniform highp float u_weight4;\n\nvoid main(void) {\nhighp vec4 resultColor = texture2D(u_sampler, v_texCoord) * u_weight0;\nresultColor += texture2D(u_sampler, v_texCoordPlus1) * u_weight1;\nresultColor += texture2D(u_sampler, v_texCoordMinus1) * u_weight1;\nresultColor += texture2D(u_sampler, v_texCoordPlus2) * u_weight2;\nresultColor += texture2D(u_sampler, v_texCoordMinus2) * u_weight2;\nresultColor += texture2D(u_sampler, v_texCoordPlus3) * u_weight3;\nresultColor += texture2D(u_sampler, v_texCoordMinus3) * u_weight3;\nresultColor += texture2D(u_sampler, v_texCoordPlus4) * u_weight4;\nresultColor += texture2D(u_sampler, v_texCoordMinus4) * u_weight4;\n\ngl_FragColor = resultColor / (u_weight0 + 2.0 * (u_weight1 + u_weight2 + u_weight3 + u_weight4));\n\n}",
WhitenFragmentShader:"precision highp float;\n\nuniform highp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nvoid main(void) {\nhighp vec4 color = texture2D(u_sampler, v_texCoord);\n\n// RGB to LAB\nfloat R = color.r * 255.0;\nfloat G = color.g * 255.0;\nfloat B = color.b * 255.0;\n\nfloat l1;\nfloat a1;\nfloat b1;\nfloat r;\nfloat g;\nfloat b;\nfloat x;\nfloat y;\nfloat z;\n\nif(R/255.0 <= 0.04045){r = 100.0 *R/255.0/12.92;} else{ r = 100.0*pow((R/255.0+0.055)/1.055,2.40);}\nif(G/255.0 <= 0.04045){g = 100.0 *G/255.0/12.92;} else{ g = 100.0*pow((G/255.0+0.055)/1.055,2.40);}\nif(B/255.0 <= 0.04045){b = 100.0 *B/255.0/12.92;} else{ b = 100.0*pow((B/255.0+0.055)/1.055,2.40);}\n\nx = 0.00433891*r  + 0.00376234915*g + 0.0018990604648*b;\ny = 0.002126*r    + 0.007152*g      + 0.000722*b;\nz = 0.000177255*r + 0.00109475308*g + 0.0087295537*b;\n\nif(x > 0.008856){x = pow(x,1.0/3.0);}else{x = 7.787*x+16.0/116.0;}\nif(y > 0.008856){y = pow(y,1.0/3.0);}else{y = 7.787*y+16.0/116.0;}\nif(z > 0.008856){z = pow(z,1.0/3.0);}else{z = 7.787*z+16.0/116.0;}\n\nl1 = 116.0*y-16.0;\na1 = 500.0*(x-y);\nb1 = 200.0*(y-z);\n\ncolor.r = l1 * 2.55; color.g = (a1+127.0); color.b = (b1+127.0);\n\n// Adjust LAB\nfloat dColor = (color.g - 132.0)*(color.g - 132.0);\n\nif(color.b < 127.0){\ndColor += (color.b - 127.0)*(color.b - 127.0);\n}\n\nfloat factor = 0.65*exp(-dColor/98.0);\n\ncolor.r = 255.0*pow(color.r/255.0,1.0/(0.5*factor+1.0));\ncolor.b = (1.0-factor)*(color.b-127.0)+127.0;\n\n// LAB to RGB\nfloat lab0 = color.r;\nfloat lab1 = color.g;\nfloat lab2 = color.b;\n\nfloat Y = ( lab0/2.55 + 16.0) / 116.0;\nfloat X = (lab1-127.0) / 500.0 + Y;\nfloat Z = Y - (lab2-127.0) / 200.0;\n\nfloat Y3 = Y*Y*Y;\nfloat X3 = X*X*X;\nfloat Z3 = Z*Z*Z;\n\nif ( Y3 > 0.008856 ){ Y = Y3;}else{Y = ( Y - 16.0 / 116.0 ) / 7.787;}\n\nif ( X3 > 0.008856 ){ X = X3;}else{X = ( X - 16.0 / 116.0 ) / 7.787;}\n\nif ( Z3 > 0.008856 ){ Z = Z3;}else{Z = ( Z - 16.0 / 116.0 ) / 7.787;}\n\nX = .95047  * X;\nY = 1.00000 * Y;\nZ = 1.08883 * Z;\n\nR = X *  3.2406 + Y * -1.5372 + Z * -0.4986;\nG = X * -0.9689 + Y *  1.8758 + Z *  0.0415;\nB = X *  0.0557 + Y * -0.2040 + Z *  1.0570;\n\nif ( R > 0.0031308 ) {R = 1.055 * ( pow(R , ( 0.41666666666667 )) ) - 0.055;}else{ R = 12.92 * R;}\nif ( G > 0.0031308 ) {G = 1.055 * ( pow(G , ( 0.41666666666667 )) ) - 0.055;}else{ G = 12.92 * G;}\nif ( B > 0.0031308 ) {B = 1.055 * ( pow(B , ( 0.41666666666667 )) ) - 0.055;}else{ B = 12.92 * B;}\n\ncolor.r = R; color.g = G; color.b = B;\ncolor.a = 1.0;\n\ngl_FragColor = color;\n}",
RedeyeFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nvoid main(void) {\nlowp vec4 color = texture2D(u_sampler, v_texCoord);\n\nfloat average = (color.g + color.b) * 0.5;\n\nfloat newRed = 0.0;\n\nif(average > 0.0){\nfloat redIntensity = color.r / average;\nif(redIntensity > 2.0){\nnewRed = average;\n}else{\nnewRed = color.r;\n}\n}else{\nnewRed = 0.0;\n}\n\ncolor.r = newRed;\n\ngl_FragColor = color;\n}",DotMatrixVertexShader:"attribute highp vec2 a_position;\nuniform float u_pointSize;\n\nvoid main()\n{\ngl_Position = vec4(a_position.x, a_position.y, 0.0, 1.0);\ngl_PointSize = u_pointSize;\n}",
DotMatrixFragmentShader:"precision highp float;\n\nuniform sampler2D u_dotSampler;\n\nvoid main()\n{\ngl_FragColor = texture2D(u_dotSampler, gl_PointCoord);\n}",BasicDotsVertexShader:"attribute highp vec2 a_position;\nattribute highp float a_pointSize;\n\nvoid main()\n{\ngl_Position = vec4(a_position.x, a_position.y, 0.0, 1.0);\ngl_PointSize = a_pointSize;\n}",DrawingVertexShader:"attribute highp vec2 a_position;\nvarying highp vec2 v_position;\n\nvoid main()\n{\ngl_Position = vec4(a_position.x, a_position.y, 0.0, 1.0);\n}\n\n",
DrawingFragmentShader:"precision highp float;\n\nuniform vec4 u_color;\n\nvoid main()\n{\nvec4 color = u_color;\ngl_FragColor = color;\n}",FlareFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nuniform highp float u_flareAmount;\nvarying highp vec2 v_texCoord;\n\nuniform int u_blendMode;\nuniform int u_flareType;\nuniform float u_scaleDiffx;\nuniform float u_scaleDiffy;\nuniform vec2 u_onePlusDxTimesCenterCoord;\nuniform lowp vec4 u_flareColor;\nuniform float u_minEXP;\nuniform float u_maxEXP;\nuniform float u_aF;\n\nvoid setFactorAndExpvForType(out float factor)\n{\nfloat theta;\nfloat a;\nfloat expV = 0.0;\n\nfloat xF = u_scaleDiffx * (v_texCoord.x - u_onePlusDxTimesCenterCoord.x);\nfloat yF = u_scaleDiffy * (v_texCoord.y - u_onePlusDxTimesCenterCoord.y);\n\nif(u_flareType == 14){\nxF -= 1.0;\nyF -= 1.0;\n}\n\nif(u_flareType == 0){\ntheta = 80.0 * (xF * xF + yF * yF);\nif (theta == 0.0) { factor = 1.0; } else {\nfactor = 1.0 - u_aF * 0.4 * (sin(theta) / sqrt(theta));\n}\n}else if(u_flareType == 1){\nexpV   = (-(xF * xF + yF * yF) * 2.0 - 16.0 * (yF + 0.5) * (yF + 0.5) * (xF + 0.5) * (xF + 0.5));\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n}else if(u_flareType == 2){\nexpV   = (-(xF * xF + yF * yF) * 2.0 - 16.0 * (yF + 1.0) * (yF + 1.0) * (xF - 0.5) * (xF - 0.5));\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n}else if(u_flareType == 3){\ntheta  = xF * xF + yF * yF;\nexpV   = -theta * 2.0 - 1.0 * (yF + 1.7) * (yF + 1.7) * (xF - 0.6) * (xF - 0.6);\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n}else if(u_flareType == 4){\n// theta  = xF * xF + yF * yF;\nexpV   = -0.5 * (yF - 1.7) * (yF - 1.7) * (xF + 0.6) * (xF + 0.6) - 0.5 * (yF + 1.7) * (yF + 1.7) * (xF - 0.6) * (xF - 0.6);\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n}else if(u_flareType == 5){\nexpV   = -(xF * xF + yF * yF) * 2.0 - 5.0 * (xF + 0.2) * (yF + 0.2) * xF * xF;\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - 0.5 * u_aF) : (1.0 - 0.5 * u_aF * exp(expV));\n}else if(u_flareType ==  6){\ntheta = xF * xF + yF * yF;\na = atan(yF, xF);\nfactor = 1.0 - u_aF * 0.2 * (1.0 - theta * theta * (sin(10.0 * a)));\n}else if(u_flareType == 7){\ntheta = xF * xF + yF * yF;\na = atan(yF, xF);\nfactor = 1.0 - u_aF * 0.5 * exp(-theta * 2.0) * (0.5 + 0.5 * sin(4.0 * a + 1.0));\n}else if(u_flareType == 8){\n// Unimplemented\n}else if(u_flareType == 9){\nexpV = (-(xF * xF) - yF * yF / 64.0);\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n}else if(u_flareType == 10){\nexpV = (-(yF * yF) - xF * xF / 64.0);\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n}else if(u_flareType == 11){\ntheta  = xF * xF + yF * yF;\nfactor = 1.0 - u_aF *exp(-(theta * theta) *2.0 + (-8.0) *(yF + 0.5) *(yF - 0.5) *(xF + 0.5) *(xF - 0.5));\n}else if(u_flareType == 12){\ntheta = xF * xF + yF * yF;\nexpV  = -(theta / 180.0) * 2.0 - 16.0 * (yF + 0.5) * (yF + 0.5) * (xF + 0.5) * (xF + 0.5);\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n}else if(u_flareType == 13){\ntheta = xF * xF + yF * yF;\nfactor = 1.0 - u_aF *exp(-(theta / 180.0) *2.0) * (exp((-8.0) * (yF + 1.0) * (yF - 1.0) * (xF + 1.0) * (xF - 1.0)));\n}else if(u_flareType == 14){\ntheta = (xF + 1.0) * xF + yF * yF;\nfactor = u_aF * exp(yF / xF + (-theta) * exp(exp(yF) * xF));\n}else if(u_flareType == 15){\ntheta = xF * xF + yF * yF;\nfactor = 1.0 - u_aF *exp(-pow(theta, 2.0) + -0.9 *(yF - 1.7) *(yF + 0.5) *(xF - 1.5) *(xF + 0.5));\n}else if(u_flareType == 16){\ntheta = xF * xF + yF * yF;\na = atan(yF, xF);\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * 0.2 * (1.0 - sin(theta) * sin(10.0 * theta) * (sin(10.0 * a))));\n}else if(u_flareType == 17){\nexpV = (-((yF * yF + xF * xF) * (yF * yF + xF * xF) * (yF * yF + xF * xF) * (yF * yF + xF * xF))) * 100.0;\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n}else if(u_flareType == 18){\nfloat xF2plusyF2 = yF * yF + xF * xF;\n\nexpV = (-1.0 * (xF2plusyF2) * (xF2plusyF2))*10.0;\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n}\n}\n\nvoid blend(inout vec4 dst, float factor)\n{\nvec4 color = vec4(0,0,0,0);\nfloat factorI = 1.0 - factor;\n\nif(u_blendMode == 0){\ncolor.rgb = u_flareColor.rgb * factor + dst.rgb * factorI;\n}else if(u_blendMode==1){\nif (dst.r <= 0.5) {\ncolor.r = factorI * dst.r + factor * 2.0 * dst.r * u_flareColor.r;\n} else {\ncolor.r = factorI * dst.r + factor * (1.0 - (1.0 - dst.r) * (1.0 - u_flareColor.r) / 0.5);\n}\nif (dst.g <= 0.5) {\ncolor.g = factorI * dst.g + factor * 2.0 * dst.g * u_flareColor.g;\n} else {\ncolor.g = factorI * dst.g + factor * (1.0 - (1.0 - dst.g) * (1.0 - u_flareColor.g) / 0.5);\n}\nif (dst.b <= 0.5) {\ncolor.b = factorI * dst.b + factor * 2.0 * dst.b * u_flareColor.b;\n} else {\ncolor.b = factorI * dst.b + factor * (1.0 - (1.0 - dst.b) * (1.0 - u_flareColor.b) / 0.5);\n}\n}else if (u_blendMode==3){\ncolor.r = factorI * dst.r + factor * (1.0 - (1.0 - dst.r) * (1.0 - u_flareColor.r));\ncolor.g = factorI * dst.g + factor * (1.0 - (1.0 - dst.r) * (1.0 - u_flareColor.g));\ncolor.b = factorI * dst.b + factor * (1.0 - (1.0 - dst.r) * (1.0 - u_flareColor.b));\n}else if (u_blendMode==4){\ncolor.r = factorI * dst.r + factor * (dst.r < u_flareColor.r ? dst.r : u_flareColor.r);\ncolor.g = factorI * dst.g + factor * (dst.g < u_flareColor.g ? dst.g : u_flareColor.g);\ncolor.b = factorI * dst.b + factor * (dst.b < u_flareColor.b ? dst.b : u_flareColor.b);\n}\nelse if (u_blendMode==5){\ncolor.r = factorI * dst.r + factor * dst.r * u_flareColor.r;\ncolor.g = factorI * dst.g + factor * dst.g * u_flareColor.g;\ncolor.b = factorI * dst.b + factor * dst.b * u_flareColor.b;\n}\ndst = color;\n}\n\nvoid main(void) {\nlowp vec4 color = texture2D(u_sampler, v_texCoord);\n\nfloat factor = 0.0;\n\nsetFactorAndExpvForType(factor);\n\nfactor = 1.0-factor;\nfactor = clamp(factor,0.0,1.0);\n\nblend(color, factor);\n\ncolor.a = 1.0;\ngl_FragColor = color;\n}",
FlareBlobFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nuniform highp float u_flareAmount;\nvarying highp vec2 v_texCoord;\n\nuniform float u_scaleDiffx;\nuniform float u_scaleDiffy;\nuniform vec2 u_onePlusDxTimesCenterCoord;\nuniform lowp vec4 u_flareColor;\nuniform float u_minEXP;\nuniform float u_maxEXP;\nuniform float u_aF;\n\nvoid main(void) {\nlowp vec4 color = u_flareColor;\n\nfloat factor = 0.0;\n\nfloat theta;\nfloat a;\nfloat expV = 0.0;\n\nfloat xF = u_scaleDiffx * (v_texCoord.x - u_onePlusDxTimesCenterCoord.x);\nfloat yF = u_scaleDiffy * (v_texCoord.y - u_onePlusDxTimesCenterCoord.y);\n\nfloat xF2plusyF2 = yF * yF + xF * xF;\n\nexpV = (-((xF2plusyF2) * (xF2plusyF2) * (xF2plusyF2) * (xF2plusyF2))) * 100.0;\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n\nfactor = 1.0-factor;\n\ncolor.a = factor;\ngl_FragColor = color;\n}",
FlareBlobOverlayFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nuniform highp float u_flareAmount;\nvarying highp vec2 v_texCoord;\n\nuniform float u_scaleDiffx;\nuniform float u_scaleDiffy;\nuniform vec2 u_onePlusDxTimesCenterCoord;\nuniform lowp vec4 u_flareColor;\nuniform float u_minEXP;\nuniform float u_maxEXP;\nuniform float u_aF;\n\nvoid main(void) {\nlowp vec4 dst = texture2D(u_sampler, v_texCoord);\nlowp vec4 color = vec4(0,0,0,0);\n\nfloat factor = 0.0;\nfloat factorI = 0.0;\n\nfloat theta;\nfloat a;\nfloat expV = 0.0;\n\nfloat xF = u_scaleDiffx * (v_texCoord.x - u_onePlusDxTimesCenterCoord.x);\nfloat yF = u_scaleDiffy * (v_texCoord.y - u_onePlusDxTimesCenterCoord.y);\n\nfloat xF2plusyF2 = yF * yF + xF * xF;\n\nexpV = (-((xF2plusyF2) * (xF2plusyF2) * (xF2plusyF2) * (xF2plusyF2))) * 100.0;\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n\nfactorI = clamp(factor, 0.0, 1.0);\nfactor = 1.0-factorI;\n\nif (dst.r <= 0.5) {\ncolor.r = factorI * dst.r + factor * 2.0 * dst.r * u_flareColor.r;\n} else {\ncolor.r = factorI * dst.r + factor * (1.0 - (1.0 - dst.r) * (1.0 - u_flareColor.r) / 0.5);\n}\nif (dst.g <= 0.5) {\ncolor.g = factorI * dst.g + factor * 2.0 * dst.g * u_flareColor.g;\n} else {\ncolor.g = factorI * dst.g + factor * (1.0 - (1.0 - dst.g) * (1.0 - u_flareColor.g) / 0.5);\n}\nif (dst.b <= 0.5) {\ncolor.b = factorI * dst.b + factor * 2.0 * dst.b * u_flareColor.b;\n} else {\ncolor.b = factorI * dst.b + factor * (1.0 - (1.0 - dst.b) * (1.0 - u_flareColor.b) / 0.5);\n}\n\ncolor.a = 1.0;\ngl_FragColor = color;\n}",
FlareAngleGaussianFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nuniform highp float u_flareAmount;\nvarying highp vec2 v_texCoord;\n\nuniform float u_scaleDiffx;\nuniform float u_scaleDiffy;\nuniform vec2 u_onePlusDxTimesCenterCoord;\nuniform lowp vec4 u_flareColor;\nuniform float u_minEXP;\nuniform float u_maxEXP;\nuniform float u_aF;\n\nvoid main(void) {\nlowp vec4 color = u_flareColor;\n\nfloat factor = 0.0;\n\nfloat theta;\nfloat a;\nfloat expV = 0.0;\n\nfloat xF = u_scaleDiffx * (v_texCoord.x - u_onePlusDxTimesCenterCoord.x);\nfloat yF = u_scaleDiffy * (v_texCoord.y - u_onePlusDxTimesCenterCoord.y);\n\nexpV   = -(xF * xF + yF * yF) * 2.0 - 5.0 * (xF + 0.2) * (yF + 0.2) * xF * xF;\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - 0.5 * u_aF) : (1.0 - 0.5 * u_aF * exp(expV));\nfactor = 1.0-factor;\n\n\ncolor.a = factor;\ngl_FragColor = color;\n}",
FlareGaussianThingFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nuniform highp float u_flareAmount;\nvarying highp vec2 v_texCoord;\n\nuniform float u_scaleDiffx;\nuniform float u_scaleDiffy;\nuniform vec2 u_onePlusDxTimesCenterCoord;\nuniform lowp vec4 u_flareColor;\nuniform float u_minEXP;\nuniform float u_maxEXP;\nuniform float u_aF;\n\nvoid main(void) {\nlowp vec4 color = u_flareColor;\n\nfloat factor = 0.0;\n\nfloat theta;\nfloat a;\nfloat expV = 0.0;\n\nfloat xF = u_scaleDiffx * (v_texCoord.x - u_onePlusDxTimesCenterCoord.x);\nfloat yF = u_scaleDiffy * (v_texCoord.y - u_onePlusDxTimesCenterCoord.y);\n\nexpV = (-(xF * xF + yF * yF) * 2.0 - 16.0 * (yF + 0.5) * (yF + 0.5) * (xF + 0.5) * (xF + 0.5));\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n\n\nfactor = 1.0-factor;\n\ncolor.a = factor;\ngl_FragColor = color;\n}",
FlareGaussianThing2FragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nuniform highp float u_flareAmount;\nvarying highp vec2 v_texCoord;\n\nuniform float u_scaleDiffx;\nuniform float u_scaleDiffy;\nuniform vec2 u_onePlusDxTimesCenterCoord;\nuniform lowp vec4 u_flareColor;\nuniform float u_minEXP;\nuniform float u_maxEXP;\nuniform float u_aF;\n\nvoid main(void) {\nlowp vec4 color = u_flareColor;\n\nfloat factor = 0.0;\n\nfloat theta;\nfloat a;\nfloat expV = 0.0;\n\nfloat xF = u_scaleDiffx * (v_texCoord.x - u_onePlusDxTimesCenterCoord.x);\nfloat yF = u_scaleDiffy * (v_texCoord.y - u_onePlusDxTimesCenterCoord.y);\n\nexpV = (-(xF * xF + yF * yF) * 2.0 - 16.0 * (yF + 1.0) * (yF + 1.0) * (xF - 0.5) * (xF - 0.5));\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n\nfactor = 1.0-factor;\ncolor.a = factor;\n\ngl_FragColor = color;\n}",
FlareBlob2FragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nuniform highp float u_flareAmount;\nvarying highp vec2 v_texCoord;\n\nuniform float u_scaleDiffx;\nuniform float u_scaleDiffy;\nuniform vec2 u_onePlusDxTimesCenterCoord;\nuniform lowp vec4 u_flareColor;\nuniform float u_minEXP;\nuniform float u_maxEXP;\nuniform float u_aF;\n\nvoid main(void) {\nlowp vec4 color = u_flareColor;\n\nfloat factor = 0.0;\n\nfloat theta;\nfloat a;\nfloat expV = 0.0;\n\nfloat xF = u_scaleDiffx * (v_texCoord.x - u_onePlusDxTimesCenterCoord.x);\nfloat yF = u_scaleDiffy * (v_texCoord.y - u_onePlusDxTimesCenterCoord.y);\n\nfloat xF2plusyF2 = yF * yF + xF * xF;\n\nexpV = (-1.0 * (xF2plusyF2) * (xF2plusyF2))*10.0;\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n\nfactor = 1.0-factor;\ncolor.a = factor;\n\ngl_FragColor = color;\n}",
FlareBlob2OverlayFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nuniform highp float u_flareAmount;\nvarying highp vec2 v_texCoord;\n\nuniform float u_scaleDiffx;\nuniform float u_scaleDiffy;\nuniform vec2 u_onePlusDxTimesCenterCoord;\nuniform lowp vec4 u_flareColor;\nuniform float u_minEXP;\nuniform float u_maxEXP;\nuniform float u_aF;\n\nvoid main(void) {\nlowp vec4 dst = texture2D(u_sampler, v_texCoord);\nlowp vec4 color = vec4(0,0,0,0);\n\nfloat factor = 0.0;\nfloat factorI = 0.0;\n\nfloat theta;\nfloat a;\nfloat expV = 0.0;\n\nfloat xF = u_scaleDiffx * (v_texCoord.x - u_onePlusDxTimesCenterCoord.x);\nfloat yF = u_scaleDiffy * (v_texCoord.y - u_onePlusDxTimesCenterCoord.y);\n\nfloat xF2plusyF2 = yF * yF + xF * xF;\n\nexpV = (-1.0 * (xF2plusyF2) * (xF2plusyF2))*10.0;\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n\nfactorI = clamp(factor, 0.0, 1.0);\nfactor = 1.0-factorI;\n\nif (dst.r <= 0.5) {\ncolor.r = factorI * dst.r + factor * 2.0 * dst.r * u_flareColor.r;\n} else {\ncolor.r = factorI * dst.r + factor * (1.0 - (1.0 - dst.r) * (1.0 - u_flareColor.r) / 0.5);\n}\nif (dst.g <= 0.5) {\ncolor.g = factorI * dst.g + factor * 2.0 * dst.g * u_flareColor.g;\n} else {\ncolor.g = factorI * dst.g + factor * (1.0 - (1.0 - dst.g) * (1.0 - u_flareColor.g) / 0.5);\n}\nif (dst.b <= 0.5) {\ncolor.b = factorI * dst.b + factor * 2.0 * dst.b * u_flareColor.b;\n} else {\ncolor.b = factorI * dst.b + factor * (1.0 - (1.0 - dst.b) * (1.0 - u_flareColor.b) / 0.5);\n}\n\ncolor.a = 1.0;\ngl_FragColor = color;\n}",
FlareCornerflaresFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nuniform highp float u_flareAmount;\nvarying highp vec2 v_texCoord;\n\nuniform float u_scaleDiffx;\nuniform float u_scaleDiffy;\nuniform vec2 u_onePlusDxTimesCenterCoord;\nuniform lowp vec4 u_flareColor;\nuniform float u_minEXP;\nuniform float u_maxEXP;\nuniform float u_aF;\n\nvoid main(void) {\nlowp vec4 color = u_flareColor;\n\nfloat factor = 0.0;\n\nfloat theta;\nfloat a;\nfloat expV = 0.0;\n\nfloat xF = u_scaleDiffx * (v_texCoord.x - u_onePlusDxTimesCenterCoord.x);\nfloat yF = u_scaleDiffy * (v_texCoord.y - u_onePlusDxTimesCenterCoord.y);\n\ntheta = xF * xF + yF * yF;\nfactor = 1.0 - u_aF *exp(-(theta / 180.0) *2.0) * (exp((-8.0) * (yF + 1.0) * (yF - 1.0) * (xF + 1.0) * (xF - 1.0)));\n\nfactor = 1.0-factor;\ncolor.a = factor;\n\ngl_FragColor = color;\n}",
FlareCornerflaresOverlayFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nuniform highp float u_flareAmount;\nvarying highp vec2 v_texCoord;\n\nuniform float u_scaleDiffx;\nuniform float u_scaleDiffy;\nuniform vec2 u_onePlusDxTimesCenterCoord;\nuniform lowp vec4 u_flareColor;\nuniform float u_minEXP;\nuniform float u_maxEXP;\nuniform float u_aF;\n\nvoid main(void) {\nlowp vec4 dst = texture2D(u_sampler, v_texCoord);\nlowp vec4 color = vec4(0,0,0,0);\n\nfloat factor = 0.0;\nfloat factorI = 0.0;\n\nfloat theta;\nfloat a;\nfloat expV = 0.0;\n\nfloat xF = u_scaleDiffx * (v_texCoord.x - u_onePlusDxTimesCenterCoord.x);\nfloat yF = u_scaleDiffy * (v_texCoord.y - u_onePlusDxTimesCenterCoord.y);\n\nfloat xF2plusyF2 = yF * yF + xF * xF;\n\ntheta = xF * xF + yF * yF;\nfactor = 1.0 - u_aF *exp(-(theta / 180.0) *2.0) * (exp((-8.0) * (yF + 1.0) * (yF - 1.0) * (xF + 1.0) * (xF - 1.0)));\n\nfactorI = clamp(factor, 0.0, 1.0);\nfactor = 1.0-factorI;\n\nif (dst.r <= 0.5) {\ncolor.r = factorI * dst.r + factor * 2.0 * dst.r * u_flareColor.r;\n} else {\ncolor.r = factorI * dst.r + factor * (1.0 - (1.0 - dst.r) * (1.0 - u_flareColor.r) / 0.5);\n}\nif (dst.g <= 0.5) {\ncolor.g = factorI * dst.g + factor * 2.0 * dst.g * u_flareColor.g;\n} else {\ncolor.g = factorI * dst.g + factor * (1.0 - (1.0 - dst.g) * (1.0 - u_flareColor.g) / 0.5);\n}\nif (dst.b <= 0.5) {\ncolor.b = factorI * dst.b + factor * 2.0 * dst.b * u_flareColor.b;\n} else {\ncolor.b = factorI * dst.b + factor * (1.0 - (1.0 - dst.b) * (1.0 - u_flareColor.b) / 0.5);\n}\n\ncolor.a = 1.0;\ngl_FragColor = color;\n}",
FlareGaussianThing3OverlayFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nuniform highp float u_flareAmount;\nvarying highp vec2 v_texCoord;\n\nuniform float u_scaleDiffx;\nuniform float u_scaleDiffy;\nuniform vec2 u_onePlusDxTimesCenterCoord;\nuniform lowp vec4 u_flareColor;\nuniform float u_minEXP;\nuniform float u_maxEXP;\nuniform float u_aF;\n\nvoid main(void) {\nlowp vec4 dst = texture2D(u_sampler, v_texCoord);\nlowp vec4 color = vec4(0,0,0,0);\n\nfloat factor = 0.0;\nfloat factorI = 0.0;\n\nfloat theta;\nfloat a;\nfloat expV = 0.0;\n\nfloat xF = u_scaleDiffx * (v_texCoord.x - u_onePlusDxTimesCenterCoord.x);\nfloat yF = u_scaleDiffy * (v_texCoord.y - u_onePlusDxTimesCenterCoord.y);\n\nfloat xF2plusyF2 = yF * yF + xF * xF;\n\ntheta  = xF * xF + yF * yF;\nexpV   = -theta * 2.0 - 1.0 * (yF + 1.7) * (yF + 1.7) * (xF - 0.6) * (xF - 0.6);\nfactor = expV < u_minEXP ? 1.0 : expV > u_maxEXP ? (1.0 - u_aF) : (1.0 - u_aF * exp(expV));\n\nfactorI = clamp(factor, 0.0, 1.0);\nfactor = 1.0-factorI;\n\nif (dst.r <= 0.5) {\ncolor.r = factorI * dst.r + factor * 2.0 * dst.r * u_flareColor.r;\n} else {\ncolor.r = factorI * dst.r + factor * (1.0 - (1.0 - dst.r) * (1.0 - u_flareColor.r) / 0.5);\n}\nif (dst.g <= 0.5) {\ncolor.g = factorI * dst.g + factor * 2.0 * dst.g * u_flareColor.g;\n} else {\ncolor.g = factorI * dst.g + factor * (1.0 - (1.0 - dst.g) * (1.0 - u_flareColor.g) / 0.5);\n}\nif (dst.b <= 0.5) {\ncolor.b = factorI * dst.b + factor * 2.0 * dst.b * u_flareColor.b;\n} else {\ncolor.b = factorI * dst.b + factor * (1.0 - (1.0 - dst.b) * (1.0 - u_flareColor.b) / 0.5);\n}\n\ncolor.a = 1.0;\ngl_FragColor = color;\n}",
RingFlareFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform float u_dr22;\nuniform float u_dr12;\nuniform float u_daa;\nuniform float u_avgD;\nuniform float u_bA;\nuniform float u_height;\nuniform float u_width;\nuniform float u_yCenter;\nuniform float u_xCenter;\nuniform vec4 u_color;\n\nvoid main(void) {\nlowp vec4 color = u_color;\n\nfloat y = u_height * v_texCoord.y ;\nfloat x = u_width * v_texCoord.x ;\nfloat yF = (y - u_yCenter) / u_avgD;\nfloat xF = (x - u_xCenter) / u_avgD;\nfloat theta = (xF * xF + yF * yF);\nfloat factor;\nif(theta > u_dr22+u_daa){\nfactor = 0.0;\n}else if(theta > u_dr22){\nfactor = (u_dr22+u_daa-theta)/u_daa;\n}else if(theta > u_dr12){\nfactor = 1.0;\n}else if(theta > u_dr12-u_daa){\nfactor = 1.0-(u_dr12-theta)/u_daa;\n}else{\nfactor = 0.0;\n}\n\nfactor = factor * factor * u_bA;\n\ncolor.a = factor;\n\ngl_FragColor = color;\n}",
GradientFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform float u_width;\nuniform float u_height;\nuniform float u_scale;\nuniform float u_xCenter;\nuniform float u_yCenter;\nuniform float u_dx_2;\nuniform float u_dy_2;\nuniform float u_denomI;\nuniform float u_alphaBlend;\nuniform int u_shapeMode;\nuniform int u_vignetteShape;\nuniform float u_angleCos;\nuniform float u_angleSin;\nuniform lowp sampler2D u_gradientMap;\n\nconst float cutoff = 1.15;\nconst float c4 = 5.0 / 3.0;\nconst float c6 = 34.0 / 45.0;\nconst float c8 = 13.0 / 63.0;\nconst float c10 = 514.0 / 14175.0;\n\nvoid main(void) {\nfloat xComp = (v_texCoord.x - u_xCenter) / u_scale;\nfloat yComp = (v_texCoord.y - u_yCenter) / u_scale;\n\nfloat factor = 0.0;\nfloat alphaBlend = u_alphaBlend;\n\nif(u_shapeMode == 0){\nfactor = u_angleCos * xComp - u_angleSin * yComp;\n}else if(u_shapeMode == 1){\nfactor = sqrt(xComp*xComp + yComp*yComp);\n}\n\nfactor = clamp(factor, 0.0, 1.0);\n\nvec4 gradientColor = texture2D(u_gradientMap, vec2(0.0, factor));\ngradientColor.a = gradientColor.a * alphaBlend;\ngl_FragColor = gradientColor;\n}",
GradientLinearVignetteFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform float u_width;\nuniform float u_height;\nuniform float u_scale;\nuniform float u_xCenter;\nuniform float u_yCenter;\nuniform float u_dx_2;\nuniform float u_dy_2;\nuniform float u_denomI;\nuniform float u_alphaBlend;\nuniform int u_shapeMode;\nuniform int u_vignetteShape;\nuniform float u_angleCos;\nuniform float u_angleSin;\nuniform lowp sampler2D u_gradientMap;\n\nconst float cutoff = 1.15;\nconst float c4 = 5.0 / 3.0;\nconst float c6 = 34.0 / 45.0;\nconst float c8 = 13.0 / 63.0;\nconst float c10 = 514.0 / 14175.0;\n\nvoid main(void) {\nfloat xComp = (v_texCoord.x - u_xCenter) / u_scale;\nfloat yComp = (v_texCoord.y - u_yCenter) / u_scale;\n\nfloat factor = 0.0;\nfloat alphaBlend = u_alphaBlend;\n\nfactor = u_angleCos * xComp - u_angleSin * yComp;\n\nfloat xDist = u_width * (v_texCoord.x - 0.5 - u_dx_2);\nfloat yDist = u_height * (v_texCoord.y - 0.5 - u_dy_2);\n\nfloat theta = u_denomI * (xDist * xDist /  (u_width * u_width) + yDist * yDist /  (u_height * u_height));\n\nif(u_vignetteShape == 1){theta *= theta;}\nelse if(u_vignetteShape == 3){theta *= theta; theta *= theta;}\nelse if(u_vignetteShape == 2){theta = pow(theta,1.5);}\n\nalphaBlend = u_alphaBlend;\n\nif (theta < 0.04) {\nalphaBlend = 0.0;\n} else if (theta <= cutoff){\nfloat t2;\nfloat t4;\nfloat t6;\nfloat t8;\nt2 = theta * theta;\nt4 = t2 * t2;\nt6 = t4 * t2;\nt8 = t6 * t2;\nalphaBlend = u_alphaBlend * (1.0 - (1.0 - 2.0 * t2 + c4 * t4 - c6 * t6 + c8 * t8 - c10 * t8 * t2));\n}\n\nfactor = clamp(factor, 0.0, 1.0);\n\nvec4 gradientColor = texture2D(u_gradientMap, vec2(0.0, factor));\ngradientColor.a = gradientColor.a * alphaBlend;\ngl_FragColor = gradientColor;\n}",
GradientOverlayFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform float u_width;\nuniform float u_height;\nuniform float u_scale;\nuniform float u_xCenter;\nuniform float u_yCenter;\nuniform float u_dx_2;\nuniform float u_dy_2;\nuniform float u_denomI;\nuniform float u_alphaBlend;\nuniform int u_shapeMode;\nuniform int u_vignetteShape;\nuniform float u_angleCos;\nuniform float u_angleSin;\nuniform lowp sampler2D u_gradientMap;\n\nconst float cutoff = 1.15;\nconst float c4 = 5.0 / 3.0;\nconst float c6 = 34.0 / 45.0;\nconst float c8 = 13.0 / 63.0;\nconst float c10 = 514.0 / 14175.0;\n\nvoid main(void) {\nlowp vec4 dst = texture2D(u_sampler, v_texCoord);\n\nfloat xComp = (v_texCoord.x - u_xCenter) / u_scale;\nfloat yComp = (v_texCoord.y - u_yCenter) / u_scale;\n\nfloat factor = 0.0;\nfloat alphaBlend = u_alphaBlend;\n\nif(u_shapeMode == 0){\nfactor = u_angleCos * xComp - u_angleSin * yComp;\n}else if(u_shapeMode == 1){\nfactor = sqrt(xComp*xComp + yComp*yComp);\n}\n\nfactor = clamp(factor, 0.0, 1.0);\n\nvec4 gradientColor = texture2D(u_gradientMap, vec2(0.0, factor));\nalphaBlend = gradientColor.a * alphaBlend;\n\nfactor = clamp(alphaBlend,0.0,1.0);\nfloat factorI = 1.0 - factor;\n\nif (dst.r <= 0.5) {\ndst.r = factorI * dst.r + factor * 2.0 * dst.r * gradientColor.r;\n} else {\ndst.r = factorI * dst.r + factor * (1.0 - (1.0 - dst.r) * (1.0 - gradientColor.r) / 0.5);\n}\nif (dst.g <= 0.5) {\ndst.g = factorI * dst.g + factor * 2.0 * dst.g * gradientColor.g;\n} else {\ndst.g = factorI * dst.g + factor * (1.0 - (1.0 - dst.g) * (1.0 - gradientColor.g) / 0.5);\n}\nif (dst.b <= 0.5) {\ndst.b = factorI * dst.b + factor * 2.0 * dst.b * gradientColor.b;\n} else {\ndst.b = factorI * dst.b + factor * (1.0 - (1.0 - dst.b) * (1.0 - gradientColor.b) / 0.5);\n}\n\ndst.a = 1.0;\n\ngl_FragColor = dst;\n}",
LineVertexShader:"attribute highp vec2 a_position;\nattribute highp vec2 a_imagePos;\nvarying highp vec2 v_imagePos;\n\nvoid main()\n{\ngl_Position = vec4(a_position.x, a_position.y, 0.0, 1.0);\nv_imagePos = a_imagePos;\n}",LineFragmentShader:"precision highp float;\n\nuniform float u_nHatx;\nuniform float u_nHaty;\nuniform float u_x1;\nuniform float u_y1;\nuniform float u_x2;\nuniform float u_y2;\nuniform float u_r;\nuniform float u_r2;\nuniform float u_dAA;\nuniform float u_bA;\nuniform float u_r2AA;\nuniform vec4 u_color;\nuniform float u_vLength2;\n\nvarying highp vec2 v_imagePos;\n\nvoid main()\n{\nfloat x = v_imagePos.x;\nfloat y = v_imagePos.y;\nfloat dMax;\nfloat dMin;\nfloat factor;\n\n//vector math stuff\nfloat proj = abs(u_nHatx * (x - u_x1) + u_nHaty * (y - u_y1));\nfloat d1   = (x - u_x1) * (x - u_x1) + (y - u_y1) * (y - u_y1);\nfloat d2   = (x - u_x2) * (x - u_x2) + (y - u_y2) * (y - u_y2);\nif (d1 < d2) {\ndMax = d2;\ndMin = d1;\n} else {\ndMax = d1;\ndMin = d2;\n}\n\nif (proj > u_r + u_dAA) {\t//Is not colinear\nfactor = 1.0;\n} else if (dMin + u_vLength2 < dMax) { //is colinear but not in between points\nif (d1 < u_r2 || d2 < u_r2) { //is within circle of one point\nfactor = 1.0 - u_bA;\n} else if (d1 < u_r2AA || d2 < u_r2AA) { //is within anti-aliasing\nfactor = 1.0 - u_bA + u_bA * (sqrt(dMin) - u_r) / u_dAA;\n} else { //outside\nfactor = 1.0;\n}\n} else { //Is colinear and in between points\nif (proj > u_r) {\t//within anti-aliasing\nfactor = 1.0 - u_bA + u_bA * (proj - u_r) / u_dAA;\n} else { //in line\nfactor = 1.0 - u_bA;\n}\n}\n\nvec4 color = u_color;\nif (factor < 0.995) {\ncolor.a = (1.0 - factor);\n}else{\ncolor.a = 0.0;\n}\ngl_FragColor = color;\n\n}",
MaskRadialFragmentShader:"precision highp float;\n\nvarying highp vec2 v_texCoord;\n\nuniform vec2 u_centerPoint;\nuniform float u_sigmaR2;\nuniform float u_width;\nuniform float u_height;\n\nvoid main(void) {\nfloat xComp = u_width * v_texCoord.x - u_centerPoint.x;\nfloat yComp = u_height * v_texCoord.y - u_centerPoint.y;\n\nfloat dr2 = xComp * xComp + yComp * yComp;\n\nfloat factor = 1.0 - exp(-1.0 * dr2 / (2.0 * u_sigmaR2));\n\ngl_FragColor = vec4(factor, factor, factor, factor); // change\n//                                                          gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n\n}",
MaskLinearFragmentShader:"\nprecision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform vec2 u_centerPoint;\nuniform float u_sigmaR2;\nuniform float u_normX;\nuniform float u_normY;\nuniform float u_width;\nuniform float u_height;\n\nvoid main(void) {\nfloat proj = abs(u_normX * (u_centerPoint.x - u_width * v_texCoord.x) + u_normY * (u_height * v_texCoord.y - u_centerPoint.y));\n\nfloat factor = 1.0 - exp(-1.0 * proj * proj / (2.0 * u_sigmaR2));\n\ngl_FragColor = vec4(factor, factor, factor, factor); // change\n//                                                          gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n\n}",
MaskDotsVertexShader:"attribute highp vec2 a_position;\nuniform float u_pointSize;\n\nvarying highp vec2 v_texCoord;\n\nvoid main()\n{\nv_texCoord = a_position;\ngl_Position = vec4(a_position.x, a_position.y, 0.0, 1.0);\ngl_PointSize = u_pointSize;\n}",MaskDotFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform mediump float u_radius;\nuniform float u_width;\nuniform float u_height;\nuniform float u_pointSize;\nuniform float u_alpha;\nuniform float u_dEdge;\n\nvoid main(void) {\nfloat xComp = gl_PointCoord.x * 2.0 - 1.0;\nfloat yComp = gl_PointCoord.y * 2.0 - 1.0;\n\nfloat dr2 = xComp * xComp + yComp * yComp;\nfloat factor = 3.0 * (1.0 - sqrt(dr2));\nfactor = clamp(factor, 0.0, 1.0);\nfactor *= u_alpha;\n\n//                                                  gl_FragColor = vec4(1,1,1,factor);\ngl_FragColor = vec4(factor,factor,factor,factor);\n//                                                  gl_FragColor = vec4(1,0,0,1);\n}",
ColorSplashAutoFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform mediump float u_radius;\nuniform float u_width;\nuniform float u_height;\nuniform float u_pointSize;\nuniform float u_alpha;\nuniform float u_dEdge;\nuniform float u_l;\nuniform float u_a;\nuniform float u_b;\nuniform float u_sigmaC;\n\nvoid main(void) {\nfloat xComp = gl_PointCoord.x * 2.0 - 1.0;\nfloat yComp = gl_PointCoord.y * 2.0 - 1.0;\n\nfloat dr2 = xComp * xComp + yComp * yComp;\n//                                                          float tmpDouble = 1.0 - (sqrt(dr2) - u_radius) / u_dEdge;\n//                                                          float factorR = tmpDouble * tmpDouble;\nfloat factorR = 1.0 - sqrt(dr2);\n\n\n// Convert to LAB\nvec4 color = texture2D(u_sampler, v_texCoord);\n\nfloat R = color.r * 255.0;\nfloat G = color.g * 255.0;\nfloat B = color.b * 255.0;\n\nfloat l1;\nfloat a1;\nfloat b1;\nfloat r;\nfloat g;\nfloat b;\nfloat x;\nfloat y;\nfloat z;\n\nif(R/255.0 <= 0.04045){r = 100.0 *R/255.0/12.92;} else{ r = 100.0*pow((R/255.0+0.055)/1.055,2.40);}\nif(G/255.0 <= 0.04045){g = 100.0 *G/255.0/12.92;} else{ g = 100.0*pow((G/255.0+0.055)/1.055,2.40);}\nif(B/255.0 <= 0.04045){b = 100.0 *B/255.0/12.92;} else{ b = 100.0*pow((B/255.0+0.055)/1.055,2.40);}\n\nx = 0.00433891*r  + 0.00376234915*g + 0.0018990604648*b;\ny = 0.002126*r    + 0.007152*g      + 0.000722*b;\nz = 0.000177255*r + 0.00109475308*g + 0.0087295537*b;\n\nif(x > 0.008856){x = pow(x,1.0/3.0);}else{x = 7.787*x+16.0/116.0;}\nif(y > 0.008856){y = pow(y,1.0/3.0);}else{y = 7.787*y+16.0/116.0;}\nif(z > 0.008856){z = pow(z,1.0/3.0);}else{z = 7.787*z+16.0/116.0;}\n\nl1 = 116.0*y-16.0;\na1 = 500.0*(x-y);\nb1 = 200.0*(y-z);\n\nl1 *= 2.55; a1 += 127.0; b1 += 127.0;\n\n// Use those values to determine color factor\nfloat dColor = (u_a - a1) * (u_a - a1) + (u_b - b1) * (u_b - b1);\nfloat factorC = exp(-1.0 * dColor/(2.0 * u_sigmaC * u_sigmaC));\n\n// Get overall color\nfloat factor = u_alpha * factorR * factorC;\ngl_FragColor = vec4(1,1,1,factor);\n}",
NoiseFragmentShader:"precision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform float u_randomSeed;\nuniform float u_intensity;\n\nfloat rand(in vec2 n)\n{\n//                                                n *= u_randomSeed;\nreturn fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453);\n}\n\nvoid main(void) {\nlowp vec4 color = texture2D(u_sampler, v_texCoord);\n\nfloat v = u_intensity * (2.0 * rand(v_texCoord) - 1.0);\n\ncolor.rgb += v;\n\ngl_FragColor = color;\n\n}",
VertexShader:"attribute vec4 a_position;\nattribute vec2 a_texCoord;\n\nvarying highp vec2 v_texCoord;\n\nvoid main(void) {\nv_texCoord = a_texCoord;\ngl_Position = a_position;\n}",TwitterGrittyDotsFragmentShader:"\nprecision highp float;\n\nvarying highp vec2 v_texCoord;\n\nuniform float u_width;\nuniform float u_height;\nuniform float u_alpha;\n\nint modi(int x,int y){\nreturn x - y * (x / y);\n}\n\nvoid main(void) {\n\n// get coords\nint xCoord = int(v_texCoord.x * u_width);\nint yCoord = int(v_texCoord.y * u_height);\n\nlowp vec4 color = vec4(0,0,0,0);\n\nif(modi(yCoord,2) == 0 && modi((xCoord + modi(yCoord,4)),4) == 0){\ncolor = vec4(1.0,1.0,1.0,u_alpha);\n}\n\n\ngl_FragColor = color;\n}",
TwitterPhotoshopSatBWShader:"\nprecision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform float u_transitionWidth;\nuniform float u_regionWidth;\nuniform float u_weights[6];\nuniform int u_saturationMode;\nuniform float u_alpha;\n\nint modi(int x,int y){\nreturn x - y * (x / y);\n}\n\nvoid main(void) {\nlowp vec4 color = texture2D(u_sampler, v_texCoord);\n\n// Can't index uniform arrays with non constant integral expressions....ugh\nfloat weights[6];\nweights[0] = u_weights[0];\nweights[1] = u_weights[1];\nweights[2] = u_weights[2];\nweights[3] = u_weights[3];\nweights[4] = u_weights[4];\nweights[5] = u_weights[5];\n\n\n// Get Color Components\n\nfloat components[6];\n\ncomponents[0] = color.r;\ncomponents[2] = color.g;\ncomponents[4] = color.b;\ncomponents[1] = (color.r + color.g) / 2.0;\ncomponents[3] = (color.g + color.b) / 2.0;\ncomponents[5] = (color.r + color.b) / 2.0;\n\n// Get H,S,V colors\nfloat r;\nfloat g;\nfloat b;\nfloat delta;\nfloat hue;\nfloat maxColor;\nfloat minColor;\n\nr = color.r;\ng = color.g;\nb = color.b;\n\nmaxColor = max(max(r,g), b);\nminColor = min(min(r,g), b);\n\ndelta = maxColor - minColor;\n\nif(maxColor == 0.0 || delta == 0.0){\nhue = 0.0;\n}else{\nif( r == maxColor ){\nhue = ( g - b ) / delta;\t\t// between yellow & magenta\n}else if( g == maxColor ){\nhue = 2.0 + ( b - r ) / delta;\t// between cyan & yellow\n}else{\nhue = 4.0 + ( r - g ) / delta;\t// between magenta & cyan\n}\n\nhue *= 60.0;\t\t\t\t// degrees\nif( hue < 0.0 ){\nhue += 360.0;\n}\n}\n\n// End hue\n\nfloat v;\nint hex;\nfloat start;\nfloat end;\nfloat w1;\nfloat w2;\nfloat w3;\nfloat weight;\n\nhex = modi(int(((hue + 30.0) / 60.0)), 6);\nv = 0.0;\n\n\nw1 = 0.0; w3 = 0.0;\nif(hex == 0){\nstart = 330.0;\nend = 30.0;\n\nif(hue > end && hue < start + u_transitionWidth){\nw1 = 0.5*(start + u_transitionWidth - hue) / u_transitionWidth;\n}else if(hue < start && hue > end - u_transitionWidth){\nw3 = 0.5*(hue - (end - u_transitionWidth)) / u_transitionWidth;\n}\n\n}else{\nstart = float(hex) * u_regionWidth - u_regionWidth/2.0;\nend   = start + u_regionWidth;\n\nif(hue < start + u_transitionWidth){\nw1 = 0.5*(start + u_transitionWidth - hue) / u_transitionWidth;\n}else if(hue > end - u_transitionWidth){\nw3 = 0.5*(hue - (end - u_transitionWidth)) / u_transitionWidth;\n}\n}\n\nw2 = 1.0 - w1 - w3;\n\nint hex5Mod = modi(hex+5,6);\nint hexMod = modi(hex,6);\nint hex1Mod = modi(hex+1,6);\n\n\nweight = \tweights[hex5Mod]*w1 +\nweights[hexMod]*w2 +\nweights[hex1Mod]*w3;\n\nv = \t\tweights[hex5Mod]*w1*components[hex5Mod] +\nweights[hexMod]*w2*components[hexMod] +\nweights[hex1Mod]*w3*components[hex1Mod];\n\nv += (1.0-weight) * min(min(r,g),b);\n\nif(u_saturationMode==0){\nweight = -1.0;\n}else{\n//Lower weight low brightness pixels\nweight *= pow(v,0.3);\n}\n\nr = (0.0-weight)*v + (weight+1.0)*r;\ng = (0.0-weight)*v + (weight+1.0)*g;\nb = (0.0-weight)*v + (weight+1.0)*b;\n\ncolor.r = mix(color.r, r, u_alpha);\ncolor.g = mix(color.g, g, u_alpha);\ncolor.b = mix(color.b, b, u_alpha);\n\ngl_FragColor = color;\n}\n",
TwitterPhotoshopSatBWOverlayShader:"\nprecision highp float;\n\nuniform lowp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform float u_transitionWidth;\nuniform float u_regionWidth;\nuniform float u_weights[6];\nuniform int u_saturationMode;\nuniform float u_alpha;\n\nint modi(int x,int y){\nreturn x - y * (x / y);\n}\n\nvoid main(void) {\nlowp vec4 color = texture2D(u_sampler, v_texCoord);\n\n// Can't index uniform arrays with non constant integral expressions....ugh\nfloat weights[6];\nweights[0] = u_weights[0];\nweights[1] = u_weights[1];\nweights[2] = u_weights[2];\nweights[3] = u_weights[3];\nweights[4] = u_weights[4];\nweights[5] = u_weights[5];\n\n\n// Get Color Components\n\nfloat components[6];\n\ncomponents[0] = color.r;\ncomponents[2] = color.g;\ncomponents[4] = color.b;\ncomponents[1] = (color.r + color.g) / 2.0;\ncomponents[3] = (color.g + color.b) / 2.0;\ncomponents[5] = (color.r + color.b) / 2.0;\n\n// Get H,S,V colors\nfloat r;\nfloat g;\nfloat b;\nfloat delta;\nfloat hue;\nfloat maxColor;\nfloat minColor;\n\nr = color.r;\ng = color.g;\nb = color.b;\n\nmaxColor = max(max(r,g), b);\nminColor = min(min(r,g), b);\n\ndelta = maxColor - minColor;\n\nif(maxColor == 0.0 || delta == 0.0){\nhue = 0.0;\n}else{\nif( r == maxColor ){\nhue = ( g - b ) / delta;\t\t// between yellow & magenta\n}else if( g == maxColor ){\nhue = 2.0 + ( b - r ) / delta;\t// between cyan & yellow\n}else{\nhue = 4.0 + ( r - g ) / delta;\t// between magenta & cyan\n}\n\nhue *= 60.0;\t\t\t\t// degrees\nif( hue < 0.0 ){\nhue += 360.0;\n}\n}\n\n// End hue\n\nfloat v;\nint hex;\nfloat start;\nfloat end;\nfloat w1;\nfloat w2;\nfloat w3;\nfloat weight;\n\nhex = modi(int(((hue + 30.0) / 60.0)), 6);\nv = 0.0;\n\n\nw1 = 0.0; w3 = 0.0;\nif(hex == 0){\nstart = 330.0;\nend = 30.0;\n\nif(hue > end && hue < start + u_transitionWidth){\nw1 = 0.5*(start + u_transitionWidth - hue) / u_transitionWidth;\n}else if(hue < start && hue > end - u_transitionWidth){\nw3 = 0.5*(hue - (end - u_transitionWidth)) / u_transitionWidth;\n}\n\n}else{\nstart = float(hex) * u_regionWidth - u_regionWidth/2.0;\nend   = start + u_regionWidth;\n\nif(hue < start + u_transitionWidth){\nw1 = 0.5*(start + u_transitionWidth - hue) / u_transitionWidth;\n}else if(hue > end - u_transitionWidth){\nw3 = 0.5*(hue - (end - u_transitionWidth)) / u_transitionWidth;\n}\n}\n\nw2 = 1.0 - w1 - w3;\n\nint hex5Mod = modi(hex+5,6);\nint hexMod = modi(hex,6);\nint hex1Mod = modi(hex+1,6);\n\n\nweight = \tweights[hex5Mod]*w1 +\nweights[hexMod]*w2 +\nweights[hex1Mod]*w3;\n\nv = \t\tweights[hex5Mod]*w1*components[hex5Mod] +\nweights[hexMod]*w2*components[hexMod] +\nweights[hex1Mod]*w3*components[hex1Mod];\n\nv += (1.0-weight) * min(min(r,g),b);\n\nif(u_saturationMode==0){\nweight = -1.0;\n}else{\n//Lower weight low brightness pixels\nweight *= pow(v,0.3);\n}\n\nr = (0.0-weight)*v + (weight+1.0)*r;\ng = (0.0-weight)*v + (weight+1.0)*g;\nb = (0.0-weight)*v + (weight+1.0)*b;\n\nfloat factor = clamp(u_alpha, 0.0, 1.0);\nfloat factorI = 1.0-factor;\n\nif (color.r <= 0.5) {\ncolor.r = factorI * color.r + factor * 2.0 * color.r * r;\n} else {\ncolor.r = factorI * color.r + factor * (1.0 - (1.0 - color.r) * (1.0 - r) / 0.5);\n}\nif (color.g <= 0.5) {\ncolor.g = factorI * color.g + factor * 2.0 * color.g * g;\n} else {\ncolor.g = factorI * color.g + factor * (1.0 - (1.0 - color.g) * (1.0 - g) / 0.5);\n}\nif (color.b <= 0.5) {\ncolor.b = factorI * color.b + factor * 2.0 * color.b * b;\n} else {\ncolor.b = factorI * color.b + factor * (1.0 - (1.0 - color.b) * (1.0 - b) / 0.5);\n}\n\n\ngl_FragColor = color;\n}\n",
TwitterClarityFragmentShader:"precision highp float;\n\nuniform highp sampler2D u_sampler;\nvarying highp vec2 v_texCoord;\n\nuniform highp sampler2D u_avgImgSampler;\nuniform highp sampler2D u_effectedAvgImgSampler;\nuniform float u_gain;\nuniform float u_sharpenAmount;\n\nconst float lowestColorVal = 1.0/255.0;\n\nvoid main(void) {\nhighp vec4 color = texture2D(u_sampler, v_texCoord);\n\n// Might want to encode these into floats;\nfloat avgGray = texture2D(u_avgImgSampler, v_texCoord).r;\nfloat avgHistGray = texture2D(u_effectedAvgImgSampler, v_texCoord).r;\n\n// Get factor and diff\nfloat factor = avgHistGray / clamp(avgGray, lowestColorVal, 1.0);\nfloat diff = avgHistGray - avgGray;\n\n// Do wonderful things to the color.\nfloat sharpenedVal = u_sharpenAmount * ((0.2 * color.r + 0.7 * color.g + 0.1 * color.b) - avgGray);\n\ncolor.rgb += sharpenedVal;\n\ncolor.r = (color.r*factor)*u_gain + (1.0-u_gain)*(color.r+diff);\ncolor.g = (color.g*factor)*u_gain + (1.0-u_gain)*(color.g+diff);\ncolor.b = (color.b*factor)*u_gain + (1.0-u_gain)*(color.b+diff);\n\ncolor.a = 1.0;\n\ngl_FragColor = color;\n}"},
j=function(b,c,a){c=a.createShader(c);a.shaderSource(c,b);a.compileShader(c);a.getShaderParameter(c,a.COMPILE_STATUS)||alert("Could not compile shaders: "+a.getShaderInfoLog(c));return c},f=function(b,c){c.useProgram(b,c);J(b,c)},n=function(b,c){c.useProgram(b,c);b.colorMatSlot=c.getUniformLocation(b,"u_colorMat");b.colorTransSlot=c.getUniformLocation(b,"u_colorTrans");J(b,c)},i=function(b,c){c.useProgram(b,c);J(b,c);b.colorMapSamplerSlot=c.getUniformLocation(b,"u_colorMapSampler");b.colorMapAmountSlot=
c.getUniformLocation(b,"u_colorMapAmount")},d=function(b,c){c.useProgram(b,c);J(b,c);b.scaleDiffxSlot=c.getUniformLocation(b,"u_scaleDiffx");b.scaleDiffySlot=c.getUniformLocation(b,"u_scaleDiffy");b.onePlusDxTimesCenterCoordSlot=c.getUniformLocation(b,"u_onePlusDxTimesCenterCoord");b.flareColorSlot=c.getUniformLocation(b,"u_flareColor");b.minEXPSlot=c.getUniformLocation(b,"u_minEXP");b.maxEXPSlot=c.getUniformLocation(b,"u_maxEXP");b.aFSlot=c.getUniformLocation(b,"u_aF");b.flareAmountSlot=c.getUniformLocation(b,
"u_flareAmount");b.flareTypeSlot=c.getUniformLocation(b,"u_flareType");b.blendModeSlot=c.getUniformLocation(b,"u_blendMode")},A=function(b,c){c.useProgram(b,c);J(b,c);b.srcSamplerSlot=c.getUniformLocation(b,"u_srcSampler");b.srcAmountSlot=c.getUniformLocation(b,"u_srcAmount");b.dstAmountSlot=c.getUniformLocation(b,"u_dstAmount")},k=function(b,c){c.useProgram(b,c);J(b,c);b.srcSamplerSlot=c.getUniformLocation(b,"u_srcSampler");b.factorSlot=c.getUniformLocation(b,"u_factor")},g=function(b,c){c.useProgram(b,
c);J(b,c);b.widthSlot=c.getUniformLocation(b,"u_width");b.heightSlot=c.getUniformLocation(b,"u_height");b.vignetteScaleSlot=c.getUniformLocation(b,"u_vignetteScale");b.vignetteColorSlot=c.getUniformLocation(b,"u_vignetteColor");b.blendModeSlot=c.getUniformLocation(b,"u_blend");b.dx_2Slot=c.getUniformLocation(b,"u_dx_2");b.dy_2Slot=c.getUniformLocation(b,"u_dy_2");b.shouldStrecthSlot=c.getUniformLocation(b,"u_shouldStretch");b.shapeModeSlot=c.getUniformLocation(b,"u_shapeMode")},l=function(b,c){c.useProgram(b,
c);J(b,c);b.dwSlot=c.getUniformLocation(b,"u_dw");b.rFactorSlot=c.getUniformLocation(b,"u_rFactor");b.widthSlot=c.getUniformLocation(b,"u_width");b.heightSlot=c.getUniformLocation(b,"u_height");b.borderStyleSlot=c.getUniformLocation(b,"u_borderStyle");b.borderColorSlot=c.getUniformLocation(b,"u_borderColor");b.linesScaleSlot=c.getUniformLocation(b,"u_linesScale");b.dotScaleSlot=c.getUniformLocation(b,"u_dotScale");b.offsetLSlot=c.getUniformLocation(b,"u_offsetL");b.offsetRSlot=c.getUniformLocation(b,
"u_offsetR");b.offsetTSlot=c.getUniformLocation(b,"u_offsetT");b.offsetBSlot=c.getUniformLocation(b,"u_offsetB");b.offsetXSlot=c.getUniformLocation(b,"u_offsetX");b.offsetYSlot=c.getUniformLocation(b,"u_offsetY")},c=function(b,c){c.useProgram(b,c);J(b,c);b.positionSlot=c.getAttribLocation(b,"a_position");b.pointSizeSlot=c.getUniformLocation(b,"u_pointSize");b.dotSamplerSlot=c.getUniformLocation(b,"u_dotSampler")},p=function(b,c){c.useProgram(b,c);J(b,c);b.positionSlot=c.getAttribLocation(b,"a_position");
b.pointSizeSlot=c.getAttribLocation(b,"a_pointSize");b.dotSamplerSlot=c.getUniformLocation(b,"u_dotSampler")},y=function(b,c){c.useProgram(b,c);J(b,c);b.dr22Slot=c.getUniformLocation(b,"u_dr22");b.dr12Slot=c.getUniformLocation(b,"u_dr12");b.daaSlot=c.getUniformLocation(b,"u_daa");b.avgDSlot=c.getUniformLocation(b,"u_avgD");b.bASlot=c.getUniformLocation(b,"u_bA");b.heightSlot=c.getUniformLocation(b,"u_height");b.widthSlot=c.getUniformLocation(b,"u_width");b.yCenterSlot=c.getUniformLocation(b,"u_yCenter");
b.xCenterSlot=c.getUniformLocation(b,"u_xCenter");b.colorSlot=c.getUniformLocation(b,"u_color")},s=function(b,c){c.useProgram(b,c);J(b,c);b.positionSlot=c.getAttribLocation(b,"a_position");b.imagePosSlot=c.getAttribLocation(b,"a_imagePos");b.nHatxSlot=c.getUniformLocation(b,"u_nHatx");b.nHatySlot=c.getUniformLocation(b,"u_nHaty");b.x1Slot=c.getUniformLocation(b,"u_x1");b.y1Slot=c.getUniformLocation(b,"u_y1");b.x2Slot=c.getUniformLocation(b,"u_x2");b.y2Slot=c.getUniformLocation(b,"u_y2");b.rSlot=c.getUniformLocation(b,
"u_r");b.r2Slot=c.getUniformLocation(b,"u_r2");b.dAASlot=c.getUniformLocation(b,"u_dAA");b.bASlot=c.getUniformLocation(b,"u_bA");b.r2AASlot=c.getUniformLocation(b,"u_r2AA");b.colorSlot=c.getUniformLocation(b,"u_color");b.vLength2Slot=c.getUniformLocation(b,"u_vLength2")},r=function(b,c){c.useProgram(b,c);J(b,c);b.randomSeedSlot=c.getUniformLocation(b,"u_randomSeed");b.intensitySlot=c.getUniformLocation(b,"u_intensity")},w=function(b,c){c.useProgram(b,c);J(b,c);b.linesSamplerSlot=c.getUniformLocation(b,
"u_linesSampler");b.heightSlot=c.getUniformLocation(b,"u_height");b.widthSlot=c.getUniformLocation(b,"u_width");b.widthTexCoordMultSlot=c.getUniformLocation(b,"u_widthTexCoordMult");b.heightTexCoordMultSlot=c.getUniformLocation(b,"u_heightTexCoordMult");b.h2Slot=c.getUniformLocation(b,"u_h2");b.w2Slot=c.getUniformLocation(b,"u_w2");b.offsetSlot=c.getUniformLocation(b,"u_offset");b.dwSlot=c.getUniformLocation(b,"u_dw");b.colorSlot=c.getUniformLocation(b,"u_color");b.scaleSlot=c.getUniformLocation(b,
"u_scale");b.floatMultSlot=c.getUniformLocation(b,"u_floatMult");b.floatTransSlot=c.getUniformLocation(b,"u_floatTrans");b.randomSeedSlot=c.getUniformLocation(b,"u_randomSeed")},u=function(b,c){c.useProgram(b,c);J(b,c);b.mapFactorSamplerSlot=c.getUniformLocation(b,"u_mapFactorSampler");b.gainSlot=c.getUniformLocation(b,"u_gain");b.rScaleSlot=c.getUniformLocation(b,"u_rScale");b.gScaleSlot=c.getUniformLocation(b,"u_gScale");b.bScaleSlot=c.getUniformLocation(b,"u_bScale");b.rMinSlot=c.getUniformLocation(b,
"u_rMin");b.gMinSlot=c.getUniformLocation(b,"u_gMin");b.bMinSlot=c.getUniformLocation(b,"u_bMin");b.floatMultSlot=c.getUniformLocation(b,"u_floatMult");b.floatTransSlot=c.getUniformLocation(b,"u_floatTrans")},z=function(b,c){c.useProgram(b,c);J(b,c)},v=function(b,c){c.useProgram(b,c);b.scaleASlot=c.getUniformLocation(b,"u_scaleA");b.scaleBSlot=c.getUniformLocation(b,"u_scaleB");J(b,c)},x=function(b,c){c.useProgram(b,c);J(b,c);b.maskSamplerSlot=c.getUniformLocation(b,"u_maskSampler")},I=function(b,
c){c.useProgram(b,c);J(b,c)},O=function(b,c){c.useProgram(b,c);J(b,c);b.colorMatSlot=c.getUniformLocation(b,"u_colorMat");b.colorTransSlot=c.getUniformLocation(b,"u_colorTrans");b.colorTransformAmountSlot=c.getUniformLocation(b,"u_colorTransformAmount");b.overlayAmountSlot=c.getUniformLocation(b,"u_overlayAmount")},E=function(b,c){c.useProgram(b,c);J(b,c);b.avgImgSamplerSlot=c.getUniformLocation(b,"u_avgImgSampler");b.effectedAvgImgSamplerSlot=c.getUniformLocation(b,"u_effectedAvgImgSampler");b.gainSlot=
c.getUniformLocation(b,"u_gain");b.sharpenAmountSlot=c.getUniformLocation(b,"u_sharpenAmount")},t=function(b,c){c.useProgram(b,c);J(b,c);b.colorMapSamplerSlot=c.getUniformLocation(b,"u_colorMapSampler");b.colorMapAmountSlot=c.getUniformLocation(b,"u_colorMapAmount");b.intensitySlot=c.getUniformLocation(b,"u_intensity")},aa=function(b,c){c.useProgram(b,c);J(b,c);b.blendColorSlot=c.getUniformLocation(b,"u_blendColor");b.blendAmountSlot=c.getUniformLocation(b,"u_blendAmount");b.blendColorAlphaSlot=c.getUniformLocation(b,
"u_blendColorAlpha")},W=function(b,c){c.useProgram(b,c);J(b,c);b.widthSlot=c.getUniformLocation(b,"u_width");b.heightSlot=c.getUniformLocation(b,"u_height");b.scaleSlot=c.getUniformLocation(b,"u_scale");b.xCenterSlot=c.getUniformLocation(b,"u_xCenter");b.yCenterSlot=c.getUniformLocation(b,"u_yCenter");b.dx_2Slot=c.getUniformLocation(b,"u_dx_2");b.dy_2Slot=c.getUniformLocation(b,"u_dy_2");b.denomISlot=c.getUniformLocation(b,"u_denomI");b.alphaBlendSlot=c.getUniformLocation(b,"u_alphaBlend");b.vignetteShapeSlot=
c.getUniformLocation(b,"u_vignetteShape");b.shapeModeSlot=c.getUniformLocation(b,"u_shapeMode");b.angleCosSlot=c.getUniformLocation(b,"u_angleCos");b.angleSinSlot=c.getUniformLocation(b,"u_angleSin");b.gradientMapSlot=c.getUniformLocation(b,"u_gradientMap")},C=function(b,c){c.useProgram(b,c);J(b,c);b.centerPointSlot=c.getUniformLocation(b,"u_centerPoint");b.sigmaR2Slot=c.getUniformLocation(b,"u_sigmaR2");b.widthSlot=c.getUniformLocation(b,"u_width");b.heightSlot=c.getUniformLocation(b,"u_height");
b.normXSlot=c.getUniformLocation(b,"u_normX");b.normYSlot=c.getUniformLocation(b,"u_normY")},L=function(b,c){c.useProgram(b,c);J(b,c);b.centerPointSlot=c.getUniformLocation(b,"u_centerPoint");b.sigmaR2Slot=c.getUniformLocation(b,"u_sigmaR2");b.widthSlot=c.getUniformLocation(b,"u_width");b.heightSlot=c.getUniformLocation(b,"u_height")},M=function(b,c){c.useProgram(b,c);J(b,c);b.maskSamplerSlot=c.getUniformLocation(b,"u_maskSampler");b.sourceSamplerSlot=c.getUniformLocation(b,"u_sourceSampler")},G=
function(b,c){c.useProgram(b,c);J(b,c);b.positionSlot=c.getAttribLocation(b,"a_position");b.pointSizeSlot=c.getUniformLocation(b,"u_pointSize");b.radiusSlot=c.getUniformLocation(b,"u_radius");b.widthSlot=c.getUniformLocation(b,"u_width");b.heightSlot=c.getUniformLocation(b,"u_height");b.alphaSlot=c.getUniformLocation(b,"u_alpha");b.dEdgeSlot=c.getUniformLocation(b,"u_dEdge")},H=function(b,c){c.useProgram(b,c);J(b,c);b.positionSlot=c.getAttribLocation(b,"a_position");b.pointSizeSlot=c.getUniformLocation(b,
"u_pointSize");b.radiusSlot=c.getUniformLocation(b,"u_radius");b.widthSlot=c.getUniformLocation(b,"u_width");b.heightSlot=c.getUniformLocation(b,"u_height");b.alphaSlot=c.getUniformLocation(b,"u_alpha");b.dEdgeSlot=c.getUniformLocation(b,"u_dEdge");b.lSlot=c.getUniformLocation(b,"u_l");b.aSlot=c.getUniformLocation(b,"u_a");b.bSlot=c.getUniformLocation(b,"u_b");b.sigmaCSlot=c.getUniformLocation(b,"u_sigmaC")},F=function(b,c){c.useProgram(b,c);J(b,c);b.texelStrideSlot=c.getUniformLocation(b,"u_texelStride")},
K=function(b,c){c.useProgram(b,c);J(b,c);b.texelStrideSlot=c.getUniformLocation(b,"u_texelStride");b.weight0Slot=c.getUniformLocation(b,"u_weight0");b.weight1Slot=c.getUniformLocation(b,"u_weight1");b.weight2Slot=c.getUniformLocation(b,"u_weight2");b.weight3Slot=c.getUniformLocation(b,"u_weight3");b.weight4Slot=c.getUniformLocation(b,"u_weight4")},J=function(b,c){b.positionSlot=c.getAttribLocation(b,"a_position");b.texCoordSlot=c.getAttribLocation(b,"a_texCoord");b.samplerSlot=c.getUniformLocation(b,
"u_sampler");b.blendModeSlot=c.getUniformLocation(b,"u_blendMode")},D=function(b,c,a,l,p,g){"undefined"===typeof b&&(b=j(a,g.VERTEX_SHADER,g),l=j(l,g.FRAGMENT_SHADER,g),a=g.createProgram(),g.attachShader(a,b),g.attachShader(a,l),g.linkProgram(a),g.getProgramParameter(a,g.LINK_STATUS)||alert("Could not create program: "+g.getProgramInfoLog(a)),g.deleteShader(b),g.deleteShader(l),(b=a)?(c(b,g),p&&g.drawArrays(GL_TRIANGLES,0,0)):(console.log("MoaLite: Error loading shader program!"),glData.state=MoaGLState.FAILED));
return b}});C.define("/src/js/filters/colorConversion.js",function(q,B){B.exports={rgb2lab:function(e,o,h,a){"object"!==typeof a&&(a=[0,0.030352698354883748,0.060705396709767497,0.09105809506465125,0.12141079341953499,0.15176349177441875,0.1821161901293025,0.21246888848418624,0.24282158683906999,0.27317428519395376,0.3035269835488375,0.3346535763899161,0.3676507324047436,0.40247170184963066,0.43914420374102936,0.4776953480693729,0.5181516702338386,0.5605391624202722,0.6048833022857054,0.6512090792594475,
0.6995410187265387,0.7499032043226175,0.8023192985384995,0.8568125618069307,0.9134058702220788,0.9721217320237849,1.0329823029626937,1.0960094006488246,1.1612245179743885,1.2286488356915872,1.2983032342173013,1.3702083047289686,1.4443843596092545,1.520851442291271,1.599629336550963,1.6807375752887384,1.7641954488384077,1.8500220128379696,1.9382360956935722,2.02885630566524,2.1219010376003555,2.2173884793387386,2.315336617811041,2.4157632448504756,2.518685962736163,2.6241221894849898,2.7320891639074896,
2.8426039504420793,2.95568344378088,3.0713443732993633,3.1896033073011534,3.3104766570885054,3.433980680868217,3.5601314875020345,3.688945040110004,3.82043715953465,3.9546235276732835,4.091519690685319,4.231141062080967,4.3735029256973466,4.518620438567554,4.666508633688009,4.8171824226889415,4.970656598412723,5.126945837404324,5.286064702318025,5.448027644244237,5.612849004960009,5.780543019106723,5.95112381629812,6.124605423161761,6.301001765316768,6.480326669290577,6.662593864377289,6.8478169844400165,
7.036009569659588,7.227185068231748,7.421356838014963,7.618538148130785,7.818742180518632,8.021982031446832,8.22827071298148,8.437621154414881,8.650046203654977,8.865558628577293,9.084171118340768,9.305896284668744,9.53074666309647,9.758734714186247,9.989872824711389,10.224173308810132,10.461648409110419,10.702310297826761,10.946171077829932,11.193242783690561,11.443537382697373,11.697066775851084,11.953842798834561,12.213877222960187,12.47718175609505,12.743768043564744,13.013647669036429,13.286832155381797,
13.563332965520566,13.843161503245183,14.126329114027165,14.412847085805778,14.702726649759498,14.995978981060857,15.292615199615017,15.59264637078274,15.89608350608804,16.2029375639111,16.513219450166762,16.826940018969076,17.14411007328226,17.464740365558505,17.78884159836291,18.116424424986022,18.4474994500441,18.782077230067788,19.120168274079138,19.46178304415758,19.806931955994887,20.155625379439705,20.507873639031693,20.863687014525574,21.223075741405523,21.586050011389926,21.95261997292692,
22.32279573168085,22.696587351009835,23.074004852434914,23.45505821610052,23.839757381227102,24.228112246555487,24.620132670783548,25.015828472995345,25.415209433082676,25.818285292159583,26.225065752969623,26.635560480286248,27.04977910130658,27.467731206038465,27.88942634768104,28.31487404299921,28.74408377269175,29.17706498175359,29.613827079832113,30.05437944157765,30.49873140698863,30.946892281750856,31.398871337571755,31.854677812509184,32.31432091129508,32.777809805654215,33.245153634617935,
33.71636150483304,34.191442490866095,34.67040563550296,35.15325995004394,35.640014414594354,36.13067797835095,36.62525955988395,37.12376804741491,37.62621229909065,38.13260114325301,38.6429433787049,39.157247774972326,39.67552307256268,40.19777798321958,40.72402119017367,41.25426134839037,41.788507084813745,42.32676699860717,42.86904966139066,43.415363617474895,43.96571738409188,44.52011945162278,45.078578283822345,45.64110231804047,46.20769996544071,46.7783796112159,47.353149614800955,47.93201831008268,
48.514994005607036,49.10208498478356,49.693299506087044,50.28864580325687,50.888132085493375,51.49176653765214,52.09955732043543,52.711512570581306,53.32764040105052,53.947948901210715,54.57244613701866,55.201140151200015,55.83403896342679,56.471150570492924,57.11248294648731,57.75804404296506,58.40784178911641,59.06188409193369,59.720178836376334,60.38273388553378,61.04955708078648,61.72065624196511,62.39603916750761,63.07571363461469,63.75968739940326,64.44796819705822,65.14056374198242,65.83748172794485,
66.5387298282272,67.24431569576875,67.95424696330939,68.66853124353135,69.38717612919899,70.11018919329732,70.83757798916868,71.56935005064807,72.30551289219693,73.04607400903537,73.79104087727309,74.54042095403875,75.29422167760778,76.05245046752924,76.8151147247507,77.58222183174236,78.35377915261935,79.12979403326302,79.9102738014409,80.69522576692516,81.48465722161012,82.27857543962836,83.07698767746547,83.879901174074,84.6873231509858,85.49926081242339,86.31572134541024,87.13671191987972,87.96223968878317,
88.79231178819663,89.62693533742664,90.46611743911495,91.30986517934193,92.15818562772947,93.01108583754237,93.8685728457888,94.73065367331999,95.59733532492861,96.46862478944651,97.34452903984125,98.22505503331172,99.11020971138298,100]);var j,e=a[e],o=a[o],h=a[h],a=0.00433891*e+0.00376234915*o+0.0018990604648*h;j=0.002126*e+0.007152*o+7.22E-4*h;e=1.77255E-4*e+0.00109475308*o+0.0087295537*h;a=0.008856<a?Math.pow(a,1/3):7.787*a+16/116;j=0.008856<j?Math.pow(j,1/3):7.787*j+16/116;e=0.008856<e?Math.pow(e,
1/3):7.787*e+16/116;return[2.55*(116*j-16),500*(a-j)+127,200*(j-e)+127]},rgb2labwithcbrtmapping:function(e,o,h,a,j){"object"!==typeof a&&(a=[0,0.030352698354883748,0.060705396709767497,0.09105809506465125,0.12141079341953499,0.15176349177441875,0.1821161901293025,0.21246888848418624,0.24282158683906999,0.27317428519395376,0.3035269835488375,0.3346535763899161,0.3676507324047436,0.40247170184963066,0.43914420374102936,0.4776953480693729,0.5181516702338386,0.5605391624202722,0.6048833022857054,0.6512090792594475,
0.6995410187265387,0.7499032043226175,0.8023192985384995,0.8568125618069307,0.9134058702220788,0.9721217320237849,1.0329823029626937,1.0960094006488246,1.1612245179743885,1.2286488356915872,1.2983032342173013,1.3702083047289686,1.4443843596092545,1.520851442291271,1.599629336550963,1.6807375752887384,1.7641954488384077,1.8500220128379696,1.9382360956935722,2.02885630566524,2.1219010376003555,2.2173884793387386,2.315336617811041,2.4157632448504756,2.518685962736163,2.6241221894849898,2.7320891639074896,
2.8426039504420793,2.95568344378088,3.0713443732993633,3.1896033073011534,3.3104766570885054,3.433980680868217,3.5601314875020345,3.688945040110004,3.82043715953465,3.9546235276732835,4.091519690685319,4.231141062080967,4.3735029256973466,4.518620438567554,4.666508633688009,4.8171824226889415,4.970656598412723,5.126945837404324,5.286064702318025,5.448027644244237,5.612849004960009,5.780543019106723,5.95112381629812,6.124605423161761,6.301001765316768,6.480326669290577,6.662593864377289,6.8478169844400165,
7.036009569659588,7.227185068231748,7.421356838014963,7.618538148130785,7.818742180518632,8.021982031446832,8.22827071298148,8.437621154414881,8.650046203654977,8.865558628577293,9.084171118340768,9.305896284668744,9.53074666309647,9.758734714186247,9.989872824711389,10.224173308810132,10.461648409110419,10.702310297826761,10.946171077829932,11.193242783690561,11.443537382697373,11.697066775851084,11.953842798834561,12.213877222960187,12.47718175609505,12.743768043564744,13.013647669036429,13.286832155381797,
13.563332965520566,13.843161503245183,14.126329114027165,14.412847085805778,14.702726649759498,14.995978981060857,15.292615199615017,15.59264637078274,15.89608350608804,16.2029375639111,16.513219450166762,16.826940018969076,17.14411007328226,17.464740365558505,17.78884159836291,18.116424424986022,18.4474994500441,18.782077230067788,19.120168274079138,19.46178304415758,19.806931955994887,20.155625379439705,20.507873639031693,20.863687014525574,21.223075741405523,21.586050011389926,21.95261997292692,
22.32279573168085,22.696587351009835,23.074004852434914,23.45505821610052,23.839757381227102,24.228112246555487,24.620132670783548,25.015828472995345,25.415209433082676,25.818285292159583,26.225065752969623,26.635560480286248,27.04977910130658,27.467731206038465,27.88942634768104,28.31487404299921,28.74408377269175,29.17706498175359,29.613827079832113,30.05437944157765,30.49873140698863,30.946892281750856,31.398871337571755,31.854677812509184,32.31432091129508,32.777809805654215,33.245153634617935,
33.71636150483304,34.191442490866095,34.67040563550296,35.15325995004394,35.640014414594354,36.13067797835095,36.62525955988395,37.12376804741491,37.62621229909065,38.13260114325301,38.6429433787049,39.157247774972326,39.67552307256268,40.19777798321958,40.72402119017367,41.25426134839037,41.788507084813745,42.32676699860717,42.86904966139066,43.415363617474895,43.96571738409188,44.52011945162278,45.078578283822345,45.64110231804047,46.20769996544071,46.7783796112159,47.353149614800955,47.93201831008268,
48.514994005607036,49.10208498478356,49.693299506087044,50.28864580325687,50.888132085493375,51.49176653765214,52.09955732043543,52.711512570581306,53.32764040105052,53.947948901210715,54.57244613701866,55.201140151200015,55.83403896342679,56.471150570492924,57.11248294648731,57.75804404296506,58.40784178911641,59.06188409193369,59.720178836376334,60.38273388553378,61.04955708078648,61.72065624196511,62.39603916750761,63.07571363461469,63.75968739940326,64.44796819705822,65.14056374198242,65.83748172794485,
66.5387298282272,67.24431569576875,67.95424696330939,68.66853124353135,69.38717612919899,70.11018919329732,70.83757798916868,71.56935005064807,72.30551289219693,73.04607400903537,73.79104087727309,74.54042095403875,75.29422167760778,76.05245046752924,76.8151147247507,77.58222183174236,78.35377915261935,79.12979403326302,79.9102738014409,80.69522576692516,81.48465722161012,82.27857543962836,83.07698767746547,83.879901174074,84.6873231509858,85.49926081242339,86.31572134541024,87.13671191987972,87.96223968878317,
88.79231178819663,89.62693533742664,90.46611743911495,91.30986517934193,92.15818562772947,93.01108583754237,93.8685728457888,94.73065367331999,95.59733532492861,96.46862478944651,97.34452903984125,98.22505503331172,99.11020971138298,100]);"object"!==typeof j&&(j=[0,0.09924488254695861,0.12504071661525748,0.14313588920856027,0.1575414309575025,0.16970636198605316,0.18033991980928551,0.18984863055466036,0.19848976509391722,0.20643767470661487,0.21381661776730748,0.2207186428753261,0.22721406110407222,
0.2333579349114362,0.2391942859295316,0.24475892765281868,0.2500814332305149,0.25518653946003345,0.2600951718542145,0.26482520821552014,0.26939205754235684,0.27380910584090884,0.27808806426285243,0.2822392443945425,0.28627177841712054,0.2901937969941595,0.2940125743549161,0.2977346476408758,0.3013659158571899,0.30491172251223664,0.3083769250994826,0.311765953881872,0.315082861915005,0.31833136784577337,0.32151489271552486,0.3246365917579799,0.3276993819951494,0.33070596628701154,0.3336588543735265,
0.336560381353843,0.3394127239721063,0.34221791501818183,0.3449778561018543,0.34769432901832303,0.350369005889286,0.3530034582361798,0.3555991651191077,0.35815752045576577,0.360679839618571,0.3631673653946448,0.36562127338186107,0.3680426768844678,0.37043263136354043,0.37279213849048415,0.3751221498457724,0.3774235702999315,0.3796972611093207,0.38194404275540383,0.38416469755287136,0.3863599720490726,0.38853057923469275,0.3906772005834086,0.39280048793632477,0.3949010652453065,0.39697953018783444,
0.3990364556647021,0.40107239119071786,0.4030878641875543,0.40508338118698156,0.40705942895191655,0.4090164755220073,0.41095497118983254,0.41287534941322973,0.41477802766875577,0.41666340825083015,0.41853187902070177,0.4203838141090141,0.4222195745754141,0.42403950902835275,0.4258439542079576,0.42763323553461496,0.4294076676256808,0.4311675547825421,0.43291319145006824,0.43464486265033075,0.43636284439232104,0.43806740405925904,0.439758800774965,0.44143728575065216,0.4431031026133969,0.44475648771744863,
0.4463976704394558,0.44802687345860653,0.4496443130226092,0.45125019920037296,0.4528447361221874,0.45442812220814444,0.4560005503854936,0.45756220829557587,0.4591132784909362,0.46065393862317483,0.46218436162206117,0.4637047158663982,0.4652151653470947,0.46671586982287233,0.46820698496900803,0.4696886625194857,0.4711610504029096,0.47262429287250746,0.4740785306305335,0.4755239009473612,0.4769605377755387,0.47838857185906314,0.4798081308381152,0.48121933934948075,0.48262231912287346,0.4840171890733601,
0.4854040653900775,0.4867830616214213,0.4881542887568748,0.4895178553056373,0.4908738673722041,0.4922224287290381,0.4935636408864699,0.4948976031599528,0.496224412734793,0.49754416472847035,0.4988569522506557,0.5001628664610298,0.501461996624999,0.5027544301674005,0.5040402527242843,0.5053195481928565,0.5065923987796591,0.5078588850470654,0.5091190859581595,0.5103730789200669,0.5116209398258046,0.5128627430947063,0.514098561711485,0.5153284672639881,0.516552529979695,0.5177708187610112,0.5189834012194042,
0.520190343708429,0.5213917113556842,0.5225875680937435,0.5237779766901,0.524962998776162,0.5261426948753368,0.5273171244302366,0.5284863458290399,0.5296504164310403,0.530809392591412,0.5319633296852224,0.5331122821307175,0.5342563034119088,0.5353954461004848,0.5365297618770742,0.5376593015518806,0.5387841150847137,0.5399042516044376,0.5410197594278565,0.5421306860780567,0.5432370783022257,0.5443389820889641,0.5454364426851102,0.5465295046120907,0.5476182116818177,0.5487026070121426,0.5497827330418863,
0.5508586315454556,0.5519303436470633,0.5529979098345615,0.5540613699729042,0.555120763317248,0.5561761285257049,0.5572275036717572,0.5582749262563468,0.5593184332196459,0.5603580609525242,0.5613938453077163,0.5624258216107048,0.5634540246703222,0.564478488789085,0.5654992477732644,0.5665163349427048,0.5675297831403955,0.5685396247418045,0.5695458916639811,0.5705486153744331,0.5715478268997879,0.5725435568342411,0.5735358353478003,0.5745246921943311,0.5755101567194079,0.5764922578679786,0.577471024191847,
0.5784464838569776,0.5794186646506286,0.5803875939883189,0.5813532989206311,0.582315806139859,0.5832751419864992,0.5842313324555962,0.5851844032029409,0.5861343795511286,0.5870812864954806,0.5880251487098322,0.5889659905521902,0.5899038360702656,0.5908387090068827,0.5917706328052692,0.5926996306142294,0.5936257252932051,0.5945489394172259,0.5954692952817516,0.5963868149074115,0.5973015200446405,0.5982134321782173,0.599122572531705,0.6000289620717986,0.60093262151258,0.6018335713196846,0.6027318317143798,
0.6036274226775593,0.6045203639536548,0.6054106750544663,0.606298375262915,0.6071834836367179,0.6080660190119893,0.6089460000067677,0.6098234450244732,0.6106983722572941,0.6115707996895061,0.6124407451007265,0.613308226069102,0.6141732599744346,0.6150358640012467,0.6158960551417848,0.6167538501989651,0.6176092657892629,0.6184623183455441,0.6193130241198446,0.620161399186094,0.6210074594427897,0.6218512206156173,0.6226926982600246,0.623531907763744,0.6243688643492697,0.6252035830762873,0.6260360788440587,
0.626866366393762,0.6276944603107898,0.6285203750270028,0.6293441248229434,0.6301657238300099,0.6309851860325884,0.6318025252701481,0.6326177552392989,0.63343088949581,0.6342419414565944,0.6350509244016576,0.6358578514760097,0.6366627356915467,0.6374655899288959,0.6382664269392303,0.6390652593460512,0.6398620996469384,0.6406569602152721,0.6414498533019224,0.6422407910369122,0.6430297854310497,0.6438168483775332,0.6446019916535295,0.6453852269217243,0.6461665657318468,0.646946019522169,0.6477235996209785,
0.6484993172480279,0.6492731835159596,0.6500452094317067,0.6508154058978702,0.651583783714075,0.6523503535783013,0.6531151260881964,0.653878111742364,0.6546393209416315,0.6553987639902987,0.6561564510973654,0.6569123923777382,0.6576665978534199,0.6584190774546778,0.6591698410211952,0.6599188983032032,0.660666258962595,0.6614119325740231,0.6621559286259783,0.6628982565218523,0.6636389255809841,0.6643779450396892,0.6651153240522729,0.665851071692029,0.6665851969522216,0.667317708747053,0.6680486159126159,
0.6687779272078317,0.6695056513153739,0.6702317968425779,0.6709563723223373,0.6716793862139855,0.6724008469041655,0.673120762707686,0.6738391418683641,0.6745559925598569,0.675271322886479,0.6759851408840097,0.6766974545204868,0.6774082716969896,0.67811760024841,0.6788254479442125,0.6795318224891835,0.6802367315241687,0.6809401826268009,0.6816421833122166,0.6823427410337628,0.6830418631836931,0.6837395570938545,0.6844358300363635,0.6851306892242741,0.6858241418122343,0.6865161948971349,0.6872068555187488,
0.687896130660361,0.6885840272493903,0.689270552158001,0.6899557122037085,0.6906395141499742,0.6913219647067927,0.6920030705312724,0.6926828382282061,0.6933612743506347,0.6940383854004035,0.6947141778287103,0.6953886580366461,0.6960618323757292,0.6967337071484312,0.6974042886086962,0.6980735829624533,0.6987415963681218,0.6994083349371105,0.7000738047343085,0.7007380117785719,0.7014009620432023,0.7020626614564196,0.7027231159018287,0.7033823312188793,0.7040403132033212,0.7046970676076518,0.7053526001415594,
0.7060069164723595,0.7066600222254262,0.7073119229846179,0.7079626242926972,0.7086121316517457,0.7092604505235738,0.7099075863301242,0.7105535444538713,0.7111983302382154,0.7118419489878712,0.7124844059692523,0.71312570641085,0.7137658555036082,0.7144048584012926,0.7150427202208567,0.7156794460428013,0.7163150409115315,0.7169495098357082,0.7175828577885948,0.7182150897084011,0.718846210498622,0.7194762250283715,0.720105138132714,0.7207329546129908,0.721359679237142,0.721985316740026,0.7226098718237337,
0.7232333491578999,0.7238557533800104,0.7244770890957053,0.7250973608790793,0.7257165732729777,0.7263347307892896,0.7269518379092367,0.7275678990836596,0.7281829187333003,0.728796901249081,0.7294098509923802,0.7300217722953055,0.7306326694609626,0.7312425467637221,0.7318514084494824,0.7324592587359297,0.7330661018127955,0.7336719418421106,0.7342767829584559,0.7348806292692114,0.735483484854801,0.7360853537689355,0.7366862400388527,0.737286147665554,0.7378850806240391,0.7384830428635379,0.7390800383077395,
0.7396760708550189,0.7402711443786605,0.7408652627270808,0.741458429724046,0.7420506491688895,0.7426419248367259,0.7432322604786622,0.7438216598220084,0.7444101265704832,0.7449976644044198,0.7455842769809682,0.7461699679342954,0.7467547408757834,0.7473385993942256,0.7479215470560205,0.748503587405363,0.7490847239644346,0.7496649602335902,0.7502442996915447,0.7508227457955557,0.7514003019816053,0.7519769716645798,0.7525527582384471,0.7531276650764331,0.753701695531195,0.7542748529349934,0.754847140599863,
0.7554185618177804,0.7559891198608314,0.7565588179813753,0.7571276594122083,0.757695647366725,0.7582627850390781,0.7588290756043364,0.7593945222186415,0.7599591280193618,0.7605228961252469,0.7610858296365782,0.7616479316353195,0.7622092051852651,0.7627696533321872,0.7633292791039805,0.7638880855108077,0.7644460755452401,0.7650032521824002,0.7655596183801003,0.7661151770789814,0.7666699312026493,0.7672238836578102,0.7677770373344053,0.7683293951057427,0.7688809598286291,0.7694317343435,0.7699817214745477,
0.7705309240298498,0.7710793448014944,0.7716269865657057,0.7721738520829675,0.772719944098145,0.7732652653406075,0.7738098185243465,0.7743536063480964,0.7748966314954512,0.775438896634981,0.7759804044203481,0.7765211574904205,0.7770611584693855,0.7776004099668616,0.7781389145780099,0.778676674883643,0.7792136934503352,0.7797499728305293,0.7802855155626435,0.7808203241711775,0.7813544011668172,0.7818877490465378,0.7824203702937074,0.782952267378188,0.783483442756437,0.7840138988716062,0.7845436381536416,
0.7850726630193806,0.7856009758726495,0.7861285791043594,0.7866554750926015,0.7871816662027413,0.7877071547875124,0.7882319431871087,0.7887560337292759,0.7892794287294033,0.7898021304906129,0.7903241413038489,0.7908454634479661,0.7913660991898175,0.7918860507843407,0.7924053204746444,0.7929239104920931,0.7934418230563915,0.7939590603756689,0.7944756246465603,0.7949915180542906,0.7955067427727543,0.7960213009645972,0.7965351947812954,0.7970484263632353,0.7975609978397913,0.7980729113294042,0.7985841689396577,
0.7990947727673552,0.799604724898595,0.8001140274088461,0.8006226823630215,0.8011306918155525,0.8016380578104618,0.8021447823814357,0.8026508675518954,0.8031563153350691,0.8036611277340616,0.8041653067419244,0.8046688543417252,0.8051717725066162,0.8056740631999023,0.8061757283751086,0.8066767699760472,0.8071771899368835,0.8076769901822017,0.8081761726270704,0.8086747391771066,0.8091726917285403,0.8096700321682774,0.8101667623739631,0.810662884214044,0.81115839954783,0.8116533102255556,0.8121476180884412,
0.8126413249687521,0.8131344326898597,0.8136269430663002,0.8141188579038331,0.8146101789994995,0.8151009081416802,0.8155910471101533,0.8160805976761496,0.8165695616024108,0.8170579406432438,0.8175457365445769,0.8180329510440145,0.8185195858708919,0.8190056427463286,0.8194911233832824,0.8199760294866028,0.8204603627530825,0.8209441248715112,0.8214273175227265,0.8219099423796651,0.8223920011074144,0.8228734953632629,0.8233544267967502,0.8238347970497164,0.8243146077563521,0.8247938605432471,0.8252725570294385,
0.8257506988264595,0.8262282875383863,0.8267053247618866,0.8271818120862655,0.8276577510935128,0.8281331433583488,0.82860799044827,0.8290822939235957,0.8295560553375114,0.8300292762361152,0.830501958158461,0.830974102636603,0.8314457111956398,0.831916785353757,0.8323873266222709,0.8328573365056704,0.8333268165016603,0.8337957681012022,0.8342641927885572,0.8347320920413266,0.8351994673304931,0.8356663201204616,0.8361326518690991,0.8365984640277758,0.8370637580414035,0.8375285353484762,0.8379927973811084,
0.8384565455650747,0.8389197813198476,0.8393825060586361,0.8398447211884238,0.8403064281100062,0.8407676282180282,0.8412283229010212,0.8416885135414399,0.8421482015156988,0.8426073881942083,0.843066074941411,0.8435242631158167,0.8439819540700386,0.8444391491508282,0.8448958496991095,0.8453520570500146,0.8458077725329176,0.8462629974714685,0.8467177331836275,0.8471719809816981,0.8476257421723606,0.8480790180567055,0.8485318099302657,0.8489841190830497,0.8494359467995736,0.8498872943588931,0.8503381630346358,
0.8507885540950325,0.8512384688029485,0.8516879084159152,0.8521368741861606,0.85258536736064,0.8530333891810667,0.8534809408839426,0.8539280237005873,0.8543746388571686,0.854820787574732,0.8552664710692298,0.8557116905515508,0.8561564472275487,0.856600742298071,0.8570445769589876,0.8574879524012193,0.8579308698107657,0.8583733303687329,0.8588153352513616,0.8592568856300545,0.859697982671404,0.8601386275372181,0.8605788213845489,0.8610185653657182,0.8614578606283446,0.8618967083153697,0.8623351095650842,
0.8627730655111538,0.8632105772826455,0.8636476460040526,0.8640842727953206,0.8645204587718719,0.8649562050446316,0.8653915127200517,0.8658263829001364,0.8662608166824664,0.866694815160223,0.8671283794222129,0.8675615105528918,0.8679942096323882,0.8684264777365276,0.8688583159368556,0.8692897253006614,0.8697207068910011,0.8701512617667205,0.8705813909824783,0.8710110955887687,0.871440376631944,0.8718692351542368,0.8722976721937826,0.872725688784642,0.8731532859568221,0.8735804647362989,0.8740072261450385,
0.8744335712010189,0.8748595009182516,0.8752850163068022,0.8757101183728118,0.876134808118518,0.8765590865422758,0.8769829546385779,0.8774064133980755,0.8778294638075984,0.8782521068501757,0.8786743435050556,0.879096174747725,0.87951760154993,0.8799386248796953,0.8803592457013438,0.8807794649755161,0.8811992836591893,0.8816187027056972,0.8820377230647484,0.8824563456824455,0.8828745715013043,0.8832924014602719,0.8837098364947455,0.884126877536591,0.8845435255141612,0.8849597813523133,0.8853756459724286,
0.8857911202924285,0.8862062052267938,0.8866209016865818,0.8870352105794438,0.8874491328096428,0.8878626692780711,0.888275820882267,0.8886885885164322,0.8891009730714491,0.8895129754348972,0.8899245964910704,0.8903358371209934,0.8907466982024383,0.8911571806099414,0.8915672852148191,0.8919770128851846,0.8923863644859639,0.8927953408789115,0.8932039429226274,0.8936121714725718,0.8940200273810814,0.8944275114973853,0.8948346246676199,0.895241367734845,0.8956477415390587,0.8960537469172131,0.896459384703229,
0.8968646557280114,0.8972695608194643,0.8976741008025054,0.8980782764990811,0.8984820887281812,0.8988855383058536,0.8992886260452183,0.8996913527564827,0.9000937192469548,0.9004957263210588,0.9008973747803478,0.9012986654235191,0.9016995990464275,0.9021001764420992,0.9025003984007458,0.9029002657097783,0.9032997791538201,0.9036989395147207,0.9040977475715697,0.9044962041007096,0.9048943098757493,0.9052920656675773,0.9056894722443748,0.906086530371629,0.9064832408121458,0.9068796043260627,0.9072756216708617,
0.9076712936013822,0.9080666208698333,0.9084616042258066,0.9088562444162888,0.909250542185674,0.909644498275776,0.9100381134258407,0.9104313883725582,0.9108243238500753,0.9112169205900067,0.911609179321448,0.9120011007709872,0.912392685662716,0.9127839347182426,0.9131748486567027,0.9135654281947713,0.9139556740466742,0.9143455869241996,0.9147351675367098,0.9151244165911517,0.9155133347920691,0.9159019228416131,0.9162901814395539,0.9166781112832916,0.9170657130678669,0.9174529874859728,0.9178399352279649,
0.9182265569818724,0.9186128534334087,0.9189988252659826,0.9193844731607087,0.9197697977964173,0.9201547998496661,0.9205394799947498,0.9209238389037109,0.9213078772463497,0.9216915956902347,0.9220749949007134,0.9224580755409214,0.9228408382717931,0.9232232837520717,0.9236054126383193,0.9239872255849265,0.9243687232441223,0.9247499062659842,0.9251307752984477,0.925511330987316,0.9258915739762699,0.9262715049068767,0.9266511244186009,0.9270304331488122,0.9274094317327963,0.9277881208037635,0.9281665009928579,
0.9285445729291671,0.9289223372397313,0.9292997945495522,0.9296769454816025,0.9300537906568345,0.9304303306941893,0.9308065662106061,0.9311824978210302,0.931558126138423,0.9319334517737698,0.9323084753360892,0.9326831974324412,0.9330576186679365,0.9334317396457447,0.9338055609671028,0.934179083231324,0.934552307035806,0.9349252329760395,0.935297861645616,0.935670193636237,0.936042229537722,0.936413969938016,0.9367854154231987,0.937156566577492,0.9375274239832683,0.9378979882210586,0.9382682598695602,
0.938638239505645,0.9390079277043673,0.9393773250389714,0.9397464320808999,0.9401152493998012,0.9404837775635372,0.9408520171381909,0.9412199686880747,0.9415876327757369,0.9419550099619702,0.9423221008058192,0.9426889058645871,0.943055425693844,0.9434216608474337,0.9437876118774816,0.9441532793344015,0.9445186637669033,0.944883765722,0.9452485857450149,0.9456131243795891,0.945977382167688,0.9463413596496092,0.9467050573639889,0.9470684758478091,0.9474316156364045,0.9477944772634701,0.9481570612610669,
0.9485193681596299,0.948881398487974,0.9492431527733017,0.9496046315412092,0.9499658353156932,0.950326764619158,0.9506874199724215,0.9510478018947224,0.9514079109037265,0.9517677475155331,0.9521273122446822,0.9524866056041599,0.9528456281054056,0.9532043802583186,0.9535628625712634,0.9539210755510774,0.9542790197030759,0.9546366955310597,0.9549941035373201,0.9553512442226458,0.955708118086329,0.9560647256261716,0.956421067338491,0.9567771437181263,0.9571329552584446,0.9574885024513466,0.9578437857872732,
0.9581988057552107,0.9585535628426971,0.9589080575358283,0.9592622903192632,0.9596162616762304,0.9599699720885332,0.9603234220365561,0.9606766119992698,0.9610295424542377,0.9613822138776207,0.9617346267441839,0.9620867815273011,0.9624386786989614,0.962790318729774,0.9631417020889744,0.9634928292444291,0.963843700662642,0.9641943168087592,0.9645446781465745,0.9648947851385351,0.9652446382457469,0.9655942379279795,0.9659435846436719,0.9662926788499377,0.9666415210025703,0.9669901115560479,0.9673384509635392,
0.9676865396769084,0.9680343781467202,0.9683819668222451,0.9687293061514642,0.969076396581075,0.9694232385564956,0.9697698325218702,0.970116178920074,0.9704622781927181,0.970808130780155,0.9711537371214826,0.9714990976545498,0.9718442128159609,0.9721890830410812,0.972533708764041,0.9728780904177409,0.9732222284338563,0.9735661232428426,0.9739097752739395,0.9742531849551758,0.9745963527133741,0.9749392789741559,0.9752819641619453,0.9756244086999749,0.9759666130102891,0.9763085775137494,0.9766503026300392,
0.9769917887776673,0.9773330363739738,0.9776740458351333,0.9780148175761602,0.9783553520109127,0.9786956495520978,0.9790357106112746,0.97937553559886,0.9797151249241322,0.9800544789952351,0.9803935982191831,0.9807324830018651,0.9810711337480483,0.9814095508613835,0.9817477347444082,0.9820856857985518,0.9824234044241392,0.9827608910203951,0.9830981459854481,0.9834351697163352,0.9837719626090052,0.9841085250583236,0.9844448574580762,0.984780960200973,0.985116833678653,0.9854524782816871,0.9857878943995831,
0.9861230824207893,0.9864580427326981,0.9867927757216505,0.9871272817729397,0.9874615612708154,0.987795614598487,0.9881294421381279,0.9884630442708796,0.9887964213768549,0.989129573835142,0.9894625020238087,0.9897952063199055,0.9901276870994697,0.9904599447375294,0.9907919796081064,0.9911237920842207,0.9914553825378941,0.9917867513401535,0.9921178988610346,0.992448825469586,0.9927795315338723,0.9931100174209779,0.9934402834970106,0.9937703301271053,0.9941001576754271,0.9944297665051756,0.9947591569785874,
0.9950883294569406,0.9954172843005578,0.9957460218688093,0.9960745425201175,0.996402846611959,0.9967309345008691,0.997058806542445,0.9973864630913489,0.9977139045013114,0.9980411311251348,0.9983681433146974,0.998694941420955,0.9990215257939463,0.9993478967827943,0.999674054735711,1]);var f,n=j.length,e=a[e],o=a[o],h=a[h],a=0.00433891*e+0.00376234915*o+0.0018990604648*h;f=0.002126*e+0.007152*o+7.22E-4*h;e=1.77255E-4*e+0.00109475308*o+0.0087295537*h;a=0.008856<a?1<=a?j[n-1]:j[a*n|0]:7.787*a+16/116;
f=0.008856<f?1<=f?j[n-1]:j[f*n|0]:7.787*f+16/116;e=0.008856<e?1<=e?j[n-1]:j[e*n|0]:7.787*e+16/116;return[2.55*(116*f-16),500*(a-f)+127,200*(f-e)+127]},lab2rgb:function(e){var o=(e[0]/2.55+16)/116,h=(e[1]-127)/500+o,e=o-(e[2]-127)/200,a=o*o*o,j=h*h*h,f=e*e*e,h=0.95047*(0.008856<j?j:(h-16/116)/7.787),o=1*(0.008856<a?a:(o-16/116)/7.787),e=1.08883*(0.008856<f?f:(e-16/116)/7.787),a=3.2406*h+-1.5372*o+-0.4986*e,j=-0.9689*h+1.8758*o+0.0415*e,o=0.0557*h+-0.204*o+1.057*e,a=0.0031308<a?1.055*Math.pow(a,0.41666666666667)-
0.055:12.92*a,j=0.0031308<j?1.055*Math.pow(j,0.41666666666667)-0.055:12.92*j,o=0.0031308<o?1.055*Math.pow(o,0.41666666666667)-0.055:12.92*o;return[255*a+0.5|0,255*j+0.5|0,255*o+0.5|0]},lab2rgbwithmapping:function(e,o){"object"!==typeof o&&(o=[0,0.01262952101661779,0.02525904203323558,0.03788856304985337,0.049711876377871826,0.05991457469741709,0.06898447286600867,0.0772092360066284,0.08477358579410943,0.091804259875822,0.09839255413111209,0.10460674144643575,0.11049941567981197,0.116112082049842,
0.12147815731101994,0.12662500399558943,0.13157535287823224,0.1363483240840589,0.1409601768441825,0.14542487095720244,0.14975449458714327,0.15395959525747982,0.1580494394769152,0.16203221890462635,0.16591521589126665,0.16970493774704687,0.17340722665014255,0.1770273503750349,0.18057007776923878,0.18403974199157158,0.18744029384710506,0.19077534704588353,0.1940482168277028,0.19726195310091915,0.20041936901604623,0.20352306571797985,0.2065754538818233,0.20957877252746188,0.21253510552056065,0.21544639609752403,
0.21831445969536206,0.2211409953214818,0.2239275956609244,0.22667575608780954,0.22938688272237368,0.2320622996539648,0.2347032554328511,0.2373109289190679,0.2398864345642407,0.24243082719196402,0.24494510633355537,0.24743022016856214,0.2498870691130589,0.25231650909335385,0.25471935453807176,0.25709638111758565,0.2594483282563151,0.2617759014404253,0.26407977434087276,0.2663605907694862,0.26861896648381073,0.27085549085472227,0.2730707284093175,0.2752652202602596,0.2774394854315987,0.27959402209005907,
0.2817293086898797,0.28384580503848866,0.2859439532895821,0.2880241788695442,0.29008689134257926,0.2921324852194264,0.2941613407140744,0.296173824452494,0.29817029013704466,0.30015107916988515,0.30211652123843086,0.3040669348656343,0.3060026279276311,0.30792389814107823,0.3098310335223196,0.3117243128203384,0.3136040059252957,0.3154703742543138,0.3173236711160275,0.3191641420553126,0.32099202517948666,0.3228075514671829,0.32461094506100485,0.32640242354498716,0.328182198207814,0.3299504742926743,
0.331707451234572,0.33345332288585067,0.3351882777306368,0.33691249908885884,0.33862616531045336,0.3403294499603252,0.3420225219945948,0.3437055459286266,0.34537868199729943,0.34704208630795363,0.3486959109864158,0.3503403043164812,0.3519754108732058,0.35360137165034033,0.3552183241822174,0.3568264026603817,0.35842573804523775,0.3600164581729729,0.3615986878579945,0.36317254899111157,0.36473816063367165,0.3662956391078557,0.36784509808331944,0.3693866486603606,0.37092039944977906,0.37244645664958986,
0.3739649241187381,0.37547590344795784,0.37697949402790815,0.3784757931147127,0.3799648958930234,0.3814468955367197,0.3829218832673514,0.3843899484104266,0.38585117844964034,0.3873056590791346,0.38875347425387746,0.39019470623824154,0.3916294356528607,0.39305774151983813,0.3944797013063766,0.3958953909668962,0.3973048849837052,0.398708256406281,0.4001055768892218,0.40149691672892146,0.40288234489901914,0.4042619290846755,0.40563573571572004,0.40700382999871526,0.4083662759479818,0.409723136415623,
0.4110744731205898,0.41242034667682187,0.4137608166205015,0.41509594143645334,0.41642577858372254,0.41775038452036234,0.41906981472746097,0.420384123732435,0.4216933651316181,0.4229975916121692,0.42429685497332564,0.4255912061470252,0.4268806952179194,0.4281653714427998,0.42944528326945836,0.43072047835500143,0.4319910035836372,0.43325690508395387,0.43451822824570774,0.43577501773613614,0.43702731751581336,0.43827517085406376,0.4395186203439474,0.44075770791683294,0.4419924748565711,0.44322296181328236,
0.4444492088167707,0.445671255289577,0.4468891400596831,0.4481029013728773,0.44931257690479337,0.45051820377263313,0.4517198185465818,0.45291745726092675,0.4541111554248895,0.4553009480331786,0.45648686957627277,0.4576689540504429,0.45884723496752006,0.46002174536441914,0.46119251781242304,0.4623595844262362,0.46352297687281546,0.46468272637998137,0.46583886374482125,0.46699141934188554,0.46814042313118737,0.469285904666008,0.47042789310051664,0.47156641719720765,0.4727015053341615,0.4738331855121353,
0.47496148536148547,0.47608643214893004,0.4772080527841532,0.47832637382625737,0.479441421490067,0.4805532216522879,0.4816617998575264,0.482767181324172,0.48386939095014764,0.48496845331853117,0.4860643927030504,0.4871572330734569,0.48824699810078104,0.48933371116247054,0.4904173953474175,0.4914980734608752,0.4925757680292682,0.49365050130489957,0.49472229527055495,0.49579117164401115,0.49685715188244534,0.49792025718675353,0.4989805085057765,0.5000379265404378,0.5010925317477942,0.5021443443450035,
0.5031933843132081,0.5042396714013406,0.5052832251298499,0.5063240647943513,0.5073622094692027,0.5083976780110088,0.5094304890620533,0.5104606610536634,0.5114882122095067,0.512513160548822,0.5135355238895871,0.514555319851623,0.5155725658596376,0.5165872791462103,0.5175994767547175,0.518609175542202,0.5196163921821871,0.5206211431674361,0.5216234448126594,0.522623313257169,0.5236207644674844,0.5246158142398872,0.5256084782029289,0.5265987718198912,0.5275867103912004,0.5285723090567965,0.5295555827984594,
0.5305365464420905,0.5315152146599541,0.5324916019728768,0.533465722752407,0.5344375912229347,0.5354072214637743,0.5363746274112078,0.5373398228604933,0.5383028214678364,0.5392636367523269,0.5402222820978414,0.5411787707549106,0.5421331158425572,0.5430853303500971,0.5440354271389132,0.5449834189441957,0.545929318376653,0.5468731379241937,0.5478148899535785,0.5487545867120445,0.5496922403289016,0.550627862817102,0.5515614660747821,0.5524930618867796,0.5534226619261247,0.5543502777555052,0.5552759208287091,
0.5561996024920415,0.5571213339857184,0.5580411264452384,0.5589589909027302,0.5598749382882796,0.5607889794312336,0.5617011250614838,0.5626113858107291,0.5635197722137174,0.5644262947094677,0.5653309636424726,0.5662337892638817,0.5671347817326651,0.5680339511167598,0.5689313073941972,0.5698268604542126,0.5707206200983378,0.5716125960414764,0.5725027979129619,0.5733912352575995,0.5742779175366926,0.5751628541290517,0.5760460543319896,0.5769275273622997,0.5778072823572206,0.5786853283753848,0.5795616743977544,
0.5804363293285412,0.5813093019961135,0.5821806011538895,0.5830502354812169,0.5839182135842398,0.5847845439967515,0.5856492351810363,0.5865122955286974,0.5873737333614738,0.5882335569320437,0.5890917744248176,0.5899483939567188,0.5908034235779529,0.5916568712727662,0.5925087449601928,0.5933590524947909,0.5942078016673694,0.5950550002057023,0.5959006557752352,0.5967447759797787,0.5975873683621958,0.5984284404050756,0.5992679995314003,0.6001060531052015,0.6009426084322078,0.601777672760483,0.6026112532810554,
0.6034433571285388,0.6042739913817439,0.6051031630642828,0.6059308791451635,0.6067571465393772,0.6075819721084775,0.6084053626611514,0.6092273249537822,0.6100478656910059,0.6108669915262589,0.6116847090623188,0.6125010248518375,0.6133159453978685,0.614129477154385,0.6149416265267927,0.6157523998724356,0.6165618035010941,0.6173698436754775,0.6181765266117102,0.6189818584798096,0.6197858454041609,0.6205884934639824,0.621389808693787,0.6221897970838367,0.6229884645805916,0.6237858170871525,0.6245818604636987,
0.6253766005279194,0.6261700430554399,0.6269621937802424,0.627753058395081,0.628542642551892,0.6293309518621987,0.6301179918975115,0.6309037681897214,0.6316882862314913,0.6324715514766395,0.6332535693405202,0.6340343452003991,0.6348138843958234,0.6355921922289883,0.6363692739650979,0.6371451348327226,0.6379197800241517,0.6386932146957418,0.6394654439682601,0.6402364729272251,0.6410063066232419,0.6417749500723333,0.6425424082562685,0.6433086861228857,0.6440737885864122,0.6448377205277801,0.645600486794939,
0.6463620922031635,0.6471225415353585,0.6478818395423597,0.6486399909432315,0.6493970004255614,0.6501528726457492,0.650907612229295,0.6516612237710832,0.6524137118356617,0.6531650809575201,0.6539153356413631,0.6546644803623813,0.6554125195665185,0.6561594576707364,0.6569052990632761,0.6576500481039163,0.6583937091242286,0.6591362864278302,0.6598777842906337,0.6606182069610937,0.6613575586604503,0.6620958435829714,0.6628330658961898,0.6635692297411403,0.664304339232592,0.665038398459279,0.6657714114841288,
0.6665033823444867,0.6672343150523395,0.6679642135945361,0.6686930819330041,0.6694209240049673,0.6701477437231571,0.6708735449760244,0.6715983316279475,0.6723221075194388,0.6730448764673485,0.6737666422650662,0.6744874086827211,0.6752071794673781,0.6759259583432347,0.6766437490118126,0.6773605551521499,0.6780763804209894,0.6787912284529659,0.6795051028607908,0.6802180072354358,0.6809299451463133,0.6816409201414555,0.6823509357476922,0.6830599954708256,0.6837681027958041,0.684475261186894,0.6851814740878487,
0.6858867449220779,0.6865910770928132,0.6872944739832727,0.6879969389568239,0.6886984753571457,0.6893990865083861,0.6900987757153224,0.6907975462635155,0.6914954014194653,0.692192344430764,0.6928883785262472,0.6935835069161438,0.6942777327922245,0.694971059327949,0.6956634896786107,0.6963550269814812,0.6970456743559527,0.6977354349036788,0.6984243117087141,0.6991123078376528,0.699799426339765,0.7004856702471326,0.7011710425747831,0.7018555463208224,0.7025391844665666,0.7032219599766716,0.7039038757992623,
0.7045849348660602,0.7052651400925095,0.7059444943779024,0.7066230006055029,0.7073006616426692,0.707977480340976,0.7086534595363333,0.7093286020491069,0.7100029106842357,0.7106763882313484,0.7113490374648795,0.7120208611441837,0.7126918620136494,0.7133620428028108,0.7140314062264597,0.7146999549847549,0.7153676917633327,0.7160346192334134,0.7167007400519098,0.7173660568615324,0.7180305722908951,0.7186942889546185,0.719357209453434,0.720019336374285,0.7206806722904288,0.7213412197615364,0.7220009813337923,
0.7226599595399918,0.7233181568996399,0.7239755759190464,0.724632219091423,0.7252880888969768,0.7259431878030049,0.7265975182639874,0.727251082721679,0.7279038836052013,0.7285559233311324,0.7292072043035966,0.7298577289143543,0.7305074995428886,0.7311565185564938,0.7318047883103603,0.7324523111476625,0.7330990893996414,0.7337451253856901,0.7343904214134368,0.7350349797788271,0.7356788027662066,0.7363218926484012,0.7369642516867986,0.7376058821314261,0.7382467862210323,0.7388869661831627,0.7395264242342394,
0.7401651625796365,0.7408031834137572,0.741440488920109,0.7420770812713791,0.7427129626295076,0.7433481351457623,0.7439826009608107,0.744616362204793,0.7452494209973932,0.7458817794479106,0.7465134396553299,0.7471444037083915,0.7477746736856601,0.7484042516555937,0.7490331396766116,0.749661339797162,0.7502888540557885,0.7509156844811968,0.75154183309232,0.7521673018983844,0.7527920928989733,0.7534162080840919,0.7540396494342302,0.7546624189204263,0.7552845185043287,0.7559059501382585,0.7565267157652705,
0.7571468173192143,0.7577662567247944,0.7583850358976305,0.7590031567443164,0.7596206211624794,0.7602374310408384,0.7608535882592614,0.7614690946888241,0.7620839521918652,0.7626981626220444,0.7633117278243974,0.7639246496353923,0.7645369298829836,0.7651485703866682,0.7657595729575378,0.766369939398335,0.7669796715035041,0.7675887710592457,0.7681972398435691,0.768805079626343,0.7694122921693485,0.7700188792263292,0.7706248425430432,0.7712301838573123,0.7718349048990725,0.7724390073904231,0.773042493045677,
0.7736453635714078,0.7742476206664997,0.7748492660221942,0.7754503013221389,0.7760507282424334,0.776650548451678,0.7772497636110178,0.7778483753741909,0.7784463853875732,0.7790437952902235,0.7796406067139292,0.7802368212832507,0.7808324406155657,0.781427466321113,0.7820219000030365,0.7826157432574284,0.7832089976733718,0.7838016648329837,0.7843937463114573,0.7849852436771035,0.7855761584913932,0.7861664923089979,0.7867562466778316,0.7873454231390905,0.787934023227294,0.7885220484703245,0.7891095003894674,
0.78969638049945,0.7902826903084814,0.790868431318291,0.7914536050241666,0.7920382129149933,0.7926222564732914,0.7932057371752538,0.7937886564907835,0.7943710158835304,0.7949528168109292,0.7955340607242347,0.7961147490685586,0.7966948832829057,0.7972744648002096,0.7978534950473676,0.7984319754452766,0.7990099074088677,0.7995872923471412,0.8001641316632006,0.8007404267542867,0.8013161790118125,0.8018913898213956,0.8024660605628923,0.8030401926104308,0.8036137873324438,0.8041868460917015,0.8047593702453443,
0.8053313611449138,0.8059028201363865,0.806473748560204,0.8070441477513057,0.8076140190391593,0.808183363747792,0.8087521831958219,0.8093204786964877,0.8098882515576799,0.8104555030819705,0.8110222345666428,0.811588447303722,0.8121541425800035,0.8127193216770835,0.8132839858713867,0.8138481364341967,0.8144117746316832,0.8149749017249316,0.8155375189699711,0.816099627617802,0.8166612289144245,0.8172223241008661,0.8177829144132087,0.8183430010826165,0.8189025853353624,0.819461668392856,0.8200202514716689,
0.8205783357835622,0.821135922535513,0.8216930129297397,0.8222496081637287,0.8228057094302597,0.8233613179174317,0.8239164348086886,0.8244710612828438,0.8250251985141056,0.8255788476721027,0.8261320099219078,0.8266846864240632,0.8272368783346047,0.827788586805086,0.8283398129826024,0.8288905580098155,0.829440823024976,0.8299906091619481,0.8305399175502322,0.8310887493149887,0.8316371055770607,0.8321849874529976,0.8327323960550771,0.8332793324913279,0.833825797865553,0.8343717932773512,0.8349173198221393,
0.835462378591175,0.8360069706715774,0.83655109714635,0.8370947590944016,0.8376379575905678,0.8381806937056326,0.8387229685063494,0.8392647830554617,0.8398061384117246,0.8403470356299247,0.8408874757609016,0.8414274598515679,0.8419669889449293,0.8425060640801054,0.8430446862923493,0.8435828566130675,0.84412057606984,0.84465784568644,0.8451946664828526,0.8457310394752956,0.8462669656762376,0.8468024460944176,0.8473374817348641,0.8478720735989141,0.8484062226842315,0.8489399299848259,0.8494731964910713,
0.8500060231897245,0.8505384110639432,0.8510703610933044,0.8516018742538222,0.8521329515179663,0.852663593854679,0.8531938022293939,0.8537235776040522,0.8542529209371217,0.854781833183613,0.8553103152950976,0.8558383682197243,0.8563659929022369,0.8568931902839906,0.8574199613029695,0.8579463068938025,0.8584722279877803,0.8589977255128725,0.8595228003937431,0.8600474535517671,0.860571685905047,0.8610954983684285,0.8616188918535168,0.8621418672686924,0.8626644255191268,0.8631865675067983,0.8637082941305079,
0.8642296062858937,0.864750504865448,0.8652709907585314,0.8657910648513881,0.8663107280271617,0.8668299811659093,0.8673488251446174,0.867867260837216,0.8683852891145937,0.8689029108446124,0.8694201268921217,0.8699369381189732,0.8704533453840357,0.8709693495432085,0.8714849514494362,0.8720001519527227,0.8725149519001453,0.8730293521358685,0.873543353501158,0.8740569568343945,0.8745701629710876,0.8750829727438886,0.8755953869826052,0.8761074065142143,0.8766190321628751,0.8771302647499432,0.8776411050939833,
0.8781515540107819,0.8786616123133618,0.8791712808119936,0.8796805603142088,0.8801894516248137,0.8806979555459011,0.8812060728768631,0.8817138044144045,0.882221150952554,0.8827281132826775,0.883234692193491,0.8837408884710714,0.8842467028988698,0.8847521362577235,0.8852571893258682,0.8857618628789493,0.8862661576900348,0.8867700745296263,0.8872736141656715,0.8877767773635756,0.8882795648862128,0.8887819774939383,0.8892840159445996,0.8897856809935476,0.8902869733936489,0.8907878938952963,0.8912884432464204,
0.8917886221925007,0.8922884314765765,0.8927878718392589,0.8932869440187404,0.8937856487508071,0.8942839867688488,0.8947819588038698,0.8952795655845005,0.8957768078370067,0.8962736862853018,0.8967702016509559,0.8972663546532074,0.8977621460089725,0.8982575764328569,0.8987526466371646,0.899247357331909,0.8997417092248232,0.90023570302137,0.9007293394247513,0.9012226191359196,0.9017155428535865,0.9022081112742335,0.9027003250921215,0.9031921849993009,0.9036836916856209,0.90417484583874,0.9046656481441341,
0.9051560992851082,0.9056461999428044,0.9061359507962115,0.9066253525221751,0.9071144057954066,0.9076031112884924,0.9080914696719034,0.9085794816140041,0.9090671477810619,0.9095544688372559,0.9100414454446862,0.9105280782633834,0.9110143679513163,0.911500315164402,0.9119859205565143,0.9124711847794927,0.9129561084831508,0.9134406923152851,0.9139249369216844,0.9144088429461374,0.9148924110304419,0.915375641814413,0.9158585359358921,0.9163410940307543,0.9168233167329184,0.9173052046743536,0.9177867584850888,
0.9182679787932209,0.9187488662249219,0.9192294214044485,0.9197096449541494,0.9201895374944735,0.9206690996439783,0.9211483320193369,0.9216272352353475,0.9221058099049397,0.9225840566391834,0.9230619760472966,0.9235395687366524,0.9240168353127874,0.9244937763794097,0.9249703925384051,0.9254466843898465,0.9259226525320003,0.9263982975613347,0.9268736200725265,0.9273486206584685,0.9278232999102779,0.9282976584173026,0.9287716967671293,0.9292454155455901,0.9297188153367703,0.9301918967230154,0.9306646602849383,
0.9311371066014265,0.9316092362496491,0.9320810498050639,0.9325525478414245,0.9330237309307874,0.9334945996435183,0.9339651545483003,0.9344353962121393,0.9349053252003717,0.9353749420766716,0.9358442474030564,0.9363132417398943,0.9367819256459111,0.9372502996781967,0.9377183643922115,0.9381861203417932,0.9386535680791633,0.9391207081549341,0.9395875411181145,0.9400540675161166,0.9405202878947628,0.9409862027982911,0.9414518127693627,0.9419171183490671,0.9423821200769295,0.9428468184909163,0.9433112141274416,
0.9437753075213736,0.9442390992060405,0.9447025897132368,0.9451657795732294,0.9456286693147632,0.946091259465068,0.946553550549864,0.9470155430933681,0.9474772376182993,0.947938634645885,0.9483997346958671,0.9488605382865075,0.9493210459345939,0.9497812581554465,0.9502411754629217,0.9507007983694208,0.9511601273858931,0.9516191630218428,0.9520779057853349,0.9525363561829999,0.9529945147200402,0.9534523819002355,0.9539099582259479,0.9543672441981287,0.9548242403163215,0.9552809470786706,0.9557373649819242,
0.9561934945214409,0.9566493361911946,0.9571048904837803,0.957560157890419,0.9580151389009636,0.9584698340039032,0.9589242436863693,0.9593783684341407,0.9598322087316485,0.9602857650619817,0.9607390379068922,0.9611920277467992,0.9616447350607958,0.9620971603266527,0.9625493040208236,0.9630011666184514,0.9634527485933709,0.9639040504181161,0.9643550725639237,0.9648058155007385,0.9652562796972185,0.9657064656207391,0.9661563737373994,0.9666060045120247,0.9670553584081741,0.9675044358881427,0.9679532374129683,
0.9684017634424352,0.9688500144350788,0.969297990848191,0.9697456931378244,0.9701931217587966,0.9706402771646961,0.9710871598078853,0.9715337701395063,0.9719801086094847,0.9724261756665348,0.9728719717581634,0.9733174973306754,0.9737627528291767,0.9742077386975799,0.9746524553786086,0.9750969033138012,0.9755410829435159,0.9759849947069349,0.9764286390420681,0.976872016385759,0.9773151271736872,0.9777579718403738,0.9782005508191854,0.9786428645423387,0.9790849134409042,0.9795266979448097,0.9799682184828468,
0.9804094754826725,0.9808504693708154,0.9812912005726785,0.9817316695125434,0.9821718766135753,0.9826118222978263,0.9830515069862399,0.9834909310986545,0.9839300950538076,0.9843689992693404,0.9848076441618009,0.9852460301466487,0.9856841576382579,0.9861220270499221,0.9865596387938579,0.9869969932812083,0.9874340909220475,0.9878709321253837,0.9883075172991641,0.9887438468502779,0.9891799211845601,0.9896157407067957,0.9900513058207229,0.9904866169290382,0.9909216744333976,0.9913564787344237,0.9917910302317056,
0.9922253293238062,0.9926593764082635,0.9930931718815946,0.9935267161393003,0.9939600095758677,0.9943930525847745,0.9948258455584919,0.9952583888884886,0.9956906829652349,0.9961227281782049,0.9965545249158808,0.9969860735657569,0.9974173745143414,0.9978484281471626,0.9982792348487693,0.9987097950027365,0.9991401089916675,0.9995701771971982,1]);var h=o.length,a=(e[0]/2.55+16)/116,j=(e[1]-127)/500+a,f=a-(e[2]-127)/200,n=a*a*a,i=j*j*j,d=f*f*f,j=0.95047*(0.008856<i?i:(j-16/116)/7.787),a=1*(0.008856<n?
n:(a-16/116)/7.787),f=1.08883*(0.008856<d?d:(f-16/116)/7.787),n=3.2406*j+-1.5372*a+-0.4986*f,i=-0.9689*j+1.8758*a+0.0415*f,a=0.0557*j+-0.204*a+1.057*f,n=0>=n?0:1<=n?1:o[n*h|0],i=0>=i?0:1<=i?1:o[i*h|0],a=0>=a?0:1<=a?1:o[a*h|0];return[255*n+0.5|0,255*i+0.5|0,255*a+0.5|0]}}});C.define("/src/js/filters/enhance.js",function(q,B){var e={};q("./colorConversion");var o=q("./histogramMapping"),h=q("../core/copy"),a=function(a){var j=[],f=[],g=[],l=[],c,p;a.moaGL&&(a=a.moaGL.getImageData());for(c=0;256>c;c++)f[c]=
0,g[c]=0,l[c]=0;c=0;for(p=a.length;c<p;c+=4)f[a[c]]++,g[a[c+1]]++,l[a[c+2]]++;j[0]=f;j[1]=g;j[2]=l;return j},j=function(a){for(var j=0,f=0;256>f;f++)j+=a[f];f=Array(256);f[0]=a[0]/j;for(var g=1;256>g;g++)f[g]=a[g]/j+f[g-1];return f},f=function(a,j){if(0>=j)return 0;if(1<=j)return 255;for(var f=0;j>a[f];)f++;return 0===f?j/a[f]:f-1+(j-a[f-1])/(a[f]-a[f-1])};e.nightenhance=function(d,i,e){var g=i*e,l=a(d),c=j(l[0]),p=j(l[1]),y=j(l[2]),s=f(c,0),r=f(c,1),c=f(p,0),w=f(p,1),p=f(y,0),u=f(y,1),s=Math.pow(s,
0.7),c=Math.pow(c,0.7),p=Math.pow(p,0.7),r=255-Math.pow(255-r,0.7),w=255-Math.pow(255-w,0.7),u=255-Math.pow(255-u,0.7),y=255/(r-s),r=255/(w-c),w=255/(u-p),h=0,u=[],v;for(v=0;256>v;v++)h+=0.213*l[0][v]+0.715*l[1][v]+0.072*l[2][v],u[v]=h/g,u[v]=0===v?1:255*(u[v]/v),u[v]=1<u[v]?Math.pow(u[v],0.65):1/Math.pow(1/u[v],0.65);u=n(u,4);if(d.moaGL)d.moaGL.renderAutoEnhance(0.8,y,r,w,s,c,p,u);else for(v=i*e;v--;)g=d[4*v],l=d[4*v+1],h=d[4*v+2],i=u[0.213*g+0.715*l+0.072*h|0],e=i*l+0.5|0,g=(g+0.8*(g*i-g)+(e-l)*
(1-0.8)-s)*y+0.5|0,h=(h+0.8*(h*i-h)+(e-l)*(1-0.8)-p)*w+0.5|0,l=(e-c)*r+0.5|0,255<g?g=255:0>g&&(g=0),255<l?l=255:0>l&&(l=0),255<h?h=255:0>h&&(h=0),d[4*v]=g,d[4*v+1]=l,d[4*v+2]=h,d[4*v+3]=d[4*v+3]};e.localcontrastenhance=function(j,f,e){var g=a(j),l=[],c=f*e,p=0,y;for(y=0;256>y;y++)p+=g[1][y],l[y]=p/c,l[y]=0===y?1:l[y]/(y/255),l[y]=1<l[y]?Math.pow(l[y],0.33):1/Math.pow(1/l[y],0);l=n(l,15);for(y=0;256>y;y++)l[y]*=y/255,l[y]=255*l[y]+0.5|0;var s={r:l,g:l,b:l},l={blurAmount:120,sharpenVal:0.3,gain:0.6},
c=l.blurAmount,g=l.gain,l=l.sharpenVal,c=Math.round(c*((f+e)/1600)/5/2);if(j.moaGL)j.moaGL.renderClarity(s,c,g,l);else{p=[];i(j,f,e,p);var r=h.copy(j);y=[];o.mapHist(r,s);i(r,f,e,y);var w,u,z,v,x,I,O,E,t,q;for(I=0;I<e;I++)for(x=0;x<f;x++)s=4*(f*I+x),O=j[s],E=j[s+1],t=j[s+2],u=x-c,w=I-c,z=x+c,v=I+c,u=0>u?0:u>f-1?f-1:u,w=0>w?0:w>e-1?e-1:w,z=0>z?0:z>f-1?f-1:z,v=0>v?0:v>e-1?e-1:v,q=(v-w)*(z-u),r=(p[z+f*v]+p[u+f*w]-p[u+f*v]-p[z+f*w])/q,w=(y[z+f*v]+y[u+f*w]-y[u+f*v]-y[z+f*w])/q,u=w-r,z=0===r?w:w/r,w=0.2*
O+0.7*E+0.1*t,O+=l*(w-r),E+=l*(w-r),t+=l*(w-r),O=g*O*z+(1-g)*(O+u),E=g*E*z+(1-g)*(E+u),t=g*t*z+(1-g)*(t+u),j[s]=255<O?255:0>O?0:O+0.5|0,j[s+1]=255<E?255:0>E?0:E+0.5|0,j[s+2]=255<t?255:0>t?0:t+0.5|0}};e.labcorrect=function(d,i,n){for(var g=0,l=0,c=[],p=[],y=[],l=[],l=0;256>l;l++)c[l]=0,p[l]=0,y[l]=0;var l=[0,0.030352698354883748,0.060705396709767497,0.09105809506465125,0.12141079341953499,0.15176349177441875,0.1821161901293025,0.21246888848418624,0.24282158683906999,0.27317428519395376,0.3035269835488375,
0.3346535763899161,0.3676507324047436,0.40247170184963066,0.43914420374102936,0.4776953480693729,0.5181516702338386,0.5605391624202722,0.6048833022857054,0.6512090792594475,0.6995410187265387,0.7499032043226175,0.8023192985384995,0.8568125618069307,0.9134058702220788,0.9721217320237849,1.0329823029626937,1.0960094006488246,1.1612245179743885,1.2286488356915872,1.2983032342173013,1.3702083047289686,1.4443843596092545,1.520851442291271,1.599629336550963,1.6807375752887384,1.7641954488384077,1.8500220128379696,
1.9382360956935722,2.02885630566524,2.1219010376003555,2.2173884793387386,2.315336617811041,2.4157632448504756,2.518685962736163,2.6241221894849898,2.7320891639074896,2.8426039504420793,2.95568344378088,3.0713443732993633,3.1896033073011534,3.3104766570885054,3.433980680868217,3.5601314875020345,3.688945040110004,3.82043715953465,3.9546235276732835,4.091519690685319,4.231141062080967,4.3735029256973466,4.518620438567554,4.666508633688009,4.8171824226889415,4.970656598412723,5.126945837404324,5.286064702318025,
5.448027644244237,5.612849004960009,5.780543019106723,5.95112381629812,6.124605423161761,6.301001765316768,6.480326669290577,6.662593864377289,6.8478169844400165,7.036009569659588,7.227185068231748,7.421356838014963,7.618538148130785,7.818742180518632,8.021982031446832,8.22827071298148,8.437621154414881,8.650046203654977,8.865558628577293,9.084171118340768,9.305896284668744,9.53074666309647,9.758734714186247,9.989872824711389,10.224173308810132,10.461648409110419,10.702310297826761,10.946171077829932,
11.193242783690561,11.443537382697373,11.697066775851084,11.953842798834561,12.213877222960187,12.47718175609505,12.743768043564744,13.013647669036429,13.286832155381797,13.563332965520566,13.843161503245183,14.126329114027165,14.412847085805778,14.702726649759498,14.995978981060857,15.292615199615017,15.59264637078274,15.89608350608804,16.2029375639111,16.513219450166762,16.826940018969076,17.14411007328226,17.464740365558505,17.78884159836291,18.116424424986022,18.4474994500441,18.782077230067788,
19.120168274079138,19.46178304415758,19.806931955994887,20.155625379439705,20.507873639031693,20.863687014525574,21.223075741405523,21.586050011389926,21.95261997292692,22.32279573168085,22.696587351009835,23.074004852434914,23.45505821610052,23.839757381227102,24.228112246555487,24.620132670783548,25.015828472995345,25.415209433082676,25.818285292159583,26.225065752969623,26.635560480286248,27.04977910130658,27.467731206038465,27.88942634768104,28.31487404299921,28.74408377269175,29.17706498175359,
29.613827079832113,30.05437944157765,30.49873140698863,30.946892281750856,31.398871337571755,31.854677812509184,32.31432091129508,32.777809805654215,33.245153634617935,33.71636150483304,34.191442490866095,34.67040563550296,35.15325995004394,35.640014414594354,36.13067797835095,36.62525955988395,37.12376804741491,37.62621229909065,38.13260114325301,38.6429433787049,39.157247774972326,39.67552307256268,40.19777798321958,40.72402119017367,41.25426134839037,41.788507084813745,42.32676699860717,42.86904966139066,
43.415363617474895,43.96571738409188,44.52011945162278,45.078578283822345,45.64110231804047,46.20769996544071,46.7783796112159,47.353149614800955,47.93201831008268,48.514994005607036,49.10208498478356,49.693299506087044,50.28864580325687,50.888132085493375,51.49176653765214,52.09955732043543,52.711512570581306,53.32764040105052,53.947948901210715,54.57244613701866,55.201140151200015,55.83403896342679,56.471150570492924,57.11248294648731,57.75804404296506,58.40784178911641,59.06188409193369,59.720178836376334,
60.38273388553378,61.04955708078648,61.72065624196511,62.39603916750761,63.07571363461469,63.75968739940326,64.44796819705822,65.14056374198242,65.83748172794485,66.5387298282272,67.24431569576875,67.95424696330939,68.66853124353135,69.38717612919899,70.11018919329732,70.83757798916868,71.56935005064807,72.30551289219693,73.04607400903537,73.79104087727309,74.54042095403875,75.29422167760778,76.05245046752924,76.8151147247507,77.58222183174236,78.35377915261935,79.12979403326302,79.9102738014409,
80.69522576692516,81.48465722161012,82.27857543962836,83.07698767746547,83.879901174074,84.6873231509858,85.49926081242339,86.31572134541024,87.13671191987972,87.96223968878317,88.79231178819663,89.62693533742664,90.46611743911495,91.30986517934193,92.15818562772947,93.01108583754237,93.8685728457888,94.73065367331999,95.59733532492861,96.46862478944651,97.34452903984125,98.22505503331172,99.11020971138298,100],s=[0,0.09924488254695861,0.12504071661525748,0.14313588920856027,0.1575414309575025,0.16970636198605316,
0.18033991980928551,0.18984863055466036,0.19848976509391722,0.20643767470661487,0.21381661776730748,0.2207186428753261,0.22721406110407222,0.2333579349114362,0.2391942859295316,0.24475892765281868,0.2500814332305149,0.25518653946003345,0.2600951718542145,0.26482520821552014,0.26939205754235684,0.27380910584090884,0.27808806426285243,0.2822392443945425,0.28627177841712054,0.2901937969941595,0.2940125743549161,0.2977346476408758,0.3013659158571899,0.30491172251223664,0.3083769250994826,0.311765953881872,
0.315082861915005,0.31833136784577337,0.32151489271552486,0.3246365917579799,0.3276993819951494,0.33070596628701154,0.3336588543735265,0.336560381353843,0.3394127239721063,0.34221791501818183,0.3449778561018543,0.34769432901832303,0.350369005889286,0.3530034582361798,0.3555991651191077,0.35815752045576577,0.360679839618571,0.3631673653946448,0.36562127338186107,0.3680426768844678,0.37043263136354043,0.37279213849048415,0.3751221498457724,0.3774235702999315,0.3796972611093207,0.38194404275540383,0.38416469755287136,
0.3863599720490726,0.38853057923469275,0.3906772005834086,0.39280048793632477,0.3949010652453065,0.39697953018783444,0.3990364556647021,0.40107239119071786,0.4030878641875543,0.40508338118698156,0.40705942895191655,0.4090164755220073,0.41095497118983254,0.41287534941322973,0.41477802766875577,0.41666340825083015,0.41853187902070177,0.4203838141090141,0.4222195745754141,0.42403950902835275,0.4258439542079576,0.42763323553461496,0.4294076676256808,0.4311675547825421,0.43291319145006824,0.43464486265033075,
0.43636284439232104,0.43806740405925904,0.439758800774965,0.44143728575065216,0.4431031026133969,0.44475648771744863,0.4463976704394558,0.44802687345860653,0.4496443130226092,0.45125019920037296,0.4528447361221874,0.45442812220814444,0.4560005503854936,0.45756220829557587,0.4591132784909362,0.46065393862317483,0.46218436162206117,0.4637047158663982,0.4652151653470947,0.46671586982287233,0.46820698496900803,0.4696886625194857,0.4711610504029096,0.47262429287250746,0.4740785306305335,0.4755239009473612,
0.4769605377755387,0.47838857185906314,0.4798081308381152,0.48121933934948075,0.48262231912287346,0.4840171890733601,0.4854040653900775,0.4867830616214213,0.4881542887568748,0.4895178553056373,0.4908738673722041,0.4922224287290381,0.4935636408864699,0.4948976031599528,0.496224412734793,0.49754416472847035,0.4988569522506557,0.5001628664610298,0.501461996624999,0.5027544301674005,0.5040402527242843,0.5053195481928565,0.5065923987796591,0.5078588850470654,0.5091190859581595,0.5103730789200669,0.5116209398258046,
0.5128627430947063,0.514098561711485,0.5153284672639881,0.516552529979695,0.5177708187610112,0.5189834012194042,0.520190343708429,0.5213917113556842,0.5225875680937435,0.5237779766901,0.524962998776162,0.5261426948753368,0.5273171244302366,0.5284863458290399,0.5296504164310403,0.530809392591412,0.5319633296852224,0.5331122821307175,0.5342563034119088,0.5353954461004848,0.5365297618770742,0.5376593015518806,0.5387841150847137,0.5399042516044376,0.5410197594278565,0.5421306860780567,0.5432370783022257,
0.5443389820889641,0.5454364426851102,0.5465295046120907,0.5476182116818177,0.5487026070121426,0.5497827330418863,0.5508586315454556,0.5519303436470633,0.5529979098345615,0.5540613699729042,0.555120763317248,0.5561761285257049,0.5572275036717572,0.5582749262563468,0.5593184332196459,0.5603580609525242,0.5613938453077163,0.5624258216107048,0.5634540246703222,0.564478488789085,0.5654992477732644,0.5665163349427048,0.5675297831403955,0.5685396247418045,0.5695458916639811,0.5705486153744331,0.5715478268997879,
0.5725435568342411,0.5735358353478003,0.5745246921943311,0.5755101567194079,0.5764922578679786,0.577471024191847,0.5784464838569776,0.5794186646506286,0.5803875939883189,0.5813532989206311,0.582315806139859,0.5832751419864992,0.5842313324555962,0.5851844032029409,0.5861343795511286,0.5870812864954806,0.5880251487098322,0.5889659905521902,0.5899038360702656,0.5908387090068827,0.5917706328052692,0.5926996306142294,0.5936257252932051,0.5945489394172259,0.5954692952817516,0.5963868149074115,0.5973015200446405,
0.5982134321782173,0.599122572531705,0.6000289620717986,0.60093262151258,0.6018335713196846,0.6027318317143798,0.6036274226775593,0.6045203639536548,0.6054106750544663,0.606298375262915,0.6071834836367179,0.6080660190119893,0.6089460000067677,0.6098234450244732,0.6106983722572941,0.6115707996895061,0.6124407451007265,0.613308226069102,0.6141732599744346,0.6150358640012467,0.6158960551417848,0.6167538501989651,0.6176092657892629,0.6184623183455441,0.6193130241198446,0.620161399186094,0.6210074594427897,
0.6218512206156173,0.6226926982600246,0.623531907763744,0.6243688643492697,0.6252035830762873,0.6260360788440587,0.626866366393762,0.6276944603107898,0.6285203750270028,0.6293441248229434,0.6301657238300099,0.6309851860325884,0.6318025252701481,0.6326177552392989,0.63343088949581,0.6342419414565944,0.6350509244016576,0.6358578514760097,0.6366627356915467,0.6374655899288959,0.6382664269392303,0.6390652593460512,0.6398620996469384,0.6406569602152721,0.6414498533019224,0.6422407910369122,0.6430297854310497,
0.6438168483775332,0.6446019916535295,0.6453852269217243,0.6461665657318468,0.646946019522169,0.6477235996209785,0.6484993172480279,0.6492731835159596,0.6500452094317067,0.6508154058978702,0.651583783714075,0.6523503535783013,0.6531151260881964,0.653878111742364,0.6546393209416315,0.6553987639902987,0.6561564510973654,0.6569123923777382,0.6576665978534199,0.6584190774546778,0.6591698410211952,0.6599188983032032,0.660666258962595,0.6614119325740231,0.6621559286259783,0.6628982565218523,0.6636389255809841,
0.6643779450396892,0.6651153240522729,0.665851071692029,0.6665851969522216,0.667317708747053,0.6680486159126159,0.6687779272078317,0.6695056513153739,0.6702317968425779,0.6709563723223373,0.6716793862139855,0.6724008469041655,0.673120762707686,0.6738391418683641,0.6745559925598569,0.675271322886479,0.6759851408840097,0.6766974545204868,0.6774082716969896,0.67811760024841,0.6788254479442125,0.6795318224891835,0.6802367315241687,0.6809401826268009,0.6816421833122166,0.6823427410337628,0.6830418631836931,
0.6837395570938545,0.6844358300363635,0.6851306892242741,0.6858241418122343,0.6865161948971349,0.6872068555187488,0.687896130660361,0.6885840272493903,0.689270552158001,0.6899557122037085,0.6906395141499742,0.6913219647067927,0.6920030705312724,0.6926828382282061,0.6933612743506347,0.6940383854004035,0.6947141778287103,0.6953886580366461,0.6960618323757292,0.6967337071484312,0.6974042886086962,0.6980735829624533,0.6987415963681218,0.6994083349371105,0.7000738047343085,0.7007380117785719,0.7014009620432023,
0.7020626614564196,0.7027231159018287,0.7033823312188793,0.7040403132033212,0.7046970676076518,0.7053526001415594,0.7060069164723595,0.7066600222254262,0.7073119229846179,0.7079626242926972,0.7086121316517457,0.7092604505235738,0.7099075863301242,0.7105535444538713,0.7111983302382154,0.7118419489878712,0.7124844059692523,0.71312570641085,0.7137658555036082,0.7144048584012926,0.7150427202208567,0.7156794460428013,0.7163150409115315,0.7169495098357082,0.7175828577885948,0.7182150897084011,0.718846210498622,
0.7194762250283715,0.720105138132714,0.7207329546129908,0.721359679237142,0.721985316740026,0.7226098718237337,0.7232333491578999,0.7238557533800104,0.7244770890957053,0.7250973608790793,0.7257165732729777,0.7263347307892896,0.7269518379092367,0.7275678990836596,0.7281829187333003,0.728796901249081,0.7294098509923802,0.7300217722953055,0.7306326694609626,0.7312425467637221,0.7318514084494824,0.7324592587359297,0.7330661018127955,0.7336719418421106,0.7342767829584559,0.7348806292692114,0.735483484854801,
0.7360853537689355,0.7366862400388527,0.737286147665554,0.7378850806240391,0.7384830428635379,0.7390800383077395,0.7396760708550189,0.7402711443786605,0.7408652627270808,0.741458429724046,0.7420506491688895,0.7426419248367259,0.7432322604786622,0.7438216598220084,0.7444101265704832,0.7449976644044198,0.7455842769809682,0.7461699679342954,0.7467547408757834,0.7473385993942256,0.7479215470560205,0.748503587405363,0.7490847239644346,0.7496649602335902,0.7502442996915447,0.7508227457955557,0.7514003019816053,
0.7519769716645798,0.7525527582384471,0.7531276650764331,0.753701695531195,0.7542748529349934,0.754847140599863,0.7554185618177804,0.7559891198608314,0.7565588179813753,0.7571276594122083,0.757695647366725,0.7582627850390781,0.7588290756043364,0.7593945222186415,0.7599591280193618,0.7605228961252469,0.7610858296365782,0.7616479316353195,0.7622092051852651,0.7627696533321872,0.7633292791039805,0.7638880855108077,0.7644460755452401,0.7650032521824002,0.7655596183801003,0.7661151770789814,0.7666699312026493,
0.7672238836578102,0.7677770373344053,0.7683293951057427,0.7688809598286291,0.7694317343435,0.7699817214745477,0.7705309240298498,0.7710793448014944,0.7716269865657057,0.7721738520829675,0.772719944098145,0.7732652653406075,0.7738098185243465,0.7743536063480964,0.7748966314954512,0.775438896634981,0.7759804044203481,0.7765211574904205,0.7770611584693855,0.7776004099668616,0.7781389145780099,0.778676674883643,0.7792136934503352,0.7797499728305293,0.7802855155626435,0.7808203241711775,0.7813544011668172,
0.7818877490465378,0.7824203702937074,0.782952267378188,0.783483442756437,0.7840138988716062,0.7845436381536416,0.7850726630193806,0.7856009758726495,0.7861285791043594,0.7866554750926015,0.7871816662027413,0.7877071547875124,0.7882319431871087,0.7887560337292759,0.7892794287294033,0.7898021304906129,0.7903241413038489,0.7908454634479661,0.7913660991898175,0.7918860507843407,0.7924053204746444,0.7929239104920931,0.7934418230563915,0.7939590603756689,0.7944756246465603,0.7949915180542906,0.7955067427727543,
0.7960213009645972,0.7965351947812954,0.7970484263632353,0.7975609978397913,0.7980729113294042,0.7985841689396577,0.7990947727673552,0.799604724898595,0.8001140274088461,0.8006226823630215,0.8011306918155525,0.8016380578104618,0.8021447823814357,0.8026508675518954,0.8031563153350691,0.8036611277340616,0.8041653067419244,0.8046688543417252,0.8051717725066162,0.8056740631999023,0.8061757283751086,0.8066767699760472,0.8071771899368835,0.8076769901822017,0.8081761726270704,0.8086747391771066,0.8091726917285403,
0.8096700321682774,0.8101667623739631,0.810662884214044,0.81115839954783,0.8116533102255556,0.8121476180884412,0.8126413249687521,0.8131344326898597,0.8136269430663002,0.8141188579038331,0.8146101789994995,0.8151009081416802,0.8155910471101533,0.8160805976761496,0.8165695616024108,0.8170579406432438,0.8175457365445769,0.8180329510440145,0.8185195858708919,0.8190056427463286,0.8194911233832824,0.8199760294866028,0.8204603627530825,0.8209441248715112,0.8214273175227265,0.8219099423796651,0.8223920011074144,
0.8228734953632629,0.8233544267967502,0.8238347970497164,0.8243146077563521,0.8247938605432471,0.8252725570294385,0.8257506988264595,0.8262282875383863,0.8267053247618866,0.8271818120862655,0.8276577510935128,0.8281331433583488,0.82860799044827,0.8290822939235957,0.8295560553375114,0.8300292762361152,0.830501958158461,0.830974102636603,0.8314457111956398,0.831916785353757,0.8323873266222709,0.8328573365056704,0.8333268165016603,0.8337957681012022,0.8342641927885572,0.8347320920413266,0.8351994673304931,
0.8356663201204616,0.8361326518690991,0.8365984640277758,0.8370637580414035,0.8375285353484762,0.8379927973811084,0.8384565455650747,0.8389197813198476,0.8393825060586361,0.8398447211884238,0.8403064281100062,0.8407676282180282,0.8412283229010212,0.8416885135414399,0.8421482015156988,0.8426073881942083,0.843066074941411,0.8435242631158167,0.8439819540700386,0.8444391491508282,0.8448958496991095,0.8453520570500146,0.8458077725329176,0.8462629974714685,0.8467177331836275,0.8471719809816981,0.8476257421723606,
0.8480790180567055,0.8485318099302657,0.8489841190830497,0.8494359467995736,0.8498872943588931,0.8503381630346358,0.8507885540950325,0.8512384688029485,0.8516879084159152,0.8521368741861606,0.85258536736064,0.8530333891810667,0.8534809408839426,0.8539280237005873,0.8543746388571686,0.854820787574732,0.8552664710692298,0.8557116905515508,0.8561564472275487,0.856600742298071,0.8570445769589876,0.8574879524012193,0.8579308698107657,0.8583733303687329,0.8588153352513616,0.8592568856300545,0.859697982671404,
0.8601386275372181,0.8605788213845489,0.8610185653657182,0.8614578606283446,0.8618967083153697,0.8623351095650842,0.8627730655111538,0.8632105772826455,0.8636476460040526,0.8640842727953206,0.8645204587718719,0.8649562050446316,0.8653915127200517,0.8658263829001364,0.8662608166824664,0.866694815160223,0.8671283794222129,0.8675615105528918,0.8679942096323882,0.8684264777365276,0.8688583159368556,0.8692897253006614,0.8697207068910011,0.8701512617667205,0.8705813909824783,0.8710110955887687,0.871440376631944,
0.8718692351542368,0.8722976721937826,0.872725688784642,0.8731532859568221,0.8735804647362989,0.8740072261450385,0.8744335712010189,0.8748595009182516,0.8752850163068022,0.8757101183728118,0.876134808118518,0.8765590865422758,0.8769829546385779,0.8774064133980755,0.8778294638075984,0.8782521068501757,0.8786743435050556,0.879096174747725,0.87951760154993,0.8799386248796953,0.8803592457013438,0.8807794649755161,0.8811992836591893,0.8816187027056972,0.8820377230647484,0.8824563456824455,0.8828745715013043,
0.8832924014602719,0.8837098364947455,0.884126877536591,0.8845435255141612,0.8849597813523133,0.8853756459724286,0.8857911202924285,0.8862062052267938,0.8866209016865818,0.8870352105794438,0.8874491328096428,0.8878626692780711,0.888275820882267,0.8886885885164322,0.8891009730714491,0.8895129754348972,0.8899245964910704,0.8903358371209934,0.8907466982024383,0.8911571806099414,0.8915672852148191,0.8919770128851846,0.8923863644859639,0.8927953408789115,0.8932039429226274,0.8936121714725718,0.8940200273810814,
0.8944275114973853,0.8948346246676199,0.895241367734845,0.8956477415390587,0.8960537469172131,0.896459384703229,0.8968646557280114,0.8972695608194643,0.8976741008025054,0.8980782764990811,0.8984820887281812,0.8988855383058536,0.8992886260452183,0.8996913527564827,0.9000937192469548,0.9004957263210588,0.9008973747803478,0.9012986654235191,0.9016995990464275,0.9021001764420992,0.9025003984007458,0.9029002657097783,0.9032997791538201,0.9036989395147207,0.9040977475715697,0.9044962041007096,0.9048943098757493,
0.9052920656675773,0.9056894722443748,0.906086530371629,0.9064832408121458,0.9068796043260627,0.9072756216708617,0.9076712936013822,0.9080666208698333,0.9084616042258066,0.9088562444162888,0.909250542185674,0.909644498275776,0.9100381134258407,0.9104313883725582,0.9108243238500753,0.9112169205900067,0.911609179321448,0.9120011007709872,0.912392685662716,0.9127839347182426,0.9131748486567027,0.9135654281947713,0.9139556740466742,0.9143455869241996,0.9147351675367098,0.9151244165911517,0.9155133347920691,
0.9159019228416131,0.9162901814395539,0.9166781112832916,0.9170657130678669,0.9174529874859728,0.9178399352279649,0.9182265569818724,0.9186128534334087,0.9189988252659826,0.9193844731607087,0.9197697977964173,0.9201547998496661,0.9205394799947498,0.9209238389037109,0.9213078772463497,0.9216915956902347,0.9220749949007134,0.9224580755409214,0.9228408382717931,0.9232232837520717,0.9236054126383193,0.9239872255849265,0.9243687232441223,0.9247499062659842,0.9251307752984477,0.925511330987316,0.9258915739762699,
0.9262715049068767,0.9266511244186009,0.9270304331488122,0.9274094317327963,0.9277881208037635,0.9281665009928579,0.9285445729291671,0.9289223372397313,0.9292997945495522,0.9296769454816025,0.9300537906568345,0.9304303306941893,0.9308065662106061,0.9311824978210302,0.931558126138423,0.9319334517737698,0.9323084753360892,0.9326831974324412,0.9330576186679365,0.9334317396457447,0.9338055609671028,0.934179083231324,0.934552307035806,0.9349252329760395,0.935297861645616,0.935670193636237,0.936042229537722,
0.936413969938016,0.9367854154231987,0.937156566577492,0.9375274239832683,0.9378979882210586,0.9382682598695602,0.938638239505645,0.9390079277043673,0.9393773250389714,0.9397464320808999,0.9401152493998012,0.9404837775635372,0.9408520171381909,0.9412199686880747,0.9415876327757369,0.9419550099619702,0.9423221008058192,0.9426889058645871,0.943055425693844,0.9434216608474337,0.9437876118774816,0.9441532793344015,0.9445186637669033,0.944883765722,0.9452485857450149,0.9456131243795891,0.945977382167688,
0.9463413596496092,0.9467050573639889,0.9470684758478091,0.9474316156364045,0.9477944772634701,0.9481570612610669,0.9485193681596299,0.948881398487974,0.9492431527733017,0.9496046315412092,0.9499658353156932,0.950326764619158,0.9506874199724215,0.9510478018947224,0.9514079109037265,0.9517677475155331,0.9521273122446822,0.9524866056041599,0.9528456281054056,0.9532043802583186,0.9535628625712634,0.9539210755510774,0.9542790197030759,0.9546366955310597,0.9549941035373201,0.9553512442226458,0.955708118086329,
0.9560647256261716,0.956421067338491,0.9567771437181263,0.9571329552584446,0.9574885024513466,0.9578437857872732,0.9581988057552107,0.9585535628426971,0.9589080575358283,0.9592622903192632,0.9596162616762304,0.9599699720885332,0.9603234220365561,0.9606766119992698,0.9610295424542377,0.9613822138776207,0.9617346267441839,0.9620867815273011,0.9624386786989614,0.962790318729774,0.9631417020889744,0.9634928292444291,0.963843700662642,0.9641943168087592,0.9645446781465745,0.9648947851385351,0.9652446382457469,
0.9655942379279795,0.9659435846436719,0.9662926788499377,0.9666415210025703,0.9669901115560479,0.9673384509635392,0.9676865396769084,0.9680343781467202,0.9683819668222451,0.9687293061514642,0.969076396581075,0.9694232385564956,0.9697698325218702,0.970116178920074,0.9704622781927181,0.970808130780155,0.9711537371214826,0.9714990976545498,0.9718442128159609,0.9721890830410812,0.972533708764041,0.9728780904177409,0.9732222284338563,0.9735661232428426,0.9739097752739395,0.9742531849551758,0.9745963527133741,
0.9749392789741559,0.9752819641619453,0.9756244086999749,0.9759666130102891,0.9763085775137494,0.9766503026300392,0.9769917887776673,0.9773330363739738,0.9776740458351333,0.9780148175761602,0.9783553520109127,0.9786956495520978,0.9790357106112746,0.97937553559886,0.9797151249241322,0.9800544789952351,0.9803935982191831,0.9807324830018651,0.9810711337480483,0.9814095508613835,0.9817477347444082,0.9820856857985518,0.9824234044241392,0.9827608910203951,0.9830981459854481,0.9834351697163352,0.9837719626090052,
0.9841085250583236,0.9844448574580762,0.984780960200973,0.985116833678653,0.9854524782816871,0.9857878943995831,0.9861230824207893,0.9864580427326981,0.9867927757216505,0.9871272817729397,0.9874615612708154,0.987795614598487,0.9881294421381279,0.9884630442708796,0.9887964213768549,0.989129573835142,0.9894625020238087,0.9897952063199055,0.9901276870994697,0.9904599447375294,0.9907919796081064,0.9911237920842207,0.9914553825378941,0.9917867513401535,0.9921178988610346,0.992448825469586,0.9927795315338723,
0.9931100174209779,0.9934402834970106,0.9937703301271053,0.9941001576754271,0.9944297665051756,0.9947591569785874,0.9950883294569406,0.9954172843005578,0.9957460218688093,0.9960745425201175,0.996402846611959,0.9967309345008691,0.997058806542445,0.9973864630913489,0.9977139045013114,0.9980411311251348,0.9983681433146974,0.998694941420955,0.9990215257939463,0.9993478967827943,0.999674054735711,1],r=[0,0.01262952101661779,0.02525904203323558,0.03788856304985337,0.049711876377871826,0.05991457469741709,
0.06898447286600867,0.0772092360066284,0.08477358579410943,0.091804259875822,0.09839255413111209,0.10460674144643575,0.11049941567981197,0.116112082049842,0.12147815731101994,0.12662500399558943,0.13157535287823224,0.1363483240840589,0.1409601768441825,0.14542487095720244,0.14975449458714327,0.15395959525747982,0.1580494394769152,0.16203221890462635,0.16591521589126665,0.16970493774704687,0.17340722665014255,0.1770273503750349,0.18057007776923878,0.18403974199157158,0.18744029384710506,0.19077534704588353,
0.1940482168277028,0.19726195310091915,0.20041936901604623,0.20352306571797985,0.2065754538818233,0.20957877252746188,0.21253510552056065,0.21544639609752403,0.21831445969536206,0.2211409953214818,0.2239275956609244,0.22667575608780954,0.22938688272237368,0.2320622996539648,0.2347032554328511,0.2373109289190679,0.2398864345642407,0.24243082719196402,0.24494510633355537,0.24743022016856214,0.2498870691130589,0.25231650909335385,0.25471935453807176,0.25709638111758565,0.2594483282563151,0.2617759014404253,
0.26407977434087276,0.2663605907694862,0.26861896648381073,0.27085549085472227,0.2730707284093175,0.2752652202602596,0.2774394854315987,0.27959402209005907,0.2817293086898797,0.28384580503848866,0.2859439532895821,0.2880241788695442,0.29008689134257926,0.2921324852194264,0.2941613407140744,0.296173824452494,0.29817029013704466,0.30015107916988515,0.30211652123843086,0.3040669348656343,0.3060026279276311,0.30792389814107823,0.3098310335223196,0.3117243128203384,0.3136040059252957,0.3154703742543138,
0.3173236711160275,0.3191641420553126,0.32099202517948666,0.3228075514671829,0.32461094506100485,0.32640242354498716,0.328182198207814,0.3299504742926743,0.331707451234572,0.33345332288585067,0.3351882777306368,0.33691249908885884,0.33862616531045336,0.3403294499603252,0.3420225219945948,0.3437055459286266,0.34537868199729943,0.34704208630795363,0.3486959109864158,0.3503403043164812,0.3519754108732058,0.35360137165034033,0.3552183241822174,0.3568264026603817,0.35842573804523775,0.3600164581729729,
0.3615986878579945,0.36317254899111157,0.36473816063367165,0.3662956391078557,0.36784509808331944,0.3693866486603606,0.37092039944977906,0.37244645664958986,0.3739649241187381,0.37547590344795784,0.37697949402790815,0.3784757931147127,0.3799648958930234,0.3814468955367197,0.3829218832673514,0.3843899484104266,0.38585117844964034,0.3873056590791346,0.38875347425387746,0.39019470623824154,0.3916294356528607,0.39305774151983813,0.3944797013063766,0.3958953909668962,0.3973048849837052,0.398708256406281,
0.4001055768892218,0.40149691672892146,0.40288234489901914,0.4042619290846755,0.40563573571572004,0.40700382999871526,0.4083662759479818,0.409723136415623,0.4110744731205898,0.41242034667682187,0.4137608166205015,0.41509594143645334,0.41642577858372254,0.41775038452036234,0.41906981472746097,0.420384123732435,0.4216933651316181,0.4229975916121692,0.42429685497332564,0.4255912061470252,0.4268806952179194,0.4281653714427998,0.42944528326945836,0.43072047835500143,0.4319910035836372,0.43325690508395387,
0.43451822824570774,0.43577501773613614,0.43702731751581336,0.43827517085406376,0.4395186203439474,0.44075770791683294,0.4419924748565711,0.44322296181328236,0.4444492088167707,0.445671255289577,0.4468891400596831,0.4481029013728773,0.44931257690479337,0.45051820377263313,0.4517198185465818,0.45291745726092675,0.4541111554248895,0.4553009480331786,0.45648686957627277,0.4576689540504429,0.45884723496752006,0.46002174536441914,0.46119251781242304,0.4623595844262362,0.46352297687281546,0.46468272637998137,
0.46583886374482125,0.46699141934188554,0.46814042313118737,0.469285904666008,0.47042789310051664,0.47156641719720765,0.4727015053341615,0.4738331855121353,0.47496148536148547,0.47608643214893004,0.4772080527841532,0.47832637382625737,0.479441421490067,0.4805532216522879,0.4816617998575264,0.482767181324172,0.48386939095014764,0.48496845331853117,0.4860643927030504,0.4871572330734569,0.48824699810078104,0.48933371116247054,0.4904173953474175,0.4914980734608752,0.4925757680292682,0.49365050130489957,
0.49472229527055495,0.49579117164401115,0.49685715188244534,0.49792025718675353,0.4989805085057765,0.5000379265404378,0.5010925317477942,0.5021443443450035,0.5031933843132081,0.5042396714013406,0.5052832251298499,0.5063240647943513,0.5073622094692027,0.5083976780110088,0.5094304890620533,0.5104606610536634,0.5114882122095067,0.512513160548822,0.5135355238895871,0.514555319851623,0.5155725658596376,0.5165872791462103,0.5175994767547175,0.518609175542202,0.5196163921821871,0.5206211431674361,0.5216234448126594,
0.522623313257169,0.5236207644674844,0.5246158142398872,0.5256084782029289,0.5265987718198912,0.5275867103912004,0.5285723090567965,0.5295555827984594,0.5305365464420905,0.5315152146599541,0.5324916019728768,0.533465722752407,0.5344375912229347,0.5354072214637743,0.5363746274112078,0.5373398228604933,0.5383028214678364,0.5392636367523269,0.5402222820978414,0.5411787707549106,0.5421331158425572,0.5430853303500971,0.5440354271389132,0.5449834189441957,0.545929318376653,0.5468731379241937,0.5478148899535785,
0.5487545867120445,0.5496922403289016,0.550627862817102,0.5515614660747821,0.5524930618867796,0.5534226619261247,0.5543502777555052,0.5552759208287091,0.5561996024920415,0.5571213339857184,0.5580411264452384,0.5589589909027302,0.5598749382882796,0.5607889794312336,0.5617011250614838,0.5626113858107291,0.5635197722137174,0.5644262947094677,0.5653309636424726,0.5662337892638817,0.5671347817326651,0.5680339511167598,0.5689313073941972,0.5698268604542126,0.5707206200983378,0.5716125960414764,0.5725027979129619,
0.5733912352575995,0.5742779175366926,0.5751628541290517,0.5760460543319896,0.5769275273622997,0.5778072823572206,0.5786853283753848,0.5795616743977544,0.5804363293285412,0.5813093019961135,0.5821806011538895,0.5830502354812169,0.5839182135842398,0.5847845439967515,0.5856492351810363,0.5865122955286974,0.5873737333614738,0.5882335569320437,0.5890917744248176,0.5899483939567188,0.5908034235779529,0.5916568712727662,0.5925087449601928,0.5933590524947909,0.5942078016673694,0.5950550002057023,0.5959006557752352,
0.5967447759797787,0.5975873683621958,0.5984284404050756,0.5992679995314003,0.6001060531052015,0.6009426084322078,0.601777672760483,0.6026112532810554,0.6034433571285388,0.6042739913817439,0.6051031630642828,0.6059308791451635,0.6067571465393772,0.6075819721084775,0.6084053626611514,0.6092273249537822,0.6100478656910059,0.6108669915262589,0.6116847090623188,0.6125010248518375,0.6133159453978685,0.614129477154385,0.6149416265267927,0.6157523998724356,0.6165618035010941,0.6173698436754775,0.6181765266117102,
0.6189818584798096,0.6197858454041609,0.6205884934639824,0.621389808693787,0.6221897970838367,0.6229884645805916,0.6237858170871525,0.6245818604636987,0.6253766005279194,0.6261700430554399,0.6269621937802424,0.627753058395081,0.628542642551892,0.6293309518621987,0.6301179918975115,0.6309037681897214,0.6316882862314913,0.6324715514766395,0.6332535693405202,0.6340343452003991,0.6348138843958234,0.6355921922289883,0.6363692739650979,0.6371451348327226,0.6379197800241517,0.6386932146957418,0.6394654439682601,
0.6402364729272251,0.6410063066232419,0.6417749500723333,0.6425424082562685,0.6433086861228857,0.6440737885864122,0.6448377205277801,0.645600486794939,0.6463620922031635,0.6471225415353585,0.6478818395423597,0.6486399909432315,0.6493970004255614,0.6501528726457492,0.650907612229295,0.6516612237710832,0.6524137118356617,0.6531650809575201,0.6539153356413631,0.6546644803623813,0.6554125195665185,0.6561594576707364,0.6569052990632761,0.6576500481039163,0.6583937091242286,0.6591362864278302,0.6598777842906337,
0.6606182069610937,0.6613575586604503,0.6620958435829714,0.6628330658961898,0.6635692297411403,0.664304339232592,0.665038398459279,0.6657714114841288,0.6665033823444867,0.6672343150523395,0.6679642135945361,0.6686930819330041,0.6694209240049673,0.6701477437231571,0.6708735449760244,0.6715983316279475,0.6723221075194388,0.6730448764673485,0.6737666422650662,0.6744874086827211,0.6752071794673781,0.6759259583432347,0.6766437490118126,0.6773605551521499,0.6780763804209894,0.6787912284529659,0.6795051028607908,
0.6802180072354358,0.6809299451463133,0.6816409201414555,0.6823509357476922,0.6830599954708256,0.6837681027958041,0.684475261186894,0.6851814740878487,0.6858867449220779,0.6865910770928132,0.6872944739832727,0.6879969389568239,0.6886984753571457,0.6893990865083861,0.6900987757153224,0.6907975462635155,0.6914954014194653,0.692192344430764,0.6928883785262472,0.6935835069161438,0.6942777327922245,0.694971059327949,0.6956634896786107,0.6963550269814812,0.6970456743559527,0.6977354349036788,0.6984243117087141,
0.6991123078376528,0.699799426339765,0.7004856702471326,0.7011710425747831,0.7018555463208224,0.7025391844665666,0.7032219599766716,0.7039038757992623,0.7045849348660602,0.7052651400925095,0.7059444943779024,0.7066230006055029,0.7073006616426692,0.707977480340976,0.7086534595363333,0.7093286020491069,0.7100029106842357,0.7106763882313484,0.7113490374648795,0.7120208611441837,0.7126918620136494,0.7133620428028108,0.7140314062264597,0.7146999549847549,0.7153676917633327,0.7160346192334134,0.7167007400519098,
0.7173660568615324,0.7180305722908951,0.7186942889546185,0.719357209453434,0.720019336374285,0.7206806722904288,0.7213412197615364,0.7220009813337923,0.7226599595399918,0.7233181568996399,0.7239755759190464,0.724632219091423,0.7252880888969768,0.7259431878030049,0.7265975182639874,0.727251082721679,0.7279038836052013,0.7285559233311324,0.7292072043035966,0.7298577289143543,0.7305074995428886,0.7311565185564938,0.7318047883103603,0.7324523111476625,0.7330990893996414,0.7337451253856901,0.7343904214134368,
0.7350349797788271,0.7356788027662066,0.7363218926484012,0.7369642516867986,0.7376058821314261,0.7382467862210323,0.7388869661831627,0.7395264242342394,0.7401651625796365,0.7408031834137572,0.741440488920109,0.7420770812713791,0.7427129626295076,0.7433481351457623,0.7439826009608107,0.744616362204793,0.7452494209973932,0.7458817794479106,0.7465134396553299,0.7471444037083915,0.7477746736856601,0.7484042516555937,0.7490331396766116,0.749661339797162,0.7502888540557885,0.7509156844811968,0.75154183309232,
0.7521673018983844,0.7527920928989733,0.7534162080840919,0.7540396494342302,0.7546624189204263,0.7552845185043287,0.7559059501382585,0.7565267157652705,0.7571468173192143,0.7577662567247944,0.7583850358976305,0.7590031567443164,0.7596206211624794,0.7602374310408384,0.7608535882592614,0.7614690946888241,0.7620839521918652,0.7626981626220444,0.7633117278243974,0.7639246496353923,0.7645369298829836,0.7651485703866682,0.7657595729575378,0.766369939398335,0.7669796715035041,0.7675887710592457,0.7681972398435691,
0.768805079626343,0.7694122921693485,0.7700188792263292,0.7706248425430432,0.7712301838573123,0.7718349048990725,0.7724390073904231,0.773042493045677,0.7736453635714078,0.7742476206664997,0.7748492660221942,0.7754503013221389,0.7760507282424334,0.776650548451678,0.7772497636110178,0.7778483753741909,0.7784463853875732,0.7790437952902235,0.7796406067139292,0.7802368212832507,0.7808324406155657,0.781427466321113,0.7820219000030365,0.7826157432574284,0.7832089976733718,0.7838016648329837,0.7843937463114573,
0.7849852436771035,0.7855761584913932,0.7861664923089979,0.7867562466778316,0.7873454231390905,0.787934023227294,0.7885220484703245,0.7891095003894674,0.78969638049945,0.7902826903084814,0.790868431318291,0.7914536050241666,0.7920382129149933,0.7926222564732914,0.7932057371752538,0.7937886564907835,0.7943710158835304,0.7949528168109292,0.7955340607242347,0.7961147490685586,0.7966948832829057,0.7972744648002096,0.7978534950473676,0.7984319754452766,0.7990099074088677,0.7995872923471412,0.8001641316632006,
0.8007404267542867,0.8013161790118125,0.8018913898213956,0.8024660605628923,0.8030401926104308,0.8036137873324438,0.8041868460917015,0.8047593702453443,0.8053313611449138,0.8059028201363865,0.806473748560204,0.8070441477513057,0.8076140190391593,0.808183363747792,0.8087521831958219,0.8093204786964877,0.8098882515576799,0.8104555030819705,0.8110222345666428,0.811588447303722,0.8121541425800035,0.8127193216770835,0.8132839858713867,0.8138481364341967,0.8144117746316832,0.8149749017249316,0.8155375189699711,
0.816099627617802,0.8166612289144245,0.8172223241008661,0.8177829144132087,0.8183430010826165,0.8189025853353624,0.819461668392856,0.8200202514716689,0.8205783357835622,0.821135922535513,0.8216930129297397,0.8222496081637287,0.8228057094302597,0.8233613179174317,0.8239164348086886,0.8244710612828438,0.8250251985141056,0.8255788476721027,0.8261320099219078,0.8266846864240632,0.8272368783346047,0.827788586805086,0.8283398129826024,0.8288905580098155,0.829440823024976,0.8299906091619481,0.8305399175502322,
0.8310887493149887,0.8316371055770607,0.8321849874529976,0.8327323960550771,0.8332793324913279,0.833825797865553,0.8343717932773512,0.8349173198221393,0.835462378591175,0.8360069706715774,0.83655109714635,0.8370947590944016,0.8376379575905678,0.8381806937056326,0.8387229685063494,0.8392647830554617,0.8398061384117246,0.8403470356299247,0.8408874757609016,0.8414274598515679,0.8419669889449293,0.8425060640801054,0.8430446862923493,0.8435828566130675,0.84412057606984,0.84465784568644,0.8451946664828526,
0.8457310394752956,0.8462669656762376,0.8468024460944176,0.8473374817348641,0.8478720735989141,0.8484062226842315,0.8489399299848259,0.8494731964910713,0.8500060231897245,0.8505384110639432,0.8510703610933044,0.8516018742538222,0.8521329515179663,0.852663593854679,0.8531938022293939,0.8537235776040522,0.8542529209371217,0.854781833183613,0.8553103152950976,0.8558383682197243,0.8563659929022369,0.8568931902839906,0.8574199613029695,0.8579463068938025,0.8584722279877803,0.8589977255128725,0.8595228003937431,
0.8600474535517671,0.860571685905047,0.8610954983684285,0.8616188918535168,0.8621418672686924,0.8626644255191268,0.8631865675067983,0.8637082941305079,0.8642296062858937,0.864750504865448,0.8652709907585314,0.8657910648513881,0.8663107280271617,0.8668299811659093,0.8673488251446174,0.867867260837216,0.8683852891145937,0.8689029108446124,0.8694201268921217,0.8699369381189732,0.8704533453840357,0.8709693495432085,0.8714849514494362,0.8720001519527227,0.8725149519001453,0.8730293521358685,0.873543353501158,
0.8740569568343945,0.8745701629710876,0.8750829727438886,0.8755953869826052,0.8761074065142143,0.8766190321628751,0.8771302647499432,0.8776411050939833,0.8781515540107819,0.8786616123133618,0.8791712808119936,0.8796805603142088,0.8801894516248137,0.8806979555459011,0.8812060728768631,0.8817138044144045,0.882221150952554,0.8827281132826775,0.883234692193491,0.8837408884710714,0.8842467028988698,0.8847521362577235,0.8852571893258682,0.8857618628789493,0.8862661576900348,0.8867700745296263,0.8872736141656715,
0.8877767773635756,0.8882795648862128,0.8887819774939383,0.8892840159445996,0.8897856809935476,0.8902869733936489,0.8907878938952963,0.8912884432464204,0.8917886221925007,0.8922884314765765,0.8927878718392589,0.8932869440187404,0.8937856487508071,0.8942839867688488,0.8947819588038698,0.8952795655845005,0.8957768078370067,0.8962736862853018,0.8967702016509559,0.8972663546532074,0.8977621460089725,0.8982575764328569,0.8987526466371646,0.899247357331909,0.8997417092248232,0.90023570302137,0.9007293394247513,
0.9012226191359196,0.9017155428535865,0.9022081112742335,0.9027003250921215,0.9031921849993009,0.9036836916856209,0.90417484583874,0.9046656481441341,0.9051560992851082,0.9056461999428044,0.9061359507962115,0.9066253525221751,0.9071144057954066,0.9076031112884924,0.9080914696719034,0.9085794816140041,0.9090671477810619,0.9095544688372559,0.9100414454446862,0.9105280782633834,0.9110143679513163,0.911500315164402,0.9119859205565143,0.9124711847794927,0.9129561084831508,0.9134406923152851,0.9139249369216844,
0.9144088429461374,0.9148924110304419,0.915375641814413,0.9158585359358921,0.9163410940307543,0.9168233167329184,0.9173052046743536,0.9177867584850888,0.9182679787932209,0.9187488662249219,0.9192294214044485,0.9197096449541494,0.9201895374944735,0.9206690996439783,0.9211483320193369,0.9216272352353475,0.9221058099049397,0.9225840566391834,0.9230619760472966,0.9235395687366524,0.9240168353127874,0.9244937763794097,0.9249703925384051,0.9254466843898465,0.9259226525320003,0.9263982975613347,0.9268736200725265,
0.9273486206584685,0.9278232999102779,0.9282976584173026,0.9287716967671293,0.9292454155455901,0.9297188153367703,0.9301918967230154,0.9306646602849383,0.9311371066014265,0.9316092362496491,0.9320810498050639,0.9325525478414245,0.9330237309307874,0.9334945996435183,0.9339651545483003,0.9344353962121393,0.9349053252003717,0.9353749420766716,0.9358442474030564,0.9363132417398943,0.9367819256459111,0.9372502996781967,0.9377183643922115,0.9381861203417932,0.9386535680791633,0.9391207081549341,0.9395875411181145,
0.9400540675161166,0.9405202878947628,0.9409862027982911,0.9414518127693627,0.9419171183490671,0.9423821200769295,0.9428468184909163,0.9433112141274416,0.9437753075213736,0.9442390992060405,0.9447025897132368,0.9451657795732294,0.9456286693147632,0.946091259465068,0.946553550549864,0.9470155430933681,0.9474772376182993,0.947938634645885,0.9483997346958671,0.9488605382865075,0.9493210459345939,0.9497812581554465,0.9502411754629217,0.9507007983694208,0.9511601273858931,0.9516191630218428,0.9520779057853349,
0.9525363561829999,0.9529945147200402,0.9534523819002355,0.9539099582259479,0.9543672441981287,0.9548242403163215,0.9552809470786706,0.9557373649819242,0.9561934945214409,0.9566493361911946,0.9571048904837803,0.957560157890419,0.9580151389009636,0.9584698340039032,0.9589242436863693,0.9593783684341407,0.9598322087316485,0.9602857650619817,0.9607390379068922,0.9611920277467992,0.9616447350607958,0.9620971603266527,0.9625493040208236,0.9630011666184514,0.9634527485933709,0.9639040504181161,0.9643550725639237,
0.9648058155007385,0.9652562796972185,0.9657064656207391,0.9661563737373994,0.9666060045120247,0.9670553584081741,0.9675044358881427,0.9679532374129683,0.9684017634424352,0.9688500144350788,0.969297990848191,0.9697456931378244,0.9701931217587966,0.9706402771646961,0.9710871598078853,0.9715337701395063,0.9719801086094847,0.9724261756665348,0.9728719717581634,0.9733174973306754,0.9737627528291767,0.9742077386975799,0.9746524553786086,0.9750969033138012,0.9755410829435159,0.9759849947069349,0.9764286390420681,
0.976872016385759,0.9773151271736872,0.9777579718403738,0.9782005508191854,0.9786428645423387,0.9790849134409042,0.9795266979448097,0.9799682184828468,0.9804094754826725,0.9808504693708154,0.9812912005726785,0.9817316695125434,0.9821718766135753,0.9826118222978263,0.9830515069862399,0.9834909310986545,0.9839300950538076,0.9843689992693404,0.9848076441618009,0.9852460301466487,0.9856841576382579,0.9861220270499221,0.9865596387938579,0.9869969932812083,0.9874340909220475,0.9878709321253837,0.9883075172991641,
0.9887438468502779,0.9891799211845601,0.9896157407067957,0.9900513058207229,0.9904866169290382,0.9909216744333976,0.9913564787344237,0.9917910302317056,0.9922253293238062,0.9926593764082635,0.9930931718815946,0.9935267161393003,0.9939600095758677,0.9943930525847745,0.9948258455584919,0.9952583888884886,0.9956906829652349,0.9961227281782049,0.9965545249158808,0.9969860735657569,0.9974173745143414,0.9978484281471626,0.9982792348487693,0.9987097950027365,0.9991401089916675,0.9995701771971982,1],w=[];
if(d.moaGL)d.moaGL.renderConvertRGBToLAB(),w=a(d);else{var e,h,v=[];for(e=0;e<n;e+=2)for(h=0;h<i;h+=2){var g=4*h+4*e*i,x,I,o,E,t,q;x=s.length;E=l[d[g]];t=l[d[g+1]];q=l[d[g+2]];I=0.00433891*E+0.00376234915*t+0.0018990604648*q;o=0.002126*E+0.007152*t+7.22E-4*q;E=1.77255E-4*E+0.00109475308*t+0.0087295537*q;I=0.008856<I?1<=I?s[x-1]:s[I*x|0]:7.787*I+16/116;o=0.008856<o?1<=o?s[x-1]:s[o*x|0]:7.787*o+16/116;E=0.008856<E?1<=E?s[x-1]:s[E*x|0]:7.787*E+16/116;x=116*o-16;I=500*(I-o);o=200*(o-E);v[0]=2.55*x;v[1]=
I+127;v[2]=o+127;c[v[0]+0.5|0]++;p[v[1]+0.5|0]++;y[v[2]+0.5|0]++}w[0]=c;w[1]=p;w[2]=y}h=j(w[1]);c=j(w[2]);e=f(h,0.1);g=f(c,0.1);h=f(h,0.9);c=f(c,0.9);e=(e+h)/2-127;h=(g+c)/2-127;g=0;e=0>e?-Math.pow(-0.5*e,1):Math.pow(0.5*e,1);g=0>h?-Math.pow(-0.5*h,1):Math.pow(0.5*h,1);c=127/(127+e);p=127/(127+g);if(d.moaGL)d.moaGL.renderConvertLABToRGB(c,p);else for(e=0;e<n;e++)for(h=0;h<i;h++)g=4*h+4*e*i,x=s.length,E=l[d[g]],t=l[d[g+1]],q=l[d[g+2]],I=0.00433891*E+0.00376234915*t+0.0018990604648*q,o=0.002126*E+0.007152*
t+7.22E-4*q,E=1.77255E-4*E+0.00109475308*t+0.0087295537*q,I=0.008856<I?1<=I?s[x-1]:s[I*x|0]:7.787*I+16/116,o=0.008856<o?1<=o?s[x-1]:s[o*x|0]:7.787*o+16/116,E=0.008856<E?1<=E?s[x-1]:s[E*x|0]:7.787*E+16/116,x=116*o-16,I=500*(I-o),o=200*(o-E),v[0]=2.55*x,v[1]=I+127,v[2]=o+127,v[1]*=c,v[2]*=p,y=r.length,w=(v[0]/2.55+16)/116,o=(v[1]-127)/500+w,I=w-(v[2]-127)/200,x=w*w*w,E=o*o*o,t=I*I*I,w=0.008856<x?x:(w-16/116)/7.787,o=0.008856<E?E:(o-16/116)/7.787,I=0.008856<t?t:(I-16/116)/7.787,o*=0.95047,w*=1,I*=1.08883,
E=3.2406*o+-1.5372*w+-0.4986*I,x=-0.9689*o+1.8758*w+0.0415*I,w=0.0557*o+-0.204*w+1.057*I,E=0>=E?0:1<=E?1:r[E*y|0],x=0>=x?0:1<=x?1:r[x*y|0],w=0>=w?0:1<=w?1:r[w*y|0],E=255*E+0.5|0,x=255*x+0.5|0,w=255*w+0.5|0,y=E+0.5|0,o=x+0.5|0,w=w+0.5|0,255<y?y=255:0>y&&(y=0),255<o?o=255:0>o&&(o=0),255<w?w=255:0>w&&(w=0),d[g]=y,d[g+1]=o,d[g+2]=w};var n=function(a,j){for(var f=[],g=a.length,l=0;l<g;l++){for(var c=0,p=0,y=0;y<g;y++)var s=Math.exp(-(y-l)*(y-l)/(2*j*j)),c=c+s*a[y],p=p+s;c/=p;f[l]=c}return f},i=function(a,
j,f,g){var l,c,p,y,s,r;for(c=0;c<f;c++)for(l=0;l<j;l++)p=j*c+l,y=a[4*p],s=a[4*p+1],r=a[4*p+2],g[p]=0.2*y+0.7*s+0.1*r,0<l&&(g[p]+=g[j*c+l-1]),0<c&&(g[p]+=g[j*(c-1)+l]),0<c&&0<l&&(g[p]-=g[j*(c-1)+l-1])};B.exports=e});C.define("/src/js/filters/histogramMapping.js",function(q,B){B.exports={fadeMapping:function(e,o){for(var h=0;256>h;h++)e.r[h]=h*(1-o)+e.r[h]*o+0.5|0,e.g[h]=h*(1-o)+e.g[h]*o+0.5|0,e.b[h]=h*(1-o)+e.b[h]*o+0.5|0,e.r[h]=0>e.r[h]?0:255<e.r[h]?255:e.r[h],e.g[h]=0>e.g[h]?0:255<e.g[h]?255:e.g[h],
e.b[h]=0>e.b[h]?0:255<e.b[h]?255:e.b[h]},mapHist:function(e,o){if(e.moaGL)e.moaGL.renderColorMap(o);else for(var h=e.length,a=0;a<h;)e[a]=o.r[e[a]],e[a+1]=o.g[e[a+1]],e[a+2]=o.b[e[a+2]],a+=4}}});C.define("/src/js/core/copy.js",function(q,B){function e(e){try{return document.createElement("canvas").getContext("2d").getImageData(0,0,1,Math.ceil(e/4)).data}catch(h){return Array(e)}}B.exports={copy:function(o){var h;if(o.moaGL)o.moaGL.renderIdentity();else{h="undefined"!==typeof Uint8ClampedArray?new Uint8ClampedArray(o.length):
e(o.length);for(var a=o.length,j=0;j<a;j+=4)h[j]=o[j],h[j+1]=o[j+1],h[j+2]=o[j+2],h[j+3]=o[j+3];return h}},copyTo:function(e,h){for(var a=h.length,j=0;j<a;j+=4)e[j]=h[j],e[j+1]=h[j+1],e[j+2]=h[j+2],e[j+3]=h[j+3];return e},makeData:function(o){return"undefined"!==typeof Uint8ClampedArray?new Uint8ClampedArray(o):e(o)}}});C.define("/src/js/legacy/whiten2.js",function(q,B){var e={},o=q("../filters/colorConversion"),h=q("./mask");e.whiten2=function(a,j,f,n,i){for(var d=[],e=0;256>e;e++)d[e]=0.04045>=
e/255?100*e/255/12.92:100*Math.pow((e/255+0.055)/1.055,2.4);for(var k=Array(j*f),e=0;e<j*f;e++)k[e]=0;for(var g=0.7*i,e=0;e<n.length;e++)h.maskspottool(j,f,k,n[e][0],n[e][1],i,g);for(var l,i=0;i<f;i++)for(e=0;e<j;e++)n=4*(e+j*i),k[e+j*i]&&(g=o.rgb2lab(a[n],a[n+1],a[n+2],d),l=Math.pow(g[1]-127,2)+Math.min(Math.pow(g[2]-154,2),Math.pow(g[2]-170,2)),l=Math.exp(-l/100)*k[e+j*i],g=o.lab2rgb([255*Math.pow(g[0]/255,1-0.4*l),g[1],(1-l)*(g[2]-127)+127]),a[n]=g[0],a[n+1]=g[1],a[n+2]=g[2])};B.exports=e});C.define("/src/js/legacy/mask.js",
function(q,B){B.exports={maskspottool:function(e,o,h,a,j,f,n,i){"undefined"===typeof i&&(i=1);for(var d=f*f,A=n*n,k=Math.max(0,Math.min(e-1,Math.round(a-f))),g=Math.max(0,Math.min(o-1,Math.round(j-f))),l=Math.max(0,Math.min(e-1,Math.round(a+f))),o=Math.max(0,Math.min(o-1,Math.round(j+f))),c,f=g;f<=o;f++)for(var p=k;p<=l;p++)g=p+e*f,c=(p-a)*(p-a)+(f-j)*(f-j),c<d&&(c=0>n?i:i*Math.exp(-c/(2*A)),c>h[g]&&(h[g]=c))}}});C.define("/src/js/legacy/redeye2.js",function(q,B){var e={};q("../filters/colorConversion");
var o=q("./mask");e.redeye2=function(e,a,j,f,n){for(var i=Array(a*j),d=0;d<a*j;d++)i[d]=0;for(var A=0.7*n,d=0;d<f.length;d++)o.maskspottool(a,j,i,f[d][0],f[d][1],n,A);for(var k,g,l,d=0;d<=j-1;d++)for(A=0;A<=a-1;A++)f=A+a*d,i[f]&&(n=e[4*f],k=e[4*f+1],g=e[4*f+2],l=n>k+g?1:0,0>l&&(l=0),l*=i[f],0.1<l&&(n=e[4*f],k=e[4*f+1],g=e[4*f+2],l*=3,1<l&&(l=1),n=(1-l)*n+l*(k+g)/2+0.5|0,e[4*f]=n))};B.exports=e});C.define("/src/js/legacy/selectiveblur.js",function(q,B){var e={},o=q("../filters/sharpness"),h=q("./mask");
e.selectiveblur=function(a,j,f,e,i){for(var d=Array(j*f),A=0;A<j*f;A++)d[A]=0;for(var k=0.5*i,A=0;A<e.length;A++)h.maskspottool(j,f,d,e[A][0],e[A][1],i,k,0.65);o.sharpenX(a,j,f,-100,d);o.sharpenY(a,j,f,-100,d)};B.exports=e});C.define("/src/js/filters/sharpness.js",function(q,B){var e={},o=q("../core/copy");e.bitmapBlend=function(a,f,e,i,d,h,k,g,l){var l="NN"===l,c="clarity"===g,p="clarityv2"===g,y="overlay"===g,g="laplaceAdd"===g,s,r,w,u,z,v=d/f,x=h/e,o,q,E,t,B,W,C,L,M,G,H,F;for(u=0;u<e;u++)for(z=
0;z<f;z++){var K=4*(z+f*u);l?(E=z*v+0.5|0,t=u*x+0.5|0,E>d-1?E=d-1:0>E&&(E=0),t>h-1?t=h-1:0>t&&(t=0),s=4*(E+d*t),E=i[s],t=i[s+1],o=i[s+2]):(E=z*v,t=u*x,s=Math.floor(E),r=Math.floor(t),o=s+1,q=r+1,E-=s,t-=r,o>d-1&&(o=d-1),s>d-1&&(s=d-1),0>o&&(o=0),0>s&&(s=0),q>h-1&&(q=h-1),r>h-1&&(r=h-1),0>q&&(q=0),0>r&&(r=0),w=4*(o+d*q),B=4*(s+d*q),W=4*(o+d*r),s=4*(s+d*r),o=i[w],r=i[w+1],w=i[w+2],C=i[B],q=i[B+1],B=i[B+2],L=i[W],M=i[W+1],W=i[W+2],G=i[s],H=i[s+1],F=i[s+2],s=G*(1-E)*(1-t)+L*E*(1-t)+C*t*(1-E)+o*t*E,r=
H*(1-E)*(1-t)+M*E*(1-t)+q*t*(1-E)+r*t*E,w=F*(1-E)*(1-t)+W*E*(1-t)+B*t*(1-E)+w*t*E,E=s,t=r,o=w);s=a[K];r=a[K+1];w=a[K+2];g?(a[K]=s+k*(E-128),a[K+1]=r+k*(t-128),a[K+2]=w+k*(o-128)):p?(r0=s,g0=r,b0=w,t=0.2*E+0.7*t+0.1*o,q=k*Math.pow(Math.abs(t-(0.2*s+0.7*r+0.1*w))/255,2),B=1-q,s=128>=s?B*s+2*q*s*E/256+0.5|0:B*s+q*(255-2*(255-s)*(255-E)/255)+0.5|0,r=128>=r?B*r+2*q*r*t/256+0.5|0:B*r+q*(255-2*(255-r)*(255-t)/255)+0.5|0,w=128>=w?B*w+2*q*w*o/256+0.5|0:B*w+q*(255-2*(255-w)*(255-o))+0.5|0,a[K]=s,a[K+1]=r,a[K+
2]=w):c?(r0=s,g0=r,b0=w,t=0.2*E+0.7*t+0.1*o,q=k*Math.pow(Math.abs(t-(0.2*s+0.7*r+0.1*w))/255,2),B=1-q,s=128>=s?B*s+2*q*s*E/256+0.5|0:B*s+q*(255-(255-(2*s-256))*(255-E)/256)+0.5|0,r=128>=r?B*r+2*q*r*t/256+0.5|0:B*r+q*(255-(255-(2*r-256))*(255-t)/256)+0.5|0,w=128>=w?B*w+2*q*w*o/256+0.5|0:B*w+q*(255-(255-(2*w-256))*(255-o)/256)+0.5|0,a[K]=s,a[K+1]=r,a[K+2]=w):y?(q=k,B=1-q,s=128>=s?B*s+2*q*s*E/256+0.5|0:B*s+q*(255-(255-(2*s-256))*(255-E)/256)+0.5|0,r=128>=r?B*r+2*q*r*t/256+0.5|0:B*r+q*(255-(255-(2*r-
256))*(255-t)/256)+0.5|0,w=128>=w?B*w+2*q*w*o/256+0.5|0:B*w+q*(255-(255-(2*w-256))*(255-o)/256)+0.5|0,a[K]=s,a[K+1]=r,a[K+2]=w):(a[K]=s*(1-k)+k*E,a[K+1]=r*(1-k)+k*t,a[K+2]=w*(1-k)+k*o);a[K+3]=255}};e.sharpenX=function(a,f,e,i,d){if(0!==i){var h="undefined"!==typeof d,k,g,l=!0;0>i&&(i=-i,l=!1);var c=4*(i/100),i=[],p=Math.ceil(2*c),y=2*p+1,s=0;for(g=0;g<y;g++)i[g]=Math.exp(-(p-g)*(p-g)/(2*c*c)),s+=i[g];g=o.makeData(4*f);var r,w,u,z,v,x;for(r=0;r<e;r++){for(c=0;c<f;c++)v=4*(r*f+c),g[4*c]=a[v],g[4*c+
1]=a[v+1],g[4*c+2]=a[v+2],g[4*c+3]=a[v+3];for(c=0;c<f;c++)if(!h||d[c+f*r]){v=4*(r*f+c);x=4*(c-p);z=u=w=0;if(c<p||c>f-1-p)for(k=0;k<y;k++)x=4*Math.max(0,Math.min(f-1,c+k-p)),w+=i[k]*g[x],u+=i[k]*g[x+1],z+=i[k]*g[x+2];else{w+=i[0]*g[x];u+=i[0]*g[x+1];z+=i[0]*g[x+2];w+=i[1]*g[x+4];u+=i[1]*g[x+5];z+=i[1]*g[x+6];w+=i[2]*g[x+8];u+=i[2]*g[x+9];z+=i[2]*g[x+10];for(k=3;k<y;k++)w+=i[k]*g[x+4*k],u+=i[k]*g[x+4*k+1],z+=i[k]*g[x+4*k+2]}l?h?(k=d[c+f*r],w=(1+0.5*k)*a[v]-k*w/s/2+0.5|0,u=(1+0.5*k)*a[v+1]-k*u/s/2+0.5|
0,z=(1+0.5*k)*a[v+2]-k*z/s/2+0.5|0):(w=1.5*a[v]-w/s/2+0.5|0,u=1.5*a[v+1]-u/s/2+0.5|0,z=1.5*a[v+2]-z/s/2+0.5|0):h?(k=d[c+f*r],w=(1-k)*a[v]+k*w/s+0.5|0,u=(1-k)*a[v+1]+k*u/s+0.5|0,z=(1-k)*a[v+2]+k*z/s+0.5|0):(w=w/s+0.5|0,u=u/s+0.5|0,z=z/s+0.5|0);a[v]=0>w?0:255<w?255:w;a[v+1]=0>u?0:255<u?255:u;a[v+2]=0>z?0:255<z?255:z}}}};e.sharpenY=function(a,f,e,i,d,h){if(0!==i){var h="mascara"===h,k=!0;0>i&&(i=-i,k=!1);for(var g="undefined"!==typeof d,l,c=4*(i/100),i=[],p=Math.ceil(2*c),y=2*p+1,s=0,r=0;r<y;r++)i[r]=
Math.exp(-(p-r)*(p-r)/(2*c*c)),s+=i[r];for(var c=o.makeData(4*e),w,u,z,v,x=0;x<f;x++){for(var I=0;I<e;I++)z=4*(I*f+x),c[4*I]=a[z],c[4*I+1]=a[z+1],c[4*I+2]=a[z+2],c[4*I+3]=a[z+3];for(I=0;I<e;I++)if(!g||d[x+f*I]){z=4*(I*f+x);v=4*(I-p);u=w=r=0;if(I<p||I>e-1-p)for(l=0;l<y;l++)v=4*Math.max(0,Math.min(e-1,I+l-p)),r+=i[l]*c[v],w+=i[l]*c[v+1],u+=i[l]*c[v+2];else{r+=i[0]*c[v];w+=i[0]*c[v+1];u+=i[0]*c[v+2];r+=i[1]*c[v+4];w+=i[1]*c[v+4+1];u+=i[1]*c[v+4+2];r+=i[2]*c[v+8];w+=i[2]*c[v+8+1];u+=i[2]*c[v+8+2];for(l=
3;l<y;l++)r+=i[l]*c[v+4*l],w+=i[l]*c[v+4*l+1],u+=i[l]*c[v+4*l+2]}k?g?(l=d[x+f*I],h&&a[z+1]>w/s&&(l=0),a[z]=(1+0.5*l)*a[z]-l*r/s/2+0.5|0,a[z+1]=(1+0.5*l)*a[z+1]-l*w/s/2+0.5|0,a[z+2]=(1+0.5*l)*a[z+2]-l*u/s/2+0.5|0):(a[z]=1.5*a[z]-r/s/2+0.5|0,a[z+1]=1.5*a[z+1]-w/s/2+0.5|0,a[z+2]=1.5*a[z+2]-u/s/2+0.5|0,a[z+3]=c[4*I+3]):g?(l=d[x+f*I],a[z]=(1-l)*a[z]+l*r/s+0.5|0,a[z+1]=(1-l)*a[z+1]+l*w/s+0.5|0,a[z+2]=(1-l)*a[z+2]+l*u/s+0.5|0):(a[z]=r/s+0.5|0,a[z+1]=w/s+0.5|0,a[z+2]=u/s+0.5|0)}}}};e.joesharpen=function(a,
f,n,i){a.moaGL?e.convolutionEffectBoxHybridSharpen(a,f,n,i):(e.sharpenX(a,f,n,i),e.sharpenY(a,f,n,i))};e.sharpen=function(a,f,n,i,d,h){if(a.moaGL)0!=d&&(e.joesharpen(a,f,n,i),1==d&&"normal"==h||("normal"==h?a.moaGL.renderBlendWithOriginal(d,1-d):"overlay"==h&&a.moaGL.renderBlendWithOriginalOverlayReverse(d)));else if(!(0==d||0==i)){var k,i=i*((f+n)/2/800);1==d&&"normal"==h?e.joesharpen(a,f,n,i):(k=o.copy(a),e.joesharpen(k,f,n,i),e.bitmapBlend(a,f,n,k,f,n,d,h))}};var h=function(a){var f,e,i,d,h,k,
g=[-1.3026537197817094,0.6419697923564902,0.019476473204185836,-0.00956151478680863,-9.46595344482036E-4,3.66839497852761E-4,4.2523324806907E-5,-2.0278578112534E-5,-1.624290004647E-6,1.30365583558E-6,1.5626441722E-8,-8.5238095915E-8,6.529054439E-9,5.059343495E-9,-9.91364156E-10,-2.27365122E-10,9.6467911E-11,2.394038E-12,-6.886027E-12,8.94487E-13,3.13092E-13,-1.12708E-13,3.81E-16,7.106E-15,-1.523E-15,-9.4E-17,1.21E-16,-2.8E-17];if(0>a)return 0;d=i=0;h=2/(2+a);k=4*h-2;for(f=27;0<f;f--)e=i,i=k*i-d+g[f],
d=e;return h*Math.exp(-a*a+0.5*(g[0]+k*i)-d)},a=function(a,f){var e;e=a/Math.SQRT2/f;e=0<=e?1-h(e):h(-e)-1;return(1+e)/2};e.convolutionEffectBoxHybridSharpen=function(j,f,e,i){var d=!1;j.moaGL&&(d=!0,0>i&&(i=-i,d=!1));var h,k,g,l,c,p,y,s,r,w,u,z,v,x,o,q,E,t;k=4*i/100*(f+e)/1600;g=!0;0>k&&(k=-k,g=!1);if(0!=k){l=Math.floor(1.5*k)+1;p=0;4<l&&(p=Math.floor((l/4-1)/2)+1,l=Math.floor(l/(2*p+1))+1);w=2*p+1;c=2*l+1;y=[];for(h=r=0;h<c;h++)r+=w*(a(h+0.5-l,k/w)-a(h-0.5-l,k/w));for(h=s=0;h<c;h++)y[h]=4096*(1/
r)*(a(h+0.5-l,k/w)-a(h-0.5-l,k/w)),s+=y[h];if(j.moaGL){g=[];l=4-((c-1)/2|0);c=4+((c-1)/2|0);for(h=0;9>h;h++)g[h]=h<l||h>c?0:y[h-l]/s;j.moaGL.renderConvolution(g,w,"horizontal")}else{s=y[0];y[0]=-y[0];for(h=1;h<c;h++)k=y[h],y[h]=-y[h]+s,s=k;y[c]=s;k=[];for(s=0;s<e;s++){h=s;r=void 0;for(r=0;r<h;r++);h=f*s;for(z=0;z<f;z++){o=x=v=2048;for(q=0;q<=c;q++)u=z+(q-l)*w-p-1,r=y[q],0>u?(E=(u+1)*k[0]|0,t=(u+1)*k[1]|0,u=(u+1)*k[2]|0):u>f-1?(E=k[4*(f-1)]+(u-(f-1))*(k[4*(f-1)]-k[4*(f-2)])|0,t=k[4*(f-1)+1]+(u-(f-
1))*(k[4*(f-1)+1]-k[4*(f-2)+1])|0,u=k[4*(f-1)+2]+(u-(f-1))*(k[4*(f-1)+2]-k[4*(f-2)+2])|0):(E=k[4*u]|0,t=k[4*u+1]|0,u=k[4*u+2]|0),v+=r*E|0,x+=r*t|0,o+=r*u|0;v=v/4096|0;x=x/4096|0;o=o/4096|0;g&&(v=(3*j[4*h]-v+1)/2|0,x=(3*j[4*h+1]-x+1)/2|0,o=(3*j[4*h+2]-o+1)/2|0);j[4*h]=255<v?255:0>v?0:v;j[4*h+1]=255<x?255:0>x?0:x;j[4*h+2]=255<o?255:0>o?0:o}}}}s=4*i/100*(f+e)/1600;h=!0;0>s&&(s=-s,h=!1);if(0!=s){g=Math.floor(1.5*s)+1;l=0;4<g&&(l=Math.floor((g/4-1)/2)+1,g=Math.floor(g/(2*l+1))+1);y=2*l+1;w=2*g+1;i=[];
for(c=k=0;c<w;c++)k+=y*(a(c+0.5-g,s/y)-a(c-0.5-g,s/y));for(c=p=0;c<w;c++)i[c]=0.5+4096*(1/k)*(a(c+0.5-g,s/y)-a(c-0.5-g,s/y)),p+=i[c];if(j.moaGL){f=[];e=4-((w-1)/2|0);w=4+((w-1)/2|0);for(c=0;9>c;c++)f[c]=c<e||c>w?0:i[c-e]/p;j.moaGL.renderConvolution(f,y,"vertical")}else{p=i[0];i[0]=-i[0];for(c=1;c<w;c++)s=i[c],i[c]=-i[c]+p,p=s;i[w]=p;s=[];for(p=0;p<f;p++){c=s;k=void 0;for(k=0;k<c;k++);for(r=0;r<e;r++){c=f*r+p;x=v=z=2048;for(o=0;o<=w;o++)t=r+(o-g)*y-l-1,k=i[o],0>t?(q=(t+1)*s[0]|0,E=(t+1)*s[1]|0,t=(t+
1)*s[2]|0):t>e-1?(q=s[4*(e-1)]+(t-(e-1))*(s[4*(e-1)]-s[4*(e-2)])|0,E=s[4*(e-1)+1]+(t-(e-1))*(s[4*(e-1)+1]-s[4*(e-2)+1])|0,t=s[4*(e-1)+2]+(t-(e-1))*(s[4*(e-1)+2]-s[4*(e-2)+2])|0):(q=s[4*t]|0,E=s[4*t+1]|0,t=s[4*t+2]|0),z+=k*q|0,v+=k*E|0,x+=k*t|0;z=z/4096|0;v=v/4096|0;x=x/4096|0;h&&(z=(3*j[4*c]-z+1)/2|0,v=(3*j[4*c+1]-v+1)/2|0,x=(3*j[4*c+2]-x+1)/2|0);j[4*c]=255<z?255:0>z?0:z;j[4*c+1]=255<v?255:0>v?0:v;j[4*c+2]=255<x?255:0>x?0:x}}}}j.moaGL&&d&&j.moaGL.renderBlendWithOriginal(-0.5,1.5)};B.exports=e});C.define("/src/js/mask-draw/colorsplash.js",
function(q,B){var e={},o=q("../filters/colorMatrixTransform"),h=q("./mask"),a=q("./drawtool");e.draw=function(a,f,e,i,d){d.constant=1;d.considerLuminosity=!1;h.masksimilarcolors(a,f,e,i,d)};e.preview=a.preview;e.drawStroke=a.drawStroke;e.init=function(j,f,e,i){if(!(f*e>i.length||0>f*e)&&4*f*e===j.length)h.initMaskOpaque(i,a.state),a.preprocess(j,function(){var a=[1,0,0,0,0,1,0,0,0,0,1,0];o.adjSaturation(a,0);o.colorMatrixTransform(j,a)})};B.exports=e});C.define("/src/js/filters/colorMatrixTransform.js",
function(q,B){var e={},o=q("./histogramMapping");e.mulcm=function(e,a){var j=Array(12);j[0]=e[0]*a[0]+e[1]*a[4]+e[2]*a[8];j[1]=e[0]*a[1]+e[1]*a[5]+e[2]*a[9];j[2]=e[0]*a[2]+e[1]*a[6]+e[2]*a[10];j[4]=e[4]*a[0]+e[5]*a[4]+e[6]*a[8];j[5]=e[4]*a[1]+e[5]*a[5]+e[6]*a[9];j[6]=e[4]*a[2]+e[5]*a[6]+e[6]*a[10];j[8]=e[8]*a[0]+e[9]*a[4]+e[10]*a[8];j[9]=e[8]*a[1]+e[9]*a[5]+e[10]*a[9];j[10]=e[8]*a[2]+e[9]*a[6]+e[10]*a[10];j[3]=e[0]*a[3]+e[1]*a[7]+e[2]*a[11]+e[3];j[7]=e[4]*a[3]+e[5]*a[7]+e[6]*a[11]+e[7];j[11]=e[8]*
a[3]+e[9]*a[7]+e[10]*a[11]+e[11];for(var f=0;12>f;f++)e[f]=j[f]};e.getIdentity=function(){return[1,0,0,0,0,1,0,0,0,0,1,0]};e.adjBrightnessContrast=function(h,a,j){var f=128*(1-j)*a,a=j*a;e.mulcm(h,[a,0,0,f,0,a,0,f,0,0,a,f])};e.adjSaturation=function(h,a){var j=0.213*(1-a),f=0.715*(1-a),n=0.072*(1-a);e.mulcm(h,[j+a,f,n,0,j,f+a,n,0,j,f,n+a,0])};e.adjBrightness=function(h,a){e.mulcm(h,[a,0,0,0,0,a,0,0,0,0,a,0])};e.adjContrast=function(h,a){var j=128*(1-a);e.mulcm(h,[a,0,0,j,0,a,0,j,0,0,a,j])};e.colorMatrixTransform=
function(e,a){if(e.moaGL)e.moaGL.renderColorMatrixTransform(a);else{var j=e.length,f,n,i,d=0;if(0===a[1]&&0===a[2]&&0===a[4]&&0===a[6]&&0===a[8]&&0===a[9]){j=[];f=[];n=[];for(i=0;256>i;i++)j[i]=Math.max(0,Math.min(255,a[0]*i+a[3]+0.5|0)),f[i]=Math.max(0,Math.min(255,a[5]*i+a[7]+0.5|0)),n[i]=Math.max(0,Math.min(255,a[10]*i+a[11]+0.5|0));o.mapHist(e,{r:j,g:f,b:n})}else for(;d<j;)f=a[0]*e[d]+a[1]*e[d+1]+a[2]*e[d+2]+a[3]+0.5|0,n=a[4]*e[d]+a[5]*e[d+1]+a[6]*e[d+2]+a[7]+0.5|0,i=a[8]*e[d]+a[9]*e[d+1]+a[10]*
e[d+2]+a[11]+0.5|0,e[d]=0>f?0:255<f?255:f,e[d+1]=0>n?0:255<n?255:n,e[d+2]=0>i?0:255<i?255:i,d+=4}};B.exports=e});C.define("/src/js/mask-draw/mask.js",function(q,B){var e={},o=q("../filters/colorConversion");e.initMaskTransparent=function(e,a,j,f){if(e.moaGL)f.maskTexId=e.moaGL.createMask(a,j),f.processedImageOverOriginal=!1;else for(a=0;a<e.length;a++)e[a]=0};e.initMaskOpaque=function(e,a,j,f){if(e.moaGL)f.maskTexId=e.moaGL.createMask(a,j),f.processedImageOverOriginal=!0;else for(a=0;a<e.length;a++)e[a]=
255};e.masksimilarcolors=function(e,a,j,f,n){var i=n.posX,d=n.posY,A=n.startX,k=n.startY,g=n.radius,l=n.sigmaC,c=n.addMask,p=n.colorLAB,y=n.alpha,n=n.considerLuminosity;g||(g=10);l||(l=6);"undefined"===typeof n&&(n=!1);var s=0.5*g,r,w=[];for(r=0;256>r;r++)w[r]=0.04045>=r/255?100*r/255/12.92:100*Math.pow((r/255+0.055)/1.055,2.4);var u=[];for(r=0;1024>r;r++)u[r]=Math.pow(r/1023,1/3);var z,v,x,A=Math.max(0,Math.min(a-1,Math.round(A))),k=Math.max(0,Math.min(j-1,Math.round(k))),A=4*(A+a*k),p="object"!==
typeof p?o.rgb2labwithcbrtmapping(e[A],e[A+1],e[A+2],w,u):p;r=Math.pow(g+s*(1-Math.sqrt(5/255)),2);z=Math.sqrt(r);var q=-2*l*l*Math.log(250/255),O=-2*l*l*Math.log(5/255),A=Math.max(0,Math.min(a-1,Math.round(i-z))),E=Math.max(0,Math.min(a-1,Math.round(i+z))),k=Math.max(0,Math.min(j-1,Math.round(d-z))),j=Math.max(0,Math.min(j-1,Math.round(d+z))),t;for(z=k;z<=j;z++)for(k=A;k<=E;k++)if(v=4*(k+a*z),t=k+a*z,x=(k-i)*(k-i)+(z-d)*(z-d),x<r){v=o.rgb2labwithcbrtmapping(e[v],e[v+1],e[v+2],w,u);v=n?Math.pow(p[0]-
v[0],2)+Math.pow(p[1]-v[1],2)+Math.pow(p[2]-v[2],2):Math.pow(p[1]-v[1],2)+Math.pow(p[2]-v[2],2);if(v<q)v=1;else if(v>O)continue;else v=Math.exp(-v/(2*l*l));x<g*g?x=1:(x=1-(Math.sqrt(x)-g)/s,x=Math.pow(x,2));x*=v;x*=y;x=c?255*(1*x+(1-x)*f[t]/255):255*(0*x+(1-x)*f[t]/255);x=0>x?0:255<x?255:x+0.5|0;f[t]=x}};e.maskradial=function(e,a,j,f,n){var e=n.posX,i=n.posY,n=n.sigmaR,d,A,k,g,l,c;g=n*n;l=-2*g*Math.log(1-1/255);c=-2*g*Math.log(1-254/255);var p;for(d=0;d<j;d++){p=(d-i)*(d-i);for(n=0;n<a;n++)A=n+a*
d,k=(n-e)*(n-e)+p,k<l?k=0:k>c?k=255:(k=1-Math.exp(-k/(2*g)),k=255*k+0.5,k=255<k?255:0>k?0:k|0),f[A]=k}};e.masklinear=function(e,a,j,f,n){var e=n.posX,i=n.posY,d=n.sigmaR,A=n.angle,k,g,l,c,p,y,n=d*d,d=Math.sqrt(-2*n*Math.log(1-1/255));c=Math.sqrt(-2*n*Math.log(1-254/255));p=-Math.sin(A);y=Math.cos(A);for(k=0;k<j;k++)for(A=0;A<a;A++)g=A+a*k,l=Math.abs(p*(e-A)+y*(k-i)),l=l<d?0:l>c?1:1-Math.exp(-l*l/(2*n)),l=255*l+0.5,l=255<l?255:0>l?0:l|0,f[g]=l};B.exports=e});C.define("/src/js/mask-draw/drawtool.js",
function(q,B){var e={},o=q("../filters/colorMatrixTransform"),h=q("../filters/sharpness"),a=q("./mask");e.sanitizeDrawParams=function(a){"undefined"===typeof a&&(a={});"number"!==typeof a.posX&&(a.posX=0);"number"!==typeof a.posY&&(a.posY=0);"number"!==typeof a.startX&&(a.startX=a.posX);"number"!==typeof a.startY&&(a.startY=a.posY);"number"!==typeof a.radius&&(a.radius=0);"number"!==typeof a.sigmaC&&(a.sigmaC=10);"number"!==typeof a.constant&&(a.constant=1);"number"!==typeof a.alpha&&(a.alpha=1);
"boolean"!==typeof a.addMask&&(a.addMask=!0);"boolean"!==typeof a.isFirstDraw&&(a.isFirstDraw=!0);"boolean"!==typeof a.considerLuminosity&&(a.considerLuminosity=!1);return a};e.draw=function(e,f,n,i,d){"colorsplash"===d.toolName||"blemish"===d.toolName?(d.constant=1,d.considerLuminosity=!1,a.masksimilarcolors(e,f,n,i,d)):"tiltshift"===d.toolName&&("linear"===d.tiltshiftMode?a.masklinear(e,f,n,i,d):"radial"===d.tiltshiftMode&&a.maskradial(e,f,n,i,d))};e.preview=function(a,f,n,i,d,h,k,g,l,c){if(a.moaGL)a.moaGL.redrawBitmapWithGLMask(e.state.processedTexID,
e.state.maskTexID,e.state.processedImageOverOriginal);else{"number"!==typeof k&&(k=0);"number"!==typeof g&&(g=0);"number"!==typeof l&&(l=d-1);"number"!==typeof c&&(c=h-1);for(var k=0>k?0:k>d-1?d-1:Math.round(k),g=0>g?0:g>h-1?h-1:Math.round(g),l=0>l?0:l>d-1?d-1:Math.round(l),c=0>c?0:c>h-1?h-1:Math.round(c),p,y;g<=c;g++)for(h=k;h<=l;h++)p=4*(d*g+h),y=i[d*g+h]/255,a[p]=y*n[p]+(1-y)*f[p],a[p+1]=y*n[p+1]+(1-y)*f[p+1],a[p+2]=y*n[p+2]+(1-y)*f[p+2]}};e.init=function(a,e,n,i,d){if(!(e*n>i.length||0>e*n)&&
4*e*n===a.length){var A="colorsplash"===d,k="blemish"===d,d="tiltshift"===d,g;if(A)for(g=0;g<i.length;g++)i[g]=255;else for(g=0;g<i.length;g++)i[g]=0;A?(e=[1,0,0,0,0,1,0,0,0,0,1,0],o.adjSaturation(e,0),o.colorMatrixTransform(a,e)):(k||d)&&h.joesharpen(a,e,n,-100)}};e.preprocess=function(a,f){var n;a.moaGL&&(n=a.moaGL.renderingMode,a.moaGL.renderingMode=RenderingMode.READ_SOURCE_WRITE_NONE,a.moaGL.createEffect());f&&f();a.moaGL&&(e.state.processedTexID=a.moaGL.glRenderingObjects.readTexture,a.moaGL.finalizeEffect(),
a.moaGL.renderingMode=n)};e.drawPoint=function(){};e.drawStroke=function(a,f,n,i,d){var h,k,g;a.moaGL&&(g=[]);for(h=i.startIndex;h<i.pointCount;h++)k=i.points[h],0==h&&MoaToolFirstDownProcessing(bitmap,i,d),a.moaGL&&(g.push(k.x/f),g.push(k.y/n));a.moaGL&&a.moaGL.maskAddPoints(e.state.maskTexID,f,n,g,i.radius,10,d.alpha,"smart"==i.brushMode?"splash":"normal",e.state.colorSelected,"erase"==i.brushMode)};B.exports=e});C.define("/src/js/filters/adjustments.js",function(q,B){var e={},o=q("./contrastCurve"),
h=q("./gamma"),a=q("./sharpness"),j=q("./colortemp"),f=q("../filters/colorMatrixTransform");e.contrast=function(a,e,d,f){e=Math.log(0.5+0.75*f/400)/Math.log(0.5);o.contrastCurve(a,1/e)};e.brightness=function(a,e,d,j){0>j?(j=Math.log(0.5+j/400)/Math.log(0.5),h.gamma(a,j)):(j=0.6*j/100+1,e=f.getIdentity(),f.adjBrightnessContrast(e,j,1),f.colorMatrixTransform(a,e))};e.saturation=function(a,e,d,j){j=j/100+1;e=f.getIdentity();f.adjSaturation(e,j);f.colorMatrixTransform(a,e)};e.sharpness=function(e,f,d,
j){a.sharpen(e,f,d,j,1,"normal")};e.colortemp=function(a,e,d,f){j.colortemp(a,f)};B.exports=e});C.define("/src/js/filters/contrastCurve.js",function(q,B){var e={},o=q("./histogramMapping");e.contrastCurve=function(e,a){for(var j=[],f=[],n=0;128>n;n++)j[n]=Math.round(127*Math.pow(n/127,a));for(n=128;256>n;n++)j[n]=Math.round(127+127*Math.pow((n-128)/127,1/a));f.r=j;f.g=j;f.b=j;o.mapHist(e,f)};B.exports=e});C.define("/src/js/filters/gamma.js",function(q,B){var e={},o=q("./histogramMapping");e.gamma=
function(e,a){"undefined"===typeof a&&(a=1);var j=[],f=[],n;for(n=0;256>n;n++)j[n]=255*Math.pow(n/255,a)+0.5|0;f.r=j;f.g=j;f.b=j;o.mapHist(e,f)};B.exports=e});C.define("/src/js/filters/colortemp.js",function(q,B){var e={},o=q("./histogramMapping");e.colortemp=function(e,a){var j=a;0!==j&&(j=100*j/Math.abs(j)*(1-Math.cos(j*Math.PI/200)));var f=[],n=[],i=[],d,A;0<j?(d=255+90.78*j/100,A=255-24*j/100,j=255-140*j/100):(d=255+155*j/100,A=255-44.625*j/100,j=255-245.31*j/100);for(var k=0;255>=k;k++)f[k]=
k*d/255+0.5|0,n[k]=k*A/255+0.5|0,i[k]=k*j/255+0.5|0,f[k]=255<f[k]?255:0>f[k]?0:f[k],n[k]=255<n[k]?255:0>n[k]?0:n[k],i[k]=255<i[k]?255:0>i[k]?0:i[k];o.mapHist(e,{r:f,g:n,b:i})};B.exports=e});C.define("/src/js/mask-draw/tiltshift.js",function(q,B){var e={},o=q("../filters/sharpness"),h=q("./mask"),a=q("./drawtool");e.draw=function(a,e,n,i,d){"linear"===d.tiltshiftMode?h.masklinear(a,e,n,i,d):"radial"===d.tiltshiftMode&&h.maskradial(a,e,n,i,d)};e.preview=a.preview;e.drawStroke=a.drawStroke;e.init=function(e,
f,n,i){if(!(f*n>i.length||0>f*n)&&4*f*n===e.length)h.initMaskTransparent(i,a.state),a.preprocess(e,function(){o.sharpen(e,f,n,-100,1,"normal")})};B.exports=e});C.define("/src/js/mask-draw/blemish.js",function(q,B){var e={},o=q("../filters/sharpness"),h=q("./mask"),a=q("./drawtool");e.draw=function(a,e,n,i,d){d.constant=1;d.considerLuminosity=!1;d.sigmaC=99999999999;h.masksimilarcolors(a,e,n,i,d)};e.preview=a.preview;e.drawStroke=a.drawStroke;e.init=function(e,f,n,i){if(!(f*n>i.length||0>f*n)&&4*f*
n===e.length)h.initMaskTransparent(i,a.state),a.preprocess(e,function(){o.sharpen(e,f,n,-100,1,"normal")})};B.exports=e});C.define("/src/js/mask-draw/redeye.js",function(q,B){var e={},o=q("./mask"),h=q("./drawtool");e.draw=function(a,e,f,n,i){i.constant=1;i.considerLuminosity=!1;i.sigmaC=1E17;i.startX=i.posX;i.startY=i.posY;i.alpha=1;o.masksimilarcolors(a,e,f,n,i)};e.preview=h.preview;e.drawStroke=h.drawStroke;e.init=function(a,j,f,n){if(!(j*f>n.length||0>j*f)&&4*j*f===a.length)o.initMaskTransparent(n,
h.state),h.preprocess(a,function(){e.redeye(a,j,f)})};e.redeye=function(a,e,f){var n,i,d,h,k,g;if(a.moaGL)a.moaGL.renderRedeye();else for(i=0;i<f;i++)for(n=0;n<e;n++)d=4*(n+e*i),h=a[d],k=a[d+1],g=a[d+2],h>=k+g&&(h=(k+g)/2,a[d]=0>h?0:255<h?255:h+0.5|0)};B.exports=e});C.define("/src/js/mask-draw/whiten.js",function(q,B){var e={},o=q("./mask"),h=q("./drawtool"),a=q("../filters/colorConversion");e.draw=function(a,e,n,i,d){d.constant=1;d.considerLuminosity=!0;d.sigmaC=10;d.startX=d.posX;d.startY=d.posY;
d.alpha=0.5;d.sigmaC=99999999999999;o.masksimilarcolors(a,e,n,i,d)};e.preview=h.preview;e.drawStroke=h.drawStroke;e.init=function(a,f,n,i){if(!(f*n>i.length||0>f*n)&&4*f*n===a.length)o.initMaskTransparent(i,h.state),h.preprocess(a,function(){e.whiten(a,f,n)})};e.whiten=function(e,f,n){if(e.moaGL)e.moaGL.renderWhiten();else{for(var i=[],d=0;256>d;d++)i[d]=0.04045>=d/255?100*d/255/12.92:100*Math.pow((d/255+0.055)/1.055,2.4);var h,k,g,l,c;for(g=0;g<n;g++)for(k=0;k<f;k++)d=4*(k+f*g),l=a.rgb2lab(e[d],
e[d+1],e[d+2],i),h=0,h+=Math.pow(l[1]-132,2),127>l[2]&&(h+=Math.pow(l[2]-127,2)),h=0.65*Math.exp(-h/98),c=255*Math.pow(l[0]/255,1/(0.5*h+1)),l=a.lab2rgb([c,l[1],(1-h)*(l[2]-127)+127]),e[d]=l[0],e[d+1]=l[1],e[d+2]=l[2]}};B.exports=e});C.define("/src/js/mask-draw/spraytan.js",function(q,B){var e={},o=q("../filters/blendWithColor"),h=q("./mask"),a=q("./drawtool");e.draw=function(e,f,n,i,d){d=a.sanitizeDrawParams(d);d.constant=1;d.alpha=0.1;d.considerLuminosity=!1;d.sigmaC=10;h.masksimilarcolors(e,f,
n,i,d)};e.preview=a.preview;e.drawStroke=a.drawStroke;e.init=function(e,f,n,i){if(!(f*n>i.length||0>f*n)&&4*f*n===e.length)h.initMaskTransparent(i,a.state),a.preprocess(e,function(){var a=[30,30,30,1];o.colorSoft(e,f,n,a[0],a[1],a[2],a[3])})};B.exports=e});C.define("/src/js/filters/blendWithColor.js",function(q,B){var e={};q("./colorMatrixTransform");var o=q("./histogramMapping"),h=function(a,e,f,n,i){var d=[];d.r=[];d.g=[];d.b=[];var h=1-i;if("normal"==a)for(a=0;256>a;a++)d.r[a]=h*a+i*e+0.5|0,d.g[a]=
h*a+i*f+0.5|0,d.b[a]=h*a+i*n+0.5|0,d.r[a]=255<d.r[a]?255:0>d.r[a]?0:d.r[a],d.g[a]=255<d.g[a]?255:0>d.g[a]?0:d.g[a],d.b[a]=255<d.b[a]?255:0>d.b[a]?0:d.b[a];else if("overlay"==a)for(a=0;256>a;a++)128>=a?(d.r[a]=h*a+2*i*a*e/255+0.5|0,d.g[a]=h*a+2*i*a*f/255+0.5|0,d.b[a]=h*a+2*i*a*n/255+0.5|0):(d.r[a]=h*a+i*(255-(255-a)*(255-e)/127.5)+0.5|0,d.g[a]=h*a+i*(255-(255-a)*(255-f)/127.5)+0.5|0,d.b[a]=h*a+i*(255-(255-a)*(255-n)/127.5)+0.5|0),d.r[a]=255<d.r[a]?255:0>d.r[a]?0:d.r[a],d.g[a]=255<d.g[a]?255:0>d.g[a]?
0:d.g[a],d.b[a]=255<d.b[a]?255:0>d.b[a]?0:d.b[a];else if("multiply"==a)for(a=0;256>a;a++)d.r[a]=h*a+i*e*a/255+0.5|0,d.g[a]=h*a+i*f*a/255+0.5|0,d.b[a]=h*a+i*n*a/255+0.5|0,d.r[a]=255<d.r[a]?255:0>d.r[a]?0:d.r[a],d.g[a]=255<d.g[a]?255:0>d.g[a]?0:d.g[a],d.b[a]=255<d.b[a]?255:0>d.b[a]?0:d.b[a];else if("darken"==a)for(a=0;256>a;a++)d.r[a]=h*a+i*(a<e?a:e)+0.5|0,d.g[a]=h*a+i*(a<f?a:f)+0.5|0,d.b[a]=h*a+i*(a<n?a:n)+0.5|0,d.r[a]=255<d.r[a]?255:0>d.r[a]?0:d.r[a],d.g[a]=255<d.g[a]?255:0>d.g[a]?0:d.g[a],d.b[a]=
255<d.b[a]?255:0>d.b[a]?0:d.b[a];else if("screen"==a)for(a=0;256>a;a++)d.r[a]=h*a+i*(255-(255-a)*(255-e)/255)+0.5|0,d.g[a]=h*a+i*(255-(255-a)*(255-f)/255)+0.5|0,d.b[a]=h*a+i*(255-(255-a)*(255-n)/255)+0.5|0,d.r[a]=255<d.r[a]?255:0>d.r[a]?0:d.r[a],d.g[a]=255<d.g[a]?255:0>d.g[a]?0:d.g[a],d.b[a]=255<d.b[a]?255:0>d.b[a]?0:d.b[a];else if("soft"==a)for(var k,a=0;256>a;a++)k=a*e>>8,d.r[a]=h*a+i*(k+(a*(255-((255-a)*(255-e)>>8)-k)>>8))+0.5|0,k=a*f>>8,d.g[a]=h*a+i*(k+(a*(255-((255-a)*(255-f)>>8)-k)>>8))+0.5|
0,k=a*n>>8,d.b[a]=h*a+i*(k+(a*(255-((255-a)*(255-n)>>8)-k)>>8))+0.5|0,d.r[a]=255<d.r[a]?255:0>d.r[a]?0:d.r[a],d.g[a]=255<d.g[a]?255:0>d.g[a]?0:d.g[a],d.b[a]=255<d.b[a]?255:0>d.b[a]?0:d.b[a];return d};e.colorOverlay=function(a,e,f,n,i,d,q){e=h("overlay",n,i,d,q);o.mapHist(a,e)};e.colorMultiply=function(a,e,f,n,i,d,q){e=h("multiply",n,i,d,q);o.mapHist(a,e)};e.colorDarken=function(a,e,f,n,i,d,q){e=h("darken",n,i,d,q);o.mapHist(a,e)};e.colorSoft=function(a,e,f,n,i,d,q){e=h("soft",n,i,d,q);o.mapHist(a,
e)};e.colorColor=function(a,e,f,h,i,d,o){var k,g,l,c=1-o,p,y,h=h/255;k=i/255;g=d/255;l=Math.max(h,k,g);var d=Math.min(h,k,g),s,i=(l+d)/2;if(l==d)s=d=0;else{p=l-d;d=0.5<i?p/(2-l-d):p/(l+d);switch(l){case h:s=(k-g)/p+(k<g?6:0);break;case k:s=(g-h)/p+2;break;case g:s=(h-k)/p+4}s/=6}if(a.moaGL)return a.moaGL.renderColorBlendColor([s,d,i],1,o),!0;for(y=0;y<f;y++)for(p=0;p<e;p++){l=4*(y*e+p);h=a[l];k=a[l+1];g=a[l+2];var r=h,w=k,u=g,i=(0.212671*h+0.71516*k+0.072169*g)/255,z=6*s,v=0.5<i?2*d*(1-i):2*d*i,x=
v*(1-Math.abs(z%2-1));1>z?(h=v,k=x,g=0):2>z?(h=x,k=v,g=0):3>z?(h=0,k=v,g=x):4>z?(h=0,k=x,g=v):5>z?(h=x,k=0,g=v):6>z&&(h=v,k=0,g=x);i-=0.5*v;h=255*(h+i)+0.5|0;k=255*(k+i)+0.5|0;g=255*(g+i)+0.5|0;h=255<h?255:0>h?0:h;k=255<k?255:0>k?0:k;g=255<g?255:0>g?0:g;h=c*r+o*h;k=c*w+o*k;g=c*u+o*g;h=255<h?255:0>h?0:h;k=255<k?255:0>k?0:k;g=255<g?255:0>g?0:g;a[l]=h;a[l+1]=k;a[l+2]=g}};e.colorScreen=function(a,e,f,n,i,d,q){e=h("screen",n,i,d,q);o.mapHist(a,e)};e.normalBlend=function(a,e,f,n,i,d,q){e=h("normal",n,i,
d,q);o.mapHist(a,e)};B.exports=e});C.define("/src/js/mask-draw/shinereduce.js",function(q,B){var e={},o=q("../filters/blendWithColor"),h=q("./mask"),a=q("./drawtool"),j=q("../filters/colorConversion");e.findBrightest=function(a,e,i,d,h,j){var d=Math.round(d),h=Math.round(h),g,l,c,p,y=Math.max(0,Math.min(e-1,Math.round(d-j)));l=Math.max(0,Math.min(i-1,Math.round(h-j)));var s=Math.max(0,Math.min(e-1,Math.round(d+j))),i=Math.max(0,Math.min(i-1,Math.round(h+j))),r=4*(d+e*h),w=[a[r],a[r+1],a[r+2]],u=0.2*
a[r]+0.7*a[r+1]+0.1*a[r+2];for(c=l;c<=i;c++)for(l=y;l<=s;l++)r=4*(e*c+l),p=Math.pow(l-d,2)+Math.pow(c-h,2),g=0.2*a[r]+0.7*a[r+1]+0.1*a[r+2],g*=Math.exp(-p/(2*j*j)),g>u&&(w=[a[r],a[r+1],a[r+2]],u=g);return w};e.draw=function(f,n,i,d,o){o=a.sanitizeDrawParams(o);o.constant=1;o.alpha=0.5;o.considerLuminosity=!0;o.sigmaC=25;console.log("draw");if(o.isFirstDraw){o.isFirstDraw=!1;var k=e.findBrightest(f,n,i,o.posX,o.posY,o.radius);o.colorLAB=j.rgb2labwithcbrtmapping(k[0],k[1],k[2]);console.log("First draw",
k,o.colorLAB)}h.masksimilarcolors(f,n,i,d,o)};e.preview=a.preview;e.drawStroke=a.drawStroke;e.init=function(e,j,i,d){if(!(j*i>d.length||0>j*i)&&4*j*i===e.length)h.initMaskTransparent(d,a.state),a.preprocess(e,function(){var a=[190,110,62,0.26];o.colorMultiply(e,j,i,a[0],a[1],a[2],a[3])})};B.exports=e});C.define("/src/js/mask-draw/blush.js",function(q,B){var e={},o=q("../filters/blendWithColor"),h=q("./mask"),a=q("./drawtool");e.draw=function(e,f,n,i,d){d=a.sanitizeDrawParams(d);d.constant=1;d.alpha=
0.1;d.considerLuminosity=!1;d.sigmaC=15;h.masksimilarcolors(e,f,n,i,d)};e.drawStroke=a.drawStroke;e.preview=a.preview;e.init=function(e,f,n,i){if(!(f*n>i.length||0>f*n)&&4*f*n===e.length)h.initMaskTransparent(i,a.state),a.preprocess(e,function(){var a=[190,30,20,0.34];o.colorSoft(e,f,n,a[0],a[1],a[2],a[3])})};B.exports=e});C.define("/src/js/mask-draw/lipstick.js",function(q,B){var e={},o=q("../filters/blendWithColor"),h=q("./mask"),a=q("./drawtool"),j=q("../filters/colorConversion");e.getColorClosestToLip=
function(a,e,i,d,h,k){var d=Math.round(d),h=Math.round(h),g=[213,128,118],l=[],c;for(c=0;256>c;c++)l[c]=0.04045>=c/255?100*c/255/12.92:100*Math.pow((c/255+0.055)/1.055,2.4);var g=j.rgb2labwithcbrtmapping(g[0],g[1],g[2],l),p=[],y,s,r;c=Math.max(0,Math.min(e-1,d-3*k));y=Math.max(0,Math.min(i-1,h-3*k));var w=Math.max(0,Math.min(e-1,d+3*k)),u=Math.max(0,Math.min(i-1,h+3*k));"number"!==typeof window.gain&&(window.gain=1);"number"!==typeof window.sigma1&&(window.sigma1=15);"number"!==typeof window.sigmaHue&&
(window.sigmaHue=0.1);"number"!==typeof window.pow&&(window.pow=0.25);var o,v=-1,x;for(s=y;s<=u;s++)for(y=c;y<=w;y++){x=4*(e*s+y);r=Math.pow(y-d,2)+Math.pow(s-h,2);var i=a[x],q=a[x+1],O=a[x+2],E,t,B;E=Math.min(i,q,O);p=t=Math.max(i,q,O);B=t-E;if(0!=B)E=B/t;else return i=E=0,[i,E,p];i=i==t?(q-O)/B:q==t?2+(O-i)/B:4+(i-q)/B;i*=60;0>i&&(i+=360);i=[i,E,p];p=j.rgb2labwithcbrtmapping(a[x],a[x+1],a[x+2],l);q=i[0];i=Math.cos(q*Math.PI/180)-1;q=Math.sin(q*Math.PI/180);i=Math.exp(-(i*i+q*q)/(2*sigmaHue*sigmaHue));
q=g;O=window.sigma1;p=Math.exp(-(Math.pow(q[1]-p[1],2)+Math.pow(q[2]-p[2],2))/(2*O*O));r=i*p*Math.exp(-r/(2*k*k));r>v&&(o=[a[x],a[x+1],a[x+2]],v=r,console.log("new best"))}return o};e.draw=function(f,n,i,d,o){o=a.sanitizeDrawParams(o);o.constant=1;o.alpha=0.5;o.considerLuminosity=!0;o.sigmaC=7;console.log("draw");if(o.isFirstDraw){o.isFirstDraw=!1;var k=e.getColorClosestToLip(f,n,i,o.posX,o.posY,o.radius/3);o.colorLAB=j.rgb2labwithcbrtmapping(k[0],k[1],k[2]);console.log("First draw",k,o.colorLAB)}h.masksimilarcolors(f,
n,i,d,o)};e.drawStroke=a.drawStroke;e.preview=a.preview;e.init=function(e,j,i,d){if(!(j*i>d.length||0>j*i)&&4*j*i===e.length)h.initMaskTransparent(d,a.state),a.preprocess(e,function(){var a=[192,42,45,0.6];o.colorSoft(e,j,i,a[0],a[1],a[2],a[3])})};B.exports=e});C.define("/src/js/mask-draw/mascara.js",function(q,B){var e={},o=q("../filters/sharpness"),h=q("./mask"),a=q("./drawtool"),j=q("../core/copy");e.draw=function(e,j,i,d,o){o=a.sanitizeDrawParams(o);o.constant=1;o.considerLuminosity=!1;o.sigmaC=
99999999999;h.masksimilarcolors(e,j,i,d,o)};e.preview=a.preview;e.drawStroke=a.drawStroke;e.init=function(e,n,i,d){if(!(n*i>d.length||0>n*i)&&4*n*i===e.length)h.initMaskTransparent(d,a.state),a.preprocess(e,function(){var a=j.copy(e);o.sharpen(e,n,i,100,1,"normal");if(!e.moaGL){var d,g,l,c;for(d=0;d<n*i;d++)g=4*d,l=0.2*a[g]+0.7*a[g+1]+0.1*a[g+2],c=0.2*e[g]+0.7*e[g+1]+0.1*e[g+2],c>l&&(e[g]=a[g],e[g+1]=a[g+1],e[g+2]=a[g+2])}})};B.exports=e});C.define("/proclist/src/js/MoaLiteProclistManager.coffee",
function(q,B){var e;e=q("./MoaLiteProclistProcessorRunning");B.exports={MLPLLoadEffect:function(e){var h,a;h=JSON.parse(e);if(!h)return console.log("Invalid JSON string."),null;e=h.identifier;a=h.processors;return!e||!a?(console.log("Missing or problematic identifier property and/or processors property."),null):h},MLPLRunEffect:function(o,h,a){var j,f,n;j=o.identifier;o=o.processors;if(!j||!o)return console.log("Missing or problematic identifier property and/or processors property."),!1;h.data.moaGL&&
h.data.moaGL.createEffect();j=0;for(n=o.length;j<n;j++)if(f=o[j],f=e.MLPLRunProcessor(f,h,a),!f)return!1;h.data.moaGL&&h.data.moaGL.finalizeEffect();return!0}}});C.define("/proclist/src/js/MoaLiteProclistProcessorRunning.coffee",function(q,B){var e,o,h,a,j,f={}.hasOwnProperty,n=function(a,l){n.__super__.constructor.call(this);this.name="Processor Error";this.processorName=l;this.message=a;this.toString=function(){return""+this.name+": "+this.message+" ("+this.processorName+")"}},i=n,d=Error,A=function(){this.constructor=
i},k;for(k in d)f.call(d,k)&&(i[k]=d[k]);A.prototype=d.prototype;i.prototype=new A;i.__super__=d.prototype;e=n;j={original:function(a,l){var c;c=q("../../../src/js/core/copy");l.data=c.copy(l.data);return!0},legacyProcessor:function(a,l,c){var p;p=q("../../../src/js/filters/legacy/legacyProcessor");if(l&&l.data.moaGL)return!0;a=null!=a?a.legacyName:void 0;if(null==a)throw new e("Legacy name '"+a+"' not found.","legacyProcessor");p[a](l.data,l.width,l.height,c);return!0},legacy_compare_processor:function(a,
l,c,e){return(void 0)(a,l,c,e)},colorMatrixTransform:function(a,l,c){var p,d,s,r,f,i,h;p=!1;f=q("../../../src/js/filters/colorMatrixTransform");r=null!=a?a.operations:void 0;a=[1,0,0,0,0,1,0,0,0,0,1,0];if(r){i=0;for(h=r.length;i<h;i++)switch(d=r[i],p=null!=d?d.value:void 0,null!=d?d.operation:void 0){case "hardSet":p=null!=d?d.gain:void 0;d=null!=d?d.entries:void 0;if(null==p||null==d)throw new e("invalid entries val for hardSet operation.","colorMatrixTransform");for(s=0;12>s;)a[s]=d[s],0===s||5===
s||10===s?a[s]=a[s]*p*c.intensity+(1-c.intensity):3!==s&&(7!==s&&11!==s)&&(a[s]=a[s]*p*c.intensity),s++;p=!0;break;case "saturation":p=o(p,1,c.intensity);f.adjSaturation(a,p);p=!0;break;case "brightness":p=o(p,1,c.intensity);f.adjBrightness(a,p);p=!0;break;case "contrast":p=o(p,1,c.intensity);f.adjContrast(a,p);p=!0;break;default:throw new e("Operation "+(null!=d?d.operation:void 0)+" not found.","colorMatrixTransform");}}f.colorMatrixTransform(null!=l?l.data:void 0,a);return p},histogramMapping:function(a,
l,c){var p;p=q("../../../src/js/filters//histogramMapping");a=null!=a?a.histMap:void 0;if(!a)throw new e("histMap dne or is not an object.","histogramMapping");a=h(a);p.fadeMapping(a,null!=c?c.intensity:void 0);p.mapHist(null!=l?l.data:void 0,a);return!0},vignette:function(a,l,c){var p,d,s,r,f,i,h,j;f=q("../../../src/js/filters/vignette");s=null!=a?a.color:void 0;d=null!=a?a.blendMode:void 0;p=null!=a?a.shape:void 0;j=null!=p?p.vignetteScale:void 0;h=null!=p?p.shapeMode:void 0;i=null!=p?p.scaling:
void 0;a=null!=p?p.dx:void 0;r=null!=p?p.dy:void 0;p=parseFloat(s.a/255);switch(i){case "average":j=(l.width+l.height)/2*j/(c.intensity+1E-9);c=!1;break;case "max":j=Math.max(l.width,l.height)*j/(c.intensity+1E-9);c=!1;break;case "stretch":j/=c.intensity+1E-9;c=!0;break;default:throw new e("scaling mode "+i+" not defined.","vignette");}f.vignette(l.data,l.width,l.height,j,s.r,s.g,s.b,p,d,h,c,a,r);return!0},contrast:function(a,l,c){var p;p=q("../../../src/js/filters/contrastCurve");a=null!=a?a.value:
void 0;if(null==a)throw new e("value is missing.","contrast");c=o(a,1,c.intensity);p.contrastCurve(l.data,c);return!0},noise:function(a,l,c){var p,d;d=q("../../../src/js/core/rng");p=q("../../../src/js/filters/noise");a=null!=a?a.intensity:void 0;if(null==a)throw new e("intensity is missing.","noise");a*=c.intensity;c=new d.RNG(c.seed);p.noise(l.data,l.width,l.height,a,c.nextInt());return!0},blendWithColor:function(a,l,c){var p,d,s;s=q("../../../src/js/filters/blendWithColor");d=null!=a?a.color:void 0;
p=null!=a?a.blendMode:void 0;a=null!=a?a.alpha:void 0;if(null==d||null==a)throw new e("color or alpha param is missing.","blendWithColor");a*=c.intensity;switch(p){case "overlay":s.colorOverlay(l.data,l.width,l.height,d.r,d.g,d.b,a);l=!0;break;case "multiply":s.colorMultiply(l.data,l.width,l.height,d.r,d.g,d.b,a);l=!0;break;case "screen":s.colorScreen(l.data,l.width,l.height,d.r,d.g,d.b,a);l=!0;break;case "darken":s.colorDarken(l.data,l.width,l.height,d.r,d.g,d.b,a);l=!0;break;case "color":s.colorColor(l.data,
l.width,l.height,d.r,d.g,d.b,a);l=!0;break;default:s.normalBlend(l.data,l.width,l.height,d.r,d.g,d.b,a),l=!0}return l},gamma:function(a,l,c){var p;p=q("../../../src/js/filters/gamma");a=null!=a?a.value:void 0;if(null==a)throw new e("value is missing.","gamma");c=o(a,1,c.intensity);p.gamma(l.data,c);return!0},flare:function(a,l,c){var p,d,s,r,f,i,h,j,n;j=q("../../../src/js/filters/flare");d=null!=a?a.color:void 0;p=null!=a?a.blendMode:void 0;n=null!=a?a.type:void 0;f=null!=a?a.dx:void 0;i=null!=a?
a.dy:void 0;s=null!=a?a.dsx:void 0;r=null!=a?a.dsy:void 0;h=null!=a?a.fScale:void 0;if(null==n||null==d||null==p||null==f||null==i||null==s||null==r||null==h)throw new e("some params are incorrect or missing.","flare");a=parseFloat(d.a/255);a*=c.intensity;j.flare(l.data,l.width,l.height,h,d.r,d.g,d.b,a,n,f,i,s,r,p);return!0},intensityMap:function(a,l,c){var p,d,s,r;r=q("../../../src/js/filters/intensityMap");s=q("../../../src/js/filters/histogramMapping");d=null!=a?a.histMap:void 0;p=null!=a?a.blendMode:
void 0;a=null!=a?a.alpha:void 0;if(null==d||null==a)throw new e("histMap or alpha missing or problematic.","intensityMap");d=h(d);s.fadeMapping(d,null!=c?c.intensity:void 0);r.mapIntensity(l.data,d,p,a*c.intensity);return!0},sharpness:function(a,l,c){var p,d,s;s=q("../../../src/js/filters/sharpness");d=null!=a?a.amount:void 0;p=null!=a?a.alpha:void 0;a=null!=a?a.blendMode:void 0;if(null==d||null==a||null==p)throw new e("amount, blendMode, or alpha param is missing.","sharpness");p*=c.intensity;s.sharpen(l.data,
l.width,l.height,d,p,a);return!0},gradient:function(a,l,c){var p,d,s,r,f,i,h,j,n,k,o,E;h=q("../../../src/js/filters/gradient");r=null!=a?a.colors:void 0;i=null!=a?a.opacities:void 0;f=null!=a?a.gradientShape:void 0;j=null!=a?a.scale:void 0;o=null!=a?a.xCenter:void 0;E=null!=a?a.yCenter:void 0;d=null!=a?a.angle:void 0;d*=Math.PI/180;p=null!=a?a.alpha:void 0;s=null!=a?a.blendMode:void 0;n=(null!=a?a.vignetteShape:void 0)||{};if(null!=a&&a.vignetteShape)switch(a=null!=n?n.scaling:void 0,k=null!=n?n.vignetteScale:
void 0,a){case "average":n.vignetteScale=(l.width+l.height)/2*k/(c.intensity+1E-9);n.stretch=!1;break;case "max":n.vignetteScale=Math.max(l.width,l.height)*k/(c.intensity+1E-9);n.stretch=!1;break;case "stretch":n.vignetteScale=k/(c.intensity+1E-9);n.stretch=!0;break;default:throw new e("scaling mode "+a+" not defined.","vignette");}console.log(n);if(null==r||null==i)throw new e("colors or opacities param is missing.","sharpness");h.applyGradient(null!=l?l.data:void 0,l.width,l.height,{colors:r,opacities:i},
f,j,o,E,d,n,s,p);return!0}};a=function(a){var l,c,e;l=[];c=0;for(e=a.length;c<e;)l.push(a[c]),c++;return l};h=function(e){return{r:a(e.r),g:a(e.g),b:a(e.b)}};o=function(a,l,c){null==c&&(c=1);return a*c+1*(1-c)};B.exports={MLPLRunProcessor:function(a,l,c){var p;p=null!=a?a.parameters:void 0;"undefined"===typeof c&&(c={});"undefined"===typeof c.border&&(c.border=!0);"undefined"===typeof c.intensity&&(c.intensity=1);"undefined"===typeof c.seed&&(c.seed=0);a=j[null!=a?a.name:void 0];if(null!=a)l=a(p,
l,c);else throw new e("unrecognized processor");return l}}});C.define("/src/js/filters/legacy/legacyProcessor.js",function(q,B){var e=q("../../core/rng"),o=q("../flare"),h=q("../vignette"),a=q("../../legacy/auto_colors_fade_max_color"),j=q("../../legacy/soft_focus"),f={},n={maxpow2:function(a){for(var c=1;2*c<=a;)c*=2;return c},getMPDRNG:function(a,c,e,d,s,r,f){"undefined"===typeof r&&(r="uniform");var g=c+n.maxpow2(e-c);a[g]=a[e];"uniform"===r?n.getMPDU(a,c,g,d,s,f):"normal"===r?n.getMPDN(a,c,g,
d,s,f):"laplacian"===r&&n.getMPDL(a,c,g,d,s,f);n.scaleLine(a,g,e);return a},scaleLine:function(a,c,e){if(!(e<=c))for(var c=e/c,d,s;0<=e;e--)d=e/c,s=d-(d|0),a[e]=s?(1-s)*a[d|0]+s*a[(d|0)+1]:a[d]},getMPDU:function(a,c,e,d,s,r){for(var f=e-c,g=(e-c)/2,i;2<=f;){for(var h=c;h<e;h+=f)i=h+g,a[i]=(a[h]+a[h+f])/2+d*(r.nextFloat()-0.5);d*=Math.pow(2,-s);f=g;g/=2}},getMPDN:function(a,c,e,d,f,r){for(var g=e-c,i=(e-c)/2,h;2<=g;){for(var j=c;j<e;j+=g)h=j+i,a[h]=(a[j]+a[j+g])/2+d*r.nextFloatNormal();d*=Math.pow(2,
-f);g=i;i/=2}},getMPDL:function(a,c,e,d,f,r){for(var g=e-c,i=(e-c)/2,h;2<=g;){for(var j=c;j<e;j+=g)h=j+i,a[h]=(a[j]+a[j+g])/2+d*r.nextFloatLaplace();d*=Math.pow(2,-f);g=i;i/=2}},getMPD:function(a,c,p,d,f,r,g){g=new e.RNG(g);n.getMPDRNG(a,c,p,d,f,r,g);return g.getState()}},i=function(a,c,p,d,f,r){"undefined"===typeof f&&(f="");var g,i,h,j,n,k,o,q,t,A,B,C,L,M,G,H,F,K=1,J,D,b,m,P,R,U;J=D=b=m=P=R=U=!1;g=(c+p)/30;h=i=0;var $=p/2|0,V=c/2|0,Q=d[0],T=d[1],X=d[2],d=255*d[3];"halftone"===f?(J=!0,g=(c+p)/30,
i=r[0],q=1E3/(c+p),"number"===typeof r[1]&&(q=0===r[1]?0:q/r[1])):"smooth"===f?(b=!0,g=r[0]*(c+p)/30,"undefined"!==typeof r[1]&&(i=r[1]/g)):"rough"===f?(R=!0,g=r[0]*(c+p)/30,"undefined"!==typeof r[1]&&(i=r[1]/g),"undefined"!==typeof r[2]&&(h=r[2]),F=new e.RNG(h)):"viewfinder"===f?(U=!0,g=(c+p)/60,B=C=M=L=0,"undefined"!==typeof r[0]&&(M=r[0]),"undefined"!==typeof r[1]&&(L=r[1]),"undefined"!==typeof r[2]&&(B=r[2]),"undefined"!==typeof r[3]&&(C=r[3]),"undefined"!==typeof r[4]&&(h=r[4]),F=new e.RNG(h)):
"lines"===f?(D=!0,g=r[0]*(c+p)/30,H=r[1]):"shadow"===f?(m=!0,g=r[0]*(c+p)/80,i=0.3,t=Math.PI/180*r[1],A=Math.sin(t),t=0.5*Math.cos(t)*g,A=0.5*A*g):"fade"===f&&(P=!0,g=(c+p)/80,"number"===typeof r[0]&&(g*=r[0]),i="number"===typeof r[1]?r[1]:1,"number"===typeof r[2]&&(K=r[2]));i*=g;U||(B=C=M=L=i);for(h=0;h<p;h++){n=h<$?h-M:p-1-h-L;for(r=0;r<c;r++)if(f=4*(c*h+r),j=r<V?r-B:c-1-r-C,o=n<Math.SQRT2*K*g&&j<Math.SQRT2*K*g?Math.SQRT2*K*g-Math.sqrt((n-Math.SQRT2*K*g)*(n-Math.SQRT2*K*g)+(j-Math.SQRT2*K*g)*(j-
Math.SQRT2*K*g)):n<j?n:j,0>n||0>j)J?(k=Math.cos((h-$)*q)*Math.cos((r-V)*q)+1,k=1-2*k,k=0>k?0:1<k?1:k,a[f]=a[f]*k+Q*(1-k)+0.5|0,a[f+1]=a[f+1]*k+T*(1-k)+0.5|0,a[f+2]=a[f+2]*k+X*(1-k)+0.5|0,a[f+3]=a[f+3]*k+d*(1-k)+0.5|0):m?(o=h<$?h-i-A:p-1-h-i+A,G=r<V?r-i-t:c-1-r-i+t,o=o<Math.SQRT2*K*g&&G<Math.SQRT2*K*g?Math.SQRT2*K*g-Math.pow(Math.pow(o-Math.SQRT2*K*g,4)+Math.pow(G-Math.SQRT2*K*g,4),0.25):o<G?o:G,o<-g&&(o=-g),k=0.6*Math.pow((o/g+1)/2,4),k=0>k?0:1<k?1:k,a[f]=Q*(1-k)+0.5|0,a[f+1]=T*(1-k)+0.5|0,a[f+2]=
X*(1-k)+0.5|0,a[f+3]=d*(1-k)+k*a[f+3]+0.5|0):(a[f]=Q,a[f+1]=T,a[f+2]=X,a[f+3]=d);else if(o<g){if(J)k=Math.cos((h-$)*q)*Math.cos((r-V)*q)+1,k=0>=o?1-2*k:1-2*k*Math.pow(1-o/g,4);else if(m){o=h<$?h-i-A:p-1-h-i+A;G=r<V?r-i-t:c-1-r-i+t;o=o<Math.SQRT2*K*g&&G<Math.SQRT2*K*g?Math.SQRT2*K*g-Math.pow(Math.pow(o-Math.SQRT2*K*g,4)+Math.pow(G-Math.SQRT2*K*g,4),0.25):o<G?o:G;if(j>=g&&n>=g)continue;o<-g&&(o=-g);o>g&&(o=Math.sqrt(o/g)*g);k=0.6*Math.pow((o/g+1)/2,4);k=0>k?0:1<k?1:k;a[f]=Q*(1-k)+0.5|0;a[f+1]=T*(1-
k)+0.5|0;a[f+2]=X*(1-k)+0.5|0;a[f+3]=255;continue}else P?(o=0>o?0:o,k=Math.pow(o/g,2)):b?k=1-2*Math.pow(1-o/g,4):R?k=1-2*(0.4*F.nextFloat()+0.6)*Math.pow(1-o/g,4):U?k=1-2*(0.4*F.nextFloat()+0.6)*Math.pow(1-o/g,4):D&&(k=1-2*((0.4*Math.random()+0.6)*(Math.cos(140*Math.PI*((h-$)/p)/H)+1))*Math.pow(1-o/g,4));k=0>k?0:1<k?1:k;a[f]=a[f]*k+Q*(1-k)+0.5|0;a[f+1]=a[f+1]*k+T*(1-k)+0.5|0;a[f+2]=a[f+2]*k+X*(1-k)+0.5|0;a[f+3]=a[f+3]*k+d*(1-k)+0.5|0}}},d=function(a,c,p,d,f,g){"undefined"==typeof f&&(f="");var i,
h,j,k;i=h=j=k=!1;var o,q,A,E,t,B,C,N,L,M,G,H,F,K,J,D,b,m,P=d[0],R=d[1],U=d[2],d=d[3],$=1!==d,V=1+(c+p)/2/1024;A=new e.RNG;"torn"===f?(h=!0,q=g[0]*(c+p)/2,o=g[1]*(c+p)/2,t=g[2],E="uniform","string"===typeof g[3]&&(E=g[3]),A=g[4],B="onlyout"===g[5],A=new e.RNG(A)):"bulge"===f?(i=!0,o=g[0]*(c+p)/2,C=g[1]*o,N=g[2]*o):"rect"===f?(j=!0,o=g[0]*(c+p)/2,1===g[1]&&(V=0)):"round"===f&&(k=!0,o=g[0]*Math.min(c,p),M=g[1]*o,G=g[2]*o,H=g[3]*o,F=g[4]*o,L=o,"number"===typeof g[5]&&(L*=g[5]));for(var Q=Math.max(c,p),
g=[],T,X,S,Y,f=[p,c,c,p],ba=[1,1,-1,-1],ca=[0,0,p-1,c-1],Z=0;4>Z;Z++){X=f[Z];S=ba[Z];Y=ca[Z];Q=X;if(h){if(g[Q-1]=Y+S*o,g[0]=Y+S*o,n.getMPD(g,0,Q-1,q,t,E,A.nextInt()),B)for(p=0;p<Q;p++)g[p]=S*Math.min(S*(Y+S*o),S*g[p])}else if(i)for(p=0;p<Q;p++)g[p]=Y-S*(C*Math.sin(p*Math.PI/Q)-N);else if(j)for(p=0;p<Q;p++)g[p]=Y+S*o;else if(k){m=L*(1-1/Math.SQRT2);0===Z&&(D=G,J=M,b=H);1===Z&&(D=M,J=G,b=F);2===Z&&(D=H,J=G,b=F);3===Z&&(D=F,J=M,b=H);D-=V/2;for(p=0;p<Q;p++)K=p,g[p]=K<J+m?Y+S*(D+m):K<J+L?Y+S*(D+L-Math.sqrt(L*
L-Math.pow(K-J-L,2))):K<X-1-b-L?Y+S*D:K<=X-1-b-m?Y+S*(D+L-Math.sqrt(L*L-Math.pow(X-1-K-b-L,2))):Y+S*(D+m)}for(p=0;p<X;p++){K=g[p];for(Q=Y;S*Q<S*(K+S*V);Q+=S)m=0===Z||3===Z?4*(p*c+Q):4*(Q*c+p),S*Q<S*(K-S*V)?$?(a[m]=d*P+(1-d)*a[m]+0.5|0,a[m+1]=d*R+(1-d)*a[m+1]+0.5|0,a[m+2]=d*U+(1-d)*a[m+2]+0.5|0,a[m+3]=255*d+(1-d)*a[m+3]+0.5|0):(a[m]=P,a[m+1]=R,a[m+2]=U,a[m+3]=255):(T=d*(1-(S*(Q-K)+V)/(2*V)),a[m]=T*P+(1-T)*a[m]+0.5|0,a[m+1]=T*R+(1-T)*a[m+1]+0.5|0,a[m+2]=T*U+(1-T)*a[m+2]+0.5|0,a[m+3]=255*T+(1-T)*a[m+
3]+0.5|0)}}},A=function(a,c,p,d,g,f){"undefined"==typeof g&&(g="");var i,h,j,k,o;"torn"===g&&(i=f[0]*(c+p)/2,h=f[1]*(c+p)/2,j=f[2],k="uniform","string"===typeof f[3]&&(k=f[3]),o=f[4]);for(var g=d[0],f=d[1],q=d[2],d=d[3],A=1!==d,E=Math.max(c,p),t=[],B=[],C=Math.max(1,0.0010*(c+p)),N,L,M,G,H,F,K,J=[p,c,c,p],D=[1,1,-1,-1],p=[0,0,p-1,c-1],b=new e.RNG(o),m=0;4>m;m++){o=J[m];F=D[m];K=p[m];E=o;t[E-1]=K+F*h;t[0]=K+F*h;n.getMPD(t,0,E-1,i,j,k,b.nextInt());B[E-1]=K+F*h;B[0]=K+F*h;n.getMPD(B,0,E-1,i,j,k,b.nextInt());
for(E=0;E<o;E++){L=t[E];M=B[E];for(N=K;F*N<F*(L+F*C);N+=F)G=0===m||3===m?4*(E*c+N):4*(N*c+E),F*N<F*(L-F*C)&&F*N>F*(M+F*C)?A?(a[G]=d*g+(1-d)*a[G]+0.5|0,a[G+1]=d*f+(1-d)*a[G+1]+0.5|0,a[G+2]=d*q+(1-d)*a[G+2]+0.5|0):(a[G]=g,a[G+1]=f,a[G+2]=q):F*N<F*(L+F*C)&&F*N>F*(M-F*C)&&(H=d*Math.min(F*(L-N)/C,F*(N-M)/C),1<H?H=1:0>H&&(H=0),a[G]=H*g+(1-H)*a[G]+0.5|0,a[G+1]=H*f+(1-H)*a[G+1]+0.5|0,a[G+2]=H*q+(1-H)*a[G+2]+0.5|0)}}},k=function(a,c,p,d){"undefined"===typeof d.offset&&(d.offset=0);"undefined"===typeof d.corner&&
(d.corner=0);"undefined"===typeof d.scale&&(d.scale=1);"undefined"===typeof d.seed&&(d.seed=0);"undefined"===typeof d.alpha&&(d.alpha=1);"undefined"===typeof d.color&&(d.color=[0,0,0,1]);var g=d.offset,f=d.corner,i=d.scale,h=d.color,j=d.alpha,d=new e.RNG(d.seed),k=h[0],o=h[1],q=h[2],h=h[3],A=Array(p),E=Array(p),t=Array(c),B=Array(c);A[p-1]=f;A[0]=0;E[p-1]=0;E[0]=0;t[c-1]=0;t[0]=0;B[c-1]=0;B[0]=f;n.getMPD(A,0,p-1,0.03*c*j,0.7,"uniform",d.nextInt());n.getMPD(E,0,p-1,0.03*c*j,0.7,"uniform",d.nextInt());
n.getMPD(t,0,c-1,0.03*p*j,0.7,"uniform",d.nextInt());n.getMPD(B,0,c-1,0.03*p*j,0.7,"uniform",d.nextInt());var C,N,j=p/2|0,L=c/2|0,M=(c+p)/30,G,H;for(H=0;H<p;H++)for(G=0;G<c;G++)f=4*(H*c+G),N=H<j?H-t[G]-g:p-1-H-B[G]-g,C=G<L?G-A[H]-g:c-1-G-E[H]-g,0>N||0>C?(C=1-h,a[f]=a[f]*C+k*(1-C)|0,a[f+1]=a[f+1]*C+o*(1-C)|0,a[f+2]=a[f+2]*C+q*(1-C)|0,a[f+3]=a[f+3]):(C=N<Math.SQRT2*M&&C<Math.SQRT2*M?Math.SQRT2*M-Math.sqrt(Math.pow(N-Math.SQRT2*M,2)+Math.pow(C-Math.SQRT2*M,2)):C<N?C:N,C<M&&(N=2*Math.pow(1-C/M,4*i),N>
1/255&&(C=0.4*d.nextFloat()+0.6,C=1-C*N,1<C?C=1:0>C&&(C=0),C=1-h+h*C,a[f]=a[f]*C+k*(1-C)|0,a[f+1]=a[f+1]*C+o*(1-C)|0,a[f+2]=a[f+2]*C+q*(1-C)|0,a[f+3]=a[f+3])))},g={drawDot:function(a,c,e,d,f,g,h,i,j,k,n,o,q,E,t){var A=c/2|0,B=e/2|0,i=i*A+E*A,j=j*A+t*B,n=1,o=1/n/A/o,n=1/n/A/q,q=k*k,E=Math.PI/(2*q),C,L,M,G;C=Math.round(Math.min(e-1,Math.max(0,B+j-5*k/n)));for(var e=Math.round(Math.max(0,Math.min(e-1,B+j+5*k/n))),t=Math.round(Math.min(c-1,Math.max(0,A+i-5*k/o))),k=Math.round(Math.max(0,Math.min(c-1,
A+i+5*k/o))),H=C;H<=e;H++){C=4*H*c;L=n*(H-B-j);for(var F=t;F<=k;F++)M=C+4*F,G=o*(F-A-i),G=G*G+L*L,G>5*q||(G=2.25>G*E?1-h*Math.max(Math.cos(G*E),Math.cos(Math.sqrt(G*E)/1.8)/2):1-h*Math.cos(Math.sqrt(G*E)/1.8)/2,1<G&&(G=1),a[M]=a[M]*G+d*(1-G)|0,a[M+1]=a[M+1]*G+f*(1-G)|0,a[M+2]=a[M+2]*G+g*(1-G)|0)}},drawChar:function(a,c,e,d,f,h,i,j,k,n,o,q,A,E){E||(E=0);q||(q=0);A||(A=1.3);var A=A*f,t=[];t[" "]=[[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,
0,0,0,0]];t["%"]=[[0,0,0,0,0,0,0],[0,0,1,1,1,0,0],[0,1,1,1,1,1,0],[0,1,1,1,1,1,0],[0,1,1,1,1,1,0],[0,0,1,1,1,0,0],[0,0,0,0,0,0,0]];t["&"]=[[0,1,1,1,1,1,0],[0,1,1,1,1,1,0],[0,1,1,1,1,1,0],[0,1,1,1,1,1,0],[0,1,1,1,1,1,0],[0,1,1,1,1,1,0],[0,1,1,1,1,1,0]];t["~"]=[[0,1,1,1,1,1,0],[0,1,1,1,1,1,0],[0,1,1,1,1,1,0],[0,1,0,1,0,1,0],[0,1,0,1,0,1,0],[0,1,0,1,0,1,0],[0,1,0,1,0,1,0]];t["{"]=[[1,0,1,0,1,0,1],[1,0,1,0,1,0,1],[1,0,1,0,1,0,1],[1,0,1,0,1,0,1],[0,1,1,1,1,1,1],[0,1,1,1,1,1,1],[0,1,1,1,1,1,1]];t["}"]=
[[0,1,1,1,0,1,0],[0,1,1,1,0,1,0],[0,1,1,1,0,1,0],[0,1,0,1,0,0,0],[0,1,0,1,0,0,0],[0,1,0,1,0,0,0],[0,1,0,1,0,0,0]];t["^"]=[[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,1,1,1,0,0],[0,1,1,1,1,1,0],[0,1,1,1,1,1,0],[1,1,1,1,1,1,1],[0,0,0,0,0,0,0]];t[">"]=[[0,1,0,0,0,0,0],[0,1,1,0,0,0,0],[0,1,1,1,0,0,0],[0,1,1,1,1,0,0],[0,1,1,1,0,0,0],[0,1,1,0,0,0,0],[0,1,0,0,0,0,0]];t["<"]=[[0,0,0,0,0,1,0],[0,0,0,0,1,1,0],[0,0,0,1,1,1,0],[0,0,1,1,1,1,0],[0,0,0,1,1,1,0],[0,0,0,0,1,1,0],[0,0,0,0,0,1,0]];t[":"]=[[0,0,0,0,0,0,0],
[0,0,0,1,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,1,0,0,0],[0,0,0,0,0,0,0]];t["-"]=[[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,1,1,1,1,1,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]];t["+"]=[[0,0,0,0,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,1,1,1,1,1,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,0,0,0,0]];t["."]=[[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,1,1,0,0,0],[0,0,1,1,0,0,0]];t["/"]=[[0,0,0,0,0,0,0],[0,0,0,0,0,1,0],[0,
0,0,0,1,0,0],[0,0,0,1,0,0,0],[0,0,1,0,0,0,0],[0,1,0,0,0,0,0],[0,0,0,0,0,0,0]];t["?"]=[[0,0,1,1,0,0,0],[0,1,0,0,1,0,0],[0,1,0,0,1,0,0],[0,0,1,1,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]];t["*"]=[[0,0,0,0,0,0,0],[0,1,0,0,0,1,0],[0,0,1,0,1,0,0],[0,0,0,1,0,0,0],[0,0,1,0,1,0,0],[0,1,0,0,0,1,0],[0,0,0,0,0,0,0]];t["|"]=[[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0]];t["@"]=[[0,0,1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,
1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,1,1,1,0,0]];t.A=[[0,0,1,1,1,0,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,1,1,1,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0]];t.B=[[0,1,1,1,1,0,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,1,1,1,0,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,1,1,1,0,0]];t.C=[[0,0,1,1,1,0,0],[0,1,0,0,0,1,0],[0,1,0,0,0,0,0],[0,1,0,0,0,0,0],[0,1,0,0,0,0,0],[0,1,0,0,0,1,0],[0,0,1,1,1,0,0]];t.D=[[0,1,1,1,1,0,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,
1,0,0,0,1,0],[0,1,1,1,1,0,0]];t.E=[[0,1,1,1,1,1,0],[0,1,0,0,0,0,0],[0,1,0,0,0,0,0],[0,1,1,1,1,0,0],[0,1,0,0,0,0,0],[0,1,0,0,0,0,0],[0,1,1,1,1,1,0]];t.F=[[0,1,1,1,1,1,0],[0,1,0,0,0,0,0],[0,1,0,0,0,0,0],[0,1,1,1,1,0,0],[0,1,0,0,0,0,0],[0,1,0,0,0,0,0],[0,1,0,0,0,0,0]];t.G=[[0,0,1,1,1,0,0],[0,1,0,0,0,1,0],[0,1,0,0,0,0,0],[0,1,0,0,0,0,0],[0,1,0,1,1,1,0],[0,1,0,0,0,1,0],[0,0,1,1,1,0,0]];t.H=[[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,1,1,1,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0]];
t.I=[[0,0,1,1,1,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,1,1,1,0,0]];t.J=[[0,0,0,0,0,1,0],[0,0,0,0,0,1,0],[0,0,0,0,0,1,0],[0,0,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,0,1,1,1,0,0]];t.K=[[0,1,0,0,0,1,0],[0,1,0,0,1,0,0],[0,1,0,1,0,0,0],[0,1,1,0,0,0,0],[0,1,0,1,0,0,0],[0,1,0,0,1,0,0],[0,1,0,0,0,1,0]];t.L=[[0,1,0,0,0,0,0],[0,1,0,0,0,0,0],[0,1,0,0,0,0,0],[0,1,0,0,0,0,0],[0,1,0,0,0,0,0],[0,1,0,0,0,0,0],[0,1,1,1,1,1,0]];t.M=[[0,1,0,0,0,1,0],[0,1,1,0,
1,1,0],[0,1,0,1,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0]];t.N=[[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,1,0,0,1,0],[0,1,0,1,0,1,0],[0,1,0,0,1,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0]];t.O=[[0,0,1,1,1,0,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,0,1,1,1,0,0]];t.P=[[0,1,1,1,1,0,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,1,1,1,0,0],[0,1,0,0,0,0,0],[0,1,0,0,0,0,0]];t.Q=[[0,0,1,1,1,0,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,
0,0,1,0],[0,1,0,1,0,1,0],[0,1,0,0,1,1,0],[0,0,1,1,1,1,0]];t.R=[[0,1,1,1,1,0,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,1,1,1,0,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0]];t.S=[[0,0,1,1,1,0,0],[0,1,0,0,0,1,0],[0,1,0,0,0,0,0],[0,0,1,1,1,0,0],[0,0,0,0,0,1,0],[0,1,0,0,0,1,0],[0,0,1,1,1,0,0]];t.T=[[0,1,1,1,1,1,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0]];t.U=[[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,
0,0,0,1,0],[0,0,1,1,1,0,0]];t.V=[[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,0,1,0,1,0,0],[0,0,0,1,0,0,0]];t.W=[[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,1,0,1,0],[0,1,1,0,1,1,0],[0,1,0,0,0,1,0]];t.X=[[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,0,1,0,1,0,0],[0,0,0,1,0,0,0],[0,0,1,0,1,0,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0]];t.Y=[[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,0,1,0,1,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0]];t.Z=
[[0,1,1,1,1,1,0],[0,0,0,0,0,1,0],[0,0,0,0,1,0,0],[0,0,0,1,0,0,0],[0,0,1,0,0,0,0],[0,1,0,0,0,0,0],[0,1,1,1,1,1,0]];t.f=[[0,0,0,0,0,0,0],[0,0,0,1,1,1,0],[0,0,1,0,0,0,0],[0,0,1,0,0,0,0],[0,0,1,1,1,0,0],[0,0,1,0,0,0,0],[0,0,1,0,0,0,0]];t.s=[[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,1,1,1,0,0],[0,1,0,0,0,0,0],[0,0,1,1,1,0,0],[0,0,0,0,0,1,0],[0,0,1,1,1,0,0]];t["1"]=[[0,0,0,1,0,0,0],[0,0,1,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0]];t["2"]=[[0,1,1,1,1,1,0],[0,0,0,
0,0,1,0],[0,0,0,0,0,1,0],[0,1,1,1,1,1,0],[0,1,0,0,0,0,0],[0,1,0,0,0,0,0],[0,1,1,1,1,1,0]];t["3"]=[[0,1,1,1,1,1,0],[0,0,0,0,0,1,0],[0,0,0,0,0,1,0],[0,0,1,1,1,1,0],[0,0,0,0,0,1,0],[0,0,0,0,0,1,0],[0,1,1,1,1,1,0]];t["4"]=[[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,1,1,1,1,0],[0,0,0,0,0,1,0],[0,0,0,0,0,1,0],[0,0,0,0,0,1,0]];t["5"]=[[0,1,1,1,1,1,0],[0,1,0,0,0,0,0],[0,1,0,0,0,0,0],[0,1,1,1,1,1,0],[0,0,0,0,0,1,0],[0,0,0,0,0,1,0],[0,1,1,1,1,1,0]];t["6"]=[[0,1,1,1,1,1,0],[0,1,0,0,0,0,0],[0,1,0,0,
0,0,0],[0,1,1,1,1,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,1,1,1,1,0]];t["7"]=[[0,1,1,1,1,1,0],[0,0,0,0,0,1,0],[0,0,0,0,0,1,0],[0,0,0,0,1,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0],[0,0,0,1,0,0,0]];t["8"]=[[0,1,1,1,1,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,1,1,1,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,1,1,1,1,0]];t["9"]=[[0,1,1,1,1,1,0],[0,1,0,0,0,1,0],[0,1,0,0,0,1,0],[0,1,1,1,1,1,0],[0,0,0,0,0,1,0],[0,0,0,0,0,1,0],[0,1,1,1,1,1,0]];t["0"]=[[0,0,1,1,1,0,0],[0,1,0,0,0,1,0],[0,1,0,0,1,1,0],[0,1,0,1,0,
1,0],[0,1,1,0,0,1,0],[0,1,0,0,0,1,0],[0,0,1,1,1,0,0]];for(var B,C,N=0;N<d.length;N++)for(var L=0;7>L;L++)for(var M=0;7>M;M++)t[d[N]]&&t[d[N]][M][L]&&(C=(7*(N+q)+L)*A*Math.cos(E)-M*A*Math.sin(E),B=(7*(N+q)+L)*A*Math.sin(E)+M*A*Math.cos(E),g.drawDot(a,c,e,j,k,n,o,C,B,f,1,1,1,h,i))},drawLine:function(a,c,e,d,f,g,h,i,j){for(var k=0;k<i.length-1;k++){var n=i[k][0],o=i[k][1],q=i[k+1][0],A=i[k+1][1],t,B,C,N,L,M,G,H=[o-A,q-n],F=Math.sqrt(H[0]*H[0]+H[1]*H[1]);H[0]/=F;H[1]/=F;var F=[q-n,A-o],F=F[0]*F[0]+F[1]*
F[1],K=j*j,J=(j+2)*(j+2);M=Math.round(Math.min(e-1,Math.max(0,Math.min(o,A)-j-2)));for(var D=Math.round(Math.max(0,Math.min(e-1,Math.max(o,A)+j+2))),b=Math.round(Math.min(c-1,Math.max(0,Math.min(n,q)-j-2))),m=Math.round(Math.max(0,Math.min(c-1,Math.max(n,q)+j+2))),P=M;P<=D;P++){M=4*P*c;for(var R=b;R<=m;R++)if(G=M+4*R,t=Math.abs(H[0]*(R-n)+H[1]*(P-o)),B=(R-n)*(R-n)+(P-o)*(P-o),C=(R-q)*(R-q)+(P-A)*(P-A),B<C?(N=C,L=B):(N=B,L=C),C=t>j+2?1:L+F<N?B<K||C<K?1-h:B<J||C<J?1-h+h*(Math.sqrt(L)-j)/2:1:t>j?1-h+
h*(t-j)/2:1-h,0.995>C)t=a[G]*C+d*(1-C)+0.5|0,B=a[G+1]*C+f*(1-C)+0.5|0,C=a[G+2]*C+g*(1-C)+0.5|0,t=0>t?0:255<t?255:t,B=0>B?0:255<B?255:B,C=0>C?0:255<C?255:C,a[G]=t,a[G+1]=B,a[G+2]=C,a[G+3]=a[G+3]}}},ringFlare:function(a,c,e,d,f,g,h,i,j,k,n){var o=(c+e)/2,q,A,t=0.01*h,B=h*h,g=g*g;q=Math.min(e,Math.max(0,Math.round(f-h*o-4)));for(var e=Math.min(e,Math.max(0,Math.round(f+h*o+4))),C=Math.min(c,Math.max(0,Math.round(d-h*o-4))),h=Math.min(c,Math.max(0,Math.round(d+h*o+4))),N,L,M,G,H=q;H<e;H++){N=4*H*c;q=
(H-f)/o;for(var F=C;F<h;F++)L=N+4*F,A=(F-d)/o,A=A*A+q*q,M=A>B+t?0:A>B?(B+t-A)/t:A>g?1:A>g-t?1-(g-A)/t:0,M=1-M*M*n,0.995>M&&(A=a[L]*M+i*(1-M)+0.5|0,G=a[L+1]*M+j*(1-M)+0.5|0,M=a[L+2]*M+k*(1-M)+0.5|0,A=0>A?0:255<A?255:A,G=0>G?0:255<G?255:G,M=0>M?0:255<M?255:M,a[L]=A,a[L+1]=G,a[L+2]=M,a[L+3]=a[L+3])}},drawBasicDot:function(a,c,e,d,f,g,h,i,j,k){var n=k*k,o=2;o>2*k&&(o=2*k);var q,A,t,B=Math.pow(k+o,2);q=Math.round(Math.min(e-1,Math.max(0,j-k-o)));for(var e=Math.round(Math.max(0,Math.min(e-1,j+k+o))),C=
Math.round(Math.min(c-1,Math.max(0,i-k-o))),N=Math.round(Math.max(0,Math.min(c-1,i+k+o))),L=q;L<=e;L++){q=4*L*c;for(var M=C;M<=N;M++)A=q+4*M,t=(i-M)*(i-M)+(j-L)*(j-L),t>B||(t=t>n?1-h+h*(Math.sqrt(t)-k)/o:1-h,a[A]=a[A]*t+d*(1-t),a[A+1]=a[A+1]*t+f*(1-t),a[A+2]=a[A+2]*t+g*(1-t))}},dirtspec:function(a,c,d,f,h,i,j,k){var k=new e.RNG(k),n=[];n[0]=[f,h,i];for(var o=1;0.2<i;){var i=0.97*i,q=k.nextFloat()*(o-1)|0,f=n[q][0],h=n[q][1],q=n[q][2],A=2*k.nextFloat()*Math.PI,f=f+0.5*(q+i)*Math.cos(A),h=h+0.5*(q+
i)*Math.sin(A);g.drawBasicDot(a,c,d,j[0],j[1],j[2],j[3],f,h,i);n[o]=[f,h,i];o++}}};f.purpleBorder=function(a,c,e,f){var g=[0,0,0,1];d(a,c,e,g,"torn",[0.02*f.intensity,0.02,0.5,"uniform",f.seed]);d(a,c,e,g,"round",[0.02,1,1,1,1,1.5])};f.san_carmenBorder=function(a,c,p,f){var g=new e.RNG(f.seed),h=f.intensity;d(a,c,p,[225,225,200,1],"round",[0.025,1,1,1,1,1.5]);for(f=4;10>f;f++)A(a,c,p,[225,225,200,0.2],"torn",[0.06*h*(10-f)/10,0.0050*f+0.01,0.4,"uniform",g.nextInt()])};f.san_carmenAutoColors=function(e,
c,d,f){a.autocolorsfade(e,c,d,f.intensity,251,233,194)};f.threshBorder=function(a,c,e){d(a,c,e,[0,0,0,1],"round",[0.025,1,1,1,1,1.5])};f.brownieBorder=function(a,c,p,f){var g=f.intensity,f=new e.RNG(f.seed);d(a,c,p,[0,0,0,0.2],"torn",[0.03*g,0.02,0.2,"uniform",f.nextInt()]);d(a,c,p,[0,0,0,0.8],"torn",[0.02*g,0.01,0.5,"uniform",f.nextInt()]);k(a,c,p,{color:[0,0,0,1],offset:-(c+p)/150,corner:0,scale:0.5,seed:f.nextInt(),alpha:g})};f.maya_unicornBorder=function(a,c,p,f){var h=f.intensity,f=new e.RNG(f.seed);
d(a,c,p,[0,0,0,1],"torn",[0,0.04*p/Math.min(c,p),0.2,"uniform",f.nextInt()]);var i="Abercrave Abilene Aith Banff Blean Caarnduncan Corrievorrie Cotterstock Dalrymple Draffan Dubuque Epsom Frolesworth Glassel Golant Harpenden Hassop Hove Popcastle Winkley".split(" "),i="&  >| "+i[f.nextFloat()*i.length|0].toUpperCase()+" |<  &",j=0.8,k=0.935,n=0.0030*Math.min(c,p)/c;g.drawChar(a,c,p,i,n,j,k,255,255,0,0.3,-i.length);g.drawChar(a,c,p,i,n,-0.8,-0.957,255,255,0,0.3,0,0,0);i=[255,255,255,1];d(a,c,p,i,"torn",
[0,0.01*p/Math.min(c,p),0.2,"uniform",f.nextInt()]);d(a,c,p,i,"torn",[0.02*h,0.01*p/Math.min(c,p),0.5,"uniform",f.nextInt()]);d(a,c,p,i,"torn",[0.0080*h,0.01*p/Math.min(c,p),0.3,"normal",f.nextInt()])};f.old_threshBorder=function(a,c,p,f){var g=f.intensity,f=new e.RNG(f.seed);d(a,c,p,[255,255,255,1],"round",[0.025,1,1,1,1,1.5]);for(var h=4;10>h;h++)A(a,c,p,[255,255,255,0.2],"torn",[0.06*g*(10-h)/10,0.0050*h+0.01,0.4,"uniform",f.nextInt()])};f.bordeauxBorder=function(a,c,d,f){var f=new e.RNG(f.seed),
h=c/((c+d)/2);g.drawLine(a,c,d,255,255,255,0.3,[[0.46*c,0.5*d-0.05*c],[0.54*c,0.5*d-0.05*c]],0);g.ringFlare(a,c,d,c/2,d/2-0.05*c,0.08*h,0.081*h,255,255,255,0.3);g.drawLine(a,c,d,255,255,255,0.3,[[0.5*c,0.5*d-0.18*c-0.05*c],[0.5*c,0.5*d-0.25*c-0.05*c]],0);g.drawLine(a,c,d,255,255,255,0.3,[[0.5*c,0.5*d+0.18*c-0.05*c],[0.5*c,0.5*d+0.25*c-0.05*c]],0);g.drawLine(a,c,d,255,255,255,0.3,[[0.5*c-0.18*c,0.5*d-0.05*c],[0.5*c-0.25*c,0.5*d-0.05*c]],0);g.drawLine(a,c,d,255,255,255,0.3,[[0.5*c+0.18*c,0.5*d-0.05*
c],[0.5*c+0.25*c,0.5*d-0.05*c]],0);g.drawLine(a,c,d,255,255,255,1,[[-c,d-0.1*c],[2*c,d-0.1*c]],0);g.drawLine(a,c,d,0,0,0,1,[[-c,d],[2*c,d]],0.1*c);var h="               ",i=h.length*f.nextFloat()|0,i=Math.min(h.length-1,Math.max(0,i)),h=h.substr(0,i)+"@"+h.substr(i+1),i=[255,255,255,0.6],j=0.5*(1-3*0.1*c/d)+0.5;g.drawChar(a,c,d,"+2..1..0..1..2-",0.0050/1.2,-0.5,j,i[0],i[1],i[2],i[3],-7.5);g.drawChar(a,c,d,h,0.0050/1.2,-0.5,j+0.035*1.3*c/d,i[0],i[1],i[2],i[3],-7.5);h=0.0050*c;i=0.8*c;j=d-8*h;g.drawLine(a,
c,d,255,255,255,1,[[i,j],[i+10*h,j]],h/4);g.drawLine(a,c,d,255,255,255,1,[[i,j-6*h],[i+10*h,j-6*h]],h/4);g.drawLine(a,c,d,255,255,255,1,[[i,j],[i,j-6*h]],h/4);g.drawLine(a,c,d,255,255,255,1,[[i+10*h,j],[i+10*h,j-6*h]],h/4);g.drawLine(a,c,d,255,255,255,1,[[i-h,j-2*h],[i-h,j-4*h]],h/4);f=4*f.nextFloat();0<f&&g.drawLine(a,c,d,255,255,255,1,[[i+8*h,j-2*h],[i+8*h,j-4*h]],h/4);1<f&&g.drawLine(a,c,d,255,255,255,1,[[i+6*h,j-2*h],[i+6*h,j-4*h]],h/4);2<f&&g.drawLine(a,c,d,255,255,255,1,[[i+4*h,j-2*h],[i+4*
h,j-4*h]],h/4);3<f&&g.drawLine(a,c,d,255,255,255,1,[[i+2*h,j-2*h],[i+2*h,j-4*h]],h/4)};f.covertBorder=function(a,c,d,f){var h=new e.RNG(f.seed);h.nextInt();h.nextInt();for(var f="1.4 2 2.8 4 5.6 8 11 16 22 32".split(" "),j=f[h.nextFloat()*f.length|0];3>j.length;)j+=" ";for(var f=["100","200","400","800","1600"],k=f[h.nextFloat()*f.length|0];4>k.length;)k+=" ";for(var f="1 2 4 8 15 30 60 125 250 500 1000".split(" "),n=f[0],j=0.5*parseFloat(k)/(0.015625*parseFloat(j)*parseFloat(j)),k=1;k<f.length;k++)Math.abs(parseInt(f[k])-
j)<Math.abs(parseInt(n)-j)&&(n=f[k]);for(;4>n.length;)n=" "+n;j="               ";h=j.length*h.nextFloat();h=Math.min(j.length-1,Math.max(0,h));j=j.substr(0,h)+"@"+j.substr(h+1);h="dfasdfsdf";h=(new Date).toDateString();h=h.toUpperCase();k=[90,250,20,0.6];i(a,c,d,[0,0,0,1],"smooth",[0.5,0.6*(Math.max(c,d)/15)]);for(var o=0.0043*Math.min(c,d)/c,q=0;q<f.length;q++){var A=1.1/f.length,B=-A*q+0.5;(n==f[q]||n==" "+f[q]||n=="  "+f[q]||n=="   "+f[q])&&g.drawLine(a,c,d,90,250,20,0.6,[[0.97*c,(B+A/2+1)*d/
2],[2*c,(B+1)*d/2]],0.7*o*c);g.drawChar(a,c,d,f[q],0.7*o,1,B,k[0],k[1],k[2],k[3],-2-f[q].length/2)}g.drawLine(a,c,d,0,0,0,0.1,[[0,d/3],[c,d/3]],0);g.drawLine(a,c,d,0,0,0,0.1,[[0,2*d/3],[c,2*d/3]],0);g.drawLine(a,c,d,0,0,0,0.1,[[c/3,0],[c/3,d]],0);g.drawLine(a,c,d,0,0,0,0.1,[[2*c/3,0],[2*c/3,d]],0);g.drawChar(a,c,d,"+2..1..0..1..2-",o/1.2,-0.5,0.915,k[0],k[1],k[2],k[3],-7.5);g.drawChar(a,c,d,j,o/1.2,-0.5,0.918+9.1*o*c/d,k[0],k[1],k[2],k[3],-7.5);g.drawChar(a,c,d,h,o,0.75,0.92,k[0],k[1],k[2],k[3],-h.length)};
f.orcaBorder=function(a,c,d,f){var h=f.seed,j=new e.RNG(h),f="1.4 2 2.8 4 5.6 8 11 16 22 32".split(" "),j=f[j.nextFloat()*f.length|0],k=[216,193,163,0.6];i(a,c,d,[0,0,0,1],"rough",[1,0.6*((c+d)/30),h]);for(var h=0.0043*Math.min(c,d)/c,n=0;n<f.length;n++){var o=1.1/f.length*n-0.5;(j==f[n]||j==f[n]+" "||j==f[n]+"  ")&&g.drawLine(a,c,d,230,50,40,0.7,[[0.95*c,(o+1)*d/2],[2*c,0.5*d]],0.7*h*c);g.drawChar(a,c,d,f[n],0.7*h,1,o,k[0],k[1],k[2],k[3],-2-f[n].length/2)}g.drawLine(a,c,d,0,0,0,0.1,[[c/4,0],[c/4,
d/3]],0);g.drawLine(a,c,d,0,0,0,0.1,[[0,d/4],[c/3,d/4]],0);g.drawLine(a,c,d,0,0,0,0.1,[[0,3*d/4],[c/3,3*d/4]],0);g.drawLine(a,c,d,0,0,0,0.1,[[c/4,d],[c/4,2*d/3]],0);g.drawLine(a,c,d,0,0,0,0.1,[[3*c/4,0],[3*c/4,d/3]],0);g.drawLine(a,c,d,0,0,0,0.1,[[c,d/4],[2*c/3,d/4]],0);g.drawLine(a,c,d,0,0,0,0.1,[[3*c/4,d],[3*c/4,2*d/3]],0);g.drawLine(a,c,d,0,0,0,0.1,[[c,3*d/4],[2*c/3,3*d/4]],0);g.drawLine(a,c,d,0,0,0,0.1,[[0,d/2],[c/4,d/2]],0);g.drawLine(a,c,d,0,0,0,0.1,[[c/2,0],[c/2,d/4]],0);g.drawLine(a,c,d,0,
0,0,0.1,[[c/2,d],[c/2,3*d/4]],0);g.drawLine(a,c,d,0,0,0,0.1,[[c,d/2],[3*c/4,d/2]],0);g.ringFlare(a,c,d,c/2,d/2,0.08,0.22,255,255,255,0.28)};f.titanBorder=function(a,c,d,f){var h=f.seed,f=new e.RNG(h),j="1.4 2 2.8 4 5.6 8 11 16 22 32".split(" "),k=j[f.nextFloat()*j.length|0],f="1 2 4 8 15 30 60 125 250 500 1000".split(" "),j=0.0050*(c+d)/c/2;i(a,c,d,[0,0,0,1],"viewfinder",[0.0050*(c+d),0.035*(c+d),0.0050*(c+d),0.035*(c+d),h]);g.drawLine(a,c,d,0,0,0,1,[[c-0.03*(c+d),0.8*d-0.035*(c+d)],[c-0.03*(c+d),
0.2*d]],(c+d)/50);var h=0.035*(c+d),n=0.5*(1-2.5*(h/d))+0.5;g.drawLine(a,c,d,255,255,255,0.2,[[0.4*c,d-h/2],[0.45*c,d-h/2]],(c+d)/100);g.drawChar(a,c,d,k,j,-0.15,n,255,255,255,1,-k.length/2);h=[230,230,255,0.8];for(k=0;k<f.length;k++)g.drawChar(a,c,d,f[k],0.7*j,1,-(1.1/f.length)*k+0.4,h[0],h[1],h[2],h[3],-3.5-f[k].length/2)};f.andyBorder=function(a,c,f,h){for(var i=h.seed,h=(new Date).toDateString(),h=h.toUpperCase(),i=new e.RNG(i),j="1.4 2 2.8 4 5.6 8 11 16 22 32".split(" "),j=j[i.nextFloat()*j.length|
0];3>j.length;)j+=" ";for(var k=["100","200","400","800","1600"],k=k[i.nextFloat()*k.length|0];4>k.length;)k+=" ";for(var n="1 2 4 8 15 30 60 125 250 500 1000".split(" "),o=n[0],q=0.5*parseFloat(k)/(0.015625*parseFloat(j)*parseFloat(j)),A=1;A<n.length;A++)Math.abs(parseInt(n[A],10)-q)<Math.abs(parseInt(o,10)-q)&&(o=n[A]);for(;4>o.length;)o=" "+o;n="               ";i=n.length*i.nextFloat();i=Math.min(n.length-1,Math.max(0,i));n=n.substr(0,i)+"@"+n.substr(i+1);i=o+"/s f"+j+"  > |";j="  | <     ISO:"+
k;d(a,c,f,[0,0,0,1],"round",[0.0080,6,4,4,4,1.5]);k=0.0043*Math.min(c,f)/c;g.drawChar(a,c,f,i,k,-0.9,-0.978,180,120,0,1);g.drawChar(a,c,f,j,k,0.9,-0.978,180,120,0,1,-j.length);g.drawChar(a,c,f,"+2..1..0..1..2-",k/1.7,0,-0.985,180,120,0,1,-7.5);g.drawChar(a,c,f,n,k/1.7,0,-0.988+9.1*k*c/f,180,120,0,1,-7.5);g.drawChar(a,c,f,h,k,0.85,0.86,230,50,40,1,-h.length)};f.aquaBorder=function(a,c,e){d(a,c,e,[255,255,255,1],"round",[0.025,1,1,1,1,1.5])};f.edgewoodBorder=function(a,c,f,h){var g,i=new e.RNG(h.seed),
j=[255,255,255,1];d(a,c,f,j,"round",[0.025,1,1,1,1,1.5]);for(g=4;10>g;g++)A(a,c,f,j,"torn",[0.03*h.intensity*(10-g)/10,0.0050*g+0.01,0.4,"uniform",i.nextInt()])};f.joe_coolBorder=function(a,c,e){d(a,c,e,[255,255,255,1],"bulge",[0.05,0.28,0.5])};f.singeBorder=function(a,c,d){i(a,c,d,[0,0,0,1],"fade",1)};f.solarBorder=function(a,c,d,f){for(var f=new e.RNG(f.seed),h=(c+d)/2/50,i=[[141,88,46,0.1],[70,48,26,0.1]],j,n,o=0;2>o;o++)for(var q=7;10>q;q++)for(var A=q;10>A;A+=0.4)j=0.02*c*f.nextFloatNormal(),
n=d*f.nextFloat(),g.dirtspec(a,c,d,j,n,h/3*q/15,i[o],f.nextInt()),j=c+0.02*c*f.nextFloatNormal(),n=d*f.nextFloat(),g.dirtspec(a,c,d,j,n,h/3*q/15,i[o],f.nextInt()),j=c*f.nextFloat(),n=0.02*d*f.nextFloatNormal(),g.dirtspec(a,c,d,j,n,h/3*q/15,i[o],f.nextInt()),j=c*f.nextFloat(),n=d+0.02*d*f.nextFloatNormal(),g.dirtspec(a,c,d,j,n,h/3*q/15,i[o],f.nextInt());k(a,c,d,{color:[200,140,80,0.3],offset:(c+d)/80,corner:(c+d)/40,seed:f.nextInt()});k(a,c,d,{color:[113,77,40,0.7],offset:(c+d)/200,corner:(c+d)/60,
seed:f.nextInt()});k(a,c,d,{color:[0,0,0,0.9],offset:0,corner:(c+d)/80,seed:f.nextInt()})};f.earthyBorder=function(a,c,f,h){var g=new e.RNG(h.seed),i=[0,15,0,1],h=h.intensity;d(a,c,f,i,"torn",[0.02*h,0.02,0.5,"uniform",g.nextInt()]);d(a,c,f,i,"torn",[0.01*h,0.02,0,"uniform",g.nextInt()]);k(a,c,f,{color:i,seed:g.nextInt(),alpha:h})};f.ithacaFlare=function(a,c,d,f){var h=f.intensity,g=new e.RNG(f.seed),f=0.3*(g.nextFloat()-0.5),i=0.3*(g.nextFloat()-0.5),g=0.4*g.nextFloat();o.flare(a,c,d,1+g,255,255,
255,0.6*h,"angleGaussian",f,i)};f.ithacaBorder=function(a,c,d){i(a,c,d,[255,255,255,1],"smooth",[1])};f.cherryBorder=function(a,c,f,h){var i=new e.RNG(h.seed);d(a,c,f,[255,255,255,1],"round",[0.03,1,1,1,1,1.5]);var h=0.03*Math.min(c,f)/c,j="ABERCRAVE ABILENE AITH BANFF BLEAN CAARNDUNCAN CORRIEVORRIE COTTERSTOCK DALRYMPLE DRAFFAN DUBUQUE EPSOM FROLESWORTH GLASSEL GOLANT HARPENDEN HASSOP HOVE POPCASTLE WINKLEY".split(" "),i="<> <> "+j[i.nextFloat()*j.length|0].toUpperCase()+" <> <>",j=1-1.4*h,k=0.85,
n=0.0030*Math.min(c,f)/c,o=-Math.PI/2;g.drawChar(a,c,f,i,n,j,k,230,50,40,0.4,0,0,o);g.drawChar(a,c,f,i,n,-1+0.6*h,k,230,50,40,0.4,0,0,o);k=-0.85;g.drawChar(a,c,f,i,n,1-1.4*h,k,230,50,40,0.4,-i.length,0,o);g.drawChar(a,c,f,i,n,-1+0.6*h,k,230,50,40,0.4,-i.length,0,o)};f.cross_processBorder=function(a,c,e,f){d(a,c,e,[255,255,255,1],"torn",[0.015*f.intensity,0.02,0.5,"uniform",f.seed])};f.sunburnFlare=function(a,c,d,f){var h=f.intensity,g=new e.RNG(f.seed),f=0.1*(g.nextFloat()-0.5),i=0.1*(g.nextFloat()-
0.5),g=0.1*(g.nextFloat()-0.5);o.flare(a,c,d,1+g,255,255,255,1*h,"gaussianThing2",f,i)};f.sunburnBorder=function(a,c,d){i(a,c,d,[0,0,0,1],"fade",[1,0,2.222])};f.fadedBorder=function(a,c,f,h){var g=h.intensity,h=new e.RNG(h.seed);d(a,c,f,[255,255,255,1],"round",[0.025,1,1,1,1,1.5]);var i;for(i=4;10>i;i++)A(a,c,f,[255,255,255,1],"torn",[0.03*g,0.0050*i+0.01,8,"uniform",h.nextInt()])};f.chronoBorder=function(a,c,f,i){var j=i.intensity,i=new e.RNG(i.seed);g.drawLine(a,c,f,255,255,0,0.2,[[0.35*c,f/8],
[0.65*c,f/8]],(c+f)/250);g.drawLine(a,c,f,255,255,0,0.2,[[0.35*c,7*f/8],[0.65*c,7*f/8]],(c+f)/250);g.drawLine(a,c,f,255,255,0,0.2,[[0.11*c,0.2*f],[0.11*c,0.8*f]],(c+f)/250);g.drawLine(a,c,f,110,110,0,0.85,[[0.965*c,0],[0.965*c,f]],0.07*c);g.drawLine(a,c,f,110,0,0,0.85,[[0.947*c,0.04*f],[1.2*c,0.3*f]],0.05*c);g.drawLine(a,c,f,110,0,0,0.85,[[0.947*c,0.96*f],[1.2*c,0.7*f]],0.05*c);g.drawLine(a,c,f,0,0,0,0.5,[[0.895*c,0],[0.895*c,f]],0);for(var n="1.4 2 2.8 4 5.6 8 11 16 22 32".split(" "),o=n[i.nextFloat()*
n.length|0],q=[0,0,0,0.8],A=0;A<n.length;A++){var v=2/n.length,x=0.9-v*A;(o==n[A]||o==n[A]+" "||o==n[A]+"  ")&&g.drawLine(a,c,f,255,255,0,0.2,[[0.86*c,(x/2-v/10+0.5)*f],[0.86*c,(x/2+v/10+0.5)*f]],(c+f)/250);g.drawChar(a,c,f,n[A],0.0040,0.95,x,q[0],q[1],q[2],q[3],-2-n[A].length/2);g.drawChar(a,c,f,"%",0.0040,0.95,x+v/2,q[0],q[1],q[2],q[3],-2.5)}k(a,c,f,{color:[0,0,0,1],seed:i.nextInt(),alpha:1,scale:0.5});h.vignette(a,c,f,1.1*((c+f)/2)/(j+1E-9),0,0,150);d(a,c,f,[0,0,0,1],"bulge",[0.05,0.28,0.5])};
f.cabanaBorder=function(a,c,e){var f=0.0053*Math.min(c,e)/c;g.drawLine(a,c,e,255,255,255,0.5,[[0,0.1*e],[0.08*c,0.1*e]],0);g.drawChar(a,c,e,"0.5",f,-0.8,-0.8-2*f,255,255,255,0.5);g.drawLine(a,c,e,255,255,255,0.5,[[0,0.3*e],[0.08*c,0.3*e]],0);g.drawChar(a,c,e,"1.0",f,-0.8,-0.4-2*f,255,255,255,0.5);g.drawLine(a,c,e,255,255,255,0.5,[[0,0.5*e],[0.08*c,0.5*e]],0);g.drawChar(a,c,e,"1.5",f,-0.8,-2*f,255,255,255,0.5);g.drawLine(a,c,e,255,255,255,0.5,[[0,0.7*e],[0.08*c,0.7*e]],0);g.drawChar(a,c,e,"2.0",f,
-0.8,0.4-2*f,255,255,255,0.5);g.drawLine(a,c,e,255,255,255,0.5,[[0,0.9*e],[0.08*c,0.9*e]],0);g.drawChar(a,c,e,"2.5",f,-0.8,0.8-2*f,255,255,255,0.5);d(a,c,e,[0,0,0,1],"round",[0.025,1,1,1,1,1.5])};f.soft_focus=function(a,c,d,e){e=e.intensity;j.softFocusConvolution(a,c,d,0.4*e,1+0.25*e)};B.exports=f});C.define("/src/js/core/rng.js",function(q,B){function e(e){this.seed=this.state="number"===typeof e&&0<=e?e:Math.floor(4294967295*Math.random())}var o={};e.prototype.nextInt=function(){return this.state=
(69069*this.state+1)%4294967296};e.prototype.nextIntN=function(e){for(;0<e;)this.state=(69069*this.state+1)%4294967296,e--;return this.state};e.prototype.nextFloat=function(){this.state=(69069*this.state+1)%4294967296;return this.state/4294967296};e.prototype.getState=function(){return this.state};e.prototype.getSeed=function(){return this.seed};e.prototype.nextFloatNormal=function(){for(var e=this.nextFloat(),a=this.nextFloat();0===e;)e=this.nextFloat();for(;0===a;)a=this.nextFloat();return Math.sqrt(-2*
Math.log(e))*Math.cos(2*Math.PI*a)};e.prototype.nextFloatLaplace=function(){var e=0.5-this.nextFloat();return 0>e?Math.log(1+2*e):-Math.log(1-2*e)};o.RNG=e;B.exports=o});C.define("/src/js/filters/flare.js",function(q,B){B.exports={flare:function(e,o,h,a,j,f,n,i,d,q,k,g,l,c){if(e.moaGL)e.moaGL.renderFlare(c,d,a,{r:j,g:f,b:n,a:255*i},q,k,g,l);else{"undefined"===typeof q&&(q=0);"undefined"===typeof k&&(k=0);"undefined"===typeof g&&(g=1);"undefined"===typeof l&&(l=1);"undefined"===typeof j?j=0:0>j?j=
0:255<j&&(j=255);"undefined"===typeof f?f=0:0>f?f=0:255<f&&(f=255);"undefined"===typeof n?n=0:0>n?n=0:255<n&&(n=255);"undefined"===typeof i&&(i=1);var p="sinc"===d,y="gaussianThing"===d,s="gaussianThing2"===d,r="gaussianThing3"===d,w="gaussianThing4"===d,u="angleGaussian"===d,z="stardom"===d,v="lobes"===d,x="stripe"===d,B="stripe2"===d,C="dimondFlare"===d,E="crossFlare"===d,t="cornerFlares"===d,aa="fingerFlare"===d,W="blobFlare"===d,N="blah"===d,L="blob"===d,d="blob2"===d;if(!(0==g||0==l||0==a||0==
i)){var M=!1;"overlay"===c&&(M=!0);var G,H,F,K,J,D,b,c=o/2|0,m=h/2|0,P=Math.log(1/255/i),q=q*c,k=k*m,g=1/a/c/g,l=1/a/m/l;p&&(l=g=2/a/(c+m));for(J=0;J<h;J++){G=4*J*o;b=l*(J-m-k);for(K=0;K<o;K++)if(a=G+4*K,D=g*(K-c-q),F=1,p?(F=80*(D*D+b*b),F=0===F?1:1-0.4*i*(Math.sin(F)/Math.sqrt(F))):y?(H=2*-(D*D+b*b)-16*(b+0.5)*(b+0.5)*(D+0.5)*(D+0.5),F=H<P?1:0<H?1-i:1-i*Math.exp(H)):s?(H=2*-(D*D+b*b)-16*(b+1)*(b+1)*(D-0.5)*(D-0.5),F=H<P?1:0<H?1-i:1-i*Math.exp(H)):r?(F=D*D+b*b,H=2*-F-1*(b+1.7)*(b+1.7)*(D-0.6)*(D-
0.6),F=H<P?1:0<H?1-i:1-i*Math.exp(H)):w?(H=-0.5*(b-1.7)*(b-1.7)*(D+0.6)*(D+0.6)-0.5*(b+1.7)*(b+1.7)*(D-0.6)*(D-0.6),F=H<P?1:0<H?1-i:1-i*Math.exp(H)):u?(H=2*-(D*D+b*b)-5*(D+0.2)*(b+0.2)*D*D,F=H<P?1:0<H?1-0.5*i:1-0.5*i*Math.exp(H)):z?(F=D*D+b*b,D=Math.atan2(b,D),F=1-0.2*i*(1-F*F*Math.sin(10*D))):v?(F=D*D+b*b,D=Math.atan2(b,D),F=1-0.5*i*Math.exp(2*-F)*(0.5+0.5*Math.sin(4*D+1))):x?(H=-(D*D)-b*b/64,F=H<P?1:0<H?1-i:1-i*Math.exp(H)):B?(H=-(b*b)-D*D/64,F=H<P?1:0<H?1-i:1-i*Math.exp(H)):C?(F=D*D+b*b,F=1-i*
Math.exp(2*-(F*F)+-8*(b+0.5)*(b-0.5)*(D+0.5)*(D-0.5))):E?(F=D*D+b*b,H=2*-(F/180)-16*(b+0.5)*(b+0.5)*(D+0.5)*(D+0.5),F=H<P?1:0<H?1-i:1-i*Math.exp(H)):t?(F=D*D+b*b,F=1-i*Math.exp(2*-(F/180))*Math.exp(-8*(b+1)*(b-1)*(D+1)*(D-1))):aa?(b=l*(J-m-k)-1,D=g*(K-c-q)-1,F=(D+1)*D+b*b,F=i*Math.exp(b/D+-F*Math.exp(Math.exp(b)*D))):W?(F=D*D+b*b,F=1-i*Math.exp(-Math.pow(F,2)+-0.9*(b-1.7)*(b+0.5)*(D-1.5)*(D+0.5))):N?(F=D*D+b*b,D=Math.atan2(b,D),F=H<P?1:0<H?1-i:1-0.2*i*(1-Math.sin(F)*Math.sin(10*F)*Math.sin(10*D))):
d?(H=10*-Math.pow(b*b+D*D,2),F=H<P?1:0<H?1-i:1-i*Math.exp(H)):L&&(H=100*-Math.pow(b*b+D*D,4),F=H<P?1:0<H?1-i:1-i*Math.exp(H)),F=0>F?0:1<F?1:F,M){D=e[a];var R=e[a+1],U=e[a+2];D=128>=D?F*D+2*(1-F)*D*j/256+0.5|0:F*D+(1-F)*(255-(255-(2*D-256))*(255-j)/256)+0.5|0;R=128>=R?F*R+2*(1-F)*R*f/256+0.5|0:F*R+(1-F)*(255-(255-(2*R-256))*(255-f)/256)+0.5|0;U=128>=U?F*U+2*(1-F)*U*n/256+0.5|0:F*U+(1-F)*(255-(255-(2*U-256))*(255-n)/256)+0.5|0;e[a]=D;e[a+1]=R;e[a+2]=U}else e[a]=e[a]*F+j*(1-F)+0.5|0,e[a+1]=e[a+1]*F+
f*(1-F)+0.5|0,e[a+2]=e[a+2]*F+n*(1-F)+0.5|0}}}}}});C.define("/src/js/filters/vignette.js",function(q,B){B.exports={vignette:function(e,o,h,a,j,f,n,i,d,q,k,g,l){if(e.moaGL)e.moaGL.renderVignette({blendMode:d,shapeMode:q,vignetteScale:a,color:{r:j,g:f,b:n,a:255*i},dx:g||0,dy:l||0,stretch:k});else{var c="overlay"===d,d="multiply"===d,p="sharp"===q,y="ultraSharp"===q,q="mediumSharp"===q;"boolean"!==typeof k&&(k=!1);"number"!==typeof i&&(i=1);"number"!==typeof g&&(g=0);"number"!==typeof l&&(l=0);var a=
1/(Math.pow(a,2)/1.15),s,r,w,u,z,v,x,B=o/2|0,C=h/2|0,E=5/3,t=34/45,aa=13/63,W=514/14175,g=g*B,l=l*C,N,L;for(L=0;L<h;L++){r=4*L*o;w=(L-C-l)*(L-C-l);for(N=0;N<o;N++)(s=r+4*N,u=k?((N-B-g)*(N-B-g)/o/o+(L-C-l)*(L-C-l)/h/h)*a:((N-B-g)*(N-B-g)+w)*a,p&&(u*=u),y&&(u*=u,u*=u),q&&(u=Math.pow(u,1.5)),1.15<u?u=0:0.04>u?u=1:(u*=u,z=u*u,v=z*u,x=v*u,u=1-2*u+E*z-t*v+aa*x-W*x*u),c)?(z=e[s],v=e[s+1],x=e[s+2],u=(1-u)*i,z=128>=z?(1-u)*z+2*u*z*j/256+0.5|0:(1-u)*z+u*(255-(255-(2*z-256))*(255-j)/256)+0.5|0,v=128>=v?(1-u)*
v+2*u*v*f/256+0.5|0:(1-u)*v+u*(255-(255-(2*v-256))*(255-f)/256)+0.5|0,x=128>=x?(1-u)*x+2*u*x*n/256+0.5|0:(1-u)*x+u*(255-(255-(2*x-256))*(255-n)/256)+0.5|0,z=255<z?255:0>z?0:z,v=255<v?255:0>v?0:v,x=255<x?255:0>x?0:x,e[s]=z,e[s+1]=v,e[s+2]=x):d?(u=1-i*(1-u),u=0>u?0:1<u?1:u,z=u*e[s]+(1-u)*j*e[s]/255+0.5|0,v=u*e[s+1]+(1-u)*f*e[s+1]/255+0.5|0,x=u*e[s+2]+(1-u)*n*e[s+2]/255+0.5|0,z=255<z?255:0>z?0:z,v=255<v?255:0>v?0:v,x=255<x?255:0>x?0:x,e[s]=z,e[s+1]=v,e[s+2]=x):(u=1-i*(1-u),u=0>u?0:1<u?1:u,e[s]=e[s]*
u+j*(1-u)+0.5|0,e[s+1]=e[s+1]*u+f*(1-u)+0.5|0,e[s+2]=e[s+2]*u+n*(1-u)+0.5|0)}}}}});C.define("/src/js/legacy/auto_colors_fade_max_color.js",function(q,B){var e=q("../filters/colorMatrixTransform"),o={getcdf:function(e){for(var a=0,j=0;256>j;j++)a+=e[j];j=Array(256);j[0]=e[0]/a;for(var f=1;256>f;f++)j[f]=e[f]/a+j[f-1];return j},cdfinv:function(e,a){if(0>=a)return 0;if(1<=a)return 255;for(var j=0;a>e[j];)j++;return 0===j?a/e[j]:j-1+(a-e[j-1])/(e[j]-e[j-1])},getHist:function(e){var a=Array(256),j=Array(256),
f=Array(256),n,i;for(n=0;256>n;n++)a[n]=0,j[n]=0,f[n]=0;n=0;for(i=e.length;n<i;n+=4)a[e[n]]++,j[e[n+1]]++,f[e[n+2]]++;return{r:a,g:j,b:f}},autocolorsfade:function(h,a,j,f,n,i,d){"undefined"===typeof f&&(f=1);var a=o.getHist(h),j=o.getcdf(a.r),q=o.getcdf(a.g),k=o.getcdf(a.b),a=f*o.cdfinv(j,0.0050),g=255*(1-f)+f*o.cdfinv(j,0.995),j=f*o.cdfinv(q,0.0050),l=255*(1-f)+f*o.cdfinv(q,0.995),q=f*o.cdfinv(k,0.0050),k=255*(1-f)+f*o.cdfinv(k,0.995);"undefined"!==typeof n&&(g=Math.max(n,g)*f+g*(1-f));"undefined"!==
typeof i&&(l=Math.max(i,l)*f+l*(1-f));"undefined"!==typeof d&&(k=Math.max(d,k)*f+k*(1-f));f=[255/(g-a),0,0,0,0,255/(l-j),0,0,0,0,255/(k-q),0];e.colorMatrixTransform(h,[1,0,0,-a,0,1,0,-j,0,0,1,-q]);e.colorMatrixTransform(h,f)}};B.exports=o});C.define("/src/js/legacy/soft_focus.js",function(q,B){var e={},o=q("../core/copy");e.softFocusConvolution=function(e,a,j,f,n){"undefined"===typeof f&&(f=0.4);"undefined"===typeof n&&(n=1.25);for(var i=o.copy(e),d,q,k,g,l,c,p=[4,0,-4,0,-10,10,-10,10,-15,15,0,0,
-6,6,-6,6,10,-10,0,0],y=[0,4,0,-4,-10,-10,10,10,0,0,15,-15,-6,-6,6,6,0,0,10,-10],s=Array(20),r=d=0;20>r;r++)s[r]=Math.exp(-(p[r]*p[r]+y[r]*y[r])/100),d+=s[r];for(r=0;20>r;r++)s[r]/=d;for(r=0;r<j;r++)for(var w=0;w<a;w++){d=4*(w+a*r);c=l=g=0;if(20>r||20>w||w>a-20||r>j-20)for(var u=0;20>u;u++)q=Math.max(0,Math.min(a-1,w+p[u])),k=Math.max(0,Math.min(j-1,r+y[u])),q=4*(q+a*k),k=s[u],g+=k*i[q],l+=k*i[q+1],c+=k*i[q+2];else for(u=0;20>u;u++)q=w+p[u],k=r+y[u],q=4*(q+a*k),k=s[u],g+=k*i[q],l+=k*i[q+1],c+=k*i[q+
2];g=n*f*g+(1-f)*i[d]+0.5|0;l=n*f*l+(1-f)*i[d+1]+0.5|0;c=n*f*c+(1-f)*i[d+2]+0.5|0;255<g?g=255:0>g&&(g=0);255<l?l=255:0>l&&(l=0);255<c?c=255:0>c&&(c=0);e[d]=g;e[d+1]=l;e[d+2]=c;e[d+3]=i[d+3]}};B.exports=e});C.define("/src/js/filters/noise.js",function(q,B){var e={},o=q("../core/rng");e.noise=function(e,a,j,f,n){var i,d,q,k,g=new o.RNG(n);if(e.moaGL)e.moaGL.renderNoise(f,n);else{f*=255;for(k=0;k<a*j;k++)n=4*k,q=f*(2*g.nextFloat()-1),i=e[n]+q+0.5|0,d=e[n+1]+q+0.5|0,q=e[n+2]+q+0.5|0,i=0>i?0:255<i?255:
i,d=0>d?0:255<d?255:d,q=0>q?0:255<q?255:q,e[n]=i,e[n+1]=d,e[n+2]=q}};B.exports=e});C.define("/src/js/filters/intensityMap.js",function(q,B){B.exports={mapIntensity:function(e,o,h,a){if(e.moaGL)e.moaGL.renderIntensityMap(o,h,a);else for(var j=e.length,f=0,n,i,d,q,k,g=1-a,l="overlay"===h,c="multiply"===h;f<j;)n=0.212671*e[f]+0.71516*e[f+1]+0.072169*e[f+2]+0.5|0,l?(h=e[f],i=e[f+1],d=e[f+2],q=o.r[n],k=o.g[n],n=o.b[n],h=128>=h?g*h+2*a*h*q/256+0.5|0:g*h+a*(255-(255-(2*h-256))*(255-q)/256)+0.5|0,i=128>=
i?g*i+2*a*i*k/256+0.5|0:g*i+a*(255-(255-(2*i-256))*(255-k)/256)+0.5|0,d=128>=d?g*d+2*a*d*n/256+0.5|0:g*d+a*(255-(255-(2*d-256))*(255-n)/256)+0.5|0,h=0>h?0:255<h?255:h,i=0>i?0:255<i?255:i,d=0>d?0:255<d?255:d,e[f]=h,e[f+1]=i,e[f+2]=d):c?(h=e[f],i=e[f+1],d=e[f+2],q=o.r[n],k=o.g[n],n=o.b[n],h=g*h+a*h*q/255+0.5|0,i=g*i+a*i*k/255+0.5|0,d=g*d+a*d*n/255+0.5|0,h=0>h?0:255<h?255:h,i=0>i?0:255<i?255:i,d=0>d?0:255<d?255:d,e[f]=h,e[f+1]=i,e[f+2]=d):(e[f]=g*e[f]+a*o.r[n],e[f+1]=g*e[f+1]+a*o.g[n],e[f+2]=g*e[f+2]+
a*o.b[n]),f+=4}}});C.define("/src/js/filters/gradient.js",function(q,B){B.exports={applyGradient:function(e,o,h,a,j,f,n,i,d,q,k,g){"string"!==typeof k&&(k="normal");"number"!==typeof g&&(k=1);if(0!=f){var l=[[],[],[],[]],c,p,y,s,r,w,u;w=0;u=1;for(c=0;1024>c;c++){for(p=1-(1023-c)/1023;a.colors[u].location<=100*p&&"object"===typeof a.colors[u+1];)u++,w++;p=(100*p-a.colors[w].location)/(a.colors[u].location-a.colors[w].location);p=Math.max(0,Math.min(1,p));p+=9*(1+1.5*Math.abs(p-0.5))*Math.sin(2*Math.PI*
(p-0.5))/255;p=Math.max(0,Math.min(1,p));s=a.colors[w].color;r=a.colors[u].color;y=1-p;l[0][c]=Math.max(0,Math.min(255,Math.round(s.r*y+p*r.r)));l[1][c]=Math.max(0,Math.min(255,Math.round(s.g*y+p*r.g)));l[2][c]=Math.max(0,Math.min(255,Math.round(s.b*y+p*r.b)))}w=0;u=1;for(c=0;1024>c;c++){for(p=1-(1023-c)/1023;a.opacities[u].location<=100*p&&"object"===typeof a.opacities[u+1];)u++,w++;p=(100*p-a.opacities[w].location)/(a.opacities[u].location-a.opacities[w].location);p=Math.max(0,Math.min(1,p));p+=
9*(1+1.5*Math.abs(p-0.5))*Math.sin(2*Math.PI*(p-0.5))/255;p=Math.max(0,Math.min(1,p));s=a.opacities[w].opacity;r=a.opacities[u].opacity;y=1-p;l[3][c]=Math.max(0,Math.min(1,s*y+p*r))}w=q.shapeMode;a="sharp"===w;c="ultraSharp"===w;w="mediumSharp"===w;u=q.dx;p=q.dy;y=1/(Math.pow(q.vignetteScale,2)/1.15);var z,v,x;s=o/2|0;r=h/2|0;u*=s;p*=r;var B=5/3,C=34/45,E=13/63,t=514/14175,aa=g,W="overlay"===k,N="multiply"===k,L="linear"===j,M="linearVignette"===j,j="radial"===j,G,H,F,K,J,D,b,m=Math.sin(d),d=Math.cos(d);
if(e.moaGL)e.moaGL.renderGradient(q,l,k,g,m,d,y);else for(K=0;K<h;K++){q=(K/h-i)/f;for(F=0;F<o;F++)k=4*(K*o+F),z=(F/o-n)/f,L?G=d*z-m*q:j?G=Math.sqrt(z*z+q*q):M&&((G=d*z-m*q,g=((F-s-u)*(F-s-u)/o/o+(K-r-p)*(K-r-p)/h/h)*y,a&&(g*=g),c&&(g*=g,g*=g),w&&(g=Math.pow(g,1.5)),1.15<g)?g=aa:0.04>g?g=0:(g*=g,z=g*g,v=z*g,x=v*g,g=aa*(1-(1-2*g+B*z-C*v+E*x-t*x*g)))),G=0>G?0:1<G?1:G,z=l[0][1023*G+0.5|0],v=l[1][1023*G+0.5|0],x=l[2][1023*G+0.5|0],G=l[3][1023*G+0.5|0],G*=g,H=1-G,J=e[k],D=e[k+1],b=e[k+2],W?(J=128>=J?H*
J+2*G*J*z/256+0.5|0:H*J+G*(255-(255-(2*J-256))*(255-z)/256),D=128>=D?H*D+2*G*D*v/256+0.5|0:H*D+G*(255-(255-(2*D-256))*(255-v)/256),b=128>=b?H*b+2*G*b*x/256+0.5|0:H*b+G*(255-(255-(2*b-256))*(255-x)/256)):N?(J=H*J+G*z*J/255,D=H*D+G*v*D/255,b=H*b+G*x*b/255):(J=H*J+z*G,D=H*D+v*G,b=H*b+x*G),J=J+0.5|0,D=D+0.5|0,b=b+0.5|0,J=255<J?255:0>J?0:J,D=255<D?255:0>D?0:D,b=255<b?255:0>b?0:b,e[k]=J,e[k+1]=D,e[k+2]=b}}}}});C.define("/proclist/src/js/FeatherEntry.coffee",function(q){q("../../../src/js/webgl/moaGL_bundle");
q("../../../src/js/filters/enhance");q("../../../src/js/legacy/whiten2");q("../../../src/js/legacy/redeye2");q("../../../src/js/legacy/selectiveblur");q("../../../src/js/mask-draw/colorsplash");q("../../../src/js/filters/adjustments");q("../../../src/js/mask-draw/drawtool");q("../../../src/js/mask-draw/tiltshift");q("../../../src/js/mask-draw/blemish");q("../../../src/js/mask-draw/redeye");q("../../../src/js/mask-draw/whiten");q("../../../src/js/mask-draw/spraytan");q("../../../src/js/mask-draw/shinereduce");
q("../../../src/js/mask-draw/blush");q("../../../src/js/mask-draw/lipstick");q("../../../src/js/mask-draw/mascara");q("./MoaLiteProclistManager");void 0!==typeof Aviary&&(Aviary.require=q)});C("/proclist/src/js/FeatherEntry.coffee")})();})();
if(typeof AV=="undefined"){AV={}}AV.Actions=function(){this.actionList=[];this.index=-1;return this};AV.Actions.prototype.undoImplicitActions=function(){while(this.index>=0&&this.actionList[this.index][2].implicit===true&&!this.isACheckpoint()){var undoAction=this.actionList[this.index][0];var undoFunc=undoAction[0];var undoObj=undoAction[1];var undoArgs=undoAction[2];undoFunc.apply(undoObj,undoArgs);this.index--}};AV.Actions.prototype.canUndo=function(){var canUndo=this.index>=0;if(this.index===0&&this.actionList[0][2].implicit===true){canUndo=false}return canUndo};AV.Actions.prototype.undo=function(){var undoAction,undoFunc,undoObj,undoArgs,dims;if(this.index<0||this.isACheckpoint()){return}do{if(AV.paintWidgetInstance){AV.paintWidgetInstance.dirty=true}undoAction=this.actionList[this.index][0];if(undoAction){undoFunc=undoAction[0];undoObj=undoAction[1];undoArgs=undoAction[2];undoFunc.apply(undoObj,undoArgs)}if(this.index>0){dims=this.actionList[this.index-1][3];if(dims){this.setDims(dims.hiresWidth||dims.width,dims.hiresHeight||dims.height)}}else{this.setDims(this._origHiresWidth,this._origHiresHeight)}this.index--}while(this.index>=0&&!this.isACheckpoint()&&this.actionList[this.index][2].implicit===true);if(AV.controlsWidgetInstance){AV.controlsWidgetInstance.layoutNotify(AV.launchData["openType"],"updateUndoRedo",[this.canUndo(),this.canRedo()])}};AV.Actions.prototype.undoFake=function(){var dims;if(this.index<0||this.isACheckpoint()){return}if(AV.paintWidgetInstance){AV.paintWidgetInstance.dirty=true}if(this.index>0){dims=this.actionList[this.index-1][3];if(dims){this.setDims(dims.hiresWidth||dims.width,dims.hiresHeight||dims.height)}}else{this.setDims(this._origHiresWidth,this._origHiresHeight)}this.index--;if(AV.controlsWidgetInstance){AV.controlsWidgetInstance.layoutNotify(AV.launchData["openType"],"updateUndoRedo",[this.canUndo(),this.canRedo()])}};AV.Actions.prototype.undoToCheckpoint=function(){var undoAction,undoFunc,undoObj,undoArgs,dims;if(this.index<0){return}if(AV.paintWidgetInstance){AV.paintWidgetInstance.dirty=true}do{undoAction=this.actionList[this.index][0];undoFunc=undoAction[0];undoObj=undoAction[1];undoArgs=undoAction[2];undoFunc.apply(undoObj,undoArgs);if(this.index>0){dims=this.actionList[this.index-1][3];if(dims){this.setDims(dims.hiresWidth||dims.width,dims.hiresHeight||dims.height)}}else{this.setDims(this._origHiresWidth,this._origHiresHeight)}this.index--}while(this.index>=0&&!this.isACheckpoint());if(AV.controlsWidgetInstance){AV.controlsWidgetInstance.layoutNotify(AV.launchData["openType"],"updateUndoRedo",[this.canUndo(),this.canRedo()])}};AV.Actions.prototype.canRedo=function(){return this.index<this.actionList.length-1};AV.Actions.prototype.redo=function(){var redoAction,redoFunc,redoObj,redoArgs,dims;if(this.index>=this.actionList.length-1){return}do{if(AV.paintWidgetInstance){AV.paintWidgetInstance.dirty=true}this.index++;redoAction=this.actionList[this.index][1];if(redoAction){redoFunc=redoAction[0];redoObj=redoAction[1];redoArgs=redoAction[2];redoFunc.apply(redoObj,redoArgs);dims=this.actionList[this.index][3];if(dims){this.setDims(dims.hiresWidth||dims.width,dims.hiresHeight||dims.height)}}}while(this.index<this.actionList.length-1&&this.actionList[this.index][2].implicit===true);if(AV.controlsWidgetInstance){AV.controlsWidgetInstance.layoutNotify(AV.launchData["openType"],"updateUndoRedo",[this.canUndo(),this.canRedo()])}};AV.Actions.prototype.redoFake=function(){var nextItem,dims;if(this.index>=this.actionList.length-1){return}if(AV.paintWidgetInstance){AV.paintWidgetInstance.dirty=true}nextItem=this.actionList[this.index+1];if(nextItem){dims=nextItem[3];if(dims){this.setDims(dims.hiresWidth||dims.width,dims.hiresHeight||dims.height)}}this.index++;if(AV.controlsWidgetInstance){AV.controlsWidgetInstance.layoutNotify(AV.launchData["openType"],"updateUndoRedo",[this.canUndo(),this.canRedo()])}};AV.Actions.prototype.redoToCheckpoint=function(){var redoAction,redoFunc,redoObj,redoArgs,dims,futureIndex,hasFutureCheckpoint=false;if(this.index>=this.actionList.length-1){return true}futureIndex=this.index;do{futureIndex++;hasFutureCheckpoint=this.isACheckpoint(futureIndex)}while(!hasFutureCheckpoint&&futureIndex<this.actionList.length-1);if(!hasFutureCheckpoint){return false}if(AV.paintWidgetInstance){AV.paintWidgetInstance.dirty=true}do{this.index++;redoAction=this.actionList[this.index][1];if(redoAction){redoFunc=redoAction[0];redoObj=redoAction[1];redoArgs=redoAction[2];redoFunc.apply(redoObj,redoArgs);dims=this.actionList[this.index][3];this.setDims(dims.hiresWidth||dims.width,dims.hiresHeight||dims.height)}}while(this.index<this.actionList.length-1&&!this.isACheckpoint());if(AV.controlsWidgetInstance){AV.controlsWidgetInstance.layoutNotify(AV.launchData["openType"],"updateUndoRedo",[this.canUndo(),this.canRedo()])}return true};AV.Actions.prototype.push=function(undo,redo,redoSerializable,hiresDimsOverride,flags){flags=flags||{};var hiresDims;this.truncate(true);hiresDims=hiresDimsOverride||this.getDims();this.actionList.push([undo,redo,flags,hiresDims,redoSerializable])};AV.Actions.prototype.setCheckpoint=function(checkpoint){if(this.index<0){return}this.actionList[this.index][2].checkpoint=checkpoint};AV.Actions.prototype.isACheckpoint=function(index){index=index!==undefined?index:this.index;if(this.actionList[index]){return!!this.actionList[index][2].checkpoint}else{return false}};AV.Actions.prototype.isImplicit=function(implicit){if(this.index<0){return}this.actionList[this.index][2].implicit=implicit};AV.Actions.prototype.truncate=function(suppressNotification){this.actionList.length=this.index+1;if(!suppressNotification&&AV.controlsWidgetInstance){AV.controlsWidgetInstance.layoutNotify(AV.launchData["openType"],"updateUndoRedo",[this.canUndo(),this.canRedo()])}};AV.Actions.prototype.getDims=function(){var wh=null;if(AV.paintWidgetInstance){wh=wh||{};wh.width=AV.paintWidgetInstance.width;wh.height=AV.paintWidgetInstance.height}if(this.hiresWidth&&this.hiresHeight){wh=wh||{};wh.hiresWidth=this.hiresWidth;wh.hiresHeight=this.hiresHeight}return wh};AV.Actions.prototype.setDims=function(w,h){if(this.hiresWidth!=w||this.hiresHeight!=h){this.hiresWidth=w;this.hiresHeight=h;if(AV.controlsWidgetInstance){AV.controlsWidgetInstance.imageSizeTracker.setImageScaledIndicator()}}};AV.Actions.prototype.setOrigSize=function(w,h){this._origHiresWidth=w;this._origHiresHeight=h;this.setDims(w,h)};AV.Actions.prototype.exportJSON=function(simplify){var origWidth,origHeight;if(AV.paintWidgetInstance){var owh=AV.paintWidgetInstance.getOrigSize();origWidth=owh.width;origHeight=owh.height}var jsonObj={metadata:{imageorigsize:[origWidth,origHeight]}};var action;var redoJSONObj;var i,j;var actionlistSimp;var addIndex;var actionName;var actionLayerId;var addAction;var newAction;var deleteList;var layerTracker;var actionlist=[];if(AV.isRelaunched&&AV.prevActionList){var previous=JSON.parse(AV.prevActionList);if(previous){actionlist=previous.actionlist.slice()}}actionlist.push({action:"setfeathereditsize",width:origWidth,height:origHeight});for(i=0;i<this.index+1;i++){action=this.actionList[i];redoJSONObj=action[4];if(!redoJSONObj){continue}if(redoJSONObj.length==undefined){actionlist.push(redoJSONObj)}else{for(j=0;j<redoJSONObj.length;j++){actionlist.push(redoJSONObj[j])}}}if(simplify){addIndex={};actionlistSimp=[];actionlistSimp.length=actionlist.length;for(i=0;i<actionlist.length;i++){action=AV.util.extend({},actionlist[i]);actionName=action.action;switch(actionName){case"addsticker":case"addtext":actionLayerId=action.id;addIndex[actionLayerId]=i;actionlistSimp[i]=action;break;case"setsticker":actionLayerId=action.id;addAction=actionlist[addIndex[actionLayerId]];newAction={};newAction.action=addAction.action;newAction.url=addAction.url;newAction.urls=addAction.urls;newAction.size=addAction.size;newAction.external=addAction.external;newAction.id=addAction.id;newAction.center=action.center;newAction.scale=action.scale;newAction.rotation=action.rotation;actionlistSimp[i]=newAction;break;case"settext":actionLayerId=action.id;addAction=actionlist[addIndex[actionLayerId]];newAction={};newAction.action=addAction.action;newAction.id=addAction.id;newAction.text=addAction.text;newAction.font=addAction.font;newAction.size=addAction.size;newAction.color=addAction.color;newAction.shadowcolor=addAction.shadowcolor;newAction.center=action.center;newAction.scale=action.scale;newAction.rotation=action.rotation;actionlistSimp[i]=newAction;break;default:actionlistSimp[i]=action;break}}deleteList={};for(i=actionlistSimp.length-1;i>=0;i--){action=actionlistSimp[i];actionName=action.action;switch(actionName){case"deletetext":case"deletesticker":actionLayerId=action.id;deleteList[actionLayerId]=true;actionlistSimp.splice(i,1);break;case"addtext":case"addsticker":actionLayerId=action.id;if(deleteList[actionLayerId]){actionlistSimp.splice(i,1)}else{deleteList[actionLayerId]=true}delete action.id;break}}jsonObj["actionlist"]=actionlistSimp}else{jsonObj["actionlist"]=actionlist}if(jsonObj&&jsonObj.actionlist&&jsonObj.actionlist.length){var list=jsonObj.actionlist;for(var i=0;i<list.length;i++){if(list[i].action=="addsticker"){if(list[i].url&&list[i].url.indexOf("https://")==0){list[i].url=list[i].url.replace("https://","http://");for(var ii=0;ii<list[i].urls.length;ii++){list[i].urls[ii]=list[i].urls[ii].replace("https://","http://")}}}}}return AV.JSON.stringify(jsonObj)};AV.Actions.prototype.importJSON=function(jsonString,callback){if(!jsonString){if(callback){callback()}return false}if(!AV.paintWidgetInstance){if(callback){callback()}return false}var origWidth,origHeight;var jsonObj,actionlist=[];var _actions=this;var i,j,actionlistLength;try{jsonObj=AV.JSON.parse(jsonString);if(jsonObj){actionlist=jsonObj.actionlist}}catch(probablyAParseError){if(callback){callback()}return false}actionlistLength=actionlist.length;var enhanceNames={labcorrect:true,backlightenhance:true,nightenhance:true,autoenhance:true};var convertEnhanceAction=function(actionObject){var actionName=actionObject.action;for(var effectName in enhanceNames){if(effectName===actionName){actionObject.id=actionName;actionObject.action="enhance";return true}}return false};var processItem=function(actionObject){convertEnhanceAction(actionObject);var actionName=actionObject.action;switch(actionName){case"addsticker":actionName="overlay";break;case"addtext":if(actionObject.align){actionName="textwithfont"}else{actionName="text"}break;case"tools":actionName=actionObject.toolname;if(actionName=="tiltshift"){actionName="focus"}break;case"rotate":actionName="straighten";break;case"colortemp":actionName="warmth";break;case"sharpness":actionName="sharpen";break;case"redeye2":actionName="redeye";break;case"whiten2":actionName="whiten";break;case"selectiveblur":actionName="blemish";break;case"imageborders":actionName="frames";break;default:break}if(AV.paintWidgetInstance.module[actionName]&&AV.paintWidgetInstance.module[actionName]["readAction"]){AV.paintWidgetInstance.moduleLoaded(actionName,function(toolName){AV.paintWidgetInstance.setMode(actionName);AV.paintWidgetInstance.module[actionName]["readAction"].apply(this,[actionObject,nextItem])})}else{nextItem()}};var nextItem=function(){_actions.setCheckpoint(true);i++;if(i<actionlistLength){processItem(actionlist[i])}else{if(callback){callback()}AV.paintWidgetInstance.setMode(null)}};i=0;nextItem();return true};!function(AV,window,document){AV.FilterManager=function(){var urls=[];var utils={};var borders={};var flares={};var tools={};var effects={};var idToEffect={};var filterPacks={};var loadingUrls={};var api=this;var _haveNotSeenUrl=function(url){var i,len=urls.length;for(i=0;i<len;i++){if(urls[i]===url){return false}}urls.push(url);return true};var _haveNotLoadedUrl=function(url){return!!loadingUrls[url]};var _fireAllCallbacksForUrl=function(url){var i,len,callback;if(loadingUrls[url]&&loadingUrls[url].length){len=loadingUrls[url].length;for(i=0;i<len;i++){callback=loadingUrls[url][i];if(callback){callback.call()}}}delete loadingUrls[url]};var _addCallbackForUrl=function(url,callback){loadingUrls[url]=loadingUrls[url]||[];loadingUrls[url].push(callback)};var _gatherProclistEffects=function(id,packs){var i,pack,effects,packLen;if(packs){for(i=0;i<packs.length;i++){pack=packs[i];if(pack&&pack["codename"]&&pack["codename"]+"_effects"===id){effects=pack.items;if(effects){filterPacks[id]=effects;packLen=effects.length;for(var j=0;j<packLen;j++){idToEffect[effects[j]["identifier"]]=effects[j]}}packs.splice(i,1);break}}}};api.getEffectById=function(id){return idToEffect[id]};api.getClickableFiltersForPack=function(id){return filterPacks[id]};api.loadPack=function(packId,url,callback){var onComplete=function(){_gatherProclistEffects(packId,AV.proclistPacks);if(callback)callback.call(this)};if(url&&_haveNotSeenUrl(url)){_addCallbackForUrl(url,onComplete);AV.util.loadFile(url,"js",function(ev){_fireAllCallbacksForUrl(url)})}else{if(_haveNotLoadedUrl(url)){_addCallbackForUrl(url,onComplete)}else{onComplete()}}};return api}}(window["AV"]||(window["AV"]={}),window,document);!function(exports){exports["AV"]=exports["AV"]||{};var AV=exports["AV"];AV.ImageBorderManager=function(){var urls=[];var idToEffect={};var filterPacks={};var api=this;var _haveNotSeenUrl=function(url){var i,len=urls.length;for(i=0;i<len;i++){if(urls[i]===url){return false}}urls.push(url);return true};var _gatherFilters=function(id,packs){var i,j,clickable,packlen,borderObj;if(packs){for(i=0;i<packs.length;i++){filterPacks[id]=packs[i];packlen=packs[i].length;for(j=0;j<packlen;j++){borderObj=packs[i][j];idToEffect[borderObj.border_name]=borderObj}}packs.splice(0,i+1)}};api.getEffectById=function(id){return idToEffect[id]};api.getClickableFiltersForPack=function(id){return filterPacks[id]};api.tileBorder=function(frameName,callback){var item=api.getEffectById(frameName);var itemImages=item.images;var imageObj0=new Image;var imageObj1=new Image;var imageObj2=new Image;var imageObj3=new Image;var imageObj4=new Image;var imageObj5=new Image;var imageObj6=new Image;var imageObj7=new Image;var tileNames=["tl","tr","br","bl","l","t","r","b"];var tileImgs=[imageObj0,imageObj1,imageObj2,imageObj3,imageObj4,imageObj5,imageObj6,imageObj7];var imagesToLoad=[];var tilesObj={};for(var i=0;i<tileNames.length;i++){var prop=tileNames[i];tilesObj[prop]={w:itemImages[prop].width,h:itemImages[prop].height,img:tileImgs[i]};imagesToLoad.push({img:tileImgs[i],src:itemImages[prop].src})}AV.util.loadImagesSync(imagesToLoad,function(){if(callback){callback.apply(this,[tilesObj])}})};api.loadPack=function(packId,url,callback){if(url&&_haveNotSeenUrl(url)){AV.util.loadFile(url,"js",function(ev){_gatherFilters(packId,AV["borderPacks"]);if(callback)callback.call(this)})}else{_gatherFilters(packId,AV["borderPacks"]);if(callback)callback.call(this)}};return api};return exports}(this);!function(AV,window,document){AV.OverlayRegistry=function(){var _registry={};var _loadSticker=function(url,callback){var onload_handler;var imgElementClean;AV.util.nextFrame(function(){avpw$.ajax({type:"GET",dataType:"json",url:AV.build["jsonp_imgserver"]+"?callback=?",data:{url:escape(url)},success:function(data){imgElementClean=document.createElement("img");imgElementClean.fullimageurl=url;avpw$(imgElementClean).attr("src",data.data);onload_handler=function(e){avpw$(imgElementClean).unbind("load",onload_handler);api.addElement(url,imgElementClean);if(callback){callback.apply(this,[e])}};avpw$(imgElementClean).load(onload_handler)}})})};var api=this;api.add=function(id,hiresurl){if(!_registry[id]){_registry[id]={}}if(hiresurl){_registry[id].hiresurl=hiresurl}};api.addElement=function(id,cleanImage){if(!_registry[id]){api.add(id)}_registry[id].element=cleanImage};api.getElement=function(id,callback){var el=null;if(!_registry[id]||!_registry[id].element){if(callback){_loadSticker(id,callback)}}else{el=_registry[id].element;if(callback){callback.apply(this,[el])}}return el};api.getHiRes=function(id){return _registry[id].hiresurl};return api}}(window["AV"]||(window["AV"]={}),window,document);!function(AV,window,document){var mediator=AV.Events;AV.ModeManager=function(){var _this=this;var activateCanvasForMode=function(mode){_this.setCurrentLayerByName("background");_this.uiLayerShow(false);if(_this.active!==null){if(_this.active.deactivate!==undefined){_this.active.deactivate()}}if(mode!==null&&mode!==undefined&&mode!==""){var newactive=_this.module[mode];if(newactive!==undefined){_this.active=newactive;if(_this.active.activate!==undefined){_this.active.activate(_this)}}}else{_this.active=null}};var init=function(context){if(context){_this=context}mediator.on("canvas:activate",activateCanvasForMode)};var shutdown=function(){mediator.off("canvas:activate",activateCanvasForMode)};var api={};api.init=init;api.shutdown=shutdown;return api}}(window["AV"]||(window["AV"]={}),window,document);!function(exports,window,document){exports["AV"]=exports["AV"]||{};var AV=exports["AV"];var mediator=AV.Events;!function($){$.support.touch=$.support.touch||"ontouchend"in document}(avpw_jQuery);AV.PaintUI=function(canvas,eventsCanvas){var $canvas=avpw$(canvas);var $eventsCanvas=avpw$(eventsCanvas);var _registry={};var _events=["mouseOutEvent","mouseMoveEvent","mouseDownEvent","mouseUpEvent"];var _canvasOffset;var _moveReady=true;var _MOVE_DELAY=30;var _panEnabled=true;var _canvasMouseIsDown=false;var api=this;var _noOp=function(){};var _getCoords=function(ev){_canvasOffset=_canvasOffset||$canvas.offset();var x,y,canvasX,canvasY,touch,frac;if(ev.type=="internal"){x=ev.x;y=ev.y}else{touch=AV.util.getTouch(ev);if(touch){x=touch.pageX;y=touch.pageY}else{x=ev.pageX;y=ev.pageY}}canvasX=x-_canvasOffset.left;canvasY=y-_canvasOffset.top;canvasControlsX=canvasX;canvasControlsY=canvasY;frac=api.viewport.getRatio();canvasX=canvasX*frac;canvasY=canvasY*frac;return{x:x|0,y:y|0,canvasX:canvasX|0,canvasY:canvasY|0,canvasControlsX:canvasControlsX,canvasControlsY:canvasControlsY}};var _isWithinCanvasByBounds=function(x,y){var frac=api.viewport.getRatio();var cpos=$canvas.offset();var x0=cpos.left;var x1=x0+$canvas.width()/frac;var y0=cpos.top;var y1=y0+$canvas.height()/frac;return x>x0&&x<x1&&y>y0&&y<y1};api.enablePan=function(){_panEnabled=true;api.viewport.clearAvailablePanDirections();api.viewport.pan()};api.disablePan=function(){_panEnabled=false;api.hidePan()};api.showPan=function(){if(_panEnabled){api.addCanvasClass("avpw_can_pan")}};api.hidePan=function(){api.removeCanvasClass("avpw_can_pan")};var PAN_RATE=20;var _panTimer=null;var _panBusy=false;var _startCoords;var _canvasPanned=function(x,y){_panBusy=true;var dx=x-_startCoords.x;var dy=y-_startCoords.y;api.viewport.pan(dx,dy);var lastCoords={x:x,y:y};window.clearTimeout(_panTimer);_panTimer=window.setTimeout(function(){_panBusy=false;_startCoords=lastCoords},PAN_RATE)};var ZOOM_RATE=20;var _zoomTimer=null;var _zoomBusy=false;var _canvasZoomed=function(scale){_zoomBusy=true;api.viewport.gestureZoomUpdate(scale);window.clearTimeout(_zoomTimer);_zoomTimer=window.setTimeout(function(){_zoomBusy=false},ZOOM_RATE)};var _canvasGestureChanged=function(ev){if(ev.scale&&!_zoomBusy){_canvasZoomed(ev.scale)}return false};var _onModeChange=function(mode){api.setMouseCursor()};var _canvasMouseOut=function(ev){if(_registry["mouseOutEvent"]){_registry["mouseOutEvent"].apply(api,[{},ev])}};var _canvasMouseMove=function(ev){var coords;if(_moveReady){_moveReady=false;window.setTimeout(function(){_moveReady=true},_MOVE_DELAY);if(_registry["mouseMoveEvent"]){coords=_getCoords(ev);return _registry["mouseMoveEvent"].apply(api,[coords,ev])}else{if(_panEnabled&&_canvasMouseIsDown){coords=_getCoords(ev);ev.preventDefault();_startCoords=_startCoords||coords;if(!_panBusy){_canvasPanned(coords.x,coords.y)}}}}};var _canvasMouseDown=function(ev){if(_registry["mouseDownEvent"]){var coords=_getCoords(ev);return _registry["mouseDownEvent"].apply(api,[coords,ev,_isWithinCanvasByBounds(coords.x,coords.y)])}else{if(_panEnabled){_startCoords=undefined;_canvasMouseIsDown=true;if(api.canvasHasClass("avpw_can_pan")){api.addCanvasClass("avpw_is_panning")}}}};var _canvasMouseUp=function(ev){if(_registry["mouseUpEvent"]){var coords=_getCoords(ev);_registry["mouseUpEvent"].apply(api,[coords,ev])}else{if(_panEnabled){_canvasMouseIsDown=false;if(api.viewport.isZoomed()){api.viewport.bounceBack()}api.removeCanvasClass("avpw_is_panning")}}};api.resetOffset=function(){_canvasOffset=undefined};api.getCoordinatesFromEventWithinCanvasBounds=function(ev){var coords=_getCoords(ev);return _isWithinCanvasByBounds(coords.x,coords.y)?coords:null};api.getCoordinatesFromEvent=function(ev){return _getCoords(ev)};api.getViewportCenter=function(){var viewportOffset,viewportEl,w,h;viewportEl=AV.controlsWidgetInstance.layoutNotify(AV.launchData["openType"],"getEmbedElement");if(viewportEl){viewportEl=avpw$(viewportEl);w=viewportEl.width();h=viewportEl.height();viewportOffset=viewportEl.offset();return _getCoords({type:"internal",x:w/2+viewportOffset.left,y:h/2+viewportOffset.top})}else{return null}};api.subscribe=function(module){for(var i=0;i<_events.length;i++){if(module[_events[i]]){_registry[_events[i]]=module[_events[i]].AV_bindInst(module)}}api.disablePan()};api.unsubscribe=function(module){_registry={};api.enablePan()};api.shutdown=function(){mediator.off("layout:resize",api.resetOffset);$eventsCanvas.unbind("mouseleave").unbind("mousedown");avpw$(window).unbind("mousemove",_canvasMouseMove).unbind("mouseup",_canvasMouseUp).unbind("scroll",api.resetOffset);if(avpw$.support.touch){$eventsCanvas.unbind("touchmove").unbind("touchstart").unbind("touchend").unbind("gesturechange").unbind("gestureend");avpw$(window).unbind("touchmove",_noOp)}api.resetOffset();api.viewport.shutdown();_registry={};_canvasMouseIsDown=false};api.setMouseCursor=function(cur){if(cur===undefined){cur=""}canvas.style.cursor=cur};api.addCanvasClass=function(className){$canvas.addClass(className)};api.removeCanvasClass=function(className){$canvas.removeClass(className)};api.canvasHasClass=function(className){return $canvas.hasClass(className)};mediator.on("tool:open",_onModeChange);mediator.on("layout:resize",api.resetOffset);$eventsCanvas.bind("mouseleave",_canvasMouseOut).bind("mousedown",_canvasMouseDown);avpw$(window).bind("mouseup",_canvasMouseUp).bind("mousemove",_canvasMouseMove).bind("scroll",api.resetOffset);if(avpw$.support.touch){avpw$(window).bind("touchmove",_noOp);$eventsCanvas.bind("touchstart",function(ev){avpw$(window).unbind("mousemove",_canvasMouseMove);$eventsCanvas.bind("touchmove",_canvasMouseMove);return _canvasMouseDown(ev)}).bind("touchend",function(ev){$eventsCanvas.unbind("touchmove",_canvasMouseMove);avpw$(window).bind("mousemove",_canvasMouseMove);_canvasMouseUp(ev);return false});$eventsCanvas.bind("gesturechange",_canvasGestureChanged).bind("gestureend",api.viewport.gestureZoomFinish)}api.viewport.setCanvas.apply(api,[canvas]);return api};AV.PaintUI.prototype.viewport=function(){var _paintUI,_canvas,api={};var _realDOMWidth,_zoomDelta;var viewportBbox=null,zoomedCanvasBbox=null;var _lastCanvasRatio=1;var _possiblePanDirections;var _getPanDirections=function(){var zoomedCanvasX1=zoomedCanvasBbox.x0+zoomedCanvasBbox.w,zoomedCanvasY1=zoomedCanvasBbox.y0+zoomedCanvasBbox.h,x=false,y=false;if(zoomedCanvasX1>viewportBbox.w||zoomedCanvasBbox.x0<viewportBbox.x0){x=true}if(zoomedCanvasBbox.y0<viewportBbox.y0||zoomedCanvasY1>viewportBbox.h){y=true}if(x||y){_paintUI.showPan()}else{_paintUI.hidePan()}return{x:x,y:y}};var TRANSFORM_PROPERTY=AV.support.getVendorProperty("transform");var _transform=function(args){if(TRANSFORM_PROPERTY&&(AV.launchData["openType"]=="mobile"||AV.launchData["openType"]=="aviary")){var scale=args&&args.scale?args.scale:1/api.getRatio();var centerOffsetX=.5*(zoomedCanvasBbox.w*1/scale-zoomedCanvasBbox.w)+.5|0;var centerOffsetY=.5*(zoomedCanvasBbox.h*1/scale-zoomedCanvasBbox.h)+.5|0;var x=zoomedCanvasBbox.x0-centerOffsetX;var y=zoomedCanvasBbox.y0-centerOffsetY;var style=new AV.TransformStyle(_canvas.style[TRANSFORM_PROPERTY]);style.set({translate:x+"px, "+y+"px",scale:scale});_canvas.style[TRANSFORM_PROPERTY]=style.serialize()}else{_canvas.style.width=zoomedCanvasBbox.w+"px";_canvas.style.height=zoomedCanvasBbox.h+"px";_canvas.style.marginLeft="-"+(zoomedCanvasBbox.w/2+.5|0)+"px";_canvas.style.marginTop="-"+(zoomedCanvasBbox.h/2+.5|0)+"px"}};api.setCanvas=function(canvas){_canvas=canvas;_paintUI=this;if(TRANSFORM_PROPERTY){_paintUI.addCanvasClass("avpw_position_by_transform")}};api.shutdown=function(){_realDOMWidth=_zoomDelta=undefined;viewportBbox=zoomedCanvasBbox=null};var _setZoomDelta=function(){_zoomDelta=Math.abs((_realDOMWidth-zoomedCanvasBbox.w)/2)+.5|0};var _zoomByIncrement=function(inc){if(inc){var w=zoomedCanvasBbox.w+_zoomDelta*inc,h=w*_canvas.height/_canvas.width+.5|0;if(h<0||w<0){return false}zoomedCanvasBbox.w=w;zoomedCanvasBbox.h=h;_centerCanvas();_clearAvailablePanDirections()}};var _lastScale=1;var _supportsAnimation=!!AV.support.getVendorProperty("transformStyle");api.gestureZoomUpdate=function(scale){_lastScale=scale;scale=scale*1/api.getRatio();_transform({scale:scale})};api.gestureZoomFinish=function(){if(_lastScale){var w=zoomedCanvasBbox.w*_lastScale+.5|0,h=zoomedCanvasBbox.h*_lastScale+.5|0,wOverH=w/h;if(w<viewportBbox.w&&h<viewportBbox.h){if(w>wOverH*h){zoomedCanvasBbox.w=viewportBbox.w;zoomedCanvasBbox.h=viewportBbox.w*h/w+.5|0}else{zoomedCanvasBbox.h=viewportBbox.h;zoomedCanvasBbox.w=viewportBbox.h*wOverH+.5|0}}else{zoomedCanvasBbox.w=w;zoomedCanvasBbox.h=h}_transform()}};var _setScale=function(maxWidth,maxHeight,clamp){var canvasWidth=_canvas.width;var canvasHeight=_canvas.height;var canvasWidthOverHeight=canvasWidth/canvasHeight;var zoomedDims;maxWidth=maxWidth||canvasWidth;maxHeight=maxHeight||canvasHeight;_realDOMWidth=canvasWidth;if(clamp){zoomedDims=AV.util.getScaledDims(canvasWidth,canvasHeight,maxWidth,maxHeight);maxWidth=zoomedDims.width;maxHeight=zoomedDims.height}zoomedCanvasBbox=new AV.Bbox(0,0,maxWidth,maxHeight);_setZoomDelta();_clearAvailablePanDirections()};var _pan=function(x,y,force){_possiblePanDirections=_possiblePanDirections||_getPanDirections();var doThePan=false;if(force||_possiblePanDirections.x){zoomedCanvasBbox.x0+=x;doThePan=true}if(force||_possiblePanDirections.y){zoomedCanvasBbox.y0+=y;doThePan=true}return doThePan};var _clearAvailablePanDirections=function(){_possiblePanDirections=undefined};var _bounceBack=function(){var zoomedCanvasX1=zoomedCanvasBbox.x0+zoomedCanvasBbox.w,zoomedCanvasY1=zoomedCanvasBbox.y0+zoomedCanvasBbox.h,overshot;if(zoomedCanvasX1>viewportBbox.w&&zoomedCanvasBbox.x0>viewportBbox.x0){overshot=viewportBbox.w-zoomedCanvasBbox.w;zoomedCanvasBbox.x0=overshot>0?overshot:0}else if(zoomedCanvasBbox.x0<viewportBbox.x0&&zoomedCanvasX1<viewportBbox.w){overshot=viewportBbox.w-zoomedCanvasBbox.w;zoomedCanvasBbox.x0=overshot<0?overshot:0}if(zoomedCanvasY1>viewportBbox.h&&zoomedCanvasBbox.y0>viewportBbox.y0){overshot=viewportBbox.h-zoomedCanvasBbox.h;zoomedCanvasBbox.y0=overshot>0?overshot:0}else if(zoomedCanvasBbox.y0<viewportBbox.x0&&zoomedCanvasY1<viewportBbox.h){overshot=viewportBbox.h-zoomedCanvasBbox.h;zoomedCanvasBbox.y0=overshot<0?overshot:0}return _pan(0,0)};var _centerCanvas=function(){if(!viewportBbox){return}var centerOffsetX=(viewportBbox.w-zoomedCanvasBbox.w)/2+.5|0;var centerOffsetY=(viewportBbox.h-zoomedCanvasBbox.h)/2+.5|0;zoomedCanvasBbox.x0=zoomedCanvasBbox.y0=0;_pan(centerOffsetX,centerOffsetY,true)};var _rotateBoundsBy90=function(angle){if(angle%180&&!(angle%90)){var w=zoomedCanvasBbox.w;zoomedCanvasBbox.w=zoomedCanvasBbox.h;zoomedCanvasBbox.h=w;_centerCanvas();return true}else{return false}};var _onCanvasResized=function(){var newCanvasRatio=api.getRatio();mediator.trigger("canvas:resize",zoomedCanvasBbox,newCanvasRatio,_lastCanvasRatio);_lastCanvasRatio=newCanvasRatio};api.isZoomed=function(){return api.getRatio()!==1};api.getRatio=function(){return zoomedCanvasBbox?_realDOMWidth/zoomedCanvasBbox.w:1};api.zoomIn=function(){if(!zoomedCanvasBbox){_setScale()}_zoomByIncrement(1);_transform();_paintUI.resetOffset();_onCanvasResized();return false};api.zoomOut=function(){if(!zoomedCanvasBbox){_setScale()}_zoomByIncrement(-1);_transform();_paintUI.resetOffset();_onCanvasResized();return false};api.zoomByRatio=function(ratio){var newW=_canvas.width*ratio;var newH=_canvas.height*ratio;var oldW=zoomedCanvasBbox.w;var oldH=zoomedCanvasBbox.h;var panX=0;var panY=0;zoomedCanvasBbox.w=newW+.5|0;zoomedCanvasBbox.h=newH+.5|0;_possiblePanDirections=_getPanDirections();if(_possiblePanDirections.x){panX=-((newW-oldW)/2+.5|0)}else{panX=(viewportBbox.w-zoomedCanvasBbox.w)/2+.5|0;zoomedCanvasBbox.x0=0}if(_possiblePanDirections.y){panY=-((newH-oldH)/2+.5|0)}else{panY=(viewportBbox.h-zoomedCanvasBbox.h)/2+.5|0;zoomedCanvasBbox.y0=0}_pan(panX,panY,true);_bounceBack();_transform();_paintUI.resetOffset();_clearAvailablePanDirections();_onCanvasResized();return false};api.fitLayout=function(w,h){viewportBbox=new AV.Bbox(0,0,w,h);_setScale(w,h,true);_centerCanvas();_transform();_paintUI.resetOffset();_onCanvasResized()};api.resize=function(w,h){_setScale(w,h,true);_centerCanvas();_transform();_paintUI.resetOffset();_onCanvasResized();return false};api.resizeFake=function(w,h){_setScale(w,h);_centerCanvas();_transform();_paintUI.resetOffset();return false};api.pan=function(x,y,force){if(_pan(x,y,force)){_transform();_paintUI.resetOffset()}};api.clearAvailablePanDirections=function(){_clearAvailablePanDirections()};api.bounceBack=function(){if(_bounceBack()){_transform();_paintUI.resetOffset()}_onCanvasResized()};api.rotate=function(x,y,z){x=x?x+"deg":"0";y=y?y+"deg":"0";z=z?z+"deg":"0";var style=new AV.TransformStyle(_canvas.style[TRANSFORM_PROPERTY]);if(_supportsAnimation){style.set({rotateX:x,rotateY:y,rotateZ:z})}else{style.set({rotate:x})}_canvas.style[TRANSFORM_PROPERTY]=style.serialize()};api.rotateBoundsBy90=function(angle){if(_rotateBoundsBy90(angle)){_onCanvasResized();return true}else{return false}};return api}();return exports}(this,typeof window!=="undefined"?window:{},typeof document!=="undefined"?document:{});!function(AV,window,document){avpw$=typeof avpw$!=="undefined"?avpw$:{};AV.CropController=function(controls,paintWidget){var _dragStart=null;var _dragCornerOffset={};var _forceAspect=false;var _wtoh=1;var _corner=-1;var _bbox;var _canvasBbox;var _cropUIElement;var _overlayModule;var lastW,lastH;var _setCanvasBounds=function(){_canvasBbox=new AV.Bbox(0,0,paintWidget.width,paintWidget.height)};var _unsetCanvasBounds=function(){_canvasBbox=null};var _storeRatio=function(){_wtoh=_bbox?Math.abs((_bbox.x1-_bbox.x0)/(_bbox.y1-_bbox.y0)):0};var _constrainBoundingBoxByPoint=function(xCoord,yCoord){var factor,constraint;if(_wtoh==0){return}var htow=1/_wtoh;if(_forceAspect){if(Math.abs((_bbox.x1-_bbox.x0)/(_bbox.y1-_bbox.y0))>_wtoh){factor=AV.math.sign(_bbox.y1-_bbox.y0)*Math.abs(_bbox.x1-_bbox.x0)*htow+.5|0;if(yCoord==="y1"){_bbox[yCoord]=_bbox.y0+factor}else{_bbox[yCoord]=_bbox.y1-factor}}else{factor=AV.math.sign(_bbox.x1-_bbox.x0)*Math.abs(_bbox.y1-_bbox.y0)*_wtoh+.5|0;if(xCoord==="x1"){_bbox[xCoord]=_bbox.x0+factor}else{_bbox[xCoord]=_bbox.x1-factor}}}constraint=_canvasBbox.constrain(_bbox[xCoord],_bbox[yCoord]);_bbox[xCoord]=constraint.x;_bbox[yCoord]=constraint.y;if(_forceAspect&&constraint.dirty){if(Math.abs((_bbox.x1-_bbox.x0)/(_bbox.y1-_bbox.y0))>_wtoh){factor=AV.math.sign(_bbox.x1-_bbox.x0)*Math.abs(_bbox.y1-_bbox.y0)*_wtoh+.5|0;if(xCoord==="x1"){_bbox[xCoord]=_bbox.x0+factor}else{_bbox[xCoord]=_bbox.x1-factor}}else{factor=AV.math.sign(_bbox.y1-_bbox.y0)*Math.abs(_bbox.x1-_bbox.x0)*htow+.5|0;if(yCoord==="y1"){_bbox[yCoord]=_bbox.y0+factor}else{_bbox[yCoord]=_bbox.y1-factor}}}};var _set_bboxByCorner=function(x,y){switch(_corner){case 1:_bbox.x1=x+_dragCornerOffset.x;_bbox.y0=y-_dragCornerOffset.y;_constrainBoundingBoxByPoint("x1","y0");break;case 2:_bbox.x0=x-_dragCornerOffset.x;_bbox.y1=y+_dragCornerOffset.y;_constrainBoundingBoxByPoint("x0","y1");
break;case 3:_bbox.x1=x+_dragCornerOffset.x;_bbox.y1=y+_dragCornerOffset.y;_constrainBoundingBoxByPoint("x1","y1");break;case 0:default:_bbox.x0=x-_dragCornerOffset.x;_bbox.y0=y-_dragCornerOffset.y;_constrainBoundingBoxByPoint("x0","y0");break}};var _move_bbox=function(dx,dy){var w,h;_bbox.x0+=dx;_bbox.x1+=dx;_bbox.y0+=dy;_bbox.y1+=dy;w=_bbox.x1-_bbox.x0;h=_bbox.y1-_bbox.y0;var topLeft=_canvasBbox.constrain(_bbox.x0,_bbox.y0);if(topLeft.dirty){_bbox.x0=topLeft.x;_bbox.y0=topLeft.y;_bbox.x1=_bbox.x0+w;_bbox.y1=_bbox.y0+h}var bottomRight=_canvasBbox.constrain(_bbox.x1,_bbox.y1);if(bottomRight.dirty){_bbox.x1=bottomRight.x;_bbox.y1=bottomRight.y;_bbox.x0=_bbox.x1-w;_bbox.y0=_bbox.y1-h}};var _addCropUI=function(){_cropUIElement=avpw$(AV.template[AV.launchData.layout].cropLayer());controls.layoutNotify(AV.launchData["openType"],"getCanvasControlsElement").append(_cropUIElement)};var _removeCropUI=function(){_cropUIElement.remove();_cropUIElement=null};var _drawCropUI=function(_bbox){var zoomScale=controls.canvasUI.viewport.getRatio();var left,top,w,h;if(_bbox.x0<_bbox.x1){left=_bbox.x0;w=_bbox.x1-_bbox.x0}else{left=_bbox.x1;w=_bbox.x0-_bbox.x1}if(_bbox.y0<_bbox.y1){top=_bbox.y0;h=_bbox.y1-_bbox.y0}else{top=_bbox.y1;h=_bbox.y0-_bbox.y1}left=left/zoomScale+.5|0;top=top/zoomScale+.5|0;w=w/zoomScale+.5|0;h=h/zoomScale+.5|0;_cropUIElement.css({left:left+"px",top:top+"px",width:w+"px",height:h+"px"})};var api=this;api.activate=function(){_bbox=new AV.Bbox;_setCanvasBounds();_overlayModule=new AV.OverlaySelectionModule(paintWidget);_forceAspect=false;_addCropUI();controls.layoutNotify(AV.launchData["openType"],"showCanvasControlsElement")};api.deactivate=function(){_bbox=null;_unsetCanvasBounds();_overlayModule=null;controls.layoutNotify(AV.launchData["openType"],"hideCanvasControlsElement");_removeCropUI()};api.updateUIDown=function(x,y){var bestDist=99999999,dist;var zoomScale=1;zoomScale=controls.canvasUI.viewport.getRatio();var hwidth=_overlayModule.getHandleImageWidth();var cutoff=zoomScale*(hwidth/2)*(hwidth/2)|0;_dragStart=null;paintWidget.uiLayerReset();paintWidget.uiLayerShow(true);_corner=-1;dist=AV.math.sqrDist(_bbox.x0,_bbox.y0,x,y);if(dist<bestDist&&dist<cutoff){_corner=0;bestDist=dist}dist=AV.math.sqrDist(_bbox.x1,_bbox.y0,x,y);if(dist<bestDist&&dist<cutoff){_corner=1;bestDist=dist}dist=AV.math.sqrDist(_bbox.x0,_bbox.y1,x,y);if(dist<bestDist&&dist<cutoff){_corner=2;bestDist=dist}dist=AV.math.sqrDist(_bbox.x1,_bbox.y1,x,y);if(dist<bestDist&&dist<cutoff){_corner=3;bestDist=dist}switch(_corner){case 0:_dragCornerOffset={x:x-_bbox.x0,y:y-_bbox.y0};break;case 3:_dragCornerOffset={x:_bbox.x1-x,y:_bbox.y1-y};break;case 1:_dragCornerOffset={x:_bbox.x1-x,y:y-_bbox.y0};break;case 2:_dragCornerOffset={x:x-_bbox.x0,y:_bbox.y1-y};break;default:if(_bbox.contains(x,y)){_dragStart={x:x,y:y}}else{return false}break}return true};api.updateUIMove=function(x,y){var dx,dy;if(_dragStart!=null){dx=x-_dragStart.x;dy=y-_dragStart.y;_move_bbox(dx,dy);_dragStart.x=x;_dragStart.y=y}else{_set_bboxByCorner(x,y)}_overlayModule.drawCropSelectionBackground(_bbox);paintWidget.recomposite(0);_drawCropUI(_bbox)};api.apply=function(x,y){var t;if(_bbox.x0>_bbox.x1){t=_bbox.x0;_bbox.x0=_bbox.x1;_bbox.x1=t}if(_bbox.y0>_bbox.y1){t=_bbox.y0;_bbox.y0=_bbox.y1;_bbox.y1=t}};api.flipIt=function(){api.setInitialSelectionTo(lastH,lastW)};api.setInitialSelectionTo=function(w,h){lastW=w;lastH=h;_bbox.x0=(paintWidget.canvas.width-w)/2+.5|0;_bbox.x1=_bbox.x0+w+.5|0;_bbox.y0=(paintWidget.canvas.height-h)/2+.5|0;_bbox.y1=_bbox.y0+h+.5|0;paintWidget.uiLayerReset();paintWidget.uiLayerShow(true);_overlayModule.drawCropSelectionBackground(_bbox);paintWidget.recomposite();_drawCropUI(_bbox)};api.setInitialSelectionByRatio=function(w2h){var margin=_overlayModule.getHandleImageWidth();var w=paintWidget.canvas.width;var h=paintWidget.canvas.height;var borderTB=margin;var borderLR=margin;var normw=w-2*borderLR;var normh=h-2*borderTB;var neww;var newh;neww=normh*w2h;newh=normh;if(neww>normw){neww=normw;newh=normw/w2h}return api.setInitialSelectionTo(neww,newh)};api.setInitialSelection=function(){var l,r,t,b;if(_forceAspect){l=t=.12}else{l=.09;t=.18}r=1-l;b=1-t;_bbox.x0=paintWidget.canvas.width*l+.5|0;_bbox.x1=paintWidget.canvas.width*r+.5|0;_bbox.y0=paintWidget.canvas.height*t+.5|0;_bbox.y1=paintWidget.canvas.height*b+.5|0;paintWidget.uiLayerReset();paintWidget.uiLayerShow(true);_overlayModule.drawCropSelectionBackground(_bbox);paintWidget.recomposite();_drawCropUI(_bbox)};api.forceAspect=function(force){if(force){_storeRatio()}_forceAspect=force};api.crop=function(){return _bbox};return api}}(window["AV"]||(window["AV"]={}),window,document);!function(AV,window,document){var mediator=AV.Events;avpw$=typeof avpw$!=="undefined"?avpw$:{};AV.OverlayController=function(controls,paintWidget,o){var modes=o.modes||{OFF_STATE:0};var _handlePosition=o.handlePosition||AV.OverlayController.HANDLE_POSITION.BOTTOM_LEFT;var _DRAG_THRESHOLD=5;var _MINIMUM_OVERLAY_WIDTH=o.minimumOverlaySize||20;var _MAXIMUM_OVERLAY_WIDTH=o.maximumOverlaySize||99999999;var _OVERLAY_BORDER_WIDTH=10;var _OVERLAY_EDITING_CLASS="avpw_selection_overlay_selected avpw_selection_overlay_editing";var _OVERLAY_DRAG_CLASS="avpw_selection_overlay_selected avpw_selection_overlay_dragonly";var TRANSFORM_PROPERTY=AV.support.getVendorProperty("transform");var _overlays;var _maxOverlayZIndex;var _currentOverlay;var _lastOverlayAddedID=null;var _clickButNotDragState=false;var _mouseDown=false;var _sizeMouseDown=false;var _initialRotation;var _forceDragMode=o.forceDragMode||false;var _resetAllOverlaysMode=function(exceptionOverlay){if(!exceptionOverlay||_currentOverlay!==exceptionOverlay){_currentOverlay=null}for(var overlay in _overlays){if(_overlays.hasOwnProperty(overlay)&&_overlays[overlay]!=exceptionOverlay){_setOverlayMode(_overlays[overlay],modes.OFF_STATE)}}};var _resizeAllOverlays=function(bbox,newRatio,oldRatio){var adjustedRatio;var overlay,overlayObject;if(newRatio!==oldRatio){newRatio=1/newRatio;oldRatio=1/oldRatio;adjustedRatio=newRatio/oldRatio;for(overlay in _overlays){overlayObject=_overlays[overlay];_moveOverlayToCoords(overlayObject,{x:overlayObject.topLeftX*adjustedRatio,y:overlayObject.topLeftY*adjustedRatio});_scaleOverlayByScale(overlayObject,adjustedRatio)}}};var _moveCurrentOverlayToTop=function(){_maxOverlayZIndex++;if(_currentOverlay&&_currentOverlay.element){_currentOverlay.zIndex=_maxOverlayZIndex;_currentOverlay.element.css("z-index",_maxOverlayZIndex)}};var _setCurrentOverlayById=function(id){_resetAllOverlaysMode(_overlays[id]);_currentOverlay=_overlays[id];_moveCurrentOverlayToTop()};var _saveDimensionsFromElement=function(element){var width,height,aspectRatio=o.aspectRatio,overlayObj=_overlays[element.id];width=element?parseInt(element.style.width,10):0;height=element?avpw$(element).height():0;var left=element?parseInt(element.style.left,10):0;var top=element?parseInt(element.style.top,10):0;var centerX=left+_OVERLAY_BORDER_WIDTH+width/2;var centerY=top+_OVERLAY_BORDER_WIDTH+height/2;if(!aspectRatio){if(width!==0&&height!==0){aspectRatio=height/width}else{aspectRatio=1}}if(overlayObj){AV.util.extend(overlayObj,{width:width,aspectRatio:aspectRatio,topLeftX:parseInt(element.style.left||0,10),topLeftY:parseInt(element.style.top||0,10),centerX:centerX,centerY:centerY})}};var _setOverlayMode=function(target,mode){target.mode=mode;target.element.removeClass(_OVERLAY_DRAG_CLASS);target.element.removeClass(_OVERLAY_EDITING_CLASS);if(mode===modes.DRAG_STATE){target.element.addClass(_OVERLAY_DRAG_CLASS)}else if(mode===modes.EDIT_STATE){target.element.addClass(_OVERLAY_EDITING_CLASS)}else{if(_currentOverlay&&_currentOverlay==target){_currentOverlay=null}}if(o.onModeChange){o.onModeChange.apply(controls,[target,mode])}};var _cycleOverlayMode=function(target,enable){if(target){if(!target.mode||target.mode===modes.OFF_STATE){if(enable&&modes.DRAG_STATE)_setOverlayMode(target,modes.DRAG_STATE)}else if(target.mode===modes.DRAG_STATE){if(enable){if(modes.EDIT_STATE){_setOverlayMode(target,modes.EDIT_STATE)}}else{_setOverlayMode(target,modes.OFF_STATE)}}else if(target.mode===modes.EDIT_STATE){if(!enable){if(modes.DRAG_STATE){_setOverlayMode(target,modes.DRAG_STATE)}else{_setOverlayMode(target,modes.OFF_STATE)}}}}};var _removeOverlay=function(overlay){if(overlay&&overlay.element){overlay.element.remove();delete _overlays[overlay.id]}};var _removeAllOverlays=function(){avpw$.each(_overlays,function(id){_removeOverlay(_overlays[id])})};var _moveOverlayToCoords=function(overlay,coords){overlay.element.css({left:coords.x+"px",top:coords.y+"px"});overlay.topLeftX=coords.x;overlay.topLeftY=coords.y};var _moveOverlay=function(overlay,coords){var initialCoordsX,initialCoordsY,dx,dy,overThreshold=false;initialCoordsX=overlay.initialCoordsX;initialCoordsY=overlay.initialCoordsY;dx=coords.x-initialCoordsX;dy=coords.y-initialCoordsY;if(Math.abs(dx)>_DRAG_THRESHOLD||Math.abs(dy)>_DRAG_THRESHOLD){overThreshold=true}if(overThreshold){overlay.element.css({left:overlay.topLeftX+dx+"px",top:overlay.topLeftY+dy+"px"})}return overThreshold};var _showCurrentOverlay=function(){if(_currentOverlay&&_currentOverlay.element){_currentOverlay.element.show()}};var _hideCurrentOverlay=function(){if(_currentOverlay&&_currentOverlay.element){_currentOverlay.element.hide()}};var _scaleOverlayByScale=function(overlay,scale){var width=overlay.width*scale;var height=width*overlay.aspectRatio;overlay.element.css({width:width+"px",height:height+"px"});overlay.width=width};var _scaleAndRotateOverlay=function(overlay,coords){var initialCoordsX,initialCoordsY,width,height,aspectRatio,topLeftX,topLeftY,centerX,centerY,handleX,handleY,handleNewX,handleNewY,canvasOffset,initialRotation,originalAngle,newAngle,scale,minScale,maxScale,rotation;topLeftX=overlay.topLeftX;topLeftY=overlay.topLeftY;initialCoordsX=overlay.initialCoordsX;initialCoordsY=overlay.initialCoordsY;canvasOffset=controls.layoutNotify(AV.launchData["openType"],"getCanvasControlsElement").offset();initialCoordsX-=canvasOffset.left;initialCoordsY-=canvasOffset.top;coords.x-=canvasOffset.left;coords.y-=canvasOffset.top;aspectRatio=overlay.aspectRatio;width=overlay.width;height=width*aspectRatio;if(_handlePosition==AV.OverlayController.HANDLE_POSITION.BOTTOM_LEFT){handleX=topLeftX;handleY=topLeftY+height+_OVERLAY_BORDER_WIDTH/2}else if(_handlePosition==AV.OverlayController.HANDLE_POSITION.BOTTOM_CENTER){handleX=topLeftX+width/2+_OVERLAY_BORDER_WIDTH;handleY=topLeftY+height+_OVERLAY_BORDER_WIDTH}else if(_handlePosition==AV.OverlayController.HANDLE_POSITION.BOTTOM_RIGHT){handleX=topLeftX+width+_OVERLAY_BORDER_WIDTH*2;handleY=topLeftY+height+_OVERLAY_BORDER_WIDTH*2}centerX=overlay.centerX;centerY=overlay.centerY;handleNewX=coords.x;handleNewY=coords.y;scale=Math.sqrt(Math.pow(handleNewX-centerX,2)+Math.pow(handleNewY-centerY,2))/Math.sqrt(Math.pow(handleX-centerX,2)+Math.pow(handleY-centerY,2));minScale=_MINIMUM_OVERLAY_WIDTH/width;maxScale=_MAXIMUM_OVERLAY_WIDTH/width;scale=scale>minScale?scale:minScale;scale=scale<maxScale?scale:maxScale;initialRotation=overlay.rotation||0;originalAngle=Math.atan2(handleY-centerY,handleX-centerX);if(initialRotation){originalAngle=initialRotation-(2*Math.PI-originalAngle)}newAngle=Math.atan2(handleNewY-centerY,handleNewX-centerX);rotation=newAngle-originalAngle+initialRotation;overlay.rotation=rotation;rotation=rotation*180/Math.PI+.5|0;overlay.element[0].style[TRANSFORM_PROPERTY]="rotate("+rotation+"deg)";overlay.element.css({left:(topLeftX-width*.5*(scale-1)+.5|0)+"px",top:(topLeftY-height*.5*(scale-1)+.5|0)+"px",width:(width*scale+.5|0)+"px",height:(height*scale+.5|0)+"px"});return scale};var _overlayRemoveClicked=function(parentOverlay,onRemoveMouseDown){var id,overlay;if(parentOverlay.length){id=parentOverlay[0].id;overlay=_overlays[id];if(overlay){if(onRemoveMouseDown){onRemoveMouseDown.apply(controls,[overlay])}_removeOverlay(overlay)}}};var _overlayMouseDown=function(element,onOverlayMouseDown){var targetOverlay=_overlays[element.attr("id")];var mouseDownOnCurrentOverlay=false;if(targetOverlay===_currentOverlay){mouseDownOnCurrentOverlay=true;_mouseDown=true}if(onOverlayMouseDown){onOverlayMouseDown.apply(controls,[targetOverlay,mouseDownOnCurrentOverlay])}return mouseDownOnCurrentOverlay};var _overlaySizeMouseDown=function(onSizeMouseDown){if(_currentOverlay){_sizeMouseDown=true;_initialRotation=_currentOverlay.rotation;if(onSizeMouseDown){onSizeMouseDown.apply(controls,[_currentOverlay])}}};var _overlayMouseUp=function(element){if(element){_saveDimensionsFromElement(element[0]);_setCurrentOverlayById(element.attr("id"))}};var _addOverlayToCanvas=function(overlay,callback){if(overlay&&overlay.element){_saveDimensionsFromElement(overlay.element[0]);if(callback){callback.apply(controls,[overlay])}}};var _addAllOverlaysToCanvas=function(callback){var i,len=_maxOverlayZIndex+1;var overlaysInOrder=new Array(len);avpw$.each(_overlays,function(id){overlaysInOrder[_overlays[id].zIndex]=_overlays[id]});for(i=0;i<len;i++){if(overlaysInOrder[i]){_addOverlayToCanvas(overlaysInOrder[i],callback)}}};var api=this;api.activate=function(){_maxOverlayZIndex=1;_overlays={};_lastOverlayAddedID=null;controls.layoutNotify(AV.launchData["openType"],"showCanvasControlsElement");mediator.on("canvas:resize",_resizeAllOverlays)};api.deactivate=function(){_removeAllOverlays();_overlays={};controls.layoutNotify(AV.launchData["openType"],"hideCanvasControlsElement");mediator.off("canvas:resize",_resizeAllOverlays)};api.updateUIDown=function(coords,ev,onOverlayMouseDown,onSizeMouseDown,onRemoveMouseDown,onClickOutside){var mouseDownOnCurrentOverlay=false;var $element=avpw$(ev.target);var $overlay=$element.closest(".avpw_selection_overlay");var $sizeHandle=$element.closest(".avpw_selection_overlay_size_handle");var $closeButton=$element.closest(".avpw_selection_overlay_close_button");if($closeButton&&$closeButton.length){_overlayRemoveClicked($overlay,onRemoveMouseDown);ev.preventDefault();return false}if($overlay&&$overlay.length){_clickButNotDragState=true;mouseDownOnCurrentOverlay=_overlayMouseDown($overlay,onOverlayMouseDown)}if($sizeHandle&&$sizeHandle.length){_overlaySizeMouseDown(onSizeMouseDown)}if(mouseDownOnCurrentOverlay){AV.util.extend(_currentOverlay,{initialCoordsX:coords.x,initialCoordsY:coords.y});_saveDimensionsFromElement($overlay[0])}else{if(_currentOverlay&&_currentOverlay.element){if(!_forceDragMode){_cycleOverlayMode(_currentOverlay,false)}if(onClickOutside){onClickOutside()}}}};api.updateUIMove=function(coords,ev,onMouseMoveStart,onScaleChanged,onOverlayDragMove){if(_mouseDown&&_currentOverlay&&_currentOverlay.element){if(_clickButNotDragState&&onMouseMoveStart){onMouseMoveStart.apply(controls,[_currentOverlay])}if(_sizeMouseDown){scale=_scaleAndRotateOverlay(_currentOverlay,coords);if(onScaleChanged){onScaleChanged.apply(controls,[_currentOverlay,scale])}_clickButNotDragState=false}else{if(_currentOverlay.mode===modes.DRAG_STATE){_clickButNotDragState=!_moveOverlay(_currentOverlay,coords);if(onOverlayDragMove){onOverlayDragMove()}}}}return false};api.apply=function(coords,ev,onMouseUp){var mouseDownOnCurrentOverlay=false;var $element=avpw$(ev.target);var $overlay=$element.closest(".avpw_selection_overlay");var targetOverlay;if($overlay&&$overlay.length){_overlayMouseUp($overlay);mouseDownOnCurrentOverlay=true;targetOverlay=_overlays[$overlay.attr("id")]}if(onMouseUp){onMouseUp.apply(controls,[targetOverlay,mouseDownOnCurrentOverlay,_sizeMouseDown])}if(_clickButNotDragState){_clickButNotDragState=false;if(_currentOverlay&&_currentOverlay.element&&!_forceDragMode){_cycleOverlayMode(_currentOverlay,true)}}_mouseDown=false;_sizeMouseDown=false};api.newOverlay=function(overlayObject){var overlayElement=overlayObject.element;_resetAllOverlaysMode();controls.layoutNotify(AV.launchData["openType"],"getCanvasControlsElement").append(overlayElement);_cycleOverlayMode(overlayObject,true);_overlays[overlayObject.id]=overlayObject;_saveDimensionsFromElement(overlayElement[0]);_currentOverlay=overlayObject;_lastOverlayAddedID=overlayObject.id;_moveCurrentOverlayToTop()};api.commit=function(callback){_addAllOverlaysToCanvas(callback)};api.currentOverlay=function(){return _currentOverlay};api.showCurrentOverlay=function(){_showCurrentOverlay()};api.hideCurrentOverlay=function(){_hideCurrentOverlay()};api.saveDimensions=function(overlay){overlay=overlay||_currentOverlay;_saveDimensionsFromElement(overlay.element[0])};api.isLastOverlayAdded=function(overlay){return _lastOverlayAddedID&&_overlays[_lastOverlayAddedID]===overlay};api.setHandlePosition=function(position_setting){_handlePosition=position_setting};api.setRotation=function(overlay,rotation){overlay.rotation=rotation;rotation=rotation*180/Math.PI+.5|0;overlay.element[0].style[TRANSFORM_PROPERTY]="rotate("+rotation+"deg)"};return api};AV.OverlayController.HANDLE_POSITION={BOTTOM_LEFT:0,BOTTOM_CENTER:1,BOTTOM_RIGHT:2}}(window["AV"]||(window["AV"]={}),window,document);var mediator=AV.Events;avpw$=typeof avpw$!=="undefined"?avpw$:{};AV.cnvs={clearCanvas:function(c){c.width=c.width},copyCanvas:function(src,x,y,w,h){var newCanvas=document.createElement("canvas");var cc;if(h===undefined){newCanvas.width=src.width;newCanvas.height=src.height;cc=newCanvas.getContext("2d");cc.drawImage(src,0,0)}else{newCanvas.width=w;newCanvas.height=h;cc=newCanvas.getContext("2d");cc.drawImage(src,-x,-y)}return newCanvas},drawImageCopy:function(context,image,x,y){var oldGCO=context.globalCompositeOperation;context.save();context.beginPath();context.rect(x,y,image.width,image.height);context.clip();context.closePath();context.globalCompositeOperation="copy";context.drawImage(image,x,y);context.globalCompositeOperation=oldGCO;context.restore()},getCanvasPixelData:function(c){var cc=c.getContext("2d");return cc.getImageData(0,0,c.width,c.height)},getImageDataRegion:function(can,x,y,w,h,pad){var cc;var tcan;var canWidth=can.width;var canHeight=can.height;var imageData;if(x<0||y<0||x+w>canWidth||y+h>canHeight){tcan=document.createElement("canvas");tcan.width=w;tcan.height=h;cc=tcan.getContext("2d");cc.drawImage(can,-x,-y);imageData=cc.getImageData(0,0,w,h);if(pad){var canCc=can.getContext("2d");var row0=canCc.getImageData(0,0,canWidth,1).data;var rowN=canCc.getImageData(0,canHeight-1,canWidth,1).data;var col0=canCc.getImageData(0,0,1,canHeight).data;var colN=canCc.getImageData(canWidth-1,0,1,canHeight).data;var pixels=imageData.data;for(var tcanY=0;tcanY<h;tcanY++){var row=null;var canY=tcanY+y;if(canY<0){canY=0;row=row0}if(canY>=canHeight){canY=canHeight-1;row=rowN}for(var tcanX=0;tcanX<w;tcanX++){var col=null;var canX=tcanX+x;if(canX<0){canX=0;col=col0}if(canX>=canWidth){canX=canWidth-1;col=colN}var tcanIndex=(tcanX+tcanY*w)*4;if(col){var colIndex=canY*4;pixels[tcanIndex++]=col[colIndex++];pixels[tcanIndex++]=col[colIndex++];pixels[tcanIndex++]=col[colIndex++];pixels[tcanIndex]=col[colIndex]}else if(row){var rowIndex=canX*4;pixels[tcanIndex++]=row[rowIndex++];pixels[tcanIndex++]=row[rowIndex++];pixels[tcanIndex++]=row[rowIndex++];pixels[tcanIndex]=row[rowIndex]}else{tcanX=canWidth-x-1}}}}}else{cc=can.getContext("2d");imageData=cc.getImageData(x,y,w,h)}return imageData},putImageDataRegion:function(can,data,x,y){var cc=can.getContext("2d");var tcc;var tcan;var canw=can.width;var canh=can.height;var dataw=data.width;var datah=data.height;if(x<0||y<0||x+dataw>=canw||y+datah>=canh){tcan=document.createElement("canvas");tcan.width=dataw;tcan.height=datah;tcc=tcan.getContext("2d");tcc.putImageData(data,0,0);cc.drawImage(tcan,x,y)}else{cc.putImageData(data,x,y)}},convertRgbToHsv:function(hsvs,rgbs,length){var i;var r,g,b;var hue,sat,val;for(i=0;i<length;i+=4){r=rgbs[i];g=rgbs[i+1];b=rgbs[i+2];var max=Math.max(r,Math.max(g,b));var min=Math.min(r,Math.min(g,b));val=max;if(max==0){hue=0;sat=0}else{var delta=max-min;sat=delta/max;if(r==max){hue=(g-b)/delta}else if(g==max){hue=2+(b-r)/delta}else{hue=4+(r-g)/delta}if(hue<0){hue+=6}hue*=60}hsvs[i]=hue;hsvs[i+1]=sat;hsvs[i+2]=val;hsvs[i+3]=rgbs[i+3]}},convertHsvToRgb:function(rgbs,hsvs,length){var i;var r,g,b;var hue,sat,val;for(i=0;i<length;i+=4){hue=hsvs[i];sat=hsvs[i+1];val=hsvs[i+2];r=g=b=val;if(sat!=0){hue/=60;var base=hue|0;var frac=hue-base;var dullest=1-sat;var dullerHi=1-sat*frac;var dullerLo=1-sat*(1-frac);switch(base){case 0:b*=dullest;g*=dullerLo;break;case 1:b*=dullest;r*=dullerHi;break;case 2:r*=dullest;b*=dullerLo;break;case 3:r*=dullest;g*=dullerHi;break;case 4:g*=dullest;r*=dullerLo;break;default:g*=dullest;b*=dullerHi}}if(r<0){r=0}if(r>255){r=255}if(g<0){g=0}if(g>255){g=255}if(b<0){b=0}if(b>255){b=255}rgbs[i]=r;rgbs[i+1]=g;rgbs[i+2]=b;rgbs[i+3]=hsvs[i+3]}},applyKernel1D:function(kernel,kernelMiddle,dest,destOffset,destStride,src,srcOffset,srcStride,count){var kernelLength=kernel.length;var i,k;var safeStart=kernelMiddle;var safeEnd=count-1-(kernelLength-kernelMiddle);for(i=0;i<count;i++){var r=0;var g=0;var b=0;if(i>=safeStart&&i<=safeEnd){var srcIndex=srcOffset+(i+(kernelLength-kernelMiddle)-1)*srcStride;var coeff;for(k=kernelLength-1;k>=3;){coeff=kernel[k--];r+=coeff*src[srcIndex];g+=coeff*src[srcIndex+1];b+=coeff*src[srcIndex+2];srcIndex-=srcStride;coeff=kernel[k--];r+=coeff*src[srcIndex];g+=coeff*src[srcIndex+1];b+=coeff*src[srcIndex+2];srcIndex-=srcStride;coeff=kernel[k--];r+=coeff*src[srcIndex];g+=coeff*src[srcIndex+1];b+=coeff*src[srcIndex+2];srcIndex-=srcStride;coeff=kernel[k--];r+=coeff*src[srcIndex];g+=coeff*src[srcIndex+1];b+=coeff*src[srcIndex+2];srcIndex-=srcStride}while(k>=0){coeff=kernel[k--];r+=coeff*src[srcIndex];g+=coeff*src[srcIndex+1];b+=coeff*src[srcIndex+2];srcIndex-=srcStride}}else{for(k=0;k<kernelLength;k++){var adjusted=i+(k-kernelMiddle);if(adjusted<0){adjusted=0}if(adjusted>=count){adjusted=count-1}var srcIndex=srcOffset+adjusted*srcStride;var coeff=kernel[k];r+=coeff*src[srcIndex];g+=coeff*src[srcIndex+1];b+=coeff*src[srcIndex+2]}}var destIndex=destOffset+i*destStride;dest[destIndex]=r;dest[destIndex+1]=g;dest[destIndex+2]=b}},shadowTransform:function(){var canvas=document.createElement("canvas");canvas.height=canvas.width=3;var offset=-1;var cc=canvas.getContext("2d");cc.shadowOffsetX=offset;cc.shadowOffsetY=offset;cc.shadowBlur=1;cc.shadowColor="red";cc.fillRect(1,1,1,1);var data=cc.getImageData(0,0,3,3).data;var transform={x:1,y:1};switch(255){case data[32]:transform.x=transform.y=-1;break;case data[24]:transform.y=-1;break;case data[8]:transform.x=-1;break;case data[0]:break}return transform}(),isOriginClean:function(canvasContext){var originClean=true;try{canvasContext.getImageData(0,0,1,1)}catch(err){if(err&&err.message){if(err.message.toLowerCase().indexOf("security")!==-1){originClean=false}}if(err&&err.name){if(err.name.toLowerCase().indexOf("security")!==-1){originClean=false}}}return originClean}};AV.math={sign:function(x){return x<0?-1:1},sqrDist:function(x0,y0,x1,y1){var dx=x1-x0;var dy=y1-y0;return dx*dx+dy*dy},solveQuadratic:function(a,b,c){var term1=-b;var term2=b*b-4*a*c;var term3=2*a;if(term2<0)return[0,0];return[(term1-Math.sqrt(term2))/term3,(term1+Math.sqrt(term2))/term3]},lowestPositiveQuadratic:function(a,b,c){var result=AV.math.solveQuadratic(a,b,c);var v0=result[0];var v1=result[1];if(v1<=0&&v0>0)return v0;if(v0<=0&&v1>0)return v1;return Math.max(Math.min(v0,v1),0)},lineSegmentIntersection:function(Ax,Ay,Bx,By,Cx,Cy,Dx,Dy,pointOfIntersection){var X,Y;var distAB,theCos,theSin,newX,ABpos;if(Ax==Bx&&Ay==By||Cx==Dx&&Cy==Dy)return null;if(Ax==Cx&&Ay==Cy||Bx==Cx&&By==Cy||Ax==Dx&&Ay==Dy||Bx==Dx&&By==Dy){return null}Bx-=Ax;By-=Ay;Cx-=Ax;Cy-=Ay;Dx-=Ax;Dy-=Ay;distAB=Math.sqrt(Bx*Bx+By*By);theCos=Bx/distAB;theSin=By/distAB;newX=Cx*theCos+Cy*theSin;Cy=Cy*theCos-Cx*theSin;Cx=newX;newX=Dx*theCos+Dy*theSin;Dy=Dy*theCos-Dx*theSin;Dx=newX;if(Cy<0&&Dy<0||Cy>=0&&Dy>=0)return null;ABpos=Dx+(Cx-Dx)*Dy/(Dy-Cy);if(ABpos<0||ABpos>distAB)return null;X=Ax+ABpos*theCos;Y=Ay+ABpos*theSin;pointOfIntersection.x=X;pointOfIntersection.y=Y;return true}};AV.Bbox=function(x0,y0,x1,y1,margin){if(y1!==undefined){this.x0=x0;this.y0=y0;this.x1=x1;this.y1=y1;this.w=this.x1-this.x0;this.h=this.y1-this.y0;if(margin!==undefined){this.margin=margin}else{this.margin=0}}else{this.reset()}};AV.Bbox.prototype.include=function(x,y){var minx=x-this.margin;var miny=y-this.margin;var maxx=x+this.margin;var maxy=y+this.margin;if(this.x0>minx){this.x0=minx}if(this.y0>miny){this.y0=miny}if(this.x1<maxx){this.x1=maxx}if(this.y1<maxy){this.y1=maxy}this.w=this.x1-this.x0;this.h=this.y1-this.y0};AV.Bbox.prototype.reset=function(){this.x0=999999999;this.y0=999999999;this.x1=-999999999;this.y1=-999999999;this.w=0;this.h=0;this.margin=0};AV.Bbox.prototype.contains=function(x,y){var t1=x>=this.x0&&x<=this.x1;var t2=y>=this.y0&&y<=this.y1;return t1&&t2};AV.Bbox.prototype.constrain=function(x,y){var dirty=false;if(x<this.x0){x=this.x0;dirty=true}if(x>this.x1){x=this.x1;dirty=true}if(y<this.y0){y=this.y0;dirty=true}if(y>this.y1){y=this.y1;dirty=true}return{x:x,y:y,dirty:dirty}};AV.Layer=function(info){this.image=this.canvas=this.drawable=null;if(info.image!==undefined){this.image=this.drawable=info.image;this.type="image"}else if(info.canvas!==undefined){this.canvas=this.drawable=info.canvas;this.type="canvas"}this.name=info.name;this.rotate=0;this.translateX=this.translateY=0;this.scaleX=this.scaleY=1};AV.Layer.prototype.worldToLocal=function(p){p.x-=this.translateX;p.y-=this.translateY;var cosa=Math.cos(-this.rotate);var sina=Math.sin(-this.rotate);var x=p.x;p.x=x*cosa-p.y*sina;p.y=x*sina+p.y*cosa;p.x/=this.scaleX;p.y/=this.scaleY};AV.Layer.prototype.localToWorld=function(p){if(this.centerX){p.x-=this.centerX}if(this.centerY){p.y-=this.centerY}p.x*=this.scaleX;p.y*=this.scaleY;var cosa=Math.cos(this.rotate);var sina=Math.sin(this.rotate);var x=p.x;p.x=x*cosa-p.y*sina;p.y=x*sina+p.y*cosa;p.x+=this.translateX;p.y+=this.translateY};AV.Layer.prototype.localPointIn=function(p){var x0=0,y0=0;if(this.centerX){x0-=this.centerX}if(this.centerY){y0-=this.centerY}return p.x>=x0&&p.y>=y0&&p.x<x0+this.drawable.width&&p.y<y0+this.drawable.height};AV.OverlaySelectionModule=function(context){var _paintWidget=context;var closeXImg=document.createElement("img");closeXImg.width=closeXImg.height=50;var handleImg=document.createElement("img");handleImg.width=handleImg.height=50;var api=this;api.getLayerByMouseClickWithTag=function(x,y,tag,value,result){var i,xo0,xoM,xo1,yo0,yoM,yo1;var scaledHandleWidth,scaledHandleHeight;for(i=_paintWidget.layers.length-1;i>=0;i--){var l=_paintWidget.layers[i];if(l.hidden){continue}if(tag!==undefined&&l[tag]!==value){continue}var txy={x:x,y:y};l.worldToLocal(txy);if(result!=null){result.x=txy.x;result.y=txy.y;result.dx=result.dy=0}if(result.handlesVisible){scaledHandleWidth=handleImg.width/l.scaleX;scaledHandleHeight=handleImg.height/l.scaleY;result.cornerHit=-1;xoM=0;xo0=xoM-scaledHandleWidth/2;xo1=xoM+scaledHandleWidth/2;yoM=l.drawable.height;yo0=yoM-scaledHandleWidth/2;yo1=yoM+scaledHandleWidth/2;if(l.centerX){xoM-=l.centerX;xo0-=l.centerX;xo1-=l.centerX}if(l.centerY){yoM-=l.centerY;yo0-=l.centerY;yo1-=l.centerY}if(txy.x>=xo0&&txy.x<=xo1&&txy.y>=yo0&&txy.y<=yo1){result.cornerHit=2;var dx=(xoM-txy.x)*l.scaleX;var dy=(yoM-txy.y)*l.scaleY;result.dx=(dx>0?dx+.5:dx-.5)|0;result.dy=(dy>0?dy+.5:dy-.5)|0;return l}xo0=l.drawable.width-closeXImg.width/2;yo0=0-closeXImg.height/2;xo1=l.drawable.width+closeXImg.width/2;yo1=closeXImg.height/2;if(l.centerX){xo0-=l.centerX;xo1-=l.centerX}if(l.centerY){yo0-=l.centerY;yo1-=l.centerY}if(txy.x>=xo0&&txy.x<=xo1&&txy.y>=yo0&&txy.y<=yo1){result.cornerHit=1;return l}}if(l.localPointIn(txy)){return l}}return null};api.uiLayerDrawRectSelection=function(selectedLayer,cornerMode){var cornerSize=handleImg.width;var x0,y0,x1,y1,w,h;var zoomScale=1;if(AV.controlsWidgetInstance&&AV.controlsWidgetInstance.canvasUI){zoomScale=AV.controlsWidgetInstance.canvasUI.viewport.getRatio()}w=selectedLayer.drawable.width;h=selectedLayer.drawable.height;x0=y0=0;x1=w;y1=h;var l=_paintWidget.getLayerByName("_ui");var c=l.canvas.getContext("2d");c.globalCompositeOperation="copy";c.clearRect(0,0,l.canvas.width,l.canvas.height);c.globalCompositeOperation="source-over";c.setTransform(1,0,0,1,0,0);c.translate(selectedLayer.translateX,selectedLayer.translateY);c.rotate(selectedLayer.rotate);c.scale(selectedLayer.scaleX,selectedLayer.scaleY);if(selectedLayer.centerX!=null&&selectedLayer.centerY!=null){c.translate(-selectedLayer.centerX,-selectedLayer.centerY)}c.globalAlpha=.5;c.strokeStyle="#000000";c.lineWidth=3*zoomScale/selectedLayer.scaleX;c.lineCap="round";c.lineJoin="miter";c.beginPath();c.moveTo(w,0);c.lineTo(8,0);c.arcTo(0,0,0,8,8);c.lineTo(0,h);c.lineTo(w-8,h);c.arcTo(w,h,w,h-8,8);c.lineTo(w,0);c.stroke();c.closePath();c.globalAlpha=1;c.setTransform(1,0,0,1,0,0);var closeXPoint={x:x1,y:y0};selectedLayer.localToWorld(closeXPoint);c.translate(closeXPoint.x,closeXPoint.y);c.rotate(selectedLayer.rotate);c.translate(-1*(closeXImg.width*zoomScale/2+.5|0),-1*(closeXImg.height*zoomScale/2+.5|0));c.scale(zoomScale,zoomScale);c.drawImage(closeXImg,0,0);c.scale(1,1);c.setTransform(1,0,0,1,0,0);var handlePoint={x:x0,y:y1};selectedLayer.localToWorld(handlePoint);c.translate(handlePoint.x,handlePoint.y);c.rotate(selectedLayer.rotate);c.translate(-1*(handleImg.width*zoomScale/2+.5|0),-1*(handleImg.height*zoomScale/2+.5|0));c.scale(zoomScale,zoomScale);c.drawImage(handleImg,0,0);c.scale(1,1);c.setTransform(1,0,0,1,0,0)};api.getHandleImageWidth=function(){return handleImg.width};api.drawCropSelection=function(_bbox){if(!_bbox){return}var x0,y0,x1,y1,w,h;var zoomScale=1;if(AV.controlsWidgetInstance&&AV.controlsWidgetInstance.canvasUI){zoomScale=AV.controlsWidgetInstance.canvasUI.viewport.getRatio()}var l=_paintWidget.getLayerByName("_ui");if(_bbox.x0<_bbox.x1){x0=_bbox.x0;x1=_bbox.x1}else{x0=_bbox.x1;x1=_bbox.x0}if(_bbox.y0<_bbox.y1){y0=_bbox.y0;y1=_bbox.y1}else{y0=_bbox.y1;y1=_bbox.y0}w=x1-x0;h=y1-y0;var c=l.canvas.getContext("2d");c.globalCompositeOperation="copy";c.clearRect(0,0,l.canvas.width,l.canvas.height);c.globalCompositeOperation="source-over";c.fillStyle="#000000";c.globalAlpha=.6;c.fillRect(0,0,x0,l.canvas.height);c.fillRect(x1,0,l.canvas.width,l.canvas.height);c.fillRect(x0,0,x1-x0,y0-0);c.fillRect(x0,y1,x1-x0,l.canvas.height-y1);c.strokeStyle="#f4f4f4";c.globalAlpha=1;c.lineWidth=zoomScale;c.lineCap="square";c.strokeRect(x0,y0,w,h);c.beginPath();c.moveTo(x0,y0+h*.33+.5|0);c.lineTo(x1,y0+h*.33+.5|0);c.moveTo(x0,y0+h*.67+.5|0);c.lineTo(x1,y0+h*.67+.5|0);c.moveTo(x0+w*.33+.5|0,y0);c.lineTo(x0+w*.33+.5|0,y1);c.moveTo(x0+w*.67+.5|0,y0);c.lineTo(x0+w*.67+.5|0,y1);c.stroke();c.closePath();c.globalAlpha=1;var handlePoints=[{x:x0,y:y0},{x:x1,y:y0},{x:x0,y:y1},{x:x1,y:y1}];for(var i=0;i<handlePoints.length;i++){var handlePoint=handlePoints[i];c.setTransform(1,0,0,1,0,0);l.localToWorld(handlePoint);c.translate(handlePoint.x,handlePoint.y);c.translate(-1*(zoomScale*handleImg.width/2+.5|0),-1*(zoomScale*handleImg.height/2+.5|0));c.scale(zoomScale,zoomScale);c.drawImage(handleImg,0,0);c.scale(1,1);c.setTransform(1,0,0,1,0,0)}};api.drawCropSelectionBackground=function(_bbox){if(!_bbox){return}var x0,y0,x1,y1,w,h;var l=_paintWidget.getLayerByName("_ui");if(_bbox.x0<_bbox.x1){x0=_bbox.x0;x1=_bbox.x1}else{x0=_bbox.x1;x1=_bbox.x0}if(_bbox.y0<_bbox.y1){y0=_bbox.y0;y1=_bbox.y1}else{y0=_bbox.y1;y1=_bbox.y0}w=x1-x0;h=y1-y0;var c=l.canvas.getContext("2d");c.globalCompositeOperation="copy";c.clearRect(0,0,l.canvas.width,l.canvas.height);c.globalCompositeOperation="source-over";c.fillStyle="#000000";c.globalAlpha=.6;c.fillRect(0,0,x0,l.canvas.height);c.fillRect(x1,0,l.canvas.width,l.canvas.height);c.fillRect(x0,0,x1-x0,y0-0);c.fillRect(x0,y1,x1-x0,l.canvas.height-y1)};return api};AV.BrushModule=function(o){var _overflow=o.overflow||0;var _layerName=o.layerName||"drawing";var _preserveBacking=o.preserveBacking||false;var _paintWidget;var _origBacking;var _radius=5;var _color="rgba(255,255,204,0.5)";var _erase=false;var _pointlist;var _bbox;var _oldX,_oldY;var _oldMidX,_oldMidY;var api=this;
var _drawUICircle=function(x,y){_paintWidget.uiLayerDrawCircleSelection(x,y,_radius)};var _createLayerIfNecessary=function(){var layer=_paintWidget.getLayerByName(_layerName);if(!layer){var dcanvas=document.createElement("canvas");dcanvas.width=_paintWidget.width;dcanvas.height=_paintWidget.height;layer=new AV.Layer({canvas:dcanvas,name:_layerName});_paintWidget.addLayer(layer);_paintWidget.uiLayerReset()}if(layer.canvas.width!=_paintWidget.width){layer.canvas.width=_paintWidget.width}if(layer.canvas.height!=_paintWidget.height){layer.canvas.height=_paintWidget.height}return layer};var _resetSpotToolLayer=function(){var i=_paintWidget.findLayerIndexByName("spot_tool");if(i!==-1){_paintWidget.layers[i].canvas.width=_paintWidget.canvas.width;_paintWidget.layers[i].canvas.height=_paintWidget.canvas.height}};var _drawLineSegment=function(c,x,y,begin,end){c.lineCap="round";c.lineJoin="round";c.lineWidth=_radius*2;if(_erase){c.strokeStyle="#fff";c.globalCompositeOperation="destination-out"}else{c.strokeStyle=_color;c.globalCompositeOperation="source-over"}c.beginPath();if(begin){_oldX=x;_oldY=y;c.moveTo(_oldX,_oldY);c.lineTo(x+.02,y);_oldMidX=x;_oldMidY=y}else if(end){c.moveTo(_oldMidX,_oldMidY);c.lineTo(_oldX,_oldY);_oldX=_oldY=_oldMidX=_oldMidY=null}else{var midX=(_oldX+x)/2|0;var midY=(_oldY+y)/2|0;c.moveTo(_oldMidX,_oldMidY);c.quadraticCurveTo(_oldX,_oldY,midX,midY);_oldX=x;_oldY=y;_oldMidX=midX;_oldMidY=midY}c.stroke();c.closePath()};var _generatePointList=function(pointList){var brushSize=_radius;var lastpoint;var i=0;var midpoints=[];var getQuadMid=function(points,x0,y0,x1,y1,cpx,cpy){var distdist=(x1-x0)*(x1-x0)+(y1-y0)*(y1-y0);if(distdist<brushSize*brushSize){return null}var ax,bx,ay,by,mx,my;if(cpx!==undefined){ax=(cpx+x0)/2;bx=(cpx+x1)/2;ay=(cpy+y0)/2;by=(cpy+y1)/2;mx=(ax+bx)/2;my=(ay+by)/2}else{mx=(x0+x1)/2;my=(y0+y1)/2}getQuadMid(points,x0,y0,mx,my,ax,ay);points.push([mx|0,my|0]);getQuadMid(points,mx,my,x1,y1,bx,by)};for(i=0;i<pointList.length-1;++i){var point1=pointList[i];var point2=pointList[i+1];var midpoint=[(point1[0]+point2[0])/2|0,(point1[1]+point2[1])/2|0];if(i===0){getQuadMid(midpoints,point1[0],point1[1],midpoint[0],midpoint[1])}else{getQuadMid(midpoints,lastpoint[0],lastpoint[1],midpoint[0],midpoint[1],point1[0],point1[1])}lastpoint=midpoint;midpoints.push(midpoint);if(i===pointList.length-2){getQuadMid(midpoints,midpoint[0],midpoint[1],point2[0],point2[1]);midpoints.push(point2)}}return midpoints};var _drawingUndo=function(layerName,backing,x,y){var layer=_paintWidget.getLayerByName(layerName);var c=layer.canvas.getContext("2d");AV.cnvs.drawImageCopy(c,backing,x,y);_paintWidget.recomposite()};var _drawingRedo=function(layerName,backing,x,y){var layer=_createLayerIfNecessary();var c=layer.canvas.getContext("2d");AV.cnvs.drawImageCopy(c,backing,x,y);_paintWidget.recomposite()};api.activate=function(paintWidget){_paintWidget=paintWidget;_bbox=new AV.Bbox;_oldX=_oldY=0;_paintWidget.uiLayerReset();_paintWidget.uiLayerShow(true)};api.deactivate=function(){_paintWidget.uiLayerShow(false)};api.updateUIDown=function(x,y){var layer=_createLayerIfNecessary();_paintWidget.currentLayer=layer;if(_preserveBacking){_origBacking=AV.cnvs.copyCanvas(layer.canvas)}_paintWidget.uiLayerShow(true);_pointlist=[[x+.5|0,y+.5|0]];_bbox.reset();_bbox.margin=(_radius+.5|0)+_overflow;_bbox.include(x,y);var c=layer.canvas.getContext("2d");_drawLineSegment(c,x,y,true);_paintWidget.recomposite()};api.updateUIMove=function(x,y){_paintWidget.uiLayerShow(true);_drawUICircle(x,y);_paintWidget.recomposite()};api.updateUIDraw=function(x,y){var layer=_paintWidget.currentLayer;var c=layer.canvas.getContext("2d");_pointlist.push([x+.5|0,y+.5|0]);_drawLineSegment(c,x,y,false);_bbox.include(x,y);_paintWidget.uiLayerShow(true);_drawUICircle(x,y);_paintWidget.recomposite()};api.commit=function(moduleName,undoFunc,redoFunc,expand){var layer,backing;if(undoFunc&&redoFunc){var pointlist=expand&&_pointlist.length>1?_generatePointList(_pointlist):_pointlist;_resetSpotToolLayer();layer=_paintWidget.layers[_paintWidget.currentLayerIndex];if(!layer.canvas){return}backing=AV.cnvs.copyCanvas(layer.canvas,_bbox.x0,_bbox.y0,_bbox.w,_bbox.h);_paintWidget.actions.push([undoFunc,this,[layer.name,backing,_bbox.x0,_bbox.y0]],[redoFunc,this,[layer.name,pointlist,_radius]],{action:moduleName,radius:_radius+.5|0,pointlist:pointlist});_paintWidget.actions.redo()}else{layer=_paintWidget.currentLayer;var c=layer.canvas.getContext("2d");_drawLineSegment(c,0,0,false,true);_paintWidget.recomposite();backing=AV.cnvs.copyCanvas(layer.canvas,_bbox.x0,_bbox.y0,_bbox.w,_bbox.h);var origBackingCrop=AV.cnvs.copyCanvas(_origBacking,_bbox.x0,_bbox.y0,_bbox.w,_bbox.h);_paintWidget.actions.push([_drawingUndo,this,[layer.name,origBackingCrop,_bbox.x0,_bbox.y0]],[_drawingRedo,this,[layer.name,backing,_bbox.x0,_bbox.y0]],{action:moduleName,erase:_erase,radius:_radius+.5|0,softness:0,color:AV.util.color_to_rgb(_color),pointlist:_pointlist});_paintWidget.actions.redoFake()}_pointlist=null;_origBacking=null};api.radius=function(){return _radius};api.setRadius=function(r){_radius=r};api.setColor=function(c){_color=c};api.setErase=function(e){_erase=e};return api};AV.BrushCursor=function(){var api={};var _brushElm,_ctx;var _createBrush=function(){_brushElm=document.createElement("canvas");_brushElm.className="avpw_cursor_circle";_brushElm.width=_brushElm.height=200;_ctx=_brushElm.getContext("2d");AV.controlsWidgetInstance.layoutNotify(AV.launchData["openType"],"getCanvasControlsElement").append(_brushElm)};api.show=function(){if(!_brushElm)_createBrush();avpw$(_brushElm).fadeIn()};api.hide=function(){if(_brushElm)avpw$(_brushElm).hide()};api.setPosition=function(x,y){var zoomScale=AV.controlsWidgetInstance.canvasUI.viewport.getRatio();_brushElm.style.top=(y/zoomScale+.5|0)+"px";_brushElm.style.left=(x/zoomScale+.5|0)+"px"};api.setSize=function(radius){if(!_brushElm)return;_brushElm.width=_brushElm.width;radius=radius*1.3;var x=radius;var y=radius;_ctx.beginPath();_ctx.strokeStyle="#ffffff";_ctx.arc(x,y,radius,0,2*Math.PI,false);_ctx.closePath();_ctx.stroke();var lineWidth=2;var innerRadius=radius-lineWidth;if(innerRadius>0){_ctx.beginPath();_ctx.strokeStyle="#000000";_ctx.arc(x,y,innerRadius,0,2*Math.PI,false);_ctx.closePath();_ctx.stroke()}_brushElm.style.marginLeft=-radius+"px";_brushElm.style.marginTop=-radius+"px"};mediator.on("canvas:showBrushCursor",api.show);mediator.on("canvas:hideBrushCursor",api.hide);mediator.on("canvas:setBrushPosition",api.setPosition);mediator.on("canvas:setBrushSize",api.setSize);return api}();AV.PaintWidget=function(width,height,actions,modeManager,filterManager,overlayRegistry,imageBorderManager){this.imgElementClean=null;this.busy=false;this.moduleLoadedCallback={};this.canvasReadyCallback=avpw$.Deferred?new avpw$.Deferred:null;this.active=null;this.layers=[];this.dirtyRect={bbox:new AV.Bbox,dirty:false};this.canvas=document.createElement("canvas");this.setDimensions(width,height);this.canvas.id="avpw_canvas_element";this.dirty=false;this.actions=actions;if(modeManager&&modeManager.init){modeManager.init(this);this.modeManager=modeManager}this.filterManager=filterManager;this.overlayRegistry=overlayRegistry;this.imageBorderManager=imageBorderManager};AV.PaintWidget.prototype.setOrigSize=function(w,h){this._origWidth=w+.5|0;this._origHeight=h+.5|0};AV.PaintWidget.prototype.getOrigSize=function(){return{width:this._origWidth,height:this._origHeight}};AV.PaintWidget.prototype.c2a=function(w,h,forceFloor){var factor,newHiresWidth,newHiresHeight,currentDims=this.getScaledSize();if(currentDims.hiresWidth&&currentDims.hiresHeight){if(w!=currentDims.width||h!=currentDims.height){factor=currentDims.hiresWidth/currentDims.width;newHiresWidth=w*factor;if(forceFloor)newHiresWidth=newHiresWidth+.5|0;factor=currentDims.hiresHeight/currentDims.height;newHiresHeight=h*factor;if(forceFloor)newHiresHeight=newHiresHeight+.5|0;return{width:w,height:h,hiresWidth:newHiresWidth,hiresHeight:newHiresHeight}}else{return currentDims}}else{return{width:w,height:h}}};AV.PaintWidget.prototype.a2c=function(w,h,forceFloor){var factor,newWidth,newHeight,currentDims=this.getScaledSize();if(currentDims.hiresWidth&&currentDims.hiresHeight){if(w!=currentDims.width||h!=currentDims.height){factor=currentDims.width/currentDims.hiresWidth;newWidth=w*factor;if(forceFloor)newWidth=newWidth+.5|0;factor=currentDims.height/currentDims.hiresHeight;newHeight=h*factor;if(forceFloor)newHeight=newHeight+.5|0;return{width:newWidth,height:newHeight,hiresWidth:w,hiresHeight:h}}else{return currentDims}}else{return{width:w,height:h}}};AV.PaintWidget.prototype.shutdown=function(){this.setMode(null);if(this.modeManager){this.modeManager.shutdown();this.modeManager=null}this.actions=null;this.layers=null;this.currentLayer=null;this.canvas=null;this.moduleLoadedCallback=null;this.canvasReadyCallback=null;this.waitThrobberShow=null};AV.PaintWidget.prototype.moduleLoaded=function(modulename,callback){var pw=this,dfd,asyncCodeDeferreds=[];var completeDeferred=function(){dfd.done(function(){if(callback){callback.apply(this,[modulename])}});pw.moduleLoadedCallback[modulename]=dfd};var buildAsyncCodeDeferreds=function(assets){var i,url;for(i=0;i<assets.length;i++){url=assets[i].resourceUrl;if(url){!function(){var codeLoad=new avpw$.Deferred;if(assets[i].assetType===AV.controlsWidgetInstance.assetManager.types.EFFECT){pw.filterManager.loadPack(assets[i].assetId,url,function(){codeLoad.resolve()})}else if(assets[i].assetType===AV.controlsWidgetInstance.assetManager.types.IMAGEBORDER){pw.imageBorderManager.loadPack(assets[i].assetId,url,codeLoad.resolve)}else{codeLoad.resolve()}asyncCodeDeferreds.push(codeLoad)}()}}asyncCodeDeferreds.push(pw.canvasReadyCallback);dfd=avpw$.when.apply(pw,asyncCodeDeferreds);completeDeferred()};if(pw.moduleLoadedCallback){dfd=pw.moduleLoadedCallback[modulename]}if(!dfd){if(modulename==="effects"){if(AV.controlsWidgetInstance.assetManager){AV.controlsWidgetInstance.assetManager.getAssets("EFFECT",buildAsyncCodeDeferreds)}}else if(modulename==="frames"){if(AV.controlsWidgetInstance.assetManager){AV.controlsWidgetInstance.assetManager.getAssets("IMAGEBORDER",buildAsyncCodeDeferreds)}}else{dfd=avpw$.when(pw.canvasReadyCallback);completeDeferred()}}else{completeDeferred()}return dfd?dfd.isResolved():false};AV.PaintWidget.prototype.setDimensions=function(w,h){this.canvas.width=this.width=w;this.canvas.height=this.height=h;if(AV.controlsWidgetInstance){if(AV.controlsWidgetInstance.canvasUI){AV.controlsWidgetInstance.canvasUI.resetOffset()}AV.controlsWidgetInstance.layoutNotify(AV.launchData["openType"],"scaleCanvas")}};AV.PaintWidget.prototype.getScaledSize=function(){if(this.actions){return this.actions.getDims()}else{return{width:this.width,height:this.height}}};AV.PaintWidget.prototype.showWaitThrobber=function(show,callback){if(callback){setTimeout(callback,5)}};AV.PaintWidget.prototype.getBackgroundLayerIndex=function(){return 0};AV.PaintWidget.prototype.findLayerIndexByName=function(name){var i;for(i=0;i<this.layers.length;i++){if(this.layers[i].name===name){return i}}return-1};AV.PaintWidget.prototype.getLayerByName=function(name){var i=this.findLayerIndexByName(name);if(i===-1){return null}return this.layers[i]};AV.PaintWidget.prototype.moveLayerByName=function(name,x,y){var l=this.getLayerByName(name);if(l===null){return}l.translateX=x;l.translateY=y};AV.PaintWidget.prototype.setCurrentLayerByName=function(name){var i=this.findLayerIndexByName(name);if(i===-1){return false}this.currentLayerIndex=i;this.currentLayer=this.layers[i];return true};AV.PaintWidget.prototype.layerToTop=function(index){var l=this.layers[index];while(index<this.layers.length-1){var t=parseInt(index,10)+1;this.layers[index]=this.layers[t];index++}this.layers[index]=l};AV.PaintWidget.prototype.layerDelete=function(index){while(index<this.layers.length-1){var t=parseInt(index,10)+1;this.layers[index]=this.layers[t];index++}this.layers.length-=1};AV.PaintWidget.prototype.uiLayerReset=function(){var i=this.findLayerIndexByName("_ui");if(i==-1){var newCanvas=document.createElement("canvas");newCanvas.width=this.canvas.width;newCanvas.height=this.canvas.height;var l=new AV.Layer({canvas:newCanvas,name:"_ui"});l.hidden=true;this.layers.push(l)}else{this.layers[i].hidden=true;this.layers[i].canvas.width=this.canvas.width;this.layers[i].canvas.height=this.canvas.height;this.layerToTop(i)}};AV.PaintWidget.prototype.uiLayerShow=function(show){var i=this.findLayerIndexByName("_ui");if(i!=-1){this.layers[i].hidden=!show;if(!show){this.recomposite()}}};AV.PaintWidget.prototype.uiLayerClear=function(){var l=this.getLayerByName("_ui");var c=l.canvas.getContext("2d");c.globalCompositeOperation="copy";c.clearRect(0,0,l.canvas.width,l.canvas.height);c.globalCompositeOperation="source-over"};AV.PaintWidget.prototype.uiLayerDrawCircleSelection=function(x,y,radius,noClear){var l=this.getLayerByName("_ui");var c=l.canvas.getContext("2d");var lineWidth=1;if(!noClear){c.globalCompositeOperation="copy";c.clearRect(0,0,l.canvas.width,l.canvas.height)}var zoomScale=1;if(AV.controlsWidgetInstance.canvasUI){zoomScale=AV.controlsWidgetInstance.canvasUI.viewport.getRatio()}lineWidth=lineWidth*zoomScale+.5|0;c.globalCompositeOperation="source-over";c.lineWidth=lineWidth;c.globalAlpha=1;c.beginPath();c.strokeStyle="#ffffff";c.arc(x,y,radius,0,2*Math.PI,false);c.closePath();c.stroke();var innerRadius=radius-lineWidth;if(innerRadius>0){c.beginPath();c.strokeStyle="#000000";c.arc(x,y,innerRadius,0,2*Math.PI,false);c.closePath();c.stroke()}};AV.PaintWidget.prototype.dirtyRectEnable=function(enable){this.dirtyRect.dirty=enable};AV.PaintWidget.prototype.recomposite=function(fromDepth){var i;var l;AV.cnvs.clearCanvas(this.canvas);var cc=this.canvas.getContext("2d");if(fromDepth==null){fromDepth=0}else{fromDepth--;if(fromDepth<0){fromDepth=0}}cc.setTransform(1,0,0,1,0,0);for(i=fromDepth;i<this.layers.length;i++){l=this.layers[i];if(l.hidden){continue}cc.save();if(this.dirtyRect.dirty){cc.beginPath();cc.rect(this.dirtyRect.bbox.x0,this.dirtyRect.bbox.y0,this.dirtyRect.bbox.w,this.dirtyRect.bbox.h);cc.clip();cc.closePath()}cc.translate(l.translateX,l.translateY);cc.rotate(l.rotate);cc.scale(l.scaleX,l.scaleY);if(l.centerX!=null&&l.centerY!=null){cc.translate(-l.centerX,-l.centerY)}if(l.alpha!=null){cc.globalAlpha=l.alpha}else{cc.globalAlpha=1}cc.drawImage(l.drawable,0,0);cc.restore()}if(this.debugPoint!=null){cc.setTransform(1,0,0,1,0,0);cc.strokeStyle="#00ffff";cc.lineWidth=1;cc.lineCap="round";cc.lineJoin="round";cc.strokeRect(this.debugPoint.x-2,this.debugPoint.y-2,4,4)}};AV.PaintWidget.prototype.makeThumbFlat=function(newCanvas,surround){this.recomposite();var w=newCanvas.width;var h=newCanvas.height;var ctx=newCanvas.getContext("2d");ctx.globalCompositeOperation="copy";ctx.clearRect(0,0,newCanvas.width,newCanvas.height);ctx.globalCompositeOperation="source-over";var wmult=w/this.canvas.width;var hmult=h/this.canvas.height;if(surround){if(wmult>hmult){var destW=this.canvas.width*hmult;var xpos=(w-destW)/2;ctx.drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height,xpos,0,destW,h)}else{var destH=this.canvas.height*wmult;var ypos=(h-destH)/2;ctx.drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height,0,ypos,w,destH)}}else{if(wmult<hmult){var destW=this.canvas.width*hmult;var xpos=-(destW-w)/2;ctx.drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height,xpos,0,destW,h)}else{var destH=this.canvas.height*wmult;var ypos=-(destH-h)/2;ctx.drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height,0,ypos,w,destH)}}return newCanvas};AV.PaintWidget.prototype.exportImage=function(mime,callback){mime=mime||"image/png";this.uiLayerShow(false);this.recomposite();var supportsToDataURL=function(){var c=document.createElement("canvas");var data=c.toDataURL("image/png");return data.indexOf("data:image/png")==0};var dataURL;if(supportsToDataURL()){dataURL=this.canvas.toDataURL(mime)}else{dataURL=AV.toBitmapURL(this.canvas)}if(callback&&typeof callback==="function"){callback.apply(this,[dataURL])}return true};AV.PaintWidget.prototype.addLayer=function(layer){this.layers.push(layer);return this.layers.length-1};AV.PaintWidget.prototype.setMode=function(mode){if(this.active!==null){if(this.active.deactivate!==undefined){this.active.deactivate()}}if(mode!==null&&mode!==undefined&&mode!==""){var newactive=this.module[mode];if(newactive!==undefined){this.active=newactive;if(this.active.activate!==undefined){this.active.activate(this)}}}else{this.active=null}};AV.PaintWidget.prototype.undo=function(){if(this.active&&this.active.userUndo!==undefined){this.active.userUndo()}this.actions.undo();if(this.active&&this.active.userPostUndo!==undefined){this.active.userPostUndo()}};AV.PaintWidget.prototype.redo=function(){if(this.active&&this.active.userRedo!==undefined){this.active.userRedo()}this.actions.redo();if(this.active&&this.active.userPostRedo!==undefined){this.active.userPostRedo()}};AV.PaintWidget.prototype.getBacking=function(x,y,w,h){var c=this.canvas.getContext("2d");var id=c.getImageData(x,y,w,h);return id};AV.PaintWidget.prototype.getBackingAll=function(){var c=this.canvas.getContext("2d");return c.getImageData(0,0,this.canvas.width,this.canvas.height)};AV.PaintWidget.prototype.putBacking=function(layer,backing,x,y){var c=layer.canvas.getContext("2d");c.putImageData(backing,x,y)};AV.PaintWidget.prototype.rotate90=function(){var i,c;var _rotateOverlay90=function(l,angle){var t;l.rotate+=angle*Math.PI/180;if(angle==90){t=l.translateX;l.translateX=this.canvas.width-l.translateY;l.translateY=t}else if(angle==270){t=l.translateX;l.translateX=l.translateY;l.translateY=this.canvas.height-t}else if(angle==180){l.translateX=this.canvas.width-l.translateX;l.translateY=this.canvas.height-l.translateY}};return function(angle){angle%=360;if(angle<0){angle+=360}angle=parseInt(angle/90,10)*90;if(angle==0){return}if(angle%180!=0){this.setDimensions(this.canvas.height,this.canvas.width)}var tx;var ty;for(i=0;i<this.layers.length;i++){var l=this.layers[i];if(l.canvas!=null){if(l.tag=="module_text"){_rotateOverlay90(l,angle)}else{var newCanvas=document.createElement("canvas");newCanvas.width=this.canvas.width;newCanvas.height=this.canvas.height;c=newCanvas.getContext("2d");c.setTransform(1,0,0,1,0,0);c.translate(newCanvas.width/2,newCanvas.height/2);c.rotate(angle*3.14159265358979/180);c.translate(-l.canvas.width/2,-l.canvas.height/2);c.globalCompositeOperation="copy";c.drawImage(l.canvas,0,0);c.globalCompositeOperation="source-over";c.setTransform(1,0,0,1,0,0);l.canvas=l.drawable=newCanvas}}else if(l.image!=null){_rotateOverlay90(l,angle)}}this.recomposite()}}();AV.PaintWidget.prototype._dupLayerAttrs=function(dest,src){if(src.hidden==true){dest.hidden=true}if(src.alpha!=undefined){dest.alpha=src.alpha}dest.rotate=src.rotate;dest.scaleX=src.scaleX;dest.scaleY=src.scaleY;dest.translateX=src.translateX;dest.translateY=src.translateY;if(src.centerX!=null){dest.centerX=src.centerX}if(src.centerY!=null){dest.centerY=src.centerY}if(src.tag!=null){dest.tag=src.tag}if(src.module_data!=null){dest.module_data=src.module_data}};AV.PaintWidget.prototype.duplicateAllLayers=function(){var newLayers=[];var i,l,c;for(i=0;i<this.layers.length;i++){if(this.layers[i].name=="_ui"){continue}if(this.layers[i].canvas!=null){var newCanvas=document.createElement("canvas");newCanvas.width=this.layers[i].canvas.width;newCanvas.height=this.layers[i].canvas.height;c=newCanvas.getContext("2d");c.drawImage(this.layers[i].canvas,0,0,newCanvas.width,newCanvas.height);l=new AV.Layer({canvas:newCanvas,name:this.layers[i].name});this._dupLayerAttrs(l,this.layers[i]);newLayers.push(l)}else if(this.layers[i].image!=null){l=new AV.Layer({image:this.layers[i].image,name:this.layers[i].name});this._dupLayerAttrs(l,this.layers[i]);newLayers.push(l)}}return newLayers};AV.PaintWidget.prototype.duplicateAllLayersFrom=function(src){var i,c;for(i=0;i<src.length;i++){if(src[i].name=="_ui"){continue}var existing=this.getLayerByName(src[i].name);if(existing===null){existing=new AV.Layer({name:src[i].name});this.layers.push(existing)}if(src[i].canvas!=null){if(existing.canvas==null){existing.canvas=document.createElement("canvas")}existing.drawable=existing.canvas;existing.canvas.width=src[i].canvas.width;existing.canvas.height=src[i].canvas.height;c=existing.canvas.getContext("2d");c.drawImage(src[i].canvas,0,0,src[i].canvas.width,src[i].canvas.height);this._dupLayerAttrs(existing,src[i])}else if(src[i].image!=null){existing.image=src[i].image;existing.drawable=existing.image;this._dupLayerAttrs(existing,src[i])}}};AV.PaintWidget.prototype.resizeAllLayers=function(width,height,rescaleImages){var i,c,l;var newLayers=[];var oldwidth=this.width,scale;this.setDimensions(width,height);for(i=0;i<this.layers.length;i++){if(this.layers[i].canvas!=null){var newCanvas=document.createElement("canvas");newCanvas.width=width;newCanvas.height=height;c=newCanvas.getContext("2d");c.drawImage(this.layers[i].canvas,0,0,width,height);l=new AV.Layer({canvas:newCanvas,name:this.layers[i].name});this._dupLayerAttrs(l,this.layers[i])}else if(this.layers[i].image!=null){l=new AV.Layer({image:this.layers[i].image,name:this.layers[i].name});this._dupLayerAttrs(l,this.layers[i])}if(l){if(rescaleImages&&(l.image||l.tag==="module_text")){scale=width/oldwidth;l.translateX*=scale;l.translateY*=scale;l.scaleX*=scale;l.scaleY*=scale}newLayers.push(l)}}this.layers=newLayers;this.recomposite()};AV.PaintWidget.prototype.resizeAllLayersQnD=function(width,height){var i;this.setDimensions(width,height);for(i=0;i<this.layers.length;i++){if(this.layers[i].canvas!=null){this.layers[i].canvas.width=width;this.layers[i].canvas.height=height}}};AV.PaintWidget.prototype.flattenAllLayers=function(){var uiLayer=this.getLayerByName("_ui");this.uiLayerShow(false);this.recomposite();this.layers.length=0;var newCanvas=document.createElement("canvas");newCanvas.width=this.canvas.width;newCanvas.height=this.canvas.height;var l=new AV.Layer({canvas:newCanvas,name:"background"});this.layers.push(l);if(uiLayer){this.layers.push(uiLayer)}var cc=newCanvas.getContext("2d");cc.drawImage(this.canvas,0,0)};AV.PaintWidget.prototype.cropAllLayers=function(x0,y0,width,height){var i,c,l,thislayer;var cropType;var newLayers=[];this.setDimensions(width,height);for(i=0;i<this.layers.length;i++){thislayer=this.layers[i];if(thislayer.canvas!=null){if(thislayer.tag=="module_text"){cropType="textcanvas"}else{cropType="canvas"}}else if(thislayer.image!=null){cropType="image"}else{continue}switch(cropType){case"canvas":var newCanvas=document.createElement("canvas");newCanvas.width=width;newCanvas.height=height;c=newCanvas.getContext("2d");c.drawImage(this.layers[i].canvas,-x0,-y0,this.layers[i].canvas.width,this.layers[i].canvas.height);l=new AV.Layer({canvas:newCanvas,name:this.layers[i].name});this._dupLayerAttrs(l,this.layers[i]);newLayers.push(l);break;case"image":l=new AV.Layer({image:this.layers[i].image,name:this.layers[i].name});this._dupLayerAttrs(l,this.layers[i]);l.translateX-=x0;l.translateY-=y0;newLayers.push(l);break;case"textcanvas":var newCanvas=document.createElement("canvas");c=newCanvas.getContext("2d");newCanvas.width=thislayer.canvas.width;newCanvas.height=thislayer.canvas.height;c.drawImage(this.layers[i].canvas,0,0);l=new AV.Layer({canvas:newCanvas,name:this.layers[i].name});this._dupLayerAttrs(l,this.layers[i]);l.translateX-=x0;l.translateY-=y0;newLayers.push(l);break}}this.layers=newLayers;this.recomposite()};AV.PaintWidget.prototype.module={};AV.PaintWidget.prototype.module["flatten"]=function(){var _paintWidget;var api={};var _flattenUndo=function(oldLayers){_paintWidget.duplicateAllLayersFrom(oldLayers);_paintWidget.recomposite()};var _flattenRedo=function(width,height){_paintWidget.flattenAllLayers();_paintWidget.recomposite()};api.activate=function(paintWidget){_paintWidget=paintWidget};api.flatten=function(){var oldLayers=_paintWidget.duplicateAllLayers();_paintWidget.actions.push([_flattenUndo,this,[oldLayers]],[_flattenRedo,this,[]],{action:"flatten"},null,{implicit:true});_paintWidget.actions.redo()};return api}();AV.BrushCursor=function(){var api={};var _brushElm,_ctx;var _createBrush=function(){_brushElm=document.createElement("canvas");_brushElm.className="avpw_cursor_circle";_brushElm.width=_brushElm.height=200;_ctx=_brushElm.getContext("2d");AV.controlsWidgetInstance.layoutNotify(AV.launchData["openType"],"getCanvasControlsElement").append(_brushElm)};api.show=function(){if(!_brushElm)_createBrush();avpw$(_brushElm).fadeIn()};api.hide=function(){if(_brushElm)avpw$(_brushElm).hide()};api.setPosition=function(x,y){var zoomScale=AV.controlsWidgetInstance.canvasUI.viewport.getRatio();_brushElm.style.top=(y/zoomScale+.5|0)+"px";_brushElm.style.left=(x/zoomScale+.5|0)+"px"};api.setSize=function(radius){if(!_brushElm)return;_brushElm.width=_brushElm.width;radius=radius*1.3;var x=radius;var y=radius;_ctx.beginPath();_ctx.strokeStyle="#ffffff";_ctx.arc(x,y,radius,0,2*Math.PI,false);_ctx.closePath();_ctx.stroke();var lineWidth=2;var innerRadius=radius-lineWidth;if(innerRadius>0){_ctx.beginPath();_ctx.strokeStyle="#000000";_ctx.arc(x,y,innerRadius,0,2*Math.PI,false);_ctx.closePath();_ctx.stroke()}_brushElm.style.marginLeft=-radius+"px";_brushElm.style.marginTop=-radius+"px"};mediator.on("canvas:showBrushCursor",api.show);mediator.on("canvas:hideBrushCursor",api.hide);mediator.on("canvas:setBrushPosition",api.setPosition);mediator.on("canvas:setBrushSize",api.setSize);return api}();AV.PaintWidget.prototype.moaGl=null;AV.PaintWidget.prototype.setBackground=function(imgElementClean){var c,originClean;this.imgElementClean=imgElementClean;var moaGL=new(AV.require("../../../src/js/webgl/moaGL_bundle").MoaGL);this.moaGL=moaGL;var bgcanvas=this.canvas;bgcanvas.width=this.width;bgcanvas.height=this.height;var gl=bgcanvas.getContext("experimental-webgl",{preserveDrawingBuffer:true});moaGL.setup(gl);moaGL.setImage(imgElementClean);moaGL.createEffect();moaGL.renderIdentity();moaGL.finalizeEffect();originClean=true;this.currentLayerIndex=0;this.currentLayer=this.layers[this.currentLayerIndex];if(this.canvasReadyCallback){this.canvasReadyCallback.resolve()}return originClean};AV.PaintWidget.prototype.recomposite=function(fromDepth){console.log("TODO recomposite. get outta here!")};AV.PaintWidget.prototype.SliderModule=function(processor){var _paintWidget;var _lastInputArgs;var _processor=processor;var api={};api.activate=function(paintWidget){_paintWidget=paintWidget;_lastInputArgs=null};api.deactivate=function(){api.reset();_processingFunction=null;_lastInputArgs=null};api.applyPreview=function(){var dest={moaGL:_paintWidget.moaGL};var inputArgs=[dest,_paintWidget.width,_paintWidget.height];var args=[].splice.call(arguments,0);inputArgs=inputArgs.concat(args);_paintWidget.moaGL.createEffect();_processor.apply(this,inputArgs);_paintWidget.moaGL.finalizeEffect()};api.commit=function(){_paintWidget.moaGL.commit();if(_lastInputArgs){_pushAction&&_pushAction.apply(null,_lastInputArgs)}};api.reset=function(){_paintWidget.moaGL.createEffect();_paintWidget.moaGL.renderIdentity();_paintWidget.moaGL.finalizeEffect()};return api};AV.PaintWidget.prototype.module["effects"]=function(){var _paintWidget;var _proclistManager=null;var _filterCancelled=false;var _origBacking,_oldLayers;var _dirty;var api={};var _filter=function(id,filterParams,flatten){_proclistManager=_proclistManager||AV.require("./MoaLiteProclistManager");var bitmap={width:_paintWidget.width,height:_paintWidget.height,data:{moaGL:_paintWidget.moaGL}};_proclistManager.MLPLRunEffect(_paintWidget.filterManager.getEffectById(id),bitmap,filterParams)};var _pushState=function(filterData){};var _filterUndo=function(backing,oldLayers){if(oldLayers){_paintWidget.duplicateAllLayersFrom(oldLayers)}else{var layer=_paintWidget.getLayerByName(layerName);var c=layer.canvas.getContext("2d");c.globalCompositeOperation="copy";c.drawImage(backing,0,0);c.globalCompositeOperation="source-over"}_paintWidget.recomposite()};var _filterRedo=function(filterName,filterParams,flatten){_filter(filterName,filterParams,flatten);_origBacking=null;_oldLayers=null;_dirty=true};api.activate=function(paintWidget){_filterCancelled=false;_paintWidget=paintWidget;_dirty=false};api.deactivate=function(){if(_paintWidget.busy){_filterCancelled=true;_paintWidget.actions.undoFake();_paintWidget.busy=false}_origBacking=null;_oldLayers=null;_proclistManager=null};api.makeThumb=function(id,canvas,pixels){var cc=canvas.getContext("2d");var imageData=cc.createImageData(canvas.width,canvas.height);imageData.data.set(pixels);_proclistManager=_proclistManager||AV.require("./MoaLiteProclistManager");var effect=_paintWidget.filterManager.getEffectById(id);if(effect){_proclistManager.MLPLRunEffect(effect,imageData)}cc.putImageData(imageData,0,0)};api.applyPreview=function(id,filterParams,flatten){_filter(id,filterParams,flatten);_pushState({filterName:id,filterParams:filterParams,flatten:flatten})};api.commit=function(){_paintWidget.moaGL.commit()};api.readAction=function(data,next){if(data&&data.name){api.applyPreview(data.name,data,data.flatten)}if(next){next.call(this)}};return api}();AV.PaintWidget.prototype.module["enhance"]=function(){var _paintWidget;var _processor=null;var _filterCancelled=false;var _origBacking,_oldLayers;var _dirty;var api={};var _filter=function(layerName,id,flatten){_processor=_processor||AV.require("../../../src/js/filters/enhance");var dest={moaGL:_paintWidget.moaGL};_paintWidget.moaGL.createEffect();_paintWidget.moaGL.renderIdentity();_processor[id](dest,_paintWidget.width,_paintWidget.height);_paintWidget.moaGL.finalizeEffect()};var _pushState=function(id,flatten){var hiResData={action:id,flatten:flatten};var layerIndex=_paintWidget.currentLayerIndex;var layer=_paintWidget.layers[layerIndex];_paintWidget.actions.push([_filterUndo,this,[layer.name,_origBacking,_oldLayers]],[_filterRedo,this,[layer.name,id,flatten]],hiResData);_paintWidget.actions.redoFake()};var _filterUndo=function(layerName,backing,oldLayers){if(oldLayers){_paintWidget.duplicateAllLayersFrom(oldLayers)}else{var layer=_paintWidget.getLayerByName(layerName);var c=layer.canvas.getContext("2d");c.globalCompositeOperation="copy";c.drawImage(backing,0,0);c.globalCompositeOperation="source-over"}_paintWidget.recomposite()};var _filterRedo=function(layerName,filterName,filterParams,flatten){_filter(layerName,filterName,filterParams,flatten);_origBacking=null;_oldLayers=null;_dirty=true};api.activate=function(paintWidget){_filterCancelled=false;_paintWidget=paintWidget;_dirty=false};api.deactivate=function(){if(_paintWidget.busy){_filterCancelled=true;_paintWidget.actions.undoFake();_paintWidget.busy=false}_origBacking=null;_oldLayers=null;_processor=null};api.applyPreview=function(id,flatten){_filter("",id,flatten)};api.readAction=function(data,next){if(data&&data.id){api.applyPreview(data.id,data.flatten)}if(next){next.call(this)}};return api}();AV.PaintWidget.prototype.module["focus"]=function(){var _paintWidget;var api={};var _sessionAction;var _origSrc,_newPixelData,src,dst,_tmp,_mask;var _processor;var _initializeImageDataFromCanvas=function(){};var _preview=function(){var w=_paintWidget.width,h=_paintWidget.height;_processor.preview(dst,src,_tmp,_mask,w,h,0,0,w,h);var layer=_paintWidget.layers[_paintWidget.currentLayerIndex];var ctx=layer.canvas.getContext("2d");ctx.putImageData(_newPixelData,0,0);_paintWidget.recomposite()};api.applyLinearBlur=function(x,y,sigmaR,angle){_processor=_processor||AV.require("../../../src/js/mask-draw/tiltshift");var w=_paintWidget.width,h=_paintWidget.height;_processor.draw(dst,w,h,_mask,{tiltshiftMode:"linear",posX:x,posY:y,sigmaR:sigmaR,angle:angle});_sessionAction={action:"tools",toolname:"tiltshift",x:x,y:y,radius:sigmaR,angle:angle,tiltshiftmode:"linear"};_preview()};api.applyRadialBlur=function(x,y,sigmaR){_processor=_processor||AV.require("../../../src/js/mask-draw/tiltshift");var w=_paintWidget.width,h=_paintWidget.height;
_processor.draw(dst,w,h,_mask,{tiltshiftMode:"radial",posX:x,posY:y,sigmaR:sigmaR});_sessionAction={action:"tools",toolname:"tiltshift",x:x,y:y,radius:sigmaR,tiltshiftmode:"radial"};_preview()};var applyImage=function(imageData){var layer=_paintWidget.layers[_paintWidget.currentLayerIndex];layer.canvas.getContext("2d").putImageData(imageData,0,0);_paintWidget.recomposite()};api.commit=function(){_paintWidget.actions.push([applyImage,this,[_origSrc]],[applyImage,this,[_newPixelData]],_sessionAction);_paintWidget.actions.redoFake()};api.reset=function(){var layer=_paintWidget.layers[_paintWidget.currentLayerIndex];var ctx=layer.canvas.getContext("2d");ctx.putImageData(_origSrc,0,0);_paintWidget.recomposite()};api.readAction=function(data,next){var i,len,point;if(data&&data.tiltshiftmode&&data.x&&data.y&&data.radius){if(data.tiltshiftmode==="radial"){api.applyRadialBlur(data.x,data.y,data.radius)}else{api.applyLinearBlur(data.x,data.y,data.radius,data.angle)}}api.commit();if(next){next.call(this)}};api.activate=function(paintWidget){_paintWidget=paintWidget;_initializeImageDataFromCanvas()};api.deactivate=function(){_processor=null};api.resetImageData=function(){_initializeImageDataFromCanvas(true)};return api}();AV.PaintWidget.prototype.module["drawing"]=function(){var _paintWidget;var _width=10,_color="#ffffff",_erase=false;var _brushModule=new AV.BrushModule({overflow:10,preserveBacking:true});var api=AV.util?AV.util.extend({},_brushModule):{};api.activate=function(paintWidget){_paintWidget=paintWidget;_brushModule.activate(_paintWidget)};api.apply=function(x,y){_brushModule.commit("drawing")};api.width=function(){return _width};api.setWidth=function(width){_width=width;_brushModule.setRadius(_width/2)};api.color=function(){return _color};api.setColor=function(color){_color=color;_brushModule.setColor(_color)};api.erase=function(){return _erase};api.setErase=function(erase){_erase=erase;_brushModule.setErase(_erase)};api.flatten=function(){_paintWidget.flattenAllLayers()};api.readAction=function(data,next){var i,len,point;if(data&&data.color&&data.radius&&data.pointlist){len=data.pointlist.length;api.setErase(data.erase);api.setColor(data.color);api.setWidth(2*data.radius);for(i=0;i<len;i++){point=data.pointlist[i];if(i===0){api.updateUIDown(point[0],point[1])}else{api.updateUIDraw(point[0],point[1])}}api.apply()}if(next){next.call(this)}};return api}();AV.SpotModule=function(o){var api={};var _paintWidget;var _params=AV.util.extend({addMask:1,alpha:1,considerLuminosity:false,constant:1,sigmaC:99999999999},o.params);var _toolName=o.toolName;var _origBackingCanvas,_origSrc,_newPixelData,src,dst,_tmp,_mask;var _oldLayers;var _toolStrokes;var _strokeBacking;var _maskBacking;var _toolName=o.processorName;var _radius=5;var _pointlist;var _currentPointList;var _lastPoint;var _oldX,_oldY;var _glState;var _oldMidX,_oldMidY;var _copyProcessor=AV.require("../../../src/js/core/copy");var _processor=AV.require("../../../src/js/mask-draw/"+_toolName);var _shouldHideCursor=o.shouldHideCursor||false;var _BRUSH_MODE_SETTINGS=o.brushModeSettings||{};api.setParam=function(name,value){_params[name]=value;return this};api.getColorAtPosition=function(x,y){x=Math.floor(x);y=Math.floor(y);var w=_paintWidget.width;var h=_paintWidget.height;if(x<0){x=0}else if(x>w-1){x=w-1}if(y<0){y=0}else if(y>h-1){y=h-1}if(src){return[src[(w*y+x)*4],src[(w*y+x)*4+1],src[(w*y+x)*4+2],src[(w*y+x)*4+3]]}};api.getBrushSettingsForMode=function(mode){return _BRUSH_MODE_SETTINGS[mode]};var _initializeImageDataFromCanvas=function(flatten){var w=_paintWidget.width,h=_paintWidget.height;_mask=_tmp={moaGL:_paintWidget.moaGL};dst=src=_tmp;_glState=_processor.init(_tmp,w,h,_mask);_processor.preview(dst,src,_tmp,_mask,w,h,0,0,0,0,_glState);_pointlist=[]};var _drawUICircle=function(x,y){if(!_shouldHideCursor)mediator.trigger("canvas:setBrushPosition",x,y)};var _generatePointList=function(pointList,scaledRadius){var brushSize=Math.floor(scaledRadius*.2)||1;var lastpoint;var i=0;var midpoints=[];var getQuadMid=function(points,x0,y0,x1,y1,cpx,cpy){var distdist=(x1-x0)*(x1-x0)+(y1-y0)*(y1-y0);if(distdist<brushSize*brushSize){return null}var ax,bx,ay,by,mx,my;if(cpx!==undefined){ax=(cpx+x0)/2;bx=(cpx+x1)/2;ay=(cpy+y0)/2;by=(cpy+y1)/2;mx=(ax+bx)/2;my=(ay+by)/2}else{mx=(x0+x1)/2;my=(y0+y1)/2}getQuadMid(points,x0,y0,mx,my,ax,ay);points.push([mx|0,my|0]);getQuadMid(points,mx,my,x1,y1,bx,by)};for(i=0;i<pointList.length-1;++i){var point1=pointList[i];var point2=pointList[i+1];var midpoint=[(point1[0]+point2[0])/2|0,(point1[1]+point2[1])/2|0];if(i===0){getQuadMid(midpoints,point1[0],point1[1],midpoint[0],midpoint[1])}else{getQuadMid(midpoints,lastpoint[0],lastpoint[1],midpoint[0],midpoint[1],point1[0],point1[1])}lastpoint=midpoint;midpoints.push(midpoint);if(i===pointList.length-2){getQuadMid(midpoints,midpoint[0],midpoint[1],point2[0],point2[1]);midpoints.push(point2)}}return midpoints};var _drawingUndo=function(layerName,backing,x,y){var layer=_paintWidget.getLayerByName(layerName);var c=layer.canvas.getContext("2d");AV.cnvs.drawImageCopy(c,backing,x,y);_paintWidget.recomposite()};api.reset=function(){_initializeImageDataFromCanvas(true)};api.activate=function(paintWidget){_paintWidget=paintWidget;_paintWidget.uiLayerReset();_paintWidget.uiLayerShow(true);_toolStrokes=[];api.reset();AV.controlsWidgetInstance.layoutNotify(AV.launchData["openType"],"showCanvasControlsElement")};api.deactivate=function(){_paintWidget.uiLayerShow(false);mediator.trigger("canvas:hideBrushCursor");_toolStrokes=null};var _applyDraw=function(x,y,scaledRadius){var layer=_paintWidget.layers[_paintWidget.currentLayerIndex];var ctx=layer.canvas.getContext("2d");var w=_paintWidget.width,h=_paintWidget.height;var minX,minY,maxX,maxY;var paddedBrushRadius=scaledRadius*1.5;if(_lastPoint!=null){var distance=Math.sqrt(Math.pow(_lastPoint[0]-x,2)+Math.pow(_lastPoint[1]-y,2));if(distance<.6*_radius){return}var fillPoints=_generatePointList([[_lastPoint[0],_lastPoint[1]],[x,y]],scaledRadius);minX=x;minY=y;maxX=x;maxY=y;var xPos,yPos;for(var i=0;i<fillPoints.length;i++){xPos=fillPoints[i][0];yPos=fillPoints[i][1];if(xPos<minX){minX=xPos}if(xPos>maxX){maxX=xPos}if(yPos<minY){minY=yPos}if(yPos>maxY){maxY=yPos}api.drawPoint(xPos,yPos,xPos,yPos,w,h,scaledRadius)}}else{minX=x;minY=y;maxX=x;maxY=y}minX-=paddedBrushRadius;minY-=paddedBrushRadius;maxX+=paddedBrushRadius;maxY+=paddedBrushRadius;_currentPointList.push([x,y]);api.drawPoint(x,y,x,y,w,h,scaledRadius);_processor.preview(dst,src,_tmp,_mask,w,h,minX,minY,maxX,maxY,_glState)};api.drawPoint=function(x,y,startX,startY,w,h,scaledRadius){var procParams=AV.util.extend({posX:x,posY:y,startX:startX,startY:startY,radius:scaledRadius},_params);_currentPointList.push([x,y]);_lastPoint=[x,y];_processor.draw(src,w,h,_mask,procParams,_glState)};api.startStroke=function(){_currentPointList=[]};api.updateUIDown=function(x,y,scaledRadius){_maskBacking=_copyProcessor.copy(_mask);if(!_shouldHideCursor){_paintWidget.uiLayerShow(true);_drawUICircle(x,y)}var layer=_paintWidget.layers[_paintWidget.currentLayerIndex];if(!layer.canvas){return}_strokeBacking=AV.cnvs.getCanvasPixelData(layer.canvas);api.startStroke();_currentPointList.push([x,y]);_applyDraw(x,y,scaledRadius)};api.updateUIMove=function(x,y,mouseDown,scaledRadius){if(mouseDown){_applyDraw(x,y,scaledRadius);_currentPointList.push([x,y])}if(!_shouldHideCursor){_paintWidget.uiLayerShow(true);_drawUICircle(x,y)}_paintWidget.recomposite()};api.updateUIUp=function(){_lastPoint=null};var _applyImage=function(imageData){var layer=_paintWidget.layers[_paintWidget.currentLayerIndex];layer.canvas.getContext("2d").putImageData(imageData,0,0);_paintWidget.recomposite();_origSrc=AV.cnvs.getCanvasPixelData(layer.canvas);src=_origSrc.data;_newPixelData=AV.cnvs.getCanvasPixelData(layer.canvas);dst=_newPixelData.data;_mask=_copyProcessor.makeData(_paintWidget.width*_paintWidget.height)};var _undoStroke=function(mask,origSrc,oldLayers){_processor.preview(dst,src,_tmp,_mask,layer.canvas.width,layer.canvas.height)};var _redoStroke=function(mask){_mask=mask;_processor.preview(dst,src,_tmp,_mask,layer.canvas.width,layer.canvas.height)};api.commitStroke=function(scaledRadius){};api.finializeStroke=function(scaledRadius){_toolStrokes.push(AV.util.extend({},{radius:scaledRadius,pointlist:_currentPointList}))};api.commit=function(isHeadless){var layer=_paintWidget.layers[_paintWidget.currentLayerIndex];var ctx=layer.canvas.getContext("2d");var dstCopy=ctx.getImageData(0,0,_paintWidget.width,_paintWidget.height);_paintWidget.actions.undoToCheckpoint();var origCopy=ctx.getImageData(0,0,_paintWidget.width,_paintWidget.height);_paintWidget.actions.push([_applyImage,this,[origCopy]],[_applyImage,this,[dstCopy]],api.getFlattenedActionList());_paintWidget.actions.redo()};api.getFlattenedActionList=function(){return{action:"tools",toolname:_toolName,strokes:_toolStrokes}};api.resetImageData=function(){_initializeImageDataFromCanvas(true)};api.radius=function(){return _radius};api.setRadius=function(r){_radius=r;mediator.trigger("canvas:setBrushSize",r)};return api};AV.PaintWidget.prototype.module["brightness"]=new AV.PaintWidget.prototype.SliderModule(AV.require("../../../src/js/filters/adjustments").brightness,"brightness");AV.PaintWidget.prototype.module["contrast"]=new AV.PaintWidget.prototype.SliderModule(AV.require("../../../src/js/filters/adjustments").contrast,"contrast");AV.PaintWidget.prototype.module["warmth"]=new AV.PaintWidget.prototype.SliderModule(AV.require("../../../src/js/filters/adjustments").colortemp,"colortemp");AV.PaintWidget.prototype.module["sharpness"]=new AV.PaintWidget.prototype.SliderModule(AV.require("../../../src/js/filters/adjustments").sharpness,"sharpness");AV.PaintWidget.prototype.module["saturation"]=new AV.PaintWidget.prototype.SliderModule(AV.require("../../../src/js/filters/adjustments").saturation,"saturation");AV.PaintWidget.prototype.module["blemish"]=new AV.SpotModule({processorName:"blemish",params:{alpha:.5}});AV.PaintWidget.prototype.module["redeye"]=new AV.SpotModule({processorName:"redeye",params:{alpha:.5}});AV.PaintWidget.prototype.module["whiten"]=new AV.SpotModule({processorName:"whiten",params:{alpha:.5}});AV.PaintWidget.prototype.module["colorsplash"]=new AV.SpotModule({processorName:"colorsplash",shouldHideCursor:true,params:{alpha:.5},brushModeSettings:{smart:{IS_FREE_HAND:false,SIGMA_COLOR:10,REVERSE:0},free:{IS_FREE_HAND:true,SIGMA_COLOR:99999999,REVERSE:0},erase:{IS_FREE_HAND:true,SIGMA_COLOR:99999999,REVERSE:1}}});