/*** P R O C E S S I N G . J S - 1.2.3 a port of the Processing visualization language Processing.js is licensed under the MIT License, see LICENSE. For a list of copyright holders, please refer to AUTHORS. http://processingjs.org ***/ (function(X,A,g,p){function wa(c,f){if(c in X)return X[c];return typeof X[f]==="function"?X[f]:function(c){if(c instanceof Array)return c;else if(typeof c==="number"){var i=[];i.length=c;return i}}}function xc(c){if(c.constructor===String){for(var f=0,Q=0;Q0;)g(v.shift())}function yc(){var c=["abs","acos","alpha", "ambient","ambientLight","append","applyMatrix","arc","arrayCopy","asin","atan","atan2","background","beginCamera","beginDraw","beginShape","bezier","bezierDetail","bezierPoint","bezierTangent","bezierVertex","binary","blend","blendColor","blit_resize","blue","box","breakShape","brightness","camera","ceil","Character","color","colorMode","concat","console","constrain","copy","cos","createFont","createGraphics","createImage","cursor","curve","curveDetail","curvePoint","curveTangent","curveTightness", "curveVertex","day","degrees","directionalLight","disableContextMenu","dist","draw","ellipse","ellipseMode","emissive","enableContextMenu","endCamera","endDraw","endShape","exit","exp","expand","externals","fill","filter","filter_bilinear","filter_new_scanline","floor","focused","frameCount","frameRate","frustum","get","glyphLook","glyphTable","green","height","hex","hint","hour","hue","image","imageMode","Import","intersect","join","key","keyCode","keyPressed","keyReleased","keyTyped","lerp","lerpColor", "lightFalloff","lights","lightSpecular","line","link","loadBytes","loadFont","loadGlyphs","loadImage","loadPixels","loadShape","loadStrings","log","loop","mag","map","match","matchAll","max","millis","min","minute","mix","modelX","modelY","modelZ","modes","month","mouseButton","mouseClicked","mouseDragged","mouseMoved","mouseOut","mouseOver","mousePressed","mouseReleased","mouseScroll","mouseScrolled","mouseX","mouseY","name","nf","nfc","nfp","nfs","noCursor","noFill","noise","noiseDetail","noiseSeed", "noLights","noLoop","norm","normal","noSmooth","noStroke","noTint","ortho","param","parseBoolean","parseByte","parseChar","parseFloat","parseInt","peg","perspective","PFont","PImage","pixels","PMatrix2D","PMatrix3D","PMatrixStack","pmouseX","pmouseY","point","pointLight","popMatrix","popStyle","pow","print","printCamera","println","printMatrix","printProjection","PShape","PShapeSVG","pushMatrix","pushStyle","quad","radians","random","Random","randomSeed","rect","rectMode","red","redraw","requestImage", "resetMatrix","reverse","rotate","rotateX","rotateY","rotateZ","round","saturation","save","saveFrame","saveStrings","scale","screenX","screenY","screenZ","second","set","setup","shape","shapeMode","shared","shininess","shorten","sin","size","smooth","sort","specular","sphere","sphereDetail","splice","split","splitTokens","spotLight","sq","sqrt","status","str","stroke","strokeCap","strokeJoin","strokeWeight","subset","tan","text","textAlign","textAscent","textDescent","textFont","textLeading","textMode", "textSize","texture","textureMode","textWidth","tint","touchCancel","touchEnd","touchMove","touchStart","translate","triangle","trim","unbinary","unhex","updatePixels","use3DContext","vertex","width","XMLElement","year","__contains","__equals","__frameRate","__hashCode","__int_cast","__instanceof","__keyPressed","__mousePressed","__printStackTrace","__replace","__replaceAll","__replaceFirst","__toCharArray","__split"],f={},g,p;g=0;for(p=c.length;g1&&!/^\[\s*\]$/.test(N[c[1]]))return a;return""+d}else return a}),a=a.replace(/\(int\)([^,\]\)\}\?\:\*\+\-\/\^\|\%\&\~<\>\=]+)/g,function(a,c){var d=f(c);return d.untrim("__int_cast("+d.middle+")")}),a=a.replace(/\bsuper(\s*"B\d+")/g,"$$superCstr$1").replace(/\bsuper(\s*\.)/g, "$$super$1"),a=a.replace(/\b0+((\d*)(?:\.[\d*])?(?:[eE][\-\+]?\d+)?[fF]?)\b/,function(a,c,d){if(c===d)return a;return d===""?"0"+c:c}),a=a.replace(/\b(\.?\d+\.?)[fF]\b/g,"$1"),a=a.replace(/([^\s])%([^=\s])/g,"$1 % $2"),a=a.replace(/\b(frameRate|keyPressed|mousePressed)\b(?!\s*"B)/g,"__$1"),a=a.replace(/\b(boolean|byte|char|float|int)\s*"B/g,function(a,c){return"parse"+c.substring(0,1).toUpperCase()+c.substring(1)+'"B'}),a=a.replace(/\bpixels\s*(("C(\d+)")|\.length)?(\s*=(?!=)([^,\]\)\}]+))?/g,function(a, c,d,Z,ia,xa){return d?(a=N[Z],ia?"pixels.setPixel"+J("("+a.substring(1,a.length-1)+","+xa+")","B"):"pixels.getPixel"+J("("+a.substring(1,a.length-1)+")","B")):c?"pixels.getLength"+J("()","B"):ia?"pixels.set"+J("("+xa+")","B"):"pixels.toArray"+J("()","B")}),B;do B=!1,a=a.replace(/((?:'\d+'|\b[A-Za-z_$][\w$]*\s*(?:"[BC]\d+")*)\s*\.\s*(?:[A-Za-z_$][\w$]*\s*(?:"[BC]\d+"\s*)*\.\s*)*)(replace|replaceAll|replaceFirst|contains|equals|hashCode|toCharArray|printStackTrace|split)\s*"B(\d+)"/g,c);while(B);do B= !1,a=a.replace(/((?:'\d+'|\b[A-Za-z_$][\w$]*\s*(?:"[BC]\d+")*)\s*(?:\.\s*[A-Za-z_$][\w$]*\s*(?:"[BC]\d+"\s*)*)*)instanceof\s+([A-Za-z_$][\w$]*\s*(?:\.\s*[A-Za-z_$][\w$]*)*)/g,d);while(B);return a=a.replace(/\bthis(\s*"B\d+")/g,"$$constr$1")}function Xc(a,c){this.baseInterfaceName=a;this.body=c;c.owner=this}function fa(a){var c=RegExp(/\bnew\s*([A-Za-z_$][\w$]*\s*(?:\.\s*[A-Za-z_$][\w$]*)*)\s*"B\d+"\s*"A(\d+)"/).exec(a),a=za,d="class"+ ++ob;za=d;var B=c[1]+"$"+d,c=new Xc(B,fb(N[c[2]],B,"","implements "+ c[1]));c.classId=d;c.scopeId=a;ba[d]=c;za=a;return c}function A(a,c,d){this.name=a;this.params=c;this.body=d}function L(a){a=RegExp(/\b([A-Za-z_$][\w$]*)\s*"B(\d+)"\s*"A(\d+)"/).exec(a);return new A(a[1]!=="function"?a[1]:null,ca(N[a[2]]),Oa(N[a[3]]))}function Xb(a){this.members=a}function X(a){for(var a=a.split(","),c=0;c=0&&a.indexOf(";")< 0?(a=a.substring(1,a.length-1).split(":"),new Qa(La(g(a[0])),Aa(a[1]))):(a=a.substring(1,a.length-1).split(";"),new Pa(La(g(a[0])),Aa(a[1]),Aa(a[2])))}function Ab(a){a.sort(function(a,c){return c.weight-a.weight})}function Ra(a,c,d){this.name=a;this.body=c;this.isStatic=d;c.owner=this}function H(a,c,d){this.name=a;this.body=c;this.isStatic=d;c.owner=this}function qa(a){var c=W.exec(a);W.lastIndex=0;var d=c[1].indexOf("static")>=0,B=N[s(c[6])],a=za,f="class"+ ++ob;za=f;c=c[2]==="interface"?new Ra(c[3], hb(B,c[3],c[4]),d):new H(c[3],fb(B,c[3],c[4],c[5]),d);c.classId=f;c.scopeId=a;ba[f]=c;za=a;return c}function qb(a,c,d,B){this.name=a;this.params=c;this.body=d;this.isStatic=B}function rb(a){a=Ya.exec(a);Ya.lastIndex=0;var c=a[1].indexOf("static")>=0,d=a[6]!==";"?N[s(a[6])]:"{}";return new qb(a[3],ca(N[s(a[4])]),Oa(d),c)}function Ca(a,c,d){this.definitions=a;this.fieldType=c;this.isStatic=d}function Ia(a){for(var c=Za.exec(a),d=c[1].indexOf("static")>=0,a=a.substring(c[0].length).split(/,\s*/g),B= hc(c[2]),f=0;f([=]?)/g,$a);while(jb);var N=function(a){for(var c=[],a=a.split(/([\{\[\(\)\]\}])/),d=a[0],f=[],g=1;g=0&&(a=a.substring(0,a.indexOf("=")));return"("+a+" in "+this.container+")"};Qa.iteratorId=0;Qa.prototype.toString=function(){var a=this.initStatement.toString(),c="$it"+Qa.iteratorId++,a=a.replace(/^\s*var\s*/, "").split("=")[0];return"("+("var "+c+" = new $p.ObjectIterator("+this.container+"), "+a+" = void(0)")+"; "+(c+".hasNext() && (("+a+" = "+c+".next()) || true)")+";)"};Ra.prototype.toString=function(){return""+this.body};H.prototype.toString=function(){return""+this.body};qb.prototype.toString=function(){var a=v({},this.params.getNames()),c=T;T=function(d){return a.hasOwnProperty(d.name)?d.name:c(d)};var d="function "+this.methodId+this.params+" "+this.body+"\n";T=c;return d};Ca.prototype.getNames= function(){for(var a=[],c=0,d=this.definitions.length;c0&&(d+=this.functions.join("\n")+"\n");Ab(this.innerClasses);q=0;for(da=this.innerClasses.length;q< da;++q)w=this.innerClasses[q],w.isStatic?(f+=c+"."+w.name+" = "+w+";\n",d+=a+"."+w.name+" = "+c+"."+w.name+";\n"):d+=a+"."+w.name+" = "+w+";\n";q=0;for(da=this.fields.length;q0&&(d+=this.cstrs.join("\n")+"\n");d+="function $constr() {\n";w=[];q=0;for(da=this.cstrs.length;q0&&(d+=w.join(" else ")+" else ");d+="$superCstr();\n}\n";d+="$constr.apply(null, arguments);\n";T=ca;return"(function() {\nfunction "+c+"() {\n"+d+"}\n"+f+i+"return "+c+";\n})()"};fb=function(a,c,d,i){var a=a.substring(1,a.length-1),a=w(a),a=x(a,c),g=[],s=[],Q=[],v=[],a=a.replace(/"([DEGH])(\d+)"/g,function(a,c,d){c==="D"?g.push(d):c==="E"?s.push(d):c==="H"?v.push(d):Q.push(d);return""}),a=a.replace(/^(?:\s*;)+/,"").split(/;(?:\s*;)*/g), q,ca;d!==p&&(q=d.replace(/^\s*extends\s+([A-Za-z_$][\w$]*\b(?:\s*\.\s*[A-Za-z_$][\w$]*\b)*)\s*$/g,"$1"));i!==p&&(ca=i.replace(/^\s*implements\s+(.+?)\s*$/g,"$1").split(/\s*,\s*/g));for(d=0;d0){s=0;for(v=g.length;s0)f.interfaces=i}}})(i);(function(){function a(c,f){var g=d[c];if(!g)return!1; var i=g.indexOf(f);if(i<0)return!1;g.splice(i,1);if(g.length>0)return!1;delete d[c];return!0}var c=[],d={},f,i,g;for(f in ba)if(ba.hasOwnProperty(f))if(g=ba[f],!g.inScope&&!g.derived)c.push(f),g.weight=0;else{var s=[];if(g.inScope)for(i in g.inScope)g.inScope.hasOwnProperty(i)&&s.push(g.inScope[i]);g.derived&&(s=s.concat(g.derived));d[f]=s}for(;c.length>0;){f=c.shift();g=ba[f];if(g.scopeId&&a(g.scopeId,g))c.push(g.scopeId),ba[g.scopeId].weight=g.weight+1;if(g.base&&a(g.base.classId,g))c.push(g.base.classId), g.base.weight=g.weight+1;if(g.interfaces){f=0;for(i=g.interfaces.length;f0&&typeof arguments[0]!=="number"?g=arguments[0].toArray():(g=[],g.length=0|arguments[0]);this.get=function(c){return g[c]}; this.contains=function(c){return this.indexOf(c)>-1};this.indexOf=function(c){for(var f=0,i=g.length;f=0&&c<=g.length)g.splice(c,0,arguments[1]);else throw c+" is not a valid index";else throw typeof c+" is not a number";}else throw"Please use the proper number of parameters.";};this.addAll=function(c,f){var i;if(typeof c=== "number"){if(c<0||c>g.length)throw"Index out of bounds for addAll: "+c+" greater or equal than "+g.length;for(i=new Ib(f);i.hasNext();)g.splice(c++,0,i.next())}else for(i=new Ib(c);i.hasNext();)g.push(i.next())};this.set=function(){if(arguments.length===2){var c=arguments[0];if(typeof c==="number")if(c>=0&&c-1)return g.splice(c,1),!0;return!1}};this.isEmpty=function(){return!g.length};this.clone=function(){return new f(this)};this.toArray=function(){return g.slice(0)};this.iterator=function(){return new c(g)}}return f}(),Gc=function(){function c(){function f(c){c=xc(c)%x.length;return c<0?x.length+c:c}function g(){if(!(A<=w*x.length)){for(var c=[],i=0;i=x.length)q=!0;else if(x[i]===p||s>=x[i].length)s=-1,++i;else break}var i=0,s=-1,q=!1;this.hasNext=function(){return!q};this.next=function(){var f=c(x[i][s]);g();return f};this.remove=function(){f(this.next());--s};g()}function q(c,f,g){this.clear=function(){G.clear()};this.contains=function(c){return f(c)};this.containsAll= function(c){for(c=c.iterator();c.hasNext();)if(!this.contains(c.next()))return!1;return!0};this.isEmpty=function(){return G.isEmpty()};this.iterator=function(){return new v(c,g)};this.remove=function(c){if(this.contains(c))return g(c),!0;return!1};this.removeAll=function(c){for(c=c.iterator();c.hasNext();){var f=c.next();this.contains(f)&&g(f)}return!0};this.retainAll=function(c){for(var f=this.iterator(),i=[];f.hasNext();){var s=f.next();c.contains(s)||i.push(s)}for(c=0;c 0};this.size=function(){return G.size()};this.toArray=function(){for(var c=[],f=this.iterator();f.hasNext();)c.push(f.next());return c}}function s(c){this._isIn=function(f){return f===G&&c.removed===p};this.equals=function(f){return qa(c.key,f.getKey())};this.getKey=function(){return c.key};this.getValue=function(){return c.value};this.hashCode=function(){return xc(c.key)};this.setValue=function(f){var g=c.value;c.value=f;return g}}if(arguments.length===1&&arguments[0].constructor===c)return arguments[0].clone(); var z=arguments.length>0?arguments[0]:16,w=arguments.length>1?arguments[1]:0.75,x=[];x.length=z;var A=0,G=this;this.clear=function(){A=0;x=[];x.length=z};this.clone=function(){var f=new c;f.putAll(this);return f};this.containsKey=function(c){var g=f(c),g=x[g];if(g===p)return!1;for(var i=0;i1?i.splice(s,1):x[g]=p,c;return null};this.size=function(){return A}; this.values=function(){for(var c=[],f=this.entrySet().iterator();f.hasNext();){var g=f.next();c.push(g.getValue())}return c}}return c}(),aa=function(){function c(f,g,i){this.x=f||0;this.y=g||0;this.z=i||0}function f(c){return function(f,g){var i=f.get();i[c](g);return i}}function p(c){return function(f,g){return f[c](g)}}var v="dist dot cross".split(" "),q=v.length;c.angleBetween=function(c,f){return g.acos(c.dot(f)/(c.mag()*f.mag()))};for(c.prototype={set:function(c,f,g){arguments.length===1?this.set(c.x|| c[0]||0,c.y||c[1]||0,c.z||c[2]||0):(this.x=c,this.y=f,this.z=g)},get:function(){return new c(this.x,this.y,this.z)},mag:function(){return g.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},add:function(c,f,g){arguments.length===3?(this.x+=c,this.y+=f,this.z+=g):arguments.length===1&&(this.x+=c.x,this.y+=c.y,this.z+=c.z)},sub:function(c,f,g){arguments.length===3?(this.x-=c,this.y-=f,this.z-=g):arguments.length===1&&(this.x-=c.x,this.y-=c.y,this.z-=c.z)},mult:function(c){typeof c==="number"?(this.x*= c,this.y*=c,this.z*=c):typeof c==="object"&&(this.x*=c.x,this.y*=c.y,this.z*=c.z)},div:function(c){typeof c==="number"?(this.x/=c,this.y/=c,this.z/=c):typeof c==="object"&&(this.x/=c.x,this.y/=c.y,this.z/=c.z)},dist:function(c){var f=this.x-c.x,i=this.y-c.y,c=this.z-c.z;return g.sqrt(f*f+i*i+c*c)},dot:function(c,f,g){if(arguments.length===3)return this.x*c+this.y*f+this.z*g;else if(arguments.length===1)return this.x*c.x+this.y*c.y+this.z*c.z},cross:function(f){return new c(this.y*f.z-f.y*this.z,this.z* f.x-f.z*this.x,this.x*f.y-f.x*this.y)},normalize:function(){var c=this.mag();c>0&&this.div(c)},limit:function(c){this.mag()>c&&(this.normalize(),this.mult(c))},heading2D:function(){return-g.atan2(-this.y,this.x)},toString:function(){return"["+this.x+", "+this.y+", "+this.z+"]"},array:function(){return[this.x,this.y,this.z]}};q--;)c[v[q]]=p(v[q]);for(q in c.prototype)c.prototype.hasOwnProperty(q)&&!c.hasOwnProperty(q)&&(c[q]=f(q));return c}();Wb.prototype=c;var la=new Wb;la.ArrayList=Fc;la.HashMap= Gc;la.PVector=aa;la.ObjectIterator=Ib;la.defineProperty=function(c,f,g){"defineProperty"in Object?Object.defineProperty(c,f,g):(g.hasOwnProperty("get")&&c.__defineGetter__(f,g.get),g.hasOwnProperty("set")&&c.__defineSetter__(f,g.set))};la.extendClassChain=function(c){for(var f=[c],g=c.$upcast;g;g=g.$upcast)xb(g,c),f.push(g),c=g;for(;f.length>0;)f.pop().$self=c};la.extendStaticMembers=function(c,f){xb(c,f)};la.extendInterfaceMembers=function(c,f){xb(c,f)};la.addMethod=function(c,f,g){if(c[f]){var p= g.length,q=c[f];c[f]=function(){return arguments.length===p?g.apply(this,arguments):q.apply(this,arguments)}}else c[f]=g};la.createJavaArray=function(c,f){var g=null;if(typeof f[0]==="number"){var p=0|f[0];if(f.length<=1){g=[];g.length=p;for(var q=0;q255?255:e)<<24&c.ALPHA_MASK|(b>255?255:b)<<16&c.RED_MASK|(k>255?255:k)<<8&c.GREEN_MASK|(m>255?255:m)&c.BLUE_MASK}function zb(){d.restore();Ga=Db=!0}function G(b,k,a){b.addEventListener?b.addEventListener(k, a,!1):b.attachEvent("on"+k,a);Kb.push({elem:b,type:k,fn:a})}function ca(b){var k=b.elem,a=b.type,b=b.fn;k.removeEventListener?k.removeEventListener(a,b,!1):k.detachEvent&&k.detachEvent("on"+a,b)}function da(b,k){var a=1;a<<=k-1;for(var c="",h=0;h>>=1;return c}function qa(b,k,a,c,h,d){k=b<0?a:k;a=h===0;h=h===p||h<0?0:h;b=g.abs(b);if(a){h=1;for(b*=10;g.abs(g.round(b)-b)>1.0E-6&&h<7;)++h,b*=10}else h!==0&&(b*=g.pow(10,h));a=b*2;g.floor(b)===b?a=b:g.floor(a)===a?(b=g.floor(b), a=b+b%2):a=g.round(b);b="";for(c+=h;c>0||a>0;)c--,b=""+a%10+b,a=g.floor(a/10);if(d!==p)for(c=b.length-3-h;c>0;)b=b.substring(0,c)+d+b.substring(c),c-=3;return h>0?k+b.substring(0,b.length-h)+"."+b.substring(b.length-h,b.length):k+b}function fa(b,k,a,c,h,d){if(b instanceof Array){for(var j=[],l=0,y=b.length;l2147483647&&(b-=4294967296);return b}function gb(b){return Array.prototype.slice.call(b, 1)}function Xb(b){if(typeof b==="number")return b!==0;else if(typeof b==="boolean")return b;else if(typeof b==="string")return b.toLowerCase()==="true";else if(b instanceof ya)return b.code===49||b.code===84||b.code===116}function Zc(b){if(typeof b==="number")return b;else if(typeof b==="boolean")return b?1:0;else if(typeof b==="string")return parseFloat(b);else if(b instanceof ya)return b.code}function pb(b,k){if(typeof b==="number")return b&4294967295;else if(typeof b==="boolean")return b?1:0;else if(typeof b=== "string")return parseInt(b,k||10)&4294967295;else if(b instanceof ya)return b.code}function ha(b,k){var a=b||362436069,c=k||521288629,h=function(){a=36969*(a&65535)+(a>>>16)&4294967295;c=18E3*(c&65535)+(c>>>16)&4294967295;return((a&65535)<<16|c&65535)&4294967295};this.nextDouble=function(){var b=h()/4294967296;return b<0?1+b:b};this.nextInt=h}function Ia(b){function k(b,k,a,m){b&=15;var c=b<8?k:a,k=b<4?a:b===12||b===14?k:m;return((b&1)===0?c:-c)+((b&2)===0?k:-k)}function a(b,k,m){k=(b&1)===0?k:m; return(b&2)===0?-k:k}function c(b,k,a){return k+b*(a-k)}var b=b!==p?new ha(b):ha.createRandomized(),h,d,j=new $c(512);for(h=0;h<256;++h)j[h]=h;for(h=0;h<256;++h){var l=j[d=b.nextInt()&255];j[d]=j[h];j[h]=l}for(h=0;h<256;++h)j[h+256]=j[h];this.noise3d=function(b,a,m){var h=g.floor(b)&255,d=g.floor(a)&255,r=g.floor(m)&255;b-=g.floor(b);a-=g.floor(a);m-=g.floor(m);var l=(3-2*b)*b*b,f=(3-2*a)*a*a,i=j[h]+d,o=j[i]+r,i=j[i+1]+r,d=j[h+1]+d,h=j[d]+r,r=j[d+1]+r;return c((3-2*m)*m*m,c(f,c(l,k(j[o],b,a,m),k(j[h], b-1,a,m)),c(l,k(j[i],b,a-1,m),k(j[r],b-1,a-1,m))),c(f,c(l,k(j[o+1],b,a,m-1),k(j[h+1],b-1,a,m-1)),c(l,k(j[i+1],b,a-1,m-1),k(j[r+1],b-1,a-1,m-1))))};this.noise2d=function(b,k){var h=g.floor(b)&255,d=g.floor(k)&255;b-=g.floor(b);k-=g.floor(k);var r=(3-2*b)*b*b,l=j[h]+d,h=j[h+1]+d;return c((3-2*k)*k*k,c(r,a(j[l],b,k),a(j[h],b-1,k)),c(r,a(j[l+1],b,k-1),a(j[h+1],b-1,k-1)))};this.noise1d=function(b){var k=g.floor(b)&255;b-=g.floor(b);return c((3-2*b)*b*b,(j[k]&1)===0?-b:b,(j[k+1]&1)===0?-(b-1):b-1)}}function ea(){if(U){if(Ga)d.fillStyle= a.color.toString(Fa),Ga=!1;d.fill()}}function Y(){if(O){if(Db)d.strokeStyle=a.color.toString(ka),Db=!1;d.stroke()}}function hc(b,k,m){m=0|m*((k&c.ALPHA_MASK)>>>24);return g.min(((b&c.ALPHA_MASK)>>>24)+m,255)<<24|a.mix(b&c.RED_MASK,k&c.RED_MASK,m)&c.RED_MASK|a.mix(b&c.GREEN_MASK,k&c.GREEN_MASK,m)&c.GREEN_MASK|a.mix(b&c.BLUE_MASK,k&c.BLUE_MASK,m)}function ma(b,k,a){var c=ad.shift();if(c===p)c={},c.canvas=A.createElement("canvas"),c.context=c.canvas.getContext("2d");ad.push(c);var h=c.canvas,d=c.context, k=k||b.width,a=a||b.height;h.width=k;h.height=a;b?"data"in b?d.putImageData(b,0,0):(d.clearRect(0,0,k,a),d.drawImage(b,0,0,k,a)):d.clearRect(0,0,k,a);return c}function Ba(){bc&&(d=bd,bc=!1,a.updatePixels())}function La(){function b(b,k){b[k]=function(){Ba();d[k].apply(d,arguments)}}function k(b,k){a.defineProperty(b,k,{get:function(){Ba();return d[k]},set:function(b){Ba();d[k]=b}})}for(var m in d)typeof d[m]==="function"?b(this,m):k(this,m)}function Pa(b){this.name="sans-serif";if(b!==p)switch(b){case "sans-serif":case "serif":case "monospace":case "fantasy":case "cursive":this.name= b;break;default:this.name='"'+b+'", sans-serif'}this.origName=b}function Ea(b){return b instanceof String?b:typeof b==="number"?b===(0|b)?b.toString():a.nf(b,0,3):b===null||b===p?"":b.toString()}function Qa(b,k,a,c){this.canvas=A.createElement("canvas");this.canvas.setAttribute("width",k+"px");this.canvas.setAttribute("height",k+"px");this.ctx=this.canvas.getContext("2d");this.ctx.font=k+"pt "+b;this.ctx.fillStyle="black";this.ctx.fillRect(0,0,k,k);this.ctx.fillStyle="white";this.ctx.fillText(c,0, a);this.imageData=this.ctx.getImageData(0,0,k,k);this.get=function(b,k){return this.imageData.data[k*this.imageData.width*4+b*4]}}function ic(b,k,a,e){var h;b.indexOf("\n")<0?(b=[b],h=1):(b=b.split(/\r?\n/g),h=b.length);var d;d=Lb===c.TOP?(1-mc)*eb:Lb===c.CENTER?(1-mc-h/2)*eb:Lb===c.BOTTOM?(1-mc-h)*eb:0;for(var j=0;jh)){var j=-1,l=0,y=0,f=0;d.font=S+"px "+ja.name;for(var g=[],i=0,n=b.length;i< n;i++){var o=b[i],p=o===" ",q=d.measureText(o).width;if(o!=="\n"&&y+q0)j=i;else return;o==="\n"?(g.push({text:b.substring(l,i),width:y,offset:f}),l=i+1):(g.push({text:b.substring(l,j),width:y,offset:f}),l=j+1);f+=eb;y=0;i=l-1}}lh)break;ga.text$line(f.text,k+b,a+f.offset+e+j,r,Mb)}}}function Ra(b){ga=b==="3D"?new I:b==="2D"?new E:new D;for(var k in D.prototype)D.prototype.hasOwnProperty(k)&&k.indexOf("$")<0&&(a[k]=ga[k]);ga.$init()}function H(b){return function(){Ra("2D");return ga[b].apply(this,arguments)}}function wa(b){var k=b,m=0,c=0;a.pmouseX=a.mouseX;a.pmouseY=a.mouseY;if(k.offsetParent){do m+=k.offsetLeft,c+=k.offsetTop;while(k=k.offsetParent)}k=b;do m-=k.scrollLeft||0,c-=k.scrollTop||0;while(k=k.parentNode);m+= cd;c+=dd;m+=ed;c+=fd;m+=X.pageXOffset;c+=X.pageYOffset;return{X:m,Y:c}}function qb(b,k){var m=wa(b,k);a.mouseX=k.pageX-m.X;a.mouseY=k.pageY-m.Y}function rb(b){var k=wa(b.changedTouches[0].target,b.changedTouches[0]),a;for(a=0;a cos( light.angle ) ) { spotAttenuation = pow( spotDot, light.concentration ); } else{ spotAttenuation = 0.0; } attenuation *= spotAttenuation;")+" float nDotVP = max( 0.0, dot( vertNormal, VP )); vec3 halfVector = normalize( VP - normalize(ecPos) ); float nDotHV = max( 0.0, dot( vertNormal, halfVector )); if( nDotVP == 0.0 ) { powerfactor = 0.0; } else { powerfactor = pow( nDotHV, shininess ); } spec += specular * powerfactor * attenuation; col += light.color * nDotVP * attenuation;}void main(void) { vec3 finalAmbient = vec3( 0.0, 0.0, 0.0 ); vec3 finalDiffuse = vec3( 0.0, 0.0, 0.0 ); vec3 finalSpecular = vec3( 0.0, 0.0, 0.0 ); vec4 col = color; if(color[0] == -1.0){ col = aColor; } vec3 norm = normalize(vec3( normalTransform * vec4( Normal, 0.0 ) )); vec4 ecPos4 = view * model * vec4(Vertex,1.0); vec3 ecPos = (vec3(ecPos4))/ecPos4.w; if( lightCount == 0 ) { frontColor = col + vec4(mat_specular,1.0); } else { for( int i = 0; i < 8; i++ ) { Light l = getLight(i); if( i >= lightCount ){ break; } if( l.type == 0 ) { AmbientLight( finalAmbient, ecPos, l ); } else if( l.type == 1 ) { DirectionalLight( finalDiffuse, finalSpecular, norm, ecPos, l ); } else if( l.type == 2 ) { PointLight( finalDiffuse, finalSpecular, norm, ecPos, l ); } else { SpotLight( finalDiffuse, finalSpecular, norm, ecPos, l ); } } if( usingMat == false ) { frontColor = vec4( vec3(col) * finalAmbient + vec3(col) * finalDiffuse + vec3(col) * finalSpecular, col[3] ); } else{ frontColor = vec4( mat_emissive + (vec3(col) * mat_ambient * finalAmbient) + (vec3(col) * finalDiffuse) + (mat_specular * finalSpecular), col[3] ); } } vTexture.xy = aTexture.xy; gl_Position = projection * view * model * vec4( Vertex, 1.0 );}", td=function(b,k,a,c){return{x:b,y:k,w:a,h:c}},tc=td,Gc=function(b,k,a,c,h){return{x:b,y:k,w:h?a:a-b,h:h?c:c-k}},Ed=function(b,k,a,c){return{x:b-a/2,y:k-c/2,w:a,h:c}},Vc=function(b,k,a){var c=b.createShader(b.VERTEX_SHADER);b.shaderSource(c,k);b.compileShader(c);if(!b.getShaderParameter(c,b.COMPILE_STATUS))throw b.getShaderInfoLog(c);k=b.createShader(b.FRAGMENT_SHADER);b.shaderSource(k,a);b.compileShader(k);if(!b.getShaderParameter(k,b.COMPILE_STATUS))throw b.getShaderInfoLog(k);a=b.createProgram(); b.attachShader(a,c);b.attachShader(a,k);b.linkProgram(a);if(!b.getProgramParameter(a,b.LINK_STATUS))throw"Error linking shaders.";return a},M=function(){},E=function(){},I=function(){},D=function(){};E.prototype=new M;E.prototype.constructor=E;I.prototype=new M;I.prototype.constructor=I;D.prototype=new M;D.prototype.constructor=D;M.prototype.a3DOnlyFunction=function(){};var Wc={},ya=a.Character=function(b){this.code=typeof b==="string"&&b.length===1?b.charCodeAt(0):typeof b==="number"?b:b instanceof ya?b:NaN;return Wc[this.code]===p?Wc[this.code]=this:Wc[this.code]};ya.prototype.toString=function(){return String.fromCharCode(this.code)};ya.prototype.valueOf=function(){return this.code};var fc=a.PShape=function(b){this.family=b||c.GROUP;this.style=this.visible=!0;this.children=[];this.nameTable=[];this.params=[];this.name="";this.parent=this.height=this.width=this.close=this.kind=this.matrix=this.image=null};fc.prototype={isVisible:function(){return this.visible},setVisible:function(b){this.visible= b},disableStyle:function(){this.style=!1;for(var b=0,k=this.children.length;b0){k=0;for(a=this.nameTable.length;k, it's <"+this.element.getName()+">";}else if(arguments.length===2)if(typeof arguments[1]==="string"){if(arguments[1].indexOf(".svg")>-1)this.element=new a.XMLElement(null,arguments[1]),this.vertexCodes=[],this.vertices=[],this.opacity=1,this.stroke=!1,this.strokeColor=c.ALPHA_MASK,this.strokeWeight=1,this.strokeCap=c.SQUARE,this.strokeJoin=c.MITER,this.strokeName= this.strokeGradientPaint=this.strokeGradient="",this.strokeOpacity=1,this.fill=!0,this.fillColor=c.ALPHA_MASK,this.fillGradientPaint=this.fillGradient=null,this.fillOpacity=1}else if(arguments[0])this.element=arguments[1],this.vertexCodes=arguments[0].vertexCodes.slice(),this.vertices=arguments[0].vertices.slice(),this.stroke=arguments[0].stroke,this.strokeColor=arguments[0].strokeColor,this.strokeWeight=arguments[0].strokeWeight,this.strokeCap=arguments[0].strokeCap,this.strokeJoin=arguments[0].strokeJoin, this.strokeGradient=arguments[0].strokeGradient,this.strokeGradientPaint=arguments[0].strokeGradientPaint,this.strokeName=arguments[0].strokeName,this.fill=arguments[0].fill,this.fillColor=arguments[0].fillColor,this.fillGradient=arguments[0].fillGradient,this.fillGradientPaint=arguments[0].fillGradientPaint,this.fillName=arguments[0].fillName,this.strokeOpacity=arguments[0].strokeOpacity,this.fillOpacity=arguments[0].fillOpacity,this.opacity=arguments[0].opacity;this.name=this.element.getStringAttribute("id"); this.visible=this.element.getStringAttribute("display","inline")!=="none";var b=this.element.getAttribute("transform");if(b)this.matrix=this.parseMatrix(b);b=this.element.getStringAttribute("viewBox");if(b!==null)b=b.split(" "),this.width=b[2],this.height=b[3];var b=this.element.getStringAttribute("width"),k=this.element.getStringAttribute("height");if(b!==null)this.width=this.parseUnitSize(b),this.height=this.parseUnitSize(k);else if(this.width===0||this.height===0)throw this.height=this.width=1, "The width and/or height is not readable in the tag of this file.";this.parseColors(this.element);this.parseChildren(this.element)};R.prototype=new fc;R.prototype.parseMatrix=function(){function b(b){var a=[];b.replace(/\((.*?)\)/,function(){return function(b,k){a=k.replace(/,+/g," ").split(/\s+/)}}());return a}return function(k){this.checkMatrix(2);var c=[];k.replace(/\s*(\w+)\((.*?)\)/g,function(b){c.push(a.trim(b))});if(c.length===0)return null;for(var k=0,e=c.length;k=65&&g<=90||g>=97&&g<=122){t=f;f++;if(f=65&&g<=90||g>=97&&g<=100||g>=102&&g<=122)&&o===!1;)g===32?i!==""&& (n.push(parseFloat(i)),i=""):g===45?b[f-1].valueOf()===101?i+=b[f].toString():(i!==""&&n.push(parseFloat(i)),i=b[f].toString()):i+=b[f].toString(),f++,f===b.length?o=!0:g=b[f].valueOf()}i!==""&&(n.push(parseFloat(i)),i="");q=b[t];g=q.valueOf();if(g===77){if(n.length>=2&&n.length%2===0&&(k=n[0],m=n[1],this.parsePathMoveto(k,m),n.length>2)){t=2;for(g=n.length;t=2&&n.length%2===0&&(k+=n[0],m+=n[1],this.parsePathMoveto(k, m),n.length>2)){t=2;for(g=n.length;t=2&&n.length%2===0){t=0;for(g=n.length;t=2&&n.length%2===0){t=0;for(g=n.length;t=6&&n.length%6===0){t=0;for(g=n.length;t=6&&n.length%6===0){t=0;for(g=n.length;t=4&&n.length%4===0){t=0;for(g=n.length;t=4&& n.length%4===0){t=0;for(g=n.length;t=4&&n.length%4=== 0){t=0;for(g=n.length;t=4&&n.length%4===0){t=0;for(g=n.length;t=2&&n.length%2===0){t=0;for(g=n.length;t=2&&n.length%2===0){t=0;for(g=n.length;t0)this.parsePathCode(c.BEZIER_VERTEX),this.parsePathVertex(b+(a-b)*2/3,k+(e-k)*2/3),this.parsePathVertex(h+(a-h)*2/3,d+(e-d)*2/3),this.parsePathVertex(h,d);else throw"Path must start with M/m";};R.prototype.parsePathCurveto=function(b,a,m,e,h,d){if(this.vertices.length>0)this.parsePathCode(c.BEZIER_VERTEX),this.parsePathVertex(b,a),this.parsePathVertex(m, e),this.parsePathVertex(h,d);else throw"Path must start with M/m";};R.prototype.parsePathLineto=function(b,a){if(this.vertices.length>0)this.parsePathCode(c.VERTEX),this.parsePathVertex(b,a),this.vertices[this.vertices.length-1].moveTo=!1;else throw"Path must start with M/m";};R.prototype.parsePathMoveto=function(b,a){this.vertices.length>0&&this.parsePathCode(c.BREAK);this.parsePathCode(c.VERTEX);this.parsePathVertex(b,a);this.vertices[this.vertices.length-1].moveTo=!0};R.prototype.parsePathVertex= function(b,a){var c=[];c[0]=b;c[1]=a;this.vertices.push(c)};R.prototype.parsePathCode=function(b){this.vertexCodes.push(b)};R.prototype.parsePoly=function(b){this.family=c.PATH;this.close=b;b=a.trim(this.element.getStringAttribute("points").replace(/[,\s]+/g," "));if(b!==null)if(b=b.split(" "),b.length%2===0)for(var k=0,m=b.length;k";};R.prototype.parseEllipse=function(b){this.kind=c.ELLIPSE;this.family=c.PRIMITIVE;this.params=[];this.params[0]=this.element.getFloatAttribute("cx")| 0;this.params[1]=this.element.getFloatAttribute("cy")|0;var a;if(b){if(b=a=this.element.getFloatAttribute("r"),b<0)throw"svg error: negative radius found while parsing ";}else if(b=this.element.getFloatAttribute("rx"),a=this.element.getFloatAttribute("ry"),b<0||a<0)throw"svg error: negative x-axis radius or y-axis radius found while parsing ";this.params[0]-=b;this.params[1]-=a;this.params[2]=b*2;this.params[3]=a*2};R.prototype.parseLine=function(){this.kind=c.LINE;this.family=c.PRIMITIVE; this.params=[];this.params[0]=this.element.getFloatAttribute("x1");this.params[1]=this.element.getFloatAttribute("y1");this.params[2]=this.element.getFloatAttribute("x2");this.params[3]=this.element.getFloatAttribute("y2")};R.prototype.parseColors=function(b){b.hasAttribute("opacity")&&this.setOpacity(b.getAttribute("opacity"));b.hasAttribute("stroke")&&this.setStroke(b.getAttribute("stroke"));b.hasAttribute("stroke-width")&&this.setStrokeWeight(b.getAttribute("stroke-width"));b.hasAttribute("stroke-linejoin")&& this.setStrokeJoin(b.getAttribute("stroke-linejoin"));b.hasAttribute("stroke-linecap")&&this.setStrokeCap(b.getStringAttribute("stroke-linecap"));b.hasAttribute("fill")&&this.setFill(b.getStringAttribute("fill"));if(b.hasAttribute("style"))for(var b=b.getStringAttribute("style").toString().split(";"),k=0,c=b.length;k=1&&arguments[0]!==null&&b.isVisible()&&(a.pushMatrix(),ec===c.CENTER?arguments.length===5?(a.translate(k-e/2,m-h/2),a.scale(e/b.getWidth(),h/b.getHeight())):arguments.length===3?a.translate(k-b.getWidth()/2,-b.getHeight()/2):a.translate(-b.getWidth()/2,-b.getHeight()/2):ec===c.CORNER?arguments.length===5?(a.translate(k,m),a.scale(e/b.getWidth(),h/b.getHeight())):arguments.length===3&&a.translate(k,m):ec===c.CORNERS&&(arguments.length===5?(e-=k,h-=m,a.translate(k, m),a.scale(e/b.getWidth(),h/b.getHeight())):arguments.length===3&&a.translate(k,m)),b.draw(),(arguments.length===1&&ec===c.CENTER||arguments.length>1)&&a.popMatrix())};a.shapeMode=function(b){ec=b};a.loadShape=function(b){if(arguments.length===1&&b.indexOf(".svg")>-1)return new R(null,b);return null};var uc=function(b,a,c,e,h){this.fullName=b||"";this.name=a||"";this.namespace=c||"";this.value=e;this.type=h};uc.prototype={getName:function(){return this.name},getFullName:function(){return this.fullName}, getNamespace:function(){return this.namespace},getValue:function(){return this.value},getType:function(){return this.type},setValue:function(b){this.value=b}};var mb=a.XMLElement=function(){this.attributes=[];this.children=[];this.name=this.fullName=null;this.namespace="";this.parent=this.content=null;this.systemID=this.lineNr="";this.type="ELEMENT";if(arguments.length===4){this.fullName=arguments[0]||"";if(arguments[1])this.name=arguments[1];else{var b=this.fullName.indexOf(":");this.name=b>=0?this.fullName.substring(b+ 1):this.fullName}this.namespace=arguments[1];this.lineNr=arguments[3];this.systemID=arguments[2]}else arguments.length===2&&arguments[1].indexOf(".")>-1?this.parse(arguments[arguments.length-1]):arguments.length===1&&typeof arguments[0]==="string"&&this.parse(arguments[0])};mb.prototype={parse:function(b){var a;try{if(b.indexOf(".xml")>-1||b.indexOf(".svg")>-1)b=Ec(b);a=(new DOMParser).parseFromString(b,"text/xml");var c=a.documentElement;if(c)this.parseChildrenRecursive(null,c);else throw"Error loading document"; return this}catch(e){throw e;}},parseChildrenRecursive:function(b,a){var c,e,h,d;b?(c=new mb(a.localName,a.nodeName,"",""),c.parent=b):(this.fullName=a.localName,this.name=a.nodeName,c=this);if(a.nodeType===3&&a.textContent!=="")return this.createPCDataElement(a.textContent);h=0;for(d=a.attributes.length;h0){a=0;for(c=this.children.length;a 0},addChild:function(b){if(b!==null)b.parent=this,this.children.push(b)},insertChild:function(b,a){if(b){if(b.getLocalName()===null&&!this.hasChildren()){var c=this.children[this.children.length-1];if(c.getLocalName()===null){c.setContent(c.getContent()+b.getContent());return}}b.parent=this;this.children.splice(a,0,b)}},getChild:function(b){if(typeof b==="number")return this.children[b];else if(b.indexOf("/")!==-1)this.getChildRecursive(b.split("/"),0);else{for(var a,c,e=0,h=this.getChildCount();e< h;e++)if(a=this.getChild(e),c=a.getName(),c!==null&&c===b)return a;return null}},getChildren:function(){if(arguments.length===1)if(typeof arguments[0]==="number")return this.getChild(arguments[0]);else if(arguments[0].indexOf("/")!==-1)return this.getChildrenRecursive(arguments[0].split("/"),0);else{for(var b=[],a,c,e=0,h=this.getChildCount();eb&&this.children.splice(b,1)},findAttribute:function(b, a){this.namespace=a||"";for(var c=0,e=this.attributes.length;c0&&z.debug("Tried to set content for XMLElement with children");this.content=b},setName:function(){if(arguments.length===1)this.name=arguments[0],this.fullName=arguments[0],this.namespace=null;else{var b= arguments[0].indexOf(":");this.name=arguments[1]===null||b<0?arguments[0]:arguments[0].substring(b+1);this.fullName=arguments[0];this.namespace=arguments[1]}},getName:function(){return this.fullName},getLocalName:function(){return this.name},getAttributeCount:function(){return this.attributes.length},toString:function(){if(this.type==="TEXT")return this.content;var b=(this.namespace!==""&&this.namespace!==this.name?this.namespace+":":"")+this.name,a="<"+b,c;for(c=0;c":">"+this.content+"";else{a+=">";for(c=0;c"}return a}};mb.parse=function(b){var a=new mb;a.parse(b);return a};var ud=function(b){for(var a=0,c=0;cc.MIN_INT){var a=this.elements[0],m=this.elements[1],e=this.elements[2],h=this.elements[3],d=this.elements[4],j=this.elements[5];this.elements[0]=d/b;this.elements[3]=-h/b;this.elements[1]=-m/b;this.elements[4]=a/b;this.elements[2]=(m*j-d*e)/b;this.elements[5]=(h*e-a*j)/b;return!0}return!1}, scale:function(b,a){b&&!a&&(a=b);b&&a&&(this.elements[0]*=b,this.elements[1]*=a,this.elements[3]*=b,this.elements[4]*=a)},invScale:function(b,a){b&&!a&&(a=b);this.scale(1/b,1/a)},apply:function(){var b;arguments.length===1&&arguments[0]instanceof ab?b=arguments[0].array():arguments.length===6?b=Array.prototype.slice.call(arguments):arguments.length===1&&arguments[0]instanceof Array&&(b=arguments[0]);for(var a=[0,0,this.elements[2],0,0,this.elements[5]],c=0,e=0;e<2;e++)for(var h=0;h<3;h++,c++)a[c]+= this.elements[e*3+0]*b[h+0]+this.elements[e*3+1]*b[h+3];this.elements=a.slice()},preApply:function(){var b;arguments.length===1&&arguments[0]instanceof ab?b=arguments[0].array():arguments.length===6?b=Array.prototype.slice.call(arguments):arguments.length===1&&arguments[0]instanceof Array&&(b=arguments[0]);var a=[0,0,b[2],0,0,b[5]];a[2]=b[2]+this.elements[2]*b[0]+this.elements[5]*b[1];a[5]=b[5]+this.elements[2]*b[3]+this.elements[5]*b[4];a[0]=this.elements[0]*b[0]+this.elements[3]*b[1];a[3]=this.elements[0]* b[3]+this.elements[3]*b[4];a[1]=this.elements[1]*b[0]+this.elements[4]*b[1];a[4]=this.elements[1]*b[3]+this.elements[4]*b[4];this.elements=a.slice()},rotate:function(b){var a=g.cos(b),b=g.sin(b),c=this.elements[0],e=this.elements[1];this.elements[0]=a*c+b*e;this.elements[1]=-b*c+a*e;c=this.elements[3];e=this.elements[4];this.elements[3]=a*c+b*e;this.elements[4]=-b*c+a*e},rotateZ:function(b){this.rotate(b)},invRotateZ:function(b){this.rotateZ(b-g.PI)},print:function(){var b=ud(this.elements),b=""+ a.nfs(this.elements[0],b,4)+" "+a.nfs(this.elements[1],b,4)+" "+a.nfs(this.elements[2],b,4)+"\n"+a.nfs(this.elements[3],b,4)+" "+a.nfs(this.elements[4],b,4)+" "+a.nfs(this.elements[5],b,4)+"\n\n";a.println(b)}};var C=a.PMatrix3D=function(){this.reset()};C.prototype={set:function(){if(arguments.length===16)this.elements=Array.prototype.slice.call(arguments);else if(arguments.length===1&&arguments[0]instanceof C)this.elements=arguments[0].array();else if(arguments.length===1&&arguments[0]instanceof Array)this.elements=arguments[0].slice()},get:function(){var b=new C;b.set(this.elements);return b},reset:function(){this.set([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])},array:function(){return this.elements.slice()},translate:function(b,a,c){c===p&&(c=0);this.elements[3]+=b*this.elements[0]+a*this.elements[1]+c*this.elements[2];this.elements[7]+=b*this.elements[4]+a*this.elements[5]+c*this.elements[6];this.elements[11]+=b*this.elements[8]+a*this.elements[9]+c*this.elements[10];this.elements[15]+=b*this.elements[12]+ a*this.elements[13]+c*this.elements[14]},transpose:function(){var b=this.elements.slice();this.elements[0]=b[0];this.elements[1]=b[4];this.elements[2]=b[8];this.elements[3]=b[12];this.elements[4]=b[1];this.elements[5]=b[5];this.elements[6]=b[9];this.elements[7]=b[13];this.elements[8]=b[2];this.elements[9]=b[6];this.elements[10]=b[10];this.elements[11]=b[14];this.elements[12]=b[3];this.elements[13]=b[7];this.elements[14]=b[11];this.elements[15]=b[15]},mult:function(b,a){var c,e,h,d;if(b instanceof aa)c=b.x,e=b.y,h=b.z,d=1,a||(a=new aa);else if(b instanceof Array&&(c=b[0],e=b[1],h=b[2],d=b[3]||1,!a||a.length!==3&&a.length!==4))a=[0,0,0];a instanceof Array&&(a.length===3?(a[0]=this.elements[0]*c+this.elements[1]*e+this.elements[2]*h+this.elements[3],a[1]=this.elements[4]*c+this.elements[5]*e+this.elements[6]*h+this.elements[7],a[2]=this.elements[8]*c+this.elements[9]*e+this.elements[10]*h+this.elements[11]):a.length===4&&(a[0]=this.elements[0]*c+this.elements[1]*e+this.elements[2]*h+this.elements[3]* d,a[1]=this.elements[4]*c+this.elements[5]*e+this.elements[6]*h+this.elements[7]*d,a[2]=this.elements[8]*c+this.elements[9]*e+this.elements[10]*h+this.elements[11]*d,a[3]=this.elements[12]*c+this.elements[13]*e+this.elements[14]*h+this.elements[15]*d));if(a instanceof aa)a.x=this.elements[0]*c+this.elements[1]*e+this.elements[2]*h+this.elements[3],a.y=this.elements[4]*c+this.elements[5]*e+this.elements[6]*h+this.elements[7],a.z=this.elements[8]*c+this.elements[9]*e+this.elements[10]*h+this.elements[11]; return a},preApply:function(){var b;arguments.length===1&&arguments[0]instanceof C?b=arguments[0].array():arguments.length===16?b=Array.prototype.slice.call(arguments):arguments.length===1&&arguments[0]instanceof Array&&(b=arguments[0]);for(var a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=0,e=0;e<4;e++)for(var h=0;h<4;h++,c++)a[c]+=this.elements[h+0]*b[e*4+0]+this.elements[h+4]*b[e*4+1]+this.elements[h+8]*b[e*4+2]+this.elements[h+12]*b[e*4+3];this.elements=a.slice()},apply:function(){var b;arguments.length=== 1&&arguments[0]instanceof C?b=arguments[0].array():arguments.length===16?b=Array.prototype.slice.call(arguments):arguments.length===1&&arguments[0]instanceof Array&&(b=arguments[0]);for(var a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=0,e=0;e<4;e++)for(var h=0;h<4;h++,c++)a[c]+=this.elements[e*4+0]*b[h+0]+this.elements[e*4+1]*b[h+4]+this.elements[e*4+2]*b[h+8]+this.elements[e*4+3]*b[h+12];this.elements=a.slice()},rotate:function(b,k,c,e){if(c){var h=a.cos(b),b=a.sin(b),d=1-h;this.apply(d*k*k+h,d*k*c-b*e, d*k*e+b*c,0,d*k*c+b*e,d*c*c+h,d*c*e-b*k,0,d*k*e-b*c,d*c*e+b*k,d*e*e+h,0,0,0,0,1)}else this.rotateZ(b)},invApply:function(){dc===p&&(dc=new C);var b=arguments;dc.set(b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15]);if(!dc.invert())return!1;this.preApply(dc);return!0},rotateX:function(b){var k=a.cos(b),b=a.sin(b);this.apply([1,0,0,0,0,k,-b,0,0,b,k,0,0,0,0,1])},rotateY:function(b){var k=a.cos(b),b=a.sin(b);this.apply([k,0,b,0,0,1,0,0,-b,0,k,0,0,0,0,1])},rotateZ:function(b){var a= g.cos(b),b=g.sin(b);this.apply([a,-b,0,0,b,a,0,0,0,0,1,0,0,0,0,1])},scale:function(b,a,c){b&&!a&&!c?a=c=b:b&&a&&!c&&(c=1);b&&a&&c&&(this.elements[0]*=b,this.elements[1]*=a,this.elements[2]*=c,this.elements[4]*=b,this.elements[5]*=a,this.elements[6]*=c,this.elements[8]*=b,this.elements[9]*=a,this.elements[10]*=c,this.elements[12]*=b,this.elements[13]*=a,this.elements[14]*=c)},skewX:function(b){this.apply(1,g.tan(b),0,0,0,1,0,0,0,0,1,0,0,0,0,1)},skewY:function(b){this.apply(1,0,0,0,g.tan(b),1,0,0,0, 0,1,0,0,0,0,1)},multX:function(b,a,c,e){return c?e?this.elements[0]*b+this.elements[1]*a+this.elements[2]*c+this.elements[3]*e:this.elements[0]*b+this.elements[1]*a+this.elements[2]*c+this.elements[3]:this.elements[0]*b+this.elements[1]*a+this.elements[3]},multY:function(b,a,c,e){return c?e?this.elements[4]*b+this.elements[5]*a+this.elements[6]*c+this.elements[7]*e:this.elements[4]*b+this.elements[5]*a+this.elements[6]*c+this.elements[7]:this.elements[4]*b+this.elements[5]*a+this.elements[7]},multZ:function(b, a,c,e){return e?this.elements[8]*b+this.elements[9]*a+this.elements[10]*c+this.elements[11]*e:this.elements[8]*b+this.elements[9]*a+this.elements[10]*c+this.elements[11]},multW:function(b,a,c,e){return e?this.elements[12]*b+this.elements[13]*a+this.elements[14]*c+this.elements[15]*e:this.elements[12]*b+this.elements[13]*a+this.elements[14]*c+this.elements[15]},invert:function(){var b=this.elements[0]*this.elements[5]-this.elements[1]*this.elements[4],a=this.elements[0]*this.elements[6]-this.elements[2]* this.elements[4],c=this.elements[0]*this.elements[7]-this.elements[3]*this.elements[4],e=this.elements[1]*this.elements[6]-this.elements[2]*this.elements[5],h=this.elements[1]*this.elements[7]-this.elements[3]*this.elements[5],d=this.elements[2]*this.elements[7]-this.elements[3]*this.elements[6],j=this.elements[8]*this.elements[13]-this.elements[9]*this.elements[12],l=this.elements[8]*this.elements[14]-this.elements[10]*this.elements[12],y=this.elements[8]*this.elements[15]-this.elements[11]*this.elements[12], f=this.elements[9]*this.elements[14]-this.elements[10]*this.elements[13],i=this.elements[9]*this.elements[15]-this.elements[11]*this.elements[13],o=this.elements[10]*this.elements[15]-this.elements[11]*this.elements[14],n=b*o-a*i+c*f+e*y-h*l+d*j;if(g.abs(n)<=1.0E-9)return!1;var p=[];p[0]=+this.elements[5]*o-this.elements[6]*i+this.elements[7]*f;p[4]=-this.elements[4]*o+this.elements[6]*y-this.elements[7]*l;p[8]=+this.elements[4]*i-this.elements[5]*y+this.elements[7]*j;p[12]=-this.elements[4]*f+this.elements[5]* l-this.elements[6]*j;p[1]=-this.elements[1]*o+this.elements[2]*i-this.elements[3]*f;p[5]=+this.elements[0]*o-this.elements[2]*y+this.elements[3]*l;p[9]=-this.elements[0]*i+this.elements[1]*y-this.elements[3]*j;p[13]=+this.elements[0]*f-this.elements[1]*l+this.elements[2]*j;p[2]=+this.elements[13]*d-this.elements[14]*h+this.elements[15]*e;p[6]=-this.elements[12]*d+this.elements[14]*c-this.elements[15]*a;p[10]=+this.elements[12]*h-this.elements[13]*c+this.elements[15]*b;p[14]=-this.elements[12]*e+this.elements[13]* a-this.elements[14]*b;p[3]=-this.elements[9]*d+this.elements[10]*h-this.elements[11]*e;p[7]=+this.elements[8]*d-this.elements[10]*c+this.elements[11]*a;p[11]=-this.elements[8]*h+this.elements[9]*c-this.elements[11]*b;p[15]=+this.elements[8]*e-this.elements[9]*a+this.elements[10]*b;b=1/n;p[0]*=b;p[1]*=b;p[2]*=b;p[3]*=b;p[4]*=b;p[5]*=b;p[6]*=b;p[7]*=b;p[8]*=b;p[9]*=b;p[10]*=b;p[11]*=b;p[12]*=b;p[13]*=b;p[14]*=b;p[15]*=b;this.elements=p.slice();return!0},toString:function(){for(var b="",a=0;a<15;a++)b+= this.elements[a]+", ";b+=this.elements[15];return b},print:function(){var b=ud(this.elements),b=""+a.nfs(this.elements[0],b,4)+" "+a.nfs(this.elements[1],b,4)+" "+a.nfs(this.elements[2],b,4)+" "+a.nfs(this.elements[3],b,4)+"\n"+a.nfs(this.elements[4],b,4)+" "+a.nfs(this.elements[5],b,4)+" "+a.nfs(this.elements[6],b,4)+" "+a.nfs(this.elements[7],b,4)+"\n"+a.nfs(this.elements[8],b,4)+" "+a.nfs(this.elements[9],b,4)+" "+a.nfs(this.elements[10],b,4)+" "+a.nfs(this.elements[11],b,4)+"\n"+a.nfs(this.elements[12], b,4)+" "+a.nfs(this.elements[13],b,4)+" "+a.nfs(this.elements[14],b,4)+" "+a.nfs(this.elements[15],b,4)+"\n\n";a.println(b)},invTranslate:function(b,a,c){this.preApply(1,0,0,-b,0,1,0,-a,0,0,1,-c,0,0,0,1)},invRotateX:function(b){var a=g.cos(-b),b=g.sin(-b);this.preApply([1,0,0,0,0,a,-b,0,0,b,a,0,0,0,0,1])},invRotateY:function(b){var a=g.cos(-b),b=g.sin(-b);this.preApply([a,0,b,0,0,1,0,0,-b,0,a,0,0,0,0,1])},invRotateZ:function(b){var a=g.cos(-b),b=g.sin(-b);this.preApply([a,-b,0,0,b,a,0,0,0,0,1,0,0, 0,0,1])},invScale:function(b,a,c){this.preApply([1/b,0,0,0,0,1/a,0,0,0,0,1/c,0,0,0,0,1])}};var bb=a.PMatrixStack=function(){this.matrixStack=[]};bb.prototype.load=function(){var b=ga.$newPMatrix();arguments.length===1?b.set(arguments[0]):b.set(arguments);this.matrixStack.push(b)};E.prototype.$newPMatrix=function(){return new ab};I.prototype.$newPMatrix=function(){return new C};bb.prototype.push=function(){this.matrixStack.push(this.peek())};bb.prototype.pop=function(){return this.matrixStack.pop()}; bb.prototype.peek=function(){var b=ga.$newPMatrix();b.set(this.matrixStack[this.matrixStack.length-1]);return b};bb.prototype.mult=function(b){this.matrixStack[this.matrixStack.length-1].apply(b)};a.split=function(b,a){return b.split(a)};a.splitTokens=function(b,a){arguments.length===1&&(a="\n\t\r\u000c ");for(var a="["+a+"]",c=[],e=0,h=b.search(a);h>=0;)h===0?b=b.substring(1):(c[e]=b.substring(0,h),e++,b=b.substring(h)),h=b.search(a);b.length>0&&(c[e]=b);c.length===0&&(c=p);return c};a.append=function(b, a){b[b.length]=a;return b};a.concat=function(b,a){return b.concat(a)};a.sort=function(b,a){var c=[];if(b.length>0){for(var e=a>0?a:b.length,h=0;h0)for(e=c.length;e>8)};a.peg=function(b){return b<0?0:b>255?255:b};a.modes={replace:function(b,a){return a},blend:function(b,k){var m=(k&c.ALPHA_MASK)>>>24;return g.min(((b&c.ALPHA_MASK)>>>24)+m,255)<<24|a.mix(b&c.RED_MASK,k&c.RED_MASK,m)&c.RED_MASK| a.mix(b&c.GREEN_MASK,k&c.GREEN_MASK,m)&c.GREEN_MASK|a.mix(b&c.BLUE_MASK,k&c.BLUE_MASK,m)},add:function(b,a){var m=(a&c.ALPHA_MASK)>>>24;return g.min(((b&c.ALPHA_MASK)>>>24)+m,255)<<24|g.min((b&c.RED_MASK)+((a&c.RED_MASK)>>8)*m,c.RED_MASK)&c.RED_MASK|g.min((b&c.GREEN_MASK)+((a&c.GREEN_MASK)>>8)*m,c.GREEN_MASK)&c.GREEN_MASK|g.min((b&c.BLUE_MASK)+((a&c.BLUE_MASK)*m>>8),c.BLUE_MASK)},subtract:function(b,a){var m=(a&c.ALPHA_MASK)>>>24;return g.min(((b&c.ALPHA_MASK)>>>24)+m,255)<<24|g.max((b&c.RED_MASK)- ((a&c.RED_MASK)>>8)*m,c.GREEN_MASK)&c.RED_MASK|g.max((b&c.GREEN_MASK)-((a&c.GREEN_MASK)>>8)*m,c.BLUE_MASK)&c.GREEN_MASK|g.max((b&c.BLUE_MASK)-((a&c.BLUE_MASK)*m>>8),0)},lightest:function(b,a){var m=(a&c.ALPHA_MASK)>>>24;return g.min(((b&c.ALPHA_MASK)>>>24)+m,255)<<24|g.max(b&c.RED_MASK,((a&c.RED_MASK)>>8)*m)&c.RED_MASK|g.max(b&c.GREEN_MASK,((a&c.GREEN_MASK)>>8)*m)&c.GREEN_MASK|g.max(b&c.BLUE_MASK,(a&c.BLUE_MASK)*m>>8)},darkest:function(b,k){var m=(k&c.ALPHA_MASK)>>>24;return g.min(((b&c.ALPHA_MASK)>>> 24)+m,255)<<24|a.mix(b&c.RED_MASK,g.min(b&c.RED_MASK,((k&c.RED_MASK)>>8)*m),m)&c.RED_MASK|a.mix(b&c.GREEN_MASK,g.min(b&c.GREEN_MASK,((k&c.GREEN_MASK)>>8)*m),m)&c.GREEN_MASK|a.mix(b&c.BLUE_MASK,g.min(b&c.BLUE_MASK,(k&c.BLUE_MASK)*m>>8),m)},difference:function(b,k){var m=(k&c.ALPHA_MASK)>>>24,e=(b&c.RED_MASK)>>16,h=(b&c.GREEN_MASK)>>8,d=b&c.BLUE_MASK,j=(k&c.RED_MASK)>>16,l=(k&c.GREEN_MASK)>>8,y=k&c.BLUE_MASK,j=e>j?e-j:j-e,l=h>l?h-l:l-h,y=d>y?d-y:y-d;return g.min(((b&c.ALPHA_MASK)>>>24)+m,255)<<24|a.peg(e+ ((j-e)*m>>8))<<16|a.peg(h+((l-h)*m>>8))<<8|a.peg(d+((y-d)*m>>8))},exclusion:function(b,k){var m=(k&c.ALPHA_MASK)>>>24,e=(b&c.RED_MASK)>>16,h=(b&c.GREEN_MASK)>>8,d=b&c.BLUE_MASK,j=(k&c.RED_MASK)>>16,l=(k&c.GREEN_MASK)>>8,y=k&c.BLUE_MASK,j=e+j-(e*j>>7),l=h+l-(h*l>>7),y=d+y-(d*y>>7);return g.min(((b&c.ALPHA_MASK)>>>24)+m,255)<<24|a.peg(e+((j-e)*m>>8))<<16|a.peg(h+((l-h)*m>>8))<<8|a.peg(d+((y-d)*m>>8))},multiply:function(b,k){var m=(k&c.ALPHA_MASK)>>>24,e=(b&c.RED_MASK)>>16,h=(b&c.GREEN_MASK)>>8,d=b& c.BLUE_MASK,j=e*((k&c.RED_MASK)>>16)>>8,l=h*((k&c.GREEN_MASK)>>8)>>8,y=d*(k&c.BLUE_MASK)>>8;return g.min(((b&c.ALPHA_MASK)>>>24)+m,255)<<24|a.peg(e+((j-e)*m>>8))<<16|a.peg(h+((l-h)*m>>8))<<8|a.peg(d+((y-d)*m>>8))},screen:function(b,k){var m=(k&c.ALPHA_MASK)>>>24,e=(b&c.RED_MASK)>>16,h=(b&c.GREEN_MASK)>>8,d=b&c.BLUE_MASK,j=255-((255-e)*(255-((k&c.RED_MASK)>>16))>>8),l=255-((255-h)*(255-((k&c.GREEN_MASK)>>8))>>8),y=255-((255-d)*(255-(k&c.BLUE_MASK))>>8);return g.min(((b&c.ALPHA_MASK)>>>24)+m,255)<< 24|a.peg(e+((j-e)*m>>8))<<16|a.peg(h+((l-h)*m>>8))<<8|a.peg(d+((y-d)*m>>8))},hard_light:function(b,k){var m=(k&c.ALPHA_MASK)>>>24,e=(b&c.RED_MASK)>>16,h=(b&c.GREEN_MASK)>>8,d=b&c.BLUE_MASK,j=(k&c.RED_MASK)>>16,l=(k&c.GREEN_MASK)>>8,y=k&c.BLUE_MASK,j=j<128?e*j>>7:255-((255-e)*(255-j)>>7),l=l<128?h*l>>7:255-((255-h)*(255-l)>>7),y=y<128?d*y>>7:255-((255-d)*(255-y)>>7);return g.min(((b&c.ALPHA_MASK)>>>24)+m,255)<<24|a.peg(e+((j-e)*m>>8))<<16|a.peg(h+((l-h)*m>>8))<<8|a.peg(d+((y-d)*m>>8))},soft_light:function(b, k){var m=(k&c.ALPHA_MASK)>>>24,e=(b&c.RED_MASK)>>16,h=(b&c.GREEN_MASK)>>8,d=b&c.BLUE_MASK,j=(k&c.RED_MASK)>>16,l=(k&c.GREEN_MASK)>>8,y=k&c.BLUE_MASK,j=(e*j>>7)+(e*e>>8)-(e*e*j>>15),l=(h*l>>7)+(h*h>>8)-(h*h*l>>15),y=(d*y>>7)+(d*d>>8)-(d*d*y>>15);return g.min(((b&c.ALPHA_MASK)>>>24)+m,255)<<24|a.peg(e+((j-e)*m>>8))<<16|a.peg(h+((l-h)*m>>8))<<8|a.peg(d+((y-d)*m>>8))},overlay:function(b,k){var m=(k&c.ALPHA_MASK)>>>24,e=(b&c.RED_MASK)>>16,h=(b&c.GREEN_MASK)>>8,d=b&c.BLUE_MASK,j=(k&c.RED_MASK)>>16,l=(k& c.GREEN_MASK)>>8,y=k&c.BLUE_MASK,j=e<128?e*j>>7:255-((255-e)*(255-j)>>7),l=h<128?h*l>>7:255-((255-h)*(255-l)>>7),y=d<128?d*y>>7:255-((255-d)*(255-y)>>7);return g.min(((b&c.ALPHA_MASK)>>>24)+m,255)<<24|a.peg(e+((j-e)*m>>8))<<16|a.peg(h+((l-h)*m>>8))<<8|a.peg(d+((y-d)*m>>8))},dodge:function(b,k){var m=(k&c.ALPHA_MASK)>>>24,e=(b&c.RED_MASK)>>16,h=(b&c.GREEN_MASK)>>8,d=b&c.BLUE_MASK,j=(k&c.RED_MASK)>>16,l=(k&c.GREEN_MASK)>>8,y=k&c.BLUE_MASK,j=j===255?255:a.peg((e<<8)/(255-j)),l=l===255?255:a.peg((h<< 8)/(255-l)),y=y===255?255:a.peg((d<<8)/(255-y));return g.min(((b&c.ALPHA_MASK)>>>24)+m,255)<<24|a.peg(e+((j-e)*m>>8))<<16|a.peg(h+((l-h)*m>>8))<<8|a.peg(d+((y-d)*m>>8))},burn:function(b,k){var m=(k&c.ALPHA_MASK)>>>24,e=(b&c.RED_MASK)>>16,h=(b&c.GREEN_MASK)>>8,d=b&c.BLUE_MASK,j=(k&c.RED_MASK)>>16,l=(k&c.GREEN_MASK)>>8,y=k&c.BLUE_MASK,j=j===0?0:255-a.peg((255-e<<8)/j),l=l===0?0:255-a.peg((255-h<<8)/l),y=y===0?0:255-a.peg((255-d<<8)/y);return g.min(((b&c.ALPHA_MASK)>>>24)+m,255)<<24|a.peg(e+((j-e)*m>> 8))<<16|a.peg(h+((l-h)*m>>8))<<8|a.peg(d+((y-d)*m>>8))}};a.color=function(b,a,m,e){if(b!==p&&a!==p&&m!==p&&e!==p)return x(b,a,m,e);if(b!==p&&a!==p&&m!==p)return x(b,a,m,Z);if(b!==p&&a!==p){var h;b&c.ALPHA_MASK?(a=g.round(255*(a/Z)),h=b-(b&c.ALPHA_MASK)+((a>255?255:a)<<24&c.ALPHA_MASK)):db===c.RGB?h=x(b,b,b,a):db===c.HSB&&(h=x(0,0,b/ia*B,a));return h}if(typeof b==="number"){var d;b<=ia&&b>=0?db===c.RGB?d=x(b,b,b,Z):db===c.HSB&&(d=x(0,0,b/ia*B,Z)):b&&(d=b);return d}return x(ia,xa,B,Z)};a.color.toString= function(b){return"rgba("+((b&c.RED_MASK)>>>16)+","+((b&c.GREEN_MASK)>>>8)+","+(b&c.BLUE_MASK)+","+((b&c.ALPHA_MASK)>>>24)/255+")"};a.color.toInt=function(b,a,m,e){return e<<24&c.ALPHA_MASK|b<<16&c.RED_MASK|a<<8&c.GREEN_MASK|m&c.BLUE_MASK};a.color.toArray=function(b){return[(b&c.RED_MASK)>>>16,(b&c.GREEN_MASK)>>>8,b&c.BLUE_MASK,(b&c.ALPHA_MASK)>>>24]};a.color.toGLArray=function(b){return[((b&c.RED_MASK)>>>16)/255,((b&c.GREEN_MASK)>>>8)/255,(b&c.BLUE_MASK)/255,((b&c.ALPHA_MASK)>>>24)/255]};a.color.toRGB= function(b,a,c){var b=b>ia?ia:b,a=a>xa?xa:a,c=c>B?B:c,b=b/ia*360,a=a/xa*100,c=c/B*100,e=g.round(c/100*255);if(a===0)return[e,e,e];else{b%=360;var h=b%60,d=g.round(c*(100-a)/1E4*255),j=g.round(c*(6E3-a*h)/6E5*255),a=g.round(c*(6E3-a*(60-h))/6E5*255);switch(g.floor(b/60)){case 0:return[e,a,d];case 1:return[j,e,d];case 2:return[d,e,a];case 3:return[d,j,e];case 4:return[a,d,e];case 5:return[e,d,j]}}};a.color.toHSB=function(b){var k,m,e;k=((b&c.RED_MASK)>>>16)/255;m=((b&c.GREEN_MASK)>>>8)/255;e=(b&c.BLUE_MASK)/ 255;var b=a.max(a.max(k,m),e),h=a.min(a.min(k,m),e);if(h===b)return[0,0,b];else k=k===b?(m-e)/(b-h):m===b?2+(e-k)/(b-h):4+(k-m)/(b-h),k/=6,k<0?k+=1:k>1&&(k-=1);return[k*ia,(b-h)/b*xa,b*B]};a.brightness=function(b){return a.color.toHSB(b)[2]};a.saturation=function(b){return a.color.toHSB(b)[1]};a.hue=function(b){return a.color.toHSB(b)[0]};a.red=function(b){return((b&c.RED_MASK)>>>16)/255*ia};a.green=function(b){return((b&c.GREEN_MASK)>>>8)/255*xa};a.blue=function(b){return(b&c.BLUE_MASK)/255*B};a.alpha= function(b){return((b&c.ALPHA_MASK)>>>24)/255*Z};a.lerpColor=function(b,k,m){var e=a.color(b),h=(e&c.RED_MASK)>>>16,d=(e&c.GREEN_MASK)>>>8,b=e&c.BLUE_MASK,e=((e&c.ALPHA_MASK)>>>24)/Z,j=a.color(k),l=(j&c.GREEN_MASK)>>>8,g=j&c.BLUE_MASK,k=((j&c.ALPHA_MASK)>>>24)/Z,h=parseInt(a.lerp(h,(j&c.RED_MASK)>>>16,m),10),d=parseInt(a.lerp(d,l,m),10),b=parseInt(a.lerp(b,g,m),10),m=parseFloat(a.lerp(e,k,m)*Z);return a.color.toInt(h,d,b,m)};a.colorMode=function(){db=arguments[0];arguments.length>1&&(ia=arguments[1], xa=arguments[2]||arguments[1],B=arguments[3]||arguments[1],Z=arguments[4]||arguments[1])};a.blendColor=function(b,k,m){var e=0;switch(m){case c.REPLACE:e=a.modes.replace(b,k);break;case c.BLEND:e=a.modes.blend(b,k);break;case c.ADD:e=a.modes.add(b,k);break;case c.SUBTRACT:e=a.modes.subtract(b,k);break;case c.LIGHTEST:e=a.modes.lightest(b,k);break;case c.DARKEST:e=a.modes.darkest(b,k);break;case c.DIFFERENCE:e=a.modes.difference(b,k);break;case c.EXCLUSION:e=a.modes.exclusion(b,k);break;case c.MULTIPLY:e= a.modes.multiply(b,k);break;case c.SCREEN:e=a.modes.screen(b,k);break;case c.HARD_LIGHT:e=a.modes.hard_light(b,k);break;case c.SOFT_LIGHT:e=a.modes.soft_light(b,k);break;case c.OVERLAY:e=a.modes.overlay(b,k);break;case c.DODGE:e=a.modes.dodge(b,k);break;case c.BURN:e=a.modes.burn(b,k)}return e};a.printMatrix=function(){V.print()};E.prototype.translate=function(b,a){ra.translate(b,a);sa.invTranslate(b,a);d.translate(b,a)};I.prototype.translate=function(b,a,c){ra.translate(b,a,c);sa.invTranslate(b, a,c)};E.prototype.scale=function(b,a){ra.scale(b,a);sa.invScale(b,a);d.scale(b,a||b)};I.prototype.scale=function(b,a,c){ra.scale(b,a,c);sa.invScale(b,a,c)};E.prototype.pushMatrix=function(){Pb.load(V);Qb.load(Wa);d.save()};I.prototype.pushMatrix=function(){Pb.load(V);Qb.load(Wa)};E.prototype.popMatrix=function(){V.set(Pb.pop());Wa.set(Qb.pop());zb()};I.prototype.popMatrix=function(){V.set(Pb.pop());Wa.set(Qb.pop())};E.prototype.resetMatrix=function(){ra.reset();sa.reset();d.setTransform(1,0,0,1,0, 0)};I.prototype.resetMatrix=function(){ra.reset();sa.reset()};M.prototype.applyMatrix=function(){var b=arguments;ra.apply(b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15]);sa.invApply(b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12],b[13],b[14],b[15])};E.prototype.applyMatrix=function(){for(var b=arguments,a=b.length;a<16;a++)b[a]=0;b[10]=b[15]=1;M.prototype.applyMatrix.apply(this,b)};a.rotateX=function(b){ra.rotateX(b);sa.invRotateX(b)};E.prototype.rotateZ= function(){throw"rotateZ() is not supported in 2D mode. Use rotate(float) instead.";};I.prototype.rotateZ=function(b){ra.rotateZ(b);sa.invRotateZ(b)};a.rotateY=function(b){ra.rotateY(b);sa.invRotateY(b)};E.prototype.rotate=function(b){ra.rotateZ(b);sa.invRotateZ(b);d.rotate(b)};I.prototype.rotate=function(b){a.rotateZ(b)};a.pushStyle=function(){d.save();a.pushMatrix();qd.push({doFill:U,currentFillColor:Fa,doStroke:O,currentStrokeColor:ka,curTint:nb,curRectMode:T,curColorMode:db,colorModeX:ia,colorModeZ:B, colorModeY:xa,colorModeA:Z,curTextFont:ja,curTextSize:S})};a.popStyle=function(){var b=qd.pop();if(b)zb(),a.popMatrix(),U=b.doFill,Fa=b.currentFillColor,O=b.doStroke,ka=b.currentStrokeColor,nb=b.curTint,T=b.curRectmode,db=b.curColorMode,ia=b.colorModeX,B=b.colorModeZ,xa=b.colorModeY,Z=b.colorModeA,ja=b.curTextFont,S=b.curTextSize;else throw"Too many popStyle() without enough pushStyle()";};a.year=function(){return(new Date).getFullYear()};a.month=function(){return(new Date).getMonth()+1};a.day=function(){return(new Date).getDate()}; a.hour=function(){return(new Date).getHours()};a.minute=function(){return(new Date).getMinutes()};a.second=function(){return(new Date).getSeconds()};a.millis=function(){return(new Date).getTime()-Vb};M.prototype.redraw=function(){var b=((new Date).getTime()-Ac)/1E3;jc++;var c=jc/b;if(b>0.5)Ac=(new Date).getTime(),jc=0,a.__frameRate=c;a.frameCount++};E.prototype.redraw=function(){M.prototype.redraw.apply(this,arguments);d.lineWidth=pa;d.save();a.draw();zb()};I.prototype.redraw=function(){M.prototype.redraw.apply(this, arguments);d.clear(d.DEPTH_BUFFER_BIT);Ma={attributes:{},locations:{}};a.noLights();a.lightFalloff(1,0,0);a.shininess(1);a.ambient(255,255,255);a.specular(0,0,0);a.emissive(0,0,0);a.camera();a.draw()};a.noLoop=function(){jb=$a=!1;clearInterval(N);$.onPause()};a.loop=function(){jb||(Ac=(new Date).getTime(),jc=0,N=X.setInterval(function(){try{$.onFrameStart(),a.redraw(),$.onFrameEnd()}catch(b){throw X.clearInterval(N),b;}},Eb),jb=$a=!0,$.onLoop())};a.frameRate=function(b){Oa=b;Eb=1E3/Oa;$a&&(a.noLoop(), a.loop())};var Kb=[];a.exit=function(){X.clearInterval(N);var b=a.externals.canvas.id;Ca.splice(lc[b],1);delete lc[b];for(var c in z.lib)z.lib.hasOwnProperty(c)&&z.lib[c].hasOwnProperty("detach")&&z.lib[c].detach(a);for(b=Kb.length;b--;)ca(Kb[b]);$.onExit()};a.cursor=function(){if(arguments.length>1||arguments.length===1&&arguments[0]instanceof a.PImage){var b=arguments[0],c,m;if(arguments.length>=3){if(c=arguments[1],m=arguments[2],c<0||m<0||m>=b.height||c>=b.width)throw"x and y must be non-negative and less than the dimensions of the image"; }else c=b.width>>>1,m=b.height>>>1;b='url("'+b.toDataURL()+'") '+c+" "+m+", default";i.style.cursor=b}else i.style.cursor=arguments.length===1?arguments[0]:Aa};a.noCursor=function(){i.style.cursor=c.NOCURSOR};a.link=function(b,a){a!==p?X.open(b,a):X.location=b};a.beginDraw=Dc;a.endDraw=Dc;a.Import=function(){};a.status=function(b){X.status=b};a.binary=function(b,a){var c=32;if(typeof b==="number")return a&&(c=a),da(b,c);b instanceof ya&&(b=b.toString().charCodeAt(0),c=a?32:16);c=da(b,c);a&&(c=c.substr(-a)); return c};a.unbinary=function(b){var c=/^[0|1]{8}$/,m=0;if(b instanceof Array){m=[];for(c=0;c=e&&(c=c.substring(c.length-e,c.length));return c};a.unhex=function(b){if(b instanceof Array){for(var a=[],c=0;c0?c:null};a.__contains=function(b,a){if(typeof b!=="string")return b.contains.apply(b,gb(arguments)); return b!==null&&a!==null&&typeof a==="string"&&b.indexOf(a)>-1};a.__replaceAll=function(b,a,c){if(typeof b!=="string")return b.replaceAll.apply(b,gb(arguments));return b.replace(RegExp(a,"g"),c)};a.__replaceFirst=function(b,a,c){if(typeof b!=="string")return b.replaceFirst.apply(b,gb(arguments));return b.replace(RegExp(a,""),c)};a.__replace=function(b,a,c){if(typeof b!=="string")return b.replace.apply(b,gb(arguments));if(a instanceof RegExp)return b.replace(a,c);typeof a!=="string"&&(a=a.toString()); if(a==="")return b;var e=b.indexOf(a);if(e<0)return b;var d=0,r="";do r+=b.substring(d,e)+c,d=e+a.length;while((e=b.indexOf(a,d))>=0);return r+b.substring(d)};a.__equals=function(b,a){if(b.equals instanceof Function)return b.equals.apply(b,gb(arguments));return b.valueOf()===a.valueOf()};a.__toCharArray=function(b){if(typeof b!=="string")return b.toCharArray.apply(b,gb(arguments));for(var a=[],c=0,e=b.length;c0;){c=e.shift();if(c===a)return!0;c.$interfaces&&(e=e.concat(c.$interfaces))}return!1}for(;c.hasOwnProperty("$base");)if(c=c.$base,c===a)return!0;return!1};a.abs=g.abs;a.ceil=g.ceil; a.constrain=function(b,a,c){return b>c?c:b0))throw"Non-empty array is expected";for(var a=b[0],c=b.length,e=1;e 0))throw"Non-empty array is expected";for(var a=b[0],c=b.length,e=1;eb[e]&&(a=b[e]);return a}};a.norm=function(b,a,c){return(b-a)/(c-a)};a.pow=g.pow;a.round=g.round;a.sq=function(b){return b*b};a.sqrt=g.sqrt;a.acos=g.acos;a.asin=g.asin;a.atan=g.atan;a.atan2=g.atan2;a.cos=g.cos;a.degrees=function(b){return b*180/g.PI};a.radians=function(b){return b/180*g.PI};a.sin=g.sin;a.tan=g.tan;var wc=g.random;a.random=function(){if(arguments.length===0)return wc();else if(arguments.length===1)return wc()* arguments[0];else{var b=arguments[0],a=arguments[1];return wc()*(a-b)+b}};ha.createRandomized=function(){var b=new Date;return new ha(b/6E4&4294967295,b&4294967295)};a.randomSeed=function(b){wc=(new ha(b)).nextDouble};a.Random=function(b){var a=!1,c,e;this.nextGaussian=function(){if(a)return a=!1,c;else{var b,d,j;do b=2*e()-1,d=2*e()-1,j=b*b+d*d;while(j>=1||j===0);j=g.sqrt(-2*g.log(j)/j);c=d*j;a=!0;return b*j}};e=b===p?g.random:(new ha(b)).nextDouble};var Xa={generator:p,octaves:4,fallout:0.5,seed:p}; a.noise=function(b,a,c){if(Xa.generator===p)Xa.generator=new Ia(Xa.seed);for(var e=Xa.generator,d=1,r=1,j=0,l=0;l0&&(i.style.removeProperty("width"),i.style.removeProperty("height"));i.width=a.width=b||100;i.height=a.height=k||100;for(var e in m)m.hasOwnProperty(e)&&(d[e]=m[e]);a.textSize(S);a.background();md=g.max(1E3,b*k*0.05);a.externals.context=d;for(m=0;m0?(a=new C,a.set(b),c=new C,c.set(e),a.mult(c),c=new C,c.set(a),c.invert(),c.transpose(),w("normalTransform3d",u,"normalTransform",!1,c.array()),s("normal3d",u,"Normal",3,Jc)):J("normal3d",u,"Normal"), s("vertex3d",u,"Vertex",3,Ic),J("aColor3d",u,"aColor"),J("aTexture3d",u,"aTexture"),d.drawArrays(d.TRIANGLES,0,rd.length/3),d.disable(d.POLYGON_OFFSET_FILL));pa>0&&O&&(d.useProgram(F),w("model2d",F,"model",!1,e.array()),w("view2d",F,"view",!1,b.array()),v("color2d",F,"color",oa),q("picktype2d",F,"picktype",0),s("vertex2d",F,"Vertex",3,Kc),J("aTextureCoord2d",F,"aTextureCoord"),d.drawArrays(d.LINES,0,sd.length/3))};a.sphereDetail=function(b,a){var m;arguments.length===1&&(b=a=arguments[0]);b<3&&(b= 3);a<2&&(a=2);if(!(b===tb&&a===qc)){var e=c.SINCOS_LENGTH/b,h=new L(b),r=new L(b);for(m=0;m0){var m=new C;m.set(b); var e=new C;e.set(c);m.mult(e);e=new C;e.set(m);e.invert();e.transpose();w("normalTransform3d",u,"normalTransform",!1,e.array());s("normal3d",u,"Normal",3,cc)}else J("normal3d",u,"Normal");d.useProgram(u);J("aTexture3d",u,"aTexture");w("model3d",u,"model",!1,c.array());w("view3d",u,"view",!1,b.array());s("vertex3d",u,"Vertex",3,cc);J("aColor3d",u,"aColor");d.enable(d.POLYGON_OFFSET_FILL);d.polygonOffset(1,1);v("color3d",u,"color",na);d.drawArrays(d.TRIANGLE_STRIP,0,P.length/3);d.disable(d.POLYGON_OFFSET_FILL)}pa> 0&&O&&(d.useProgram(F),w("model2d",F,"model",!1,c.array()),w("view2d",F,"view",!1,b.array()),s("vertex2d",F,"Vertex",3,cc),J("aTextureCoord2d",F,"aTextureCoord"),v("color2d",F,"color",oa),q("picktype2d",F,"picktype",0),d.drawArrays(d.LINE_STRIP,0,P.length/3))};a.modelX=function(b,a,c){var e=V.array(),d=Va.array(),r=e[0]*b+e[1]*a+e[2]*c+e[3],j=e[4]*b+e[5]*a+e[6]*c+e[7],l=e[8]*b+e[9]*a+e[10]*c+e[11],a=e[12]*b+e[13]*a+e[14]*c+e[15],b=d[0]*r+d[1]*j+d[2]*l+d[3]*a,d=d[12]*r+d[13]*j+d[14]*l+d[15]*a;return d!== 0?b/d:b};a.modelY=function(b,a,c){var e=V.array(),d=Va.array(),r=e[0]*b+e[1]*a+e[2]*c+e[3],j=e[4]*b+e[5]*a+e[6]*c+e[7],l=e[8]*b+e[9]*a+e[10]*c+e[11],a=e[12]*b+e[13]*a+e[14]*c+e[15],b=d[4]*r+d[5]*j+d[6]*l+d[7]*a,d=d[12]*r+d[13]*j+d[14]*l+d[15]*a;return d!==0?b/d:b};a.modelZ=function(b,a,c){var e=V.array(),d=Va.array(),r=e[0]*b+e[1]*a+e[2]*c+e[3],j=e[4]*b+e[5]*a+e[6]*c+e[7],l=e[8]*b+e[9]*a+e[10]*c+e[11],a=e[12]*b+e[13]*a+e[14]*c+e[15],b=d[8]*r+d[9]*j+d[10]*l+d[11]*a,d=d[12]*r+d[13]*j+d[14]*l+d[15]* a;return d!==0?b/d:b};E.prototype.ambient=M.prototype.a3DOnlyFunction;I.prototype.ambient=function(){var b=arguments;d.useProgram(u);q("usingMat3d",u,"usingMat",!0);b.length===1?typeof b[0]==="string"?(b=b[0].slice(5,-1).split(","),v("mat_ambient3d",u,"mat_ambient",[b[0]/255,b[1]/255,b[2]/255])):v("mat_ambient3d",u,"mat_ambient",[b[0]/255,b[0]/255,b[0]/255]):v("mat_ambient3d",u,"mat_ambient",[b[0]/255,b[1]/255,b[2]/255])};E.prototype.emissive=M.prototype.a3DOnlyFunction;I.prototype.emissive=function(){var b= arguments;d.useProgram(u);q("usingMat3d",u,"usingMat",!0);b.length===1?typeof b[0]==="string"?(b=b[0].slice(5,-1).split(","),v("mat_emissive3d",u,"mat_emissive",[b[0]/255,b[1]/255,b[2]/255])):v("mat_emissive3d",u,"mat_emissive",[b[0]/255,b[0]/255,b[0]/255]):v("mat_emissive3d",u,"mat_emissive",[b[0]/255,b[1]/255,b[2]/255])};E.prototype.shininess=M.prototype.a3DOnlyFunction;I.prototype.shininess=function(b){d.useProgram(u);q("usingMat3d",u,"usingMat",!0);v("shininess3d",u,"shininess",b)};E.prototype.specular= M.prototype.a3DOnlyFunction;I.prototype.specular=function(){var b=a.color.apply(this,arguments);d.useProgram(u);q("usingMat3d",u,"usingMat",!0);v("mat_specular3d",u,"mat_specular",a.color.toGLArray(b).slice(0,3))};a.screenX=function(b,c,d){var e=V.array();if(e.length===16){var h=e[0]*b+e[1]*c+e[2]*d+e[3],r=e[4]*b+e[5]*c+e[6]*d+e[7],j=e[8]*b+e[9]*c+e[10]*d+e[11],c=e[12]*b+e[13]*c+e[14]*d+e[15],d=Na.array(),b=d[0]*h+d[1]*r+d[2]*j+d[3]*c,h=d[12]*h+d[13]*r+d[14]*j+d[15]*c;h!==0&&(b/=h);return a.width* (1+b)/2}else return V.multX(b,c)};a.screenY=function(b,c,d){var e=V.array();if(e.length===16){var h=e[0]*b+e[1]*c+e[2]*d+e[3],r=e[4]*b+e[5]*c+e[6]*d+e[7],j=e[8]*b+e[9]*c+e[10]*d+e[11],c=e[12]*b+e[13]*c+e[14]*d+e[15],d=Na.array(),b=d[4]*h+d[5]*r+d[6]*j+d[7]*c,h=d[12]*h+d[13]*r+d[14]*j+d[15]*c;h!==0&&(b/=h);return a.height*(1+b)/2}else return V.multY(b,c)};a.screenZ=function(b,a,c){var d=V.array();if(d.length!==16)return 0;var h=Na.array(),r=d[0]*b+d[1]*a+d[2]*c+d[3],j=d[4]*b+d[5]*a+d[6]*c+d[7],l=d[8]* b+d[9]*a+d[10]*c+d[11],a=d[12]*b+d[13]*a+d[14]*c+d[15],b=h[8]*r+h[9]*j+h[10]*l+h[11]*a,h=h[12]*r+h[13]*j+h[14]*l+h[15]*a;h!==0&&(b/=h);return(b+1)/2};M.prototype.fill=function(b,c,d,e){b=a.color(b,c,d,e);b===Fa&&U||(U=!0,Fa=b)};E.prototype.fill=function(){M.prototype.fill.apply(this,arguments);Ga=!0};I.prototype.fill=function(){M.prototype.fill.apply(this,arguments);na=a.color.toGLArray(Fa)};a.noFill=function(){U=!1};M.prototype.stroke=function(b,c,d,e){b=a.color(b,c,d,e);b===ka&&O||(O=!0,ka=b)}; E.prototype.stroke=function(){M.prototype.stroke.apply(this,arguments);Db=!0};I.prototype.stroke=function(){M.prototype.stroke.apply(this,arguments);oa=a.color.toGLArray(ka)};a.noStroke=function(){O=!1};M.prototype.strokeWeight=function(b){pa=b};E.prototype.strokeWeight=function(b){M.prototype.strokeWeight.apply(this,arguments);d.lineWidth=b};I.prototype.strokeWeight=function(b){M.prototype.strokeWeight.apply(this,arguments);d.useProgram(F);v("pointSize2d",F,"pointSize",b);d.useProgram(ua);v("pointSizeUnlitShape", ua,"pointSize",b);d.lineWidth(b)};a.strokeCap=function(b){ga.$ensureContext().lineCap=b};a.strokeJoin=function(b){ga.$ensureContext().lineJoin=b};M.prototype.smooth=function(){i.style.setProperty("image-rendering","optimizeQuality","important")};E.prototype.smooth=function(){M.prototype.smooth.apply(this,arguments);if("mozImageSmoothingEnabled"in d)d.mozImageSmoothingEnabled=!0};M.prototype.noSmooth=function(){i.style.setProperty("image-rendering","optimizeSpeed","important")};E.prototype.noSmooth= function(){M.prototype.noSmooth.apply(this,arguments);if("mozImageSmoothingEnabled"in d)d.mozImageSmoothingEnabled=!1};E.prototype.point=function(b,k){if(O)if($.options.crispLines){var m=g.PI/4,e=a.get(b,k);a.set(b,k,hc(e,ka,m))}else pa>1?(d.fillStyle=a.color.toString(ka),Ga=!0,d.beginPath(),d.arc(b,k,pa/2,0,c.TWO_PI,!1),d.fill(),d.closePath()):(d.fillStyle=a.color.toString(ka),d.fillRect(g.round(b),g.round(k),1,1),Ga=!0)};I.prototype.point=function(b,a,c){var e=new C;e.translate(b,a,c||0);e.transpose(); b=new C;b.scale(1,-1,1);b.apply(V.array());b.transpose();d.useProgram(F);w("model2d",F,"model",!1,e.array());w("view2d",F,"view",!1,b.array());pa>0&&O&&(v("color2d",F,"color",oa),q("picktype2d",F,"picktype",0),s("vertex2d",F,"Vertex",3,oc),J("aTextureCoord2d",F,"aTextureCoord"),d.drawArrays(d.POINTS,0,1))};a.beginShape=function(b){W=b;o=[]};E.prototype.vertex=function(b,a,c,d){var h=[];lb&&(lb=!1);h.isVert=!0;h[0]=b;h[1]=a;h[2]=0;h[3]=c;h[4]=d;h[5]=Fa;h[6]=ka;o.push(h)};I.prototype.vertex=function(b, a,c,d,h){var r=[];lb&&(lb=!1);r.isVert=!0;r[0]=b;r[1]=a;r[2]=c||0;r[3]=d||0;r[4]=h||0;r[5]=na[0];r[6]=na[1];r[7]=na[2];r[8]=na[3];r[9]=oa[0];r[10]=oa[1];r[11]=oa[2];r[12]=oa[3];r[13]=za;r[14]=ob;r[15]=fb;o.push(r)};var vd=function(b,a){var c=new C;c.scale(1,-1,1);c.apply(V.array());c.transpose();d.useProgram(ua);w("uViewUS",ua,"uView",!1,c.array());s("aVertexUS",ua,"aVertex",3,oc);d.bufferData(d.ARRAY_BUFFER,new L(b),d.STREAM_DRAW);s("aColorUS",ua,"aColor",4,Nc);d.bufferData(d.ARRAY_BUFFER,new L(a), d.STREAM_DRAW);d.drawArrays(d.POINTS,0,b.length/3)},Ja=function(b,a,c){var a=a==="LINES"?d.LINES:a==="LINE_LOOP"?d.LINE_LOOP:d.LINE_STRIP,e=new C;e.scale(1,-1,1);e.apply(V.array());e.transpose();d.useProgram(ua);w("uViewUS",ua,"uView",!1,e.array());s("aVertexUS",ua,"aVertex",3,Mc);d.bufferData(d.ARRAY_BUFFER,new L(b),d.STREAM_DRAW);s("aColorUS",ua,"aColor",4,gd);d.bufferData(d.ARRAY_BUFFER,new L(c),d.STREAM_DRAW);d.drawArrays(a,0,b.length/3)},cb=function(b,a,m,e){var a=a==="TRIANGLES"?d.TRIANGLES: a==="TRIANGLE_FAN"?d.TRIANGLE_FAN:d.TRIANGLE_STRIP,h=new C;h.scale(1,-1,1);h.apply(V.array());h.transpose();d.useProgram(u);w("model3d",u,"model",!1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);w("view3d",u,"view",!1,h.array());d.enable(d.POLYGON_OFFSET_FILL);d.polygonOffset(1,1);v("color3d",u,"color",[-1,0,0,0]);s("vertex3d",u,"Vertex",3,Wb);d.bufferData(d.ARRAY_BUFFER,new L(b),d.STREAM_DRAW);s("aColor3d",u,"aColor",4,Nc);d.bufferData(d.ARRAY_BUFFER,new L(m),d.STREAM_DRAW);J("normal3d",u,"Normal");if(Da){if(kd=== c.IMAGE)for(m=0;m1&&(e[m+0]-=e[m+0]-1),e[m+1]>1&&(e[m+1]-=e[m+1]-1);q("usingTexture3d",u,"usingTexture",Da);s("aTexture3d",u,"aTexture",2,hd);d.bufferData(d.ARRAY_BUFFER,new L(e),d.STREAM_DRAW)}d.drawArrays(a,0,b.length/3);d.disable(d.POLYGON_OFFSET_FILL)};E.prototype.endShape=function(b){if(o.length!==0){var b=b===c.CLOSE,k=[],m=[],e=[],h=[],r;lb=!0;var j,l,g=o.length;for(j=0;j3){k=[];m=1-Ya;d.beginPath();d.moveTo(o[1][0],o[1][1]);for(j=1;j+22){d.beginPath();d.moveTo(o[0][0],o[0][1]);d.lineTo(o[1][0],o[1][1]);d.lineTo(o[2][0],o[2][1]);U&&(a.fill(o[2][5]),ea());O&&(a.stroke(o[2][6]),Y());d.closePath();for(j=3;j3)for(j=0;j+12)for(l=0;l+22)for(l=0;l+22){for(l=0;l<3;l++){j=o[l];for(f=0;f<3;f++)b.push(j[f])}for(l=0;l<3;l++){j=o[l];for(f=9;f<13;f++)h.push(j[f])}O&&Ja(b,"LINE_LOOP",h);for(l=2;l+13){for(l=0;l<2;l++){j=o[l];for(f=0;f<3;f++)b.push(j[f])}for(l=0;l<2;l++){j=o[l];for(f=9;f<13;f++)h.push(j[f])}Ja(b,"LINE_STRIP",h);i>4&&i%2>0&&(m.splice(m.length- 3),o.pop());for(l=0;l+33){var h=va[ta-4][0],f=va[ta-4][1],j=va[ta-4][2],g=va[ta-3][0],i=va[ta-3][1],p=va[ta- 3][2],o=va[ta-2][0],q=va[ta-2][1],n=va[ta-2][2],s=va[ta-1][0],v=va[ta-1][1],u=va[ta-1][2],b=g,c=i,d=p,t=Gb.array(),e=t[4]*h+t[5]*g+t[6]*o+t[7]*s,w=t[8]*h+t[9]*g+t[10]*o+t[11]*s,h=t[12]*h+t[13]*g+t[14]*o+t[15]*s,g=t[4]*f+t[5]*i+t[6]*q+t[7]*v,o=t[8]*f+t[9]*i+t[10]*q+t[11]*v,f=t[12]*f+t[13]*i+t[14]*q+t[15]*v,i=t[4]*j+t[5]*p+t[6]*n+t[7]*u,q=t[8]*j+t[9]*p+t[10]*n+t[11]*u,j=t[12]*j+t[13]*p+t[14]*n+t[15]*u;a.vertex(b,c,d);for(p=0;pc.TWO_PI)h=0,f=c.TWO_PI;m/= 2;e/=2;b+=m;d+=e;var h=0|-0.5+h/c.TWO_PI*c.SINCOS_LENGTH,f=0|0.5+f/c.TWO_PI*c.SINCOS_LENGTH,j,g;if(U){var i=O;O=!1;a.beginShape();a.vertex(b,d);for(g=j=h;j=c.SINCOS_LENGTH&&(g-=c.SINCOS_LENGTH),a.vertex(b+Ob[g]*m,d+Nb[g]*e);a.endShape(c.CLOSE);O=i}if(O){i=U;U=!1;a.beginShape();for(g=j=h;j=c.SINCOS_LENGTH&&(g-=c.SINCOS_LENGTH),a.vertex(b+Ob[g]*m,d+Nb[g]*e);g=f%c.SINCOS_LENGTH;a.vertex(b+Ob[g]*m,d+Nb[g]*e);a.endShape();U=i}}};E.prototype.line=function(b,c,m,e){if(b===m&&c=== e)a.point(b,c);else if((b===m||c===e)&&pa<=1&&O&&$.options.crispLines){var h;if(b===m){c>e&&(h=c,c=e,e=h);for(;c<=e;++c)a.set(b,c,ka)}else{b>m&&(h=b,b=m,m=h);for(;b<=m;++b)a.set(b,c,ka)}}else O&&(d.beginPath(),d.moveTo(b||0,c||0),d.lineTo(m||0,e||0),Y(),d.closePath())};I.prototype.line=function(b,c,m,e,h,f){if(h===p||f===p)f=0,h=e,e=m,m=0;b===e&&c===h&&m===f?a.point(b,c,m):(b=[b,c,m,e,h,f],c=new C,c.scale(1,-1,1),c.apply(V.array()),c.transpose(),pa>0&&O&&(d.useProgram(F),w("model2d",F,"model",!1, [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),w("view2d",F,"view",!1,c.array()),v("color2d",F,"color",oa),q("picktype2d",F,"picktype",0),s("vertex2d",F,"Vertex",3,Mc),J("aTextureCoord2d",F,"aTextureCoord"),d.bufferData(d.ARRAY_BUFFER,new L(b),d.STREAM_DRAW),d.drawArrays(d.LINES,0,2)))};E.prototype.bezier=function(){if(arguments.length!==8)throw"You must use 8 parameters for bezier() in 2D mode";a.beginShape();a.vertex(arguments[0],arguments[1]);a.bezierVertex(arguments[2],arguments[3],arguments[4],arguments[5], arguments[6],arguments[7]);a.endShape()};I.prototype.bezier=function(){if(arguments.length!==12)throw"You must use 12 parameters for bezier() in 3D mode";a.beginShape();a.vertex(arguments[0],arguments[1],arguments[2]);a.bezierVertex(arguments[3],arguments[4],arguments[5],arguments[6],arguments[7],arguments[8],arguments[9],arguments[10],arguments[11]);a.endShape()};a.bezierDetail=function(a){yb=a};a.bezierPoint=function(a,c,d,e,h){return(1-h)*(1-h)*(1-h)*a+3*(1-h)*(1-h)*h*c+3*(1-h)*h*h*d+h*h*h*e}; a.bezierTangent=function(a,c,d,e,h){return 3*h*h*(-a+3*c-3*d+e)+6*h*(a-2*c+d)+3*(-a+c)};a.curvePoint=function(a,c,d,e,h){return 0.5*(2*c+(-a+d)*h+(2*a-5*c+4*d-e)*h*h+(-a+3*c-3*d+e)*h*h*h)};a.curveTangent=function(a,c,d,e,h){return 0.5*(-a+d+2*(2*a-5*c+4*d-e)*h+3*(-a+3*c-3*d+e)*h*h)};a.triangle=function(b,d,m,e,h,f){a.beginShape(c.TRIANGLES);a.vertex(b,d,0);a.vertex(m,e,0);a.vertex(h,f,0);a.endShape()};a.quad=function(b,d,f,e,h,g,j,l){a.beginShape(c.QUADS);a.vertex(b,d,0);a.vertex(f,e,0);a.vertex(h, g,0);a.vertex(j,l,0);a.endShape()};E.prototype.rect=function(b,k,f,e){if(f||e)if(O&&!U&&pa<=1&&$.options.crispLines){var h,r=b+f-1,j=k+e-1;for(h=0;h0&&O&&(d.useProgram(F),w("model2d",F,"model",!1,h.array()),w("view2d",F,"view",!1,c.array()),v("color2d",F,"color",oa),q("picktype2d",F,"picktype",0),s("vertex2d",F,"Vertex",3,nc),J("aTextureCoord2d",F,"aTextureCoord"),d.drawArrays(d.LINE_LOOP,0,Uc.length/3));U&&(d.useProgram(u),w("model3d",u,"model",!1,h.array()),w("view3d",u,"view",!1,c.array()),d.enable(d.POLYGON_OFFSET_FILL),d.polygonOffset(1,1),v("color3d", u,"color",na),K>0?(a=new C,a.set(c),c=new C,c.set(h),a.mult(c),h=new C,h.set(a),h.invert(),h.transpose(),w("normalTransform3d",u,"normalTransform",!1,h.array()),s("normal3d",u,"Normal",3,Lc)):J("normal3d",u,"Normal"),s("vertex3d",u,"Vertex",3,nc),d.drawArrays(d.TRIANGLE_FAN,0,Uc.length/3),d.disable(d.POLYGON_OFFSET_FILL))};M.prototype.ellipse=function(a,d,f,e){a=a||0;d=d||0;if(!(f<=0&&e<=0)){ba===c.RADIUS&&(f*=2,e*=2);ba===c.CORNERS&&(f-=a,e-=d);if(ba===c.CORNER||ba===c.CORNERS)a+=f/2,d+=e/2;return{x:a, y:d,width:f,height:e}}};E.prototype.ellipse=function(b,k,f,e){var h=M.prototype.ellipse.apply(this,arguments);if(h)if(b=h.x,k=h.y,f=h.width,e=h.height,f===e)d.beginPath(),d.arc(b-0,k-0,f/2,0,c.TWO_PI,!1),ea(),Y(),d.closePath();else{var h=f/2,g=e/2,j=0.5522847498307933*h,l=0.5522847498307933*g;a.beginShape();a.vertex(b+h,k);a.bezierVertex(b+h,k-l,b+j,k-g,b,k-g);a.bezierVertex(b-j,k-g,b-h,k-l,b-h,k);a.bezierVertex(b-h,k+l,b-j,k+g,b,k+g);a.bezierVertex(b+j,k+g,b+h,k+l,b+h,k);a.endShape()}};I.prototype.ellipse= function(b,c,d,e){var h=M.prototype.ellipse.apply(this,arguments);if(h){var b=h.x,c=h.y,d=h.width,e=h.height,h=d/2,f=e/2,j=0.5522847498307933*h,g=0.5522847498307933*f;a.beginShape();a.vertex(b+h,c);a.bezierVertex(b+h,c-g,0,b+j,c-f,0,b,c-f,0);a.bezierVertex(b-j,c-f,0,b-h,c-g,0,b-h,c,0);a.bezierVertex(b-h,c+g,0,b-j,c+f,0,b,c+f,0);a.bezierVertex(b+j,c+f,0,b+h,c+g,0,b+h,c,0);a.endShape();if(U){var g=j=0,i;for(i=0;i>>16;a.imageData.data[e+1]=(d&c.GREEN_MASK)>>>8;a.imageData.data[e+2]=d&c.BLUE_MASK;a.imageData.data[e+3]=(d&c.ALPHA_MASK)>>>24}}(this),set:function(a){if(this.isRemote)throw"Image is loaded remotely. Cannot set pixels."; else for(var b=0,c=a.length;b=0&&k>=0&&k=0&&c>=0&&cmd&&Ba()):f instanceof Ka&&a.image(f,b,c);else if(arguments.length===4)if(e.isRemote)throw"Image is loaded remotely. Cannot set x,y."; else{var h=a.color.toArray(f),g=c*e.width*4+b*4,j=e.imageData.data;j[g]=h[0];j[g+1]=h[1];j[g+2]=h[2];j[g+3]=h[3]}};a.imageData={};a.pixels={getLength:function(){return a.imageData.data.length?a.imageData.data.length/4:0},getPixel:function(b){b*=4;return a.imageData.data[b+3]<<24&4278190080|a.imageData.data[b+0]<<16&16711680|a.imageData.data[b+1]<<8&65280|a.imageData.data[b+2]&255},setPixel:function(b,c){var d=b*4;a.imageData.data[d+0]=(c&16711680)>>>16;a.imageData.data[d+1]=(c&65280)>>>8;a.imageData.data[d+ 2]=c&255;a.imageData.data[d+3]=(c&4278190080)>>>24},set:function(a){for(var c=0,d=a.length;c0&&zd(b,c,f,e);var h=a.color.toGLArray(Za);d.clearColor(h[0],h[1],h[2],h[3]);d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};E.prototype.image=function(a,c,f,e,h){if(a.width>0){var g=tc(c||0,f||0,e||a.width,h||a.height,arguments.length<4);if(a.sourceImg&&nb===null&&!a.__mask){var j=a.sourceImg;d.drawImage(j,0,0,j.width,j.height,g.x,g.y,g.w,g.h)}else{j=a.toImageData();if(a.__mask){var l,i;if(a.__mask instanceof Ka){var p=a.__mask.toImageData();l=2;for(i=a.width*a.height*4;l0&&(e=e||b.width,h=h||b.height,a.beginShape(a.QUADS),a.texture(b.externals.canvas),a.vertex(c,d,0,0,0),a.vertex(c,d+h,0,0,h),a.vertex(c+e,d+h,0,e,h),a.vertex(c+e,d,0,e,0),a.endShape())};a.tint=function(){var b= a.color.apply(this,arguments),c=a.red(b)/ia,d=a.green(b)/xa,e=a.blue(b)/B,h=a.alpha(b)/Z;nb=function(a){for(var b=a.data,a=4*a.width*a.height,f=0;f=g&&(p=d),q<0&&(q=0),n>=e&&(n=d),q=c.pixels.getPixel(q),o=c.pixels.getPixel(o),n=c.pixels.getPixel(n),p=c.pixels.getPixel(p),l=77*(l>>16&255)+151*(l>>8&255)+28*(l&255),v=77*(o>>16&255)+151*(o>>8&255)+28*(o&255),s=77*(p>>16&255)+151*(p>>8&255)+28*(p&255),u=77*(q>>16&255)+151*(q>>8&255)+28*(q&255),t=77*(n>>16&255)+151*(n>>8&255)+28*(n&255),v=g&&(p=d),q<0&&(q=0),n>=e&&(n=d),q=c.pixels.getPixel(q),o=c.pixels.getPixel(o),n=c.pixels.getPixel(n),p=c.pixels.getPixel(p),l=77*(l>>16&255)+151*(l>>8&255)+28*(l&255),v=77*(o>>16&255)+151*(o>>8&255)+28*(o&255),s=77*(p>>16&255)+151*(p>>8&255)+28*(p&255),u=77*(q>>16&255)+151*(q>>8&255)+28*(q&255),t=77*(n>>16&255)+151*(n>>8&255)+28*(n&255),v>l&& (i=o,l=v),s>l&&(i=p,l=s),u>l&&(i=q,l=u),t>l&&(i=n),h[d++]=i}c.pixels.set(h)};a.filter=function(b,d,f){var e,h,g,j;arguments.length===3?(f.loadPixels(),e=f):(a.loadPixels(),e=a);d===p&&(d=null);if(e.isRemote)throw"Image is loaded remotely. Cannot filter image.";else{var l=e.pixels.getLength();switch(b){case c.BLUR:var i=d||1,o=e,q,s,n,v,u,w,t,x,z;g=o.pixels.getLength();j=new L(g);l=new L(g);h=new L(g);g=new L(g);var Q=0,B,C,G,i=a.floor(i*3.5),A,i=i<1?1:i<248?i:248;if(a.shared.blurRadius!==i){a.shared.blurRadius= i;a.shared.blurKernelSize=1+(a.shared.blurRadius<<1);a.shared.blurKernel=new L(a.shared.blurKernelSize);var D=a.shared.blurKernel,F=a.shared.blurKernelSize;for(A=0;A=A)break;u=0}for(G=u;G=A)break;t=(w+Q)*4;u=F[G];v+=u*E[t+3]; q+=u*E[t];s+=u*E[t+1];n+=u*E[t+2];o+=u;w++}t=Q+B;g[t]=v/o;j[t]=q/o;l[t]=s/o;h[t]=n/o}Q+=A}Q=0;x=-x;z=x*A;for(C=0;C=i)break;u=0;t=x;w=B+z}for(G=u;G=i)break;u=F[G];v+=u*g[w];q+=u*j[w];s+=u*l[w];n+=u*h[w];o+=u;t++;w+=A}t=(B+Q)*4;E[t]=q/o;E[t+1]=s/o;E[t+2]=n/o;E[t+3]=v/o}Q+=A;z+=A;x++}break;case c.GRAY:if(e.format===c.ALPHA){for(j=0;j>16&255)+151*(h>>8&255)+28*(h&255)>>8,e.pixels.setPixel(j,h&c.ALPHA_MASK|g<<16|g<<8|g);break;case c.INVERT:for(j=0;j255)throw"Levels must be between 2 and 255 for filter(POSTERIZE, levels)";g=h-1;for(j=0;j>16&255,i=e.pixels.getPixel(j)>>8&255,A= e.pixels.getPixel(j)&255,Q=(Q*h>>8)*255/g,i=(i*h>>8)*255/g,A=(A*h>>8)*255/g,e.pixels.setPixel(j,4278190080&e.pixels.getPixel(j)|Q<<16|i<<8|A);break;case c.OPAQUE:for(j=0;j1)throw"Level must be between 0 and 1 for filter(THRESHOLD, level)";h=a.floor(d*255);for(j=0;j>16,a.max((e.pixels.getPixel(j)&c.GREEN_MASK)>>8,e.pixels.getPixel(j)& c.BLUE_MASK)),e.pixels.setPixel(j,e.pixels.getPixel(j)&c.ALPHA_MASK|(gd&&(g=d)):(a=d+a-h,g>a&& (g=a));fe&&(l=e)):(c=e+c-f,l>c&&(l=c));return!(g<=0||l<=0)};a.filter_new_scanline=function(){a.shared.sX=a.shared.srcXOffset;a.shared.fracV=a.shared.srcYOffset&c.PREC_MAXVAL;a.shared.ifV=c.PREC_MAXVAL-a.shared.fracV;a.shared.v1=(a.shared.srcYOffset>>c.PRECISIONB)*a.shared.iw;a.shared.v2=g.min((a.shared.srcYOffset>>c.PRECISIONB)+1,a.shared.ih1)*a.shared.iw};a.filter_bilinear=function(){a.shared.fracU=a.shared.sX&c.PREC_MAXVAL;a.shared.ifU=c.PREC_MAXVAL-a.shared.fracU;a.shared.ul=a.shared.ifU* a.shared.ifV>>c.PRECISIONB;a.shared.ll=a.shared.ifU*a.shared.fracV>>c.PRECISIONB;a.shared.ur=a.shared.fracU*a.shared.ifV>>c.PRECISIONB;a.shared.lr=a.shared.fracU*a.shared.fracV>>c.PRECISIONB;a.shared.u1=a.shared.sX>>c.PRECISIONB;a.shared.u2=g.min(a.shared.u1+1,a.shared.iw1);var b=(a.shared.v1+a.shared.u1)*4,d=(a.shared.v1+a.shared.u2)*4,f=(a.shared.v2+a.shared.u1)*4,e=(a.shared.v2+a.shared.u2)*4;a.shared.cUL=a.color.toInt(a.shared.srcBuffer[b],a.shared.srcBuffer[b+1],a.shared.srcBuffer[b+2],a.shared.srcBuffer[b+ 3]);a.shared.cUR=a.color.toInt(a.shared.srcBuffer[d],a.shared.srcBuffer[d+1],a.shared.srcBuffer[d+2],a.shared.srcBuffer[d+3]);a.shared.cLL=a.color.toInt(a.shared.srcBuffer[f],a.shared.srcBuffer[f+1],a.shared.srcBuffer[f+2],a.shared.srcBuffer[f+3]);a.shared.cLR=a.color.toInt(a.shared.srcBuffer[e],a.shared.srcBuffer[e+1],a.shared.srcBuffer[e+2],a.shared.srcBuffer[e+3]);a.shared.r=a.shared.ul*((a.shared.cUL&c.RED_MASK)>>16)+a.shared.ll*((a.shared.cLL&c.RED_MASK)>>16)+a.shared.ur*((a.shared.cUR&c.RED_MASK)>> 16)+a.shared.lr*((a.shared.cLR&c.RED_MASK)>>16)<>>c.PRECISIONB&c.GREEN_MASK;a.shared.b=a.shared.ul*(a.shared.cUL&c.BLUE_MASK)+a.shared.ll*(a.shared.cLL&c.BLUE_MASK)+a.shared.ur*(a.shared.cUR&c.BLUE_MASK)+a.shared.lr*(a.shared.cLR&c.BLUE_MASK)>>>c.PRECISIONB;a.shared.a=a.shared.ul*((a.shared.cUL&c.ALPHA_MASK)>>> 24)+a.shared.ll*((a.shared.cLL&c.ALPHA_MASK)>>>24)+a.shared.ur*((a.shared.cUR&c.ALPHA_MASK)>>>24)+a.shared.lr*((a.shared.cLR&c.ALPHA_MASK)>>>24)<=b.width&&(e=b.width-1);h>=b.height&&(h=b.height-1);e-=d;h-=f;q-=o;s-=p;if(!(q<=0||s<=0||e<=0||h<=0||o>=j||p>=l||d>=b.width||f>=b.height))switch(e=g.floor(e/q*c.PRECISIONF),h=g.floor(h/s*c.PRECISIONF), a.shared.srcXOffset=g.floor(o<0?-o*e:d*c.PRECISIONF),a.shared.srcYOffset=g.floor(p<0?-p*h:f*c.PRECISIONF),o<0&&(q+=o,o=0),p<0&&(s+=p,p=0),q=g.min(q,j-o),s=g.min(s,l-p),d=p*j+o,a.shared.srcBuffer=b.imageData.data,a.shared.iw=b.width,a.shared.iw1=b.width-1,a.shared.ih1=b.height-1,n){case c.BLEND:for(f=0;f":return a.greater;case "?":return a.question;case "@":return a.at; case "[":return a.bracketleft;case "\\":return a.backslash;case "]":return a.bracketright;case "^":return a.asciicircum;case "`":return a.grave;case "{":return a.braceleft;case "|":return a.bar;case "}":return a.braceright;case "~":return a.asciitilde;default:return a[c]}}catch(d){z.debug(d)}};E.prototype.text$line=function(b,f,g,e,h){e=e=0;if(ja.glyph){e=a.glyphTable[ja.name];d.save();d.translate(f,g+S);(h===c.RIGHT||h===c.CENTER)&&e.width(b);f=1/e.units_per_em*S;d.scale(f,f);f=0;for(g=b.length;f< g;f++)try{a.glyphLook(e,b[f]).draw()}catch(i){z.debug(i)}zb()}else if(b&&"fillText"in d){if(Ga)d.fillStyle=a.color.toString(Fa),Ga=!1;if(h===c.RIGHT||h===c.CENTER)e=d.measureText(b).width,e=h===c.RIGHT?-e:-e/2;d.fillText(b,f+e,g)}};I.prototype.text$line=function(a,f,g,e,h){Ha===p&&(Ha=A.createElement("canvas"));var i=d;d=Ha.getContext("2d");d.font=S+"px "+ja.name;var j=d.measureText(a).width;Ha.width=j;Ha.height=S;d=Ha.getContext("2d");d.font=S+"px "+ja.name;d.textBaseline="top";E.prototype.text$line(a, 0,0,0,c.LEFT);a=Ha.width/Ha.height;d=i;d.bindTexture(d.TEXTURE_2D,jd);Tb(Ha);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,d.LINEAR);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.LINEAR);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE);i=0;h===c.RIGHT?i=-j:h===c.CENTER&&(i=-j/2);h=new C;j=S*0.5;h.translate(f+i-j/2,g-j,e);h.scale(-a*j,-j,j);h.translate(-1,-1,-1);h.transpose();f=new C;f.scale(1,-1,1);f.apply(V.array()); f.transpose();d.useProgram(F);s("vertex2d",F,"Vertex",3,Oc);s("aTextureCoord2d",F,"aTextureCoord",2,Pc);q("uSampler2d",F,"uSampler",[0]);q("picktype2d",F,"picktype",1);w("model2d",F,"model",!1,h.array());w("view2d",F,"view",!1,f.array());v("color2d",F,"color",na);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,Qc);d.drawElements(d.TRIANGLES,6,d.UNSIGNED_SHORT,0)};a.text=function(){if(Rc===c.SCREEN){a.pushMatrix();a.resetMatrix();var b=a.textAscent(),d=a.textDescent(),f=a.textWidth(arguments[0]),e=b+d,d=a.loadFont(ja.origName), f=a.createGraphics(f,e);f.beginDraw();f.fill(Fa);f.opaque=!1;f.background(0,0,0,0);f.textFont(d);f.textSize(S);f.text(arguments[0],0,b);f.endDraw();arguments.length===5||arguments.length===6?a.image(f,arguments[1],arguments[2]-b,arguments[3],arguments[4]):a.image(f,arguments[1],arguments[2]-b);a.popMatrix()}else Rc!==c.SHAPE&&(arguments.length===3?ic(Ea(arguments[0]),arguments[1],arguments[2],0):arguments.length===4?ic(Ea(arguments[0]),arguments[1],arguments[2],arguments[3]):arguments.length===5? Ab(Ea(arguments[0]),arguments[1],arguments[2],arguments[3],arguments[4],0):arguments.length===6&&Ab(Ea(arguments[0]),arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]))};a.textMode=function(a){Rc=a};a.loadGlyphs=function(b){var c,f,e,h,i,j,l,o,q,s,u,n,v=function(a,b){var c=0,d=[],e,f=RegExp(a,"g");for(e=d[c]=f.exec(b);e;)c++,e=d[c]=f.exec(b);return d},w=function(a){var b=v("[A-Za-z][0-9\\- ]+|Z",a);n="return {draw:function(){var curContext=beforePathDraw();curContext.beginPath();"; o=a=j=i=h=e=f=c=0;q="";s=b.length-1;for(var l=0;lf&&(c=f-g);Ca.height=c/f*100+"%";G.paddingBottom=ha.clientHeight+"px"},Qa=[da(f,"mousemove",function(c){if(ma)Ea(x.innerHeight-c.clientY),Y.scrollTop=La}),da(f,"mouseup",function(){ma&&(ma=La=!1)}),da(ea,"dblclick",function(c){c.preventDefault();Ba?(Ea(Ba),Ba=!1):(Ba=ha.clientHeight,Ca.height="0px")}),da(ea,"mousedown",function(c){c.preventDefault();ma=!0;La=Y.scrollTop}),da(ea, "contextmenu",function(){ma=!1}),da(wa,"click",function(){qa()})];qa=function(){for(var f=Qa.length;f--;)X.apply(c,Qa[f]);L.removeChild(ha);G.paddingBottom=Ia;fa(Y);fa(ha);c.log=la};ca(ha,g,Y,p,ea,q,wa,s);wa.title="Close Log";aa(wa,f.createTextNode("\u2716"));ea.title="Double-click to toggle log minimization";L.insertBefore(ha,L.firstChild);c.log=function(c){Pa===512?Y.removeChild(Y.firstChild):Pa++;var g=aa(Y,f.createElement("div")),i=aa(g,f.createElement("div"));g.title=(new Date).toLocaleTimeString(); ca(g,z,i,w);aa(i,f.createTextNode(c));Y.scrollTop=Y.scrollHeight};c.log(A);G.paddingBottom=ha.clientHeight+"px"}}():typeof print==="function"&&(c.log=print);return c}();z.logger=Hb;z.version="1.2.3";z.lib={};z.registerLibrary=function(c,f){z.lib[c]=f;f.hasOwnProperty("init")&&f.init(la)};z.instances=Ca;z.getInstanceById=function(c){return Ca[lc[c]]};z.Sketch=function(c){this.attachFunction=c;this.options={crispLines:!1,pauseOnBlur:!1,globalKeyEvents:!1};this.onExit=this.onFrameEnd=this.onFrameStart= this.onLoop=this.onPause=this.onSetup=this.onLoad=Dc;this.params={};this.imageCache={pending:0,images:{},add:function(c){if(Ia){var g=new Image;g.onload=function(c){return function(){c.pending--}}(this);this.pending++;this.images[c]=g;g.src=c}else this.images[c]=null}};this.fonts={template:function(){if(!Ia)return null;var c=A.createElement("p");c.style.fontFamily="serif";c.style.fontSize="72px";c.style.visibility="hidden";c.innerHTML="This element is a text block for font loading";A.getElementsByTagName("body")[0].appendChild(c); return c}(),attempt:0,pending:function(){for(var c=!0,g=0;g=30){c=!0;for(g=0;g "+p);if(w===J)if(s.length===0)try{return new z(c,q.join("\n"))}catch(A){z.logger.log("Unable to execute pjs sketch: "+A)}else z.logger.log("Unable to load pjs sketch files: "+s.join("\n"))}if(v.charAt(0)==="#"){var L=A.getElementById(v.substring(1));L?x(L.text||L.textContent):x("","Unable to load pjs sketch: element with id '"+v.substring(1)+"' was not found")}else g(v,x)}for(var q=[],s=[],J=f.length,w=0,x=0;x