/*** P R O C E S S I N G . J S - 1.2.3-API 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(S,E,j,q){function za(d,j){if(d in S)return S[d];return typeof S[j]==="function"?S[j]:function(d){if(d instanceof Array)return d;else if(typeof d==="number"){var j=[];j.length=d;return j}}}function ac(d){if(d.constructor===String){for(var L=0,G=0;G0;)q(z.shift())}var bc=function(){},Ka=function(){return"console"in S?function(d){S.console.log("Processing.js: "+d)}:void 0}(),cc=function(d){var j=new XMLHttpRequest;j.open("GET",d,!1);j.overrideMimeType&&j.overrideMimeType("text/plain");j.setRequestHeader("If-Modified-Since","Fri, 01 Jan 1960 00:00:00 GMT");j.send(null);if(j.status!==200&&j.status!==0)throw"XMLHttpRequest failed, status code "+j.status;return j.responseText},ua="document"in this&&!("fake"in this.document),P=za("Float32Array","WebGLFloatArray"),sd=za("Int32Array","WebGLIntArray"),td=za("Uint16Array", "WebGLUnsignedShortArray"),Fc=za("Uint8Array","WebGLUnsignedByteArray"),d={X:0,Y:1,Z:2,R:3,G:4,B:5,A:6,U:7,V:8,NX:9,NY:10,NZ:11,EDGE:12,SR:13,SG:14,SB:15,SA:16,SW:17,TX:18,TY:19,TZ:20,VX:21,VY:22,VZ:23,VW:24,AR:25,AG:26,AB:27,DR:3,DG:4,DB:5,DA:6,SPR:28,SPG:29,SPB:30,SHINE:31,ER:32,EG:33,EB:34,BEEN_LIT:35,VERTEX_FIELD_COUNT:36,P2D:1,JAVA2D:1,WEBGL:2,P3D:2,OPENGL:2,PDF:0,DXF:0,OTHER:0,WINDOWS:1,MAXOSX:2,LINUX:3,EPSILON:1.0E-4,MAX_FLOAT:3.4028235E38,MIN_FLOAT:-3.4028235E38,MAX_INT:2147483647,MIN_INT:-2147483648, PI:j.PI,TWO_PI:2*j.PI,HALF_PI:j.PI/2,THIRD_PI:j.PI/3,QUARTER_PI:j.PI/4,DEG_TO_RAD:j.PI/180,RAD_TO_DEG:180/j.PI,WHITESPACE:" \t\n\r\u000c\u00a0",RGB:1,ARGB:2,HSB:3,ALPHA:4,CMYK:5,TIFF:0,TARGA:1,JPEG:2,GIF:3,BLUR:11,GRAY:12,INVERT:13,OPAQUE:14,POSTERIZE:15,THRESHOLD:16,ERODE:17,DILATE:18,REPLACE:0,BLEND:1,ADD:2,SUBTRACT:4,LIGHTEST:8,DARKEST:16,DIFFERENCE:32,EXCLUSION:64,MULTIPLY:128,SCREEN:256,OVERLAY:512,HARD_LIGHT:1024,SOFT_LIGHT:2048,DODGE:4096,BURN:8192,ALPHA_MASK:4278190080,RED_MASK:16711680,GREEN_MASK:65280, BLUE_MASK:255,CUSTOM:0,ORTHOGRAPHIC:2,PERSPECTIVE:3,POINT:2,POINTS:2,LINE:4,LINES:4,TRIANGLE:8,TRIANGLES:9,TRIANGLE_STRIP:10,TRIANGLE_FAN:11,QUAD:16,QUADS:16,QUAD_STRIP:17,POLYGON:20,PATH:21,RECT:30,ELLIPSE:31,ARC:32,SPHERE:40,BOX:41,GROUP:0,PRIMITIVE:1,GEOMETRY:3,VERTEX:0,BEZIER_VERTEX:1,CURVE_VERTEX:2,BREAK:3,CLOSESHAPE:4,OPEN:1,CLOSE:2,CORNER:0,CORNERS:1,RADIUS:2,CENTER_RADIUS:2,CENTER:3,DIAMETER:3,CENTER_DIAMETER:3,BASELINE:0,TOP:101,BOTTOM:102,NORMAL:1,NORMALIZED:1,IMAGE:2,MODEL:4,SHAPE:5,SQUARE:"butt", ROUND:"round",PROJECT:"square",MITER:"miter",BEVEL:"bevel",AMBIENT:0,DIRECTIONAL:1,SPOT:3,BACKSPACE:8,TAB:9,ENTER:10,RETURN:13,ESC:27,DELETE:127,CODED:65535,SHIFT:16,CONTROL:17,ALT:18,CAPSLK:20,PGUP:33,PGDN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUMLK:144,META:157,INSERT:155,ARROW:"default",CROSS:"crosshair",HAND:"pointer",MOVE:"move",TEXT:"text",WAIT:"wait",NOCURSOR:"url('data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), auto", DISABLE_OPENGL_2X_SMOOTH:1,ENABLE_OPENGL_2X_SMOOTH:-1,ENABLE_OPENGL_4X_SMOOTH:2,ENABLE_NATIVE_FONTS:3,DISABLE_DEPTH_TEST:4,ENABLE_DEPTH_TEST:-4,ENABLE_DEPTH_SORT:5,DISABLE_DEPTH_SORT:-5,DISABLE_OPENGL_ERROR_REPORT:6,ENABLE_OPENGL_ERROR_REPORT:-6,ENABLE_ACCURATE_TEXTURES:7,DISABLE_ACCURATE_TEXTURES:-7,HINT_COUNT:10,SINCOS_LENGTH:parseInt(720,10),PRECISIONB:15,PRECISIONF:32768,PREC_MAXVAL:32767,PREC_ALPHA_SHIFT:9,PREC_RED_SHIFT:1,NORMAL_MODE_AUTO:0,NORMAL_MODE_SHAPE:1,NORMAL_MODE_VERTEX:2,MAX_LIGHTS:8}, Aa=function(d){if(d.iterator instanceof Function)return d.iterator();else if(d instanceof Array){var j=-1;this.hasNext=function(){return++j0&&typeof arguments[0]!=="number"?q=arguments[0].toArray():(q=[],q.length= 0|arguments[0]);this.get=function(d){return q[d]};this.contains=function(d){return this.indexOf(d)>-1};this.indexOf=function(d){for(var j=0,p=q.length;j=0&&d<=q.length)q.splice(d,0,arguments[1]);else throw d+" is not a valid index";else throw typeof d+" is not a number";}else throw"Please use the proper number of parameters."; };this.addAll=function(d,j){var p;if(typeof d==="number"){if(d<0||d>q.length)throw"Index out of bounds for addAll: "+d+" greater or equal than "+q.length;for(p=new Aa(j);p.hasNext();)q.splice(d++,0,p.next())}else for(p=new Aa(d);p.hasNext();)q.push(p.next())};this.set=function(){if(arguments.length===2){var d=arguments[0];if(typeof d==="number")if(d>=0&&d-1)return q.splice(d,1),!0;return!1}};this.isEmpty=function(){return!q.length};this.clone=function(){return new j(this)};this.toArray=function(){return q.slice(0)};this.iterator=function(){return new d(q)}}return j}(),ec=function(){function d(){function j(d){d=ac(d)%J.length;return d<0?J.length+d:d}function G(){if(!(E<=N*J.length)){for(var d= [],p=0;p=J.length)G=!0;else if(J[t]===q||L>=J[t].length)L=-1,++t;else break}var t=0,L=-1,G=!1;this.hasNext=function(){return!G};this.next=function(){var j=d(J[t][L]);p();return j};this.remove=function(){j(this.next());--L};p()}function u(d,j,p){this.clear=function(){O.clear()};this.contains=function(d){return j(d)}; this.containsAll=function(d){for(d=d.iterator();d.hasNext();)if(!this.contains(d.next()))return!1;return!0};this.isEmpty=function(){return O.isEmpty()};this.iterator=function(){return new z(d,p)};this.remove=function(d){if(this.contains(d))return p(d),!0;return!1};this.removeAll=function(d){for(d=d.iterator();d.hasNext();){var j=d.next();this.contains(j)&&p(j)}return!0};this.retainAll=function(d){for(var j=this.iterator(),q=[];j.hasNext();){var t=j.next();d.contains(t)||q.push(t)}for(d=0;d0};this.size=function(){return O.size()};this.toArray=function(){for(var d=[],j=this.iterator();j.hasNext();)d.push(j.next());return d}}function t(d){this._isIn=function(j){return j===O&&d.removed===q};this.equals=function(j){return ia(d.key,j.getKey())};this.getKey=function(){return d.key};this.getValue=function(){return d.value};this.hashCode=function(){return ac(d.key)};this.setValue=function(j){var p=d.value;d.value=j;return p}}if(arguments.length===1&&arguments[0].constructor=== d)return arguments[0].clone();var A=arguments.length>0?arguments[0]:16,N=arguments.length>1?arguments[1]:0.75,J=[];J.length=A;var E=0,O=this;this.clear=function(){E=0;J=[];J.length=A};this.clone=function(){var j=new d;j.putAll(this);return j};this.containsKey=function(d){var p=j(d),p=J[p];if(p===q)return!1;for(var t=0;t1?t.splice(G,1):J[p]=q,d;return null};this.size= function(){return E};this.values=function(){for(var d=[],j=this.entrySet().iterator();j.hasNext();){var p=j.next();d.push(p.getValue())}return d}}return d}(),aa=function(){function d(j,p,q){this.x=j||0;this.y=p||0;this.z=q||0}function q(d){return function(j,p){var q=j.get();q[d](p);return q}}function G(d){return function(j,p){return j[d](p)}}var z="dist dot cross".split(" "),u=z.length;d.angleBetween=function(d,p){return j.acos(d.dot(p)/(d.mag()*p.mag()))};for(d.prototype={set:function(d,j,p){arguments.length=== 1?this.set(d.x||d[0]||0,d.y||d[1]||0,d.z||d[2]||0):(this.x=d,this.y=j,this.z=p)},get:function(){return new d(this.x,this.y,this.z)},mag:function(){return j.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},add:function(d,j,p){arguments.length===3?(this.x+=d,this.y+=j,this.z+=p):arguments.length===1&&(this.x+=d.x,this.y+=d.y,this.z+=d.z)},sub:function(d,j,p){arguments.length===3?(this.x-=d,this.y-=j,this.z-=p):arguments.length===1&&(this.x-=d.x,this.y-=d.y,this.z-=d.z)},mult:function(d){typeof d=== "number"?(this.x*=d,this.y*=d,this.z*=d):typeof d==="object"&&(this.x*=d.x,this.y*=d.y,this.z*=d.z)},div:function(d){typeof d==="number"?(this.x/=d,this.y/=d,this.z/=d):typeof d==="object"&&(this.x/=d.x,this.y/=d.y,this.z/=d.z)},dist:function(d){var p=this.x-d.x,q=this.y-d.y,d=this.z-d.z;return j.sqrt(p*p+q*q+d*d)},dot:function(d,j,p){if(arguments.length===3)return this.x*d+this.y*j+this.z*p;else if(arguments.length===1)return this.x*d.x+this.y*d.y+this.z*d.z},cross:function(j){return new d(this.y* j.z-j.y*this.z,this.z*j.x-j.z*this.x,this.x*j.y-j.x*this.y)},normalize:function(){var d=this.mag();d>0&&this.div(d)},limit:function(d){this.mag()>d&&(this.normalize(),this.mult(d))},heading2D:function(){return-j.atan2(-this.y,this.x)},toString:function(){return"["+this.x+", "+this.y+", "+this.z+"]"},array:function(){return[this.x,this.y,this.z]}};u--;)d[z[u]]=G(z[u]);for(u in d.prototype)d.prototype.hasOwnProperty(u)&&!d.hasOwnProperty(u)&&(d[u]=q(u));return d}();xb.prototype=d;var W=new xb;W.ArrayList= dc;W.HashMap=ec;W.PVector=aa;W.ObjectIterator=Aa;W.defineProperty=function(d,j,q){"defineProperty"in Object?Object.defineProperty(d,j,q):(q.hasOwnProperty("get")&&d.__defineGetter__(j,q.get),q.hasOwnProperty("set")&&d.__defineSetter__(j,q.set))};W.extendClassChain=function(d){for(var j=[d],q=d.$upcast;q;q=q.$upcast)Sa(q,d),j.push(q),d=q;for(;j.length>0;)j.pop().$self=d};W.extendStaticMembers=function(d,j){Sa(d,j)};W.extendInterfaceMembers=function(d,j){Sa(d,j)};W.addMethod=function(d,j,q){if(d[j]){var z= q.length,u=d[j];d[j]=function(){return arguments.length===z?q.apply(this,arguments):u.apply(this,arguments)}}else d[j]=q};W.createJavaArray=function(d,j){var q=null;if(typeof j[0]==="number"){var z=0|j[0];if(j.length<=1){q=[];q.length=z;for(var u=0;u255?255:l)<<24&d.ALPHA_MASK|(a>255?255:a)<<16&d.RED_MASK|(b>255?255:b)<<8&d.GREEN_MASK|(f>255?255:f)&d.BLUE_MASK}function hb(){h.restore();Ma=Ib=!0}function O(a,b,f){a.addEventListener?a.addEventListener(b, f,!1):a.attachEvent("on"+b,f);ib.push({elem:a,type:b,fn:f})}function ia(a){var b=a.elem,f=a.type,a=a.fn;b.removeEventListener?b.removeEventListener(f,a,!1):b.detachEvent&&b.detachEvent("on"+f,a)}function Gc(a,b){var f=1;f<<=b-1;for(var c="",e=0;e>>=1;return c}function za(a,b,f,c,e,d){b=a<0?f:b;f=e===0;e=e===q||e<0?0:e;a=j.abs(a);if(f){e=1;for(a*=10;j.abs(j.round(a)-a)>1.0E-6&&e<7;)++e,a*=10}else e!==0&&(a*=j.pow(10,e));f=a*2;j.floor(a)===a?f=a:j.floor(f)===f?(a=j.floor(a), f=a+a%2):f=j.round(a);a="";for(c+=e;c>0||f>0;)c--,a=""+f%10+a,f=j.floor(f/10);if(d!==q)for(c=a.length-3-e;c>0;)a=a.substring(0,c)+d+a.substring(c),c-=3;return e>0?b+a.substring(0,a.length-e)+"."+a.substring(a.length-e,a.length):b+a}function Fb(a,b,f,c,e,d){if(a instanceof Array){for(var i=[],k=0,m=a.length;k2147483647&&(a-=4294967296);return a}function Ba(a){return Array.prototype.slice.call(a, 1)}function Hc(a){if(typeof a==="number")return a!==0;else if(typeof a==="boolean")return a;else if(typeof a==="string")return a.toLowerCase()==="true";else if(a instanceof ka)return a.code===49||a.code===84||a.code===116}function Ic(a){if(typeof a==="number")return a;else if(typeof a==="boolean")return a?1:0;else if(typeof a==="string")return parseFloat(a);else if(a instanceof ka)return a.code}function Jc(a,b){if(typeof a==="number")return a&4294967295;else if(typeof a==="boolean")return a?1:0;else if(typeof a=== "string")return parseInt(a,b||10)&4294967295;else if(a instanceof ka)return a.code}function Z(a,b){var f=a||362436069,c=b||521288629,e=function(){f=36969*(f&65535)+(f>>>16)&4294967295;c=18E3*(c&65535)+(c>>>16)&4294967295;return((f&65535)<<16|c&65535)&4294967295};this.nextDouble=function(){var a=e()/4294967296;return a<0?1+a:a};this.nextInt=e}function ua(a){function b(a,b,f,c){a&=15;var l=a<8?b:f,b=a<4?f:a===12||a===14?b:c;return((a&1)===0?l:-l)+((a&2)===0?b:-b)}function f(a,b,f){b=(a&1)===0?b:f;return(a& 2)===0?-b:b}function c(a,b,f){return b+a*(f-b)}var a=a!==q?new Z(a):Z.createRandomized(),e,d,i=new Fc(512);for(e=0;e<256;++e)i[e]=e;for(e=0;e<256;++e){var k=i[d=a.nextInt()&255];i[d]=i[e];i[e]=k}for(e=0;e<256;++e)i[e+256]=i[e];this.noise3d=function(a,f,e){var d=j.floor(a)&255,g=j.floor(f)&255,k=j.floor(e)&255;a-=j.floor(a);f-=j.floor(f);e-=j.floor(e);var h=(3-2*a)*a*a,o=(3-2*f)*f*f,r=i[d]+g,q=i[r]+k,r=i[r+1]+k,g=i[d+1]+g,d=i[g]+k,k=i[g+1]+k;return c((3-2*e)*e*e,c(o,c(h,b(i[q],a,f,e),b(i[d],a-1,f, e)),c(h,b(i[r],a,f-1,e),b(i[k],a-1,f-1,e))),c(o,c(h,b(i[q+1],a,f,e-1),b(i[d+1],a-1,f,e-1)),c(h,b(i[r+1],a,f-1,e-1),b(i[k+1],a-1,f-1,e-1))))};this.noise2d=function(a,b){var e=j.floor(a)&255,d=j.floor(b)&255;a-=j.floor(a);b-=j.floor(b);var g=(3-2*a)*a*a,k=i[e]+d,e=i[e+1]+d;return c((3-2*b)*b*b,c(g,f(i[k],a,b),f(i[e],a-1,b)),c(g,f(i[k+1],a,b-1),f(i[e+1],a-1,b-1)))};this.noise1d=function(a){var b=j.floor(a)&255;a-=j.floor(a);return c((3-2*a)*a*a,(i[b]&1)===0?-a:a,(i[b+1]&1)===0?-(a-1):a-1)}}function X(){if(R){if(Ma)h.fillStyle= c.color.toString(Na),Ma=!1;h.fill()}}function V(){if(I){if(Ib)h.strokeStyle=c.color.toString(ba),Ib=!1;h.stroke()}}function ud(a,b,f){f=0|f*((b&d.ALPHA_MASK)>>>24);return j.min(((a&d.ALPHA_MASK)>>>24)+f,255)<<24|c.mix(a&d.RED_MASK,b&d.RED_MASK,f)&d.RED_MASK|c.mix(a&d.GREEN_MASK,b&d.GREEN_MASK,f)&d.GREEN_MASK|c.mix(a&d.BLUE_MASK,b&d.BLUE_MASK,f)}function qa(a,b,f){var c=Kc.shift();if(c===q)c={},c.canvas=E.createElement("canvas"),c.context=c.canvas.getContext("2d");Kc.push(c);var e=c.canvas,d=c.context, b=b||a.width,f=f||a.height;e.width=b;e.height=f;a?"data"in a?d.putImageData(a,0,0):(d.clearRect(0,0,b,f),d.drawImage(a,0,0,b,f)):d.clearRect(0,0,b,f);return c}function Da(){yb&&(h=Lc,yb=!1,c.updatePixels())}function vd(){function a(a,b){a[b]=function(){Da();h[b].apply(h,arguments)}}function b(a,b){c.defineProperty(a,b,{get:function(){Da();return h[b]},set:function(a){Da();h[b]=a}})}for(var f in h)typeof h[f]==="function"?a(this,f):b(this,f)}function Za(a){this.name="sans-serif";if(a!==q)switch(a){case "sans-serif":case "serif":case "monospace":case "fantasy":case "cursive":this.name= a;break;default:this.name='"'+a+'", sans-serif'}this.origName=a}function Oa(a){return a instanceof String?a:typeof a==="number"?a===(0|a)?a.toString():c.nf(a,0,3):a===null||a===q?"":a.toString()}function Mc(a,b,f,c){this.canvas=E.createElement("canvas");this.canvas.setAttribute("width",b+"px");this.canvas.setAttribute("height",b+"px");this.ctx=this.canvas.getContext("2d");this.ctx.font=b+"pt "+a;this.ctx.fillStyle="black";this.ctx.fillRect(0,0,b,b);this.ctx.fillStyle="white";this.ctx.fillText(c,0, f);this.imageData=this.ctx.getImageData(0,0,b,b);this.get=function(a,b){return this.imageData.data[b*this.imageData.width*4+a*4]}}function Nc(a,b,f,c){var e;a.indexOf("\n")<0?(a=[a],e=1):(a=a.split(/\r?\n/g),e=a.length);var g;g=jb===d.TOP?(1-Jb)*Ua:jb===d.CENTER?(1-Jb-e/2)*Ua:jb===d.BOTTOM?(1-Jb-e)*Ua:0;for(var i=0;ie)){var i=-1,k=0,m=0,j=0;h.font=M+"px "+Y.name;for(var o=[],q=0,n=a.length;q0)i=q;else return;p==="\n"?(o.push({text:a.substring(k,q),width:m,offset:j}),k=q+1):(o.push({text:a.substring(k,i),width:m,offset:j}),k=i+1);j+=Ua;m=0;q=k-1}}ke)break; $.text$line(j.text,b+a,f+j.offset+c+i,g,kb)}}}function lb(a){$=a==="3D"?new B:a==="2D"?new v:new y;for(var b in y.prototype)y.prototype.hasOwnProperty(b)&&b.indexOf("$")<0&&(c[b]=$[b]);$.$init()}function C(a){return function(){lb("2D");return $[a].apply(this,arguments)}}function Sa(a){var b=a,f=0,l=0;c.pmouseX=c.mouseX;c.pmouseY=c.mouseY;if(b.offsetParent){do f+=b.offsetLeft,l+=b.offsetTop;while(b=b.offsetParent)}b=a;do f-=b.scrollLeft||0,l-=b.scrollTop||0;while(b=b.parentNode);f+=Pc;l+=Qc;f+=Rc; l+=Sc;f+=S.pageXOffset;l+=S.pageYOffset;return{X:f,Y:l}}function Kb(a,b){var f=Sa(a,b);c.mouseX=b.pageX-f.X;c.mouseY=b.pageY-f.Y}function Lb(a){var b=Sa(a.changedTouches[0].target,a.changedTouches[0]),f;for(f=0;f 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 );}", jd=function(a,b,f,c){return{x:a,y:b,w:f,h:c}},Xb=jd,Cd=function(a,b,f,c,e){return{x:a,y:b,w:e?f:f-a,h:e?c:c-b}},Dd=function(a,b,f,c){return{x:a-f/2,y:b-c/2,w:f,h:c}},Dc=function(a,b,f){var c=a.createShader(a.VERTEX_SHADER);a.shaderSource(c,b);a.compileShader(c);if(!a.getShaderParameter(c,a.COMPILE_STATUS))throw a.getShaderInfoLog(c);b=a.createShader(a.FRAGMENT_SHADER);a.shaderSource(b,f);a.compileShader(b);if(!a.getShaderParameter(b,a.COMPILE_STATUS))throw a.getShaderInfoLog(b);f=a.createProgram(); a.attachShader(f,c);a.attachShader(f,b);a.linkProgram(f);if(!a.getProgramParameter(f,a.LINK_STATUS))throw"Error linking shaders.";return f},F=function(){},v=function(){},B=function(){},y=function(){};v.prototype=new F;v.prototype.constructor=v;B.prototype=new F;B.prototype.constructor=B;y.prototype=new F;y.prototype.constructor=y;F.prototype.a3DOnlyFunction=function(){};var Ec={},ka=c.Character=function(a){this.code=typeof a==="string"&&a.length===1?a.charCodeAt(0):typeof a==="number"?a:a instanceof ka?a:NaN;return Ec[this.code]===q?Ec[this.code]=this:Ec[this.code]};ka.prototype.toString=function(){return String.fromCharCode(this.code)};ka.prototype.valueOf=function(){return this.code};var Db=c.PShape=function(a){this.family=a||d.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};Db.prototype={isVisible:function(){return this.visible},setVisible:function(a){this.visible= a},disableStyle:function(){this.style=!1;for(var a=0,b=this.children.length;a0){b=0;for(f=this.nameTable.length;b, it's <"+this.element.getName()+">";}else if(arguments.length===2)if(typeof arguments[1]==="string"){if(arguments[1].indexOf(".svg")>-1)this.element=new c.XMLElement(null,arguments[1]),this.vertexCodes=[],this.vertices=[],this.opacity=1,this.stroke=!1,this.strokeColor=d.ALPHA_MASK,this.strokeWeight=1,this.strokeCap=d.SQUARE,this.strokeJoin=d.MITER,this.strokeName= this.strokeGradientPaint=this.strokeGradient="",this.strokeOpacity=1,this.fill=!0,this.fillColor=d.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 a=this.element.getAttribute("transform");if(a)this.matrix=this.parseMatrix(a);a=this.element.getStringAttribute("viewBox");if(a!==null)a=a.split(" "),this.width=a[2],this.height=a[3];var a=this.element.getStringAttribute("width"),b=this.element.getStringAttribute("height");if(a!==null)this.width=this.parseUnitSize(a),this.height=this.parseUnitSize(b);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)};K.prototype=new Db;K.prototype.parseMatrix=function(){function a(a){var f=[];a.replace(/\((.*?)\)/,function(){return function(a,b){f=b.replace(/,+/g," ").split(/\s+/)}}());return f}return function(b){this.checkMatrix(2);var f=[];b.replace(/\s*(\w+)\((.*?)\)/g,function(a){f.push(c.trim(a))});if(f.length===0)return null;for(var b=0,l=f.length;b=65&&j<=90||j>=97&&j<=122){r=h;h++;if(h=65&&j<=90||j>=97&&j<=100||j>=102&&j<=122)&&q===!1;)j===32?o!==""&& (n.push(parseFloat(o)),o=""):j===45?a[h-1].valueOf()===101?o+=a[h].toString():(o!==""&&n.push(parseFloat(o)),o=a[h].toString()):o+=a[h].toString(),h++,h===a.length?q=!0:j=a[h].valueOf()}o!==""&&(n.push(parseFloat(o)),o="");s=a[r];j=s.valueOf();if(j===77){if(n.length>=2&&n.length%2===0&&(b=n[0],f=n[1],this.parsePathMoveto(b,f),n.length>2)){r=2;for(j=n.length;r=2&&n.length%2===0&&(b+=n[0],f+=n[1],this.parsePathMoveto(b, f),n.length>2)){r=2;for(j=n.length;r=2&&n.length%2===0){r=0;for(j=n.length;r=2&&n.length%2===0){r=0;for(j=n.length;r=6&&n.length%6===0){r=0;for(j=n.length;r=6&&n.length%6===0){r=0;for(j=n.length;r=4&&n.length%4===0){r=0;for(j=n.length;r=4&& n.length%4===0){r=0;for(j=n.length;r=4&&n.length%4=== 0){r=0;for(j=n.length;r=4&&n.length%4===0){r=0;for(j=n.length;r=2&&n.length%2===0){r=0;for(j=n.length;r=2&&n.length%2===0){r=0;for(j=n.length;r0)this.parsePathCode(d.BEZIER_VERTEX),this.parsePathVertex(a+(f-a)*2/3,b+(c-b)*2/3),this.parsePathVertex(e+(f-e)*2/3,g+(c-g)*2/3),this.parsePathVertex(e,g);else throw"Path must start with M/m";};K.prototype.parsePathCurveto=function(a,b,f,c,e,g){if(this.vertices.length>0)this.parsePathCode(d.BEZIER_VERTEX),this.parsePathVertex(a,b),this.parsePathVertex(f, c),this.parsePathVertex(e,g);else throw"Path must start with M/m";};K.prototype.parsePathLineto=function(a,b){if(this.vertices.length>0)this.parsePathCode(d.VERTEX),this.parsePathVertex(a,b),this.vertices[this.vertices.length-1].moveTo=!1;else throw"Path must start with M/m";};K.prototype.parsePathMoveto=function(a,b){this.vertices.length>0&&this.parsePathCode(d.BREAK);this.parsePathCode(d.VERTEX);this.parsePathVertex(a,b);this.vertices[this.vertices.length-1].moveTo=!0};K.prototype.parsePathVertex= function(a,b){var f=[];f[0]=a;f[1]=b;this.vertices.push(f)};K.prototype.parsePathCode=function(a){this.vertexCodes.push(a)};K.prototype.parsePoly=function(a){this.family=d.PATH;this.close=a;a=c.trim(this.element.getStringAttribute("points").replace(/[,\s]+/g," "));if(a!==null)if(a=a.split(" "),a.length%2===0)for(var b=0,f=a.length;b";};K.prototype.parseEllipse=function(a){this.kind=d.ELLIPSE;this.family=d.PRIMITIVE;this.params=[];this.params[0]=this.element.getFloatAttribute("cx")| 0;this.params[1]=this.element.getFloatAttribute("cy")|0;var b;if(a){if(a=b=this.element.getFloatAttribute("r"),a<0)throw"svg error: negative radius found while parsing ";}else if(a=this.element.getFloatAttribute("rx"),b=this.element.getFloatAttribute("ry"),a<0||b<0)throw"svg error: negative x-axis radius or y-axis radius found while parsing ";this.params[0]-=a;this.params[1]-=b;this.params[2]=a*2;this.params[3]=b*2};K.prototype.parseLine=function(){this.kind=d.LINE;this.family=d.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")};K.prototype.parseColors=function(a){a.hasAttribute("opacity")&&this.setOpacity(a.getAttribute("opacity"));a.hasAttribute("stroke")&&this.setStroke(a.getAttribute("stroke"));a.hasAttribute("stroke-width")&&this.setStrokeWeight(a.getAttribute("stroke-width"));a.hasAttribute("stroke-linejoin")&& this.setStrokeJoin(a.getAttribute("stroke-linejoin"));a.hasAttribute("stroke-linecap")&&this.setStrokeCap(a.getStringAttribute("stroke-linecap"));a.hasAttribute("fill")&&this.setFill(a.getStringAttribute("fill"));if(a.hasAttribute("style"))for(var a=a.getStringAttribute("style").toString().split(";"),b=0,f=a.length;b=1&&arguments[0]!==null&&a.isVisible()&&(c.pushMatrix(),Cb===d.CENTER?arguments.length===5?(c.translate(b-l/2,f-e/2),c.scale(l/a.getWidth(),e/a.getHeight())):arguments.length===3?c.translate(b-a.getWidth()/2,-a.getHeight()/2):c.translate(-a.getWidth()/2,-a.getHeight()/2):Cb===d.CORNER?arguments.length===5?(c.translate(b,f),c.scale(l/a.getWidth(),e/a.getHeight())):arguments.length===3&&c.translate(b,f):Cb===d.CORNERS&&(arguments.length===5?(l-=b,e-=f,c.translate(b, f),c.scale(l/a.getWidth(),e/a.getHeight())):arguments.length===3&&c.translate(b,f)),a.draw(),(arguments.length===1&&Cb===d.CENTER||arguments.length>1)&&c.popMatrix())};c.shapeMode=function(a){Cb=a};c.loadShape=function(a){if(arguments.length===1&&a.indexOf(".svg")>-1)return new K(null,a);return null};var Yb=function(a,b,f,c,e){this.fullName=a||"";this.name=b||"";this.namespace=f||"";this.value=c;this.type=e};Yb.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(a){this.value=a}};var Ya=c.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 a=this.fullName.indexOf(":");this.name=a>=0?this.fullName.substring(a+ 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])};Ya.prototype={parse:function(a){var b;try{if(a.indexOf(".xml")>-1||a.indexOf(".svg")>-1)a=cc(a);b=(new DOMParser).parseFromString(a,"text/xml");var f=b.documentElement;if(f)this.parseChildrenRecursive(null,f);else throw"Error loading document"; return this}catch(c){throw c;}},parseChildrenRecursive:function(a,b){var f,c,e,d;a?(f=new Ya(b.localName,b.nodeName,"",""),f.parent=a):(this.fullName=b.localName,this.name=b.nodeName,f=this);if(b.nodeType===3&&b.textContent!=="")return this.createPCDataElement(b.textContent);e=0;for(d=b.attributes.length;e0){b=0;for(f=this.children.length;b 0},addChild:function(a){if(a!==null)a.parent=this,this.children.push(a)},insertChild:function(a,b){if(a){if(a.getLocalName()===null&&!this.hasChildren()){var f=this.children[this.children.length-1];if(f.getLocalName()===null){f.setContent(f.getContent()+a.getContent());return}}a.parent=this;this.children.splice(b,0,a)}},getChild:function(a){if(typeof a==="number")return this.children[a];else if(a.indexOf("/")!==-1)this.getChildRecursive(a.split("/"),0);else{for(var b,f,c=0,e=this.getChildCount();c< e;c++)if(b=this.getChild(c),f=b.getName(),f!==null&&f===a)return b;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 a=[],b,f,c=0,e=this.getChildCount();ca&&this.children.splice(a,1)},findAttribute:function(a, b){this.namespace=b||"";for(var f=0,c=this.attributes.length;f0&&A.debug("Tried to set content for XMLElement with children");this.content=a},setName:function(){if(arguments.length===1)this.name=arguments[0],this.fullName=arguments[0],this.namespace=null;else{var a= arguments[0].indexOf(":");this.name=arguments[1]===null||a<0?arguments[0]:arguments[0].substring(a+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 a=(this.namespace!==""&&this.namespace!==this.name?this.namespace+":":"")+this.name,b="<"+a,f;for(f=0;f":">"+this.content+"";else{b+=">";for(f=0;f"}return b}};Ya.parse=function(a){var b=new Ya;b.parse(a);return b};var kd=function(a){for(var b=0,f=0;fd.MIN_INT){var b=this.elements[0],f=this.elements[1],c=this.elements[2],e=this.elements[3],g=this.elements[4],i=this.elements[5];this.elements[0]=g/a;this.elements[3]=-e/a;this.elements[1]=-f/a;this.elements[4]=b/a;this.elements[2]=(f*i-g*c)/a;this.elements[5]=(e*c-b*i)/a;return!0}return!1}, scale:function(a,b){a&&!b&&(b=a);a&&b&&(this.elements[0]*=a,this.elements[1]*=b,this.elements[3]*=a,this.elements[4]*=b)},invScale:function(a,b){a&&!b&&(b=a);this.scale(1/a,1/b)},apply:function(){var a;arguments.length===1&&arguments[0]instanceof Pa?a=arguments[0].array():arguments.length===6?a=Array.prototype.slice.call(arguments):arguments.length===1&&arguments[0]instanceof Array&&(a=arguments[0]);for(var b=[0,0,this.elements[2],0,0,this.elements[5]],f=0,c=0;c<2;c++)for(var e=0;e<3;e++,f++)b[f]+= this.elements[c*3+0]*a[e+0]+this.elements[c*3+1]*a[e+3];this.elements=b.slice()},preApply:function(){var a;arguments.length===1&&arguments[0]instanceof Pa?a=arguments[0].array():arguments.length===6?a=Array.prototype.slice.call(arguments):arguments.length===1&&arguments[0]instanceof Array&&(a=arguments[0]);var b=[0,0,a[2],0,0,a[5]];b[2]=a[2]+this.elements[2]*a[0]+this.elements[5]*a[1];b[5]=a[5]+this.elements[2]*a[3]+this.elements[5]*a[4];b[0]=this.elements[0]*a[0]+this.elements[3]*a[1];b[3]=this.elements[0]* a[3]+this.elements[3]*a[4];b[1]=this.elements[1]*a[0]+this.elements[4]*a[1];b[4]=this.elements[1]*a[3]+this.elements[4]*a[4];this.elements=b.slice()},rotate:function(a){var b=j.cos(a),a=j.sin(a),f=this.elements[0],c=this.elements[1];this.elements[0]=b*f+a*c;this.elements[1]=-a*f+b*c;f=this.elements[3];c=this.elements[4];this.elements[3]=b*f+a*c;this.elements[4]=-a*f+b*c},rotateZ:function(a){this.rotate(a)},invRotateZ:function(a){this.rotateZ(a-j.PI)},print:function(){var a=kd(this.elements),a=""+ c.nfs(this.elements[0],a,4)+" "+c.nfs(this.elements[1],a,4)+" "+c.nfs(this.elements[2],a,4)+"\n"+c.nfs(this.elements[3],a,4)+" "+c.nfs(this.elements[4],a,4)+" "+c.nfs(this.elements[5],a,4)+"\n\n";c.println(a)}};var w=c.PMatrix3D=function(){this.reset()};w.prototype={set:function(){if(arguments.length===16)this.elements=Array.prototype.slice.call(arguments);else if(arguments.length===1&&arguments[0]instanceof w)this.elements=arguments[0].array();else if(arguments.length===1&&arguments[0]instanceof Array)this.elements=arguments[0].slice()},get:function(){var a=new w;a.set(this.elements);return a},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(a,b,f){f===q&&(f=0);this.elements[3]+=a*this.elements[0]+b*this.elements[1]+f*this.elements[2];this.elements[7]+=a*this.elements[4]+b*this.elements[5]+f*this.elements[6];this.elements[11]+=a*this.elements[8]+b*this.elements[9]+f*this.elements[10];this.elements[15]+=a*this.elements[12]+ b*this.elements[13]+f*this.elements[14]},transpose:function(){var a=this.elements.slice();this.elements[0]=a[0];this.elements[1]=a[4];this.elements[2]=a[8];this.elements[3]=a[12];this.elements[4]=a[1];this.elements[5]=a[5];this.elements[6]=a[9];this.elements[7]=a[13];this.elements[8]=a[2];this.elements[9]=a[6];this.elements[10]=a[10];this.elements[11]=a[14];this.elements[12]=a[3];this.elements[13]=a[7];this.elements[14]=a[11];this.elements[15]=a[15]},mult:function(a,b){var f,c,e,d;if(a instanceof aa)f=a.x,c=a.y,e=a.z,d=1,b||(b=new aa);else if(a instanceof Array&&(f=a[0],c=a[1],e=a[2],d=a[3]||1,!b||b.length!==3&&b.length!==4))b=[0,0,0];b instanceof Array&&(b.length===3?(b[0]=this.elements[0]*f+this.elements[1]*c+this.elements[2]*e+this.elements[3],b[1]=this.elements[4]*f+this.elements[5]*c+this.elements[6]*e+this.elements[7],b[2]=this.elements[8]*f+this.elements[9]*c+this.elements[10]*e+this.elements[11]):b.length===4&&(b[0]=this.elements[0]*f+this.elements[1]*c+this.elements[2]*e+this.elements[3]* d,b[1]=this.elements[4]*f+this.elements[5]*c+this.elements[6]*e+this.elements[7]*d,b[2]=this.elements[8]*f+this.elements[9]*c+this.elements[10]*e+this.elements[11]*d,b[3]=this.elements[12]*f+this.elements[13]*c+this.elements[14]*e+this.elements[15]*d));if(b instanceof aa)b.x=this.elements[0]*f+this.elements[1]*c+this.elements[2]*e+this.elements[3],b.y=this.elements[4]*f+this.elements[5]*c+this.elements[6]*e+this.elements[7],b.z=this.elements[8]*f+this.elements[9]*c+this.elements[10]*e+this.elements[11]; return b},preApply:function(){var a;arguments.length===1&&arguments[0]instanceof w?a=arguments[0].array():arguments.length===16?a=Array.prototype.slice.call(arguments):arguments.length===1&&arguments[0]instanceof Array&&(a=arguments[0]);for(var b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=0,c=0;c<4;c++)for(var e=0;e<4;e++,f++)b[f]+=this.elements[e+0]*a[c*4+0]+this.elements[e+4]*a[c*4+1]+this.elements[e+8]*a[c*4+2]+this.elements[e+12]*a[c*4+3];this.elements=b.slice()},apply:function(){var a;arguments.length=== 1&&arguments[0]instanceof w?a=arguments[0].array():arguments.length===16?a=Array.prototype.slice.call(arguments):arguments.length===1&&arguments[0]instanceof Array&&(a=arguments[0]);for(var b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=0,c=0;c<4;c++)for(var e=0;e<4;e++,f++)b[f]+=this.elements[c*4+0]*a[e+0]+this.elements[c*4+1]*a[e+4]+this.elements[c*4+2]*a[e+8]+this.elements[c*4+3]*a[e+12];this.elements=b.slice()},rotate:function(a,b,f,d){if(f){var e=c.cos(a),a=c.sin(a),g=1-e;this.apply(g*b*b+e,g*b*f-a*d, g*b*d+a*f,0,g*b*f+a*d,g*f*f+e,g*f*d-a*b,0,g*b*d-a*f,g*f*d+a*b,g*d*d+e,0,0,0,0,1)}else this.rotateZ(a)},invApply:function(){Bb===q&&(Bb=new w);var a=arguments;Bb.set(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15]);if(!Bb.invert())return!1;this.preApply(Bb);return!0},rotateX:function(a){var b=c.cos(a),a=c.sin(a);this.apply([1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1])},rotateY:function(a){var b=c.cos(a),a=c.sin(a);this.apply([b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1])},rotateZ:function(a){var b= j.cos(a),a=j.sin(a);this.apply([b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1])},scale:function(a,b,f){a&&!b&&!f?b=f=a:a&&b&&!f&&(f=1);a&&b&&f&&(this.elements[0]*=a,this.elements[1]*=b,this.elements[2]*=f,this.elements[4]*=a,this.elements[5]*=b,this.elements[6]*=f,this.elements[8]*=a,this.elements[9]*=b,this.elements[10]*=f,this.elements[12]*=a,this.elements[13]*=b,this.elements[14]*=f)},skewX:function(a){this.apply(1,j.tan(a),0,0,0,1,0,0,0,0,1,0,0,0,0,1)},skewY:function(a){this.apply(1,0,0,0,j.tan(a),1,0,0,0, 0,1,0,0,0,0,1)},multX:function(a,b,f,c){return f?c?this.elements[0]*a+this.elements[1]*b+this.elements[2]*f+this.elements[3]*c:this.elements[0]*a+this.elements[1]*b+this.elements[2]*f+this.elements[3]:this.elements[0]*a+this.elements[1]*b+this.elements[3]},multY:function(a,b,f,c){return f?c?this.elements[4]*a+this.elements[5]*b+this.elements[6]*f+this.elements[7]*c:this.elements[4]*a+this.elements[5]*b+this.elements[6]*f+this.elements[7]:this.elements[4]*a+this.elements[5]*b+this.elements[7]},multZ:function(a, b,f,c){return c?this.elements[8]*a+this.elements[9]*b+this.elements[10]*f+this.elements[11]*c:this.elements[8]*a+this.elements[9]*b+this.elements[10]*f+this.elements[11]},multW:function(a,b,f,c){return c?this.elements[12]*a+this.elements[13]*b+this.elements[14]*f+this.elements[15]*c:this.elements[12]*a+this.elements[13]*b+this.elements[14]*f+this.elements[15]},invert:function(){var a=this.elements[0]*this.elements[5]-this.elements[1]*this.elements[4],b=this.elements[0]*this.elements[6]-this.elements[2]* this.elements[4],f=this.elements[0]*this.elements[7]-this.elements[3]*this.elements[4],c=this.elements[1]*this.elements[6]-this.elements[2]*this.elements[5],e=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],i=this.elements[8]*this.elements[13]-this.elements[9]*this.elements[12],k=this.elements[8]*this.elements[14]-this.elements[10]*this.elements[12],m=this.elements[8]*this.elements[15]-this.elements[11]*this.elements[12], h=this.elements[9]*this.elements[14]-this.elements[10]*this.elements[13],o=this.elements[9]*this.elements[15]-this.elements[11]*this.elements[13],q=this.elements[10]*this.elements[15]-this.elements[11]*this.elements[14],n=a*q-b*o+f*h+c*m-e*k+d*i;if(j.abs(n)<=1.0E-9)return!1;var p=[];p[0]=+this.elements[5]*q-this.elements[6]*o+this.elements[7]*h;p[4]=-this.elements[4]*q+this.elements[6]*m-this.elements[7]*k;p[8]=+this.elements[4]*o-this.elements[5]*m+this.elements[7]*i;p[12]=-this.elements[4]*h+this.elements[5]* k-this.elements[6]*i;p[1]=-this.elements[1]*q+this.elements[2]*o-this.elements[3]*h;p[5]=+this.elements[0]*q-this.elements[2]*m+this.elements[3]*k;p[9]=-this.elements[0]*o+this.elements[1]*m-this.elements[3]*i;p[13]=+this.elements[0]*h-this.elements[1]*k+this.elements[2]*i;p[2]=+this.elements[13]*d-this.elements[14]*e+this.elements[15]*c;p[6]=-this.elements[12]*d+this.elements[14]*f-this.elements[15]*b;p[10]=+this.elements[12]*e-this.elements[13]*f+this.elements[15]*a;p[14]=-this.elements[12]*c+this.elements[13]* b-this.elements[14]*a;p[3]=-this.elements[9]*d+this.elements[10]*e-this.elements[11]*c;p[7]=+this.elements[8]*d-this.elements[10]*f+this.elements[11]*b;p[11]=-this.elements[8]*e+this.elements[9]*f-this.elements[11]*a;p[15]=+this.elements[8]*c-this.elements[9]*b+this.elements[10]*a;a=1/n;p[0]*=a;p[1]*=a;p[2]*=a;p[3]*=a;p[4]*=a;p[5]*=a;p[6]*=a;p[7]*=a;p[8]*=a;p[9]*=a;p[10]*=a;p[11]*=a;p[12]*=a;p[13]*=a;p[14]*=a;p[15]*=a;this.elements=p.slice();return!0},toString:function(){for(var a="",b=0;b<15;b++)a+= this.elements[b]+", ";a+=this.elements[15];return a},print:function(){var a=kd(this.elements),a=""+c.nfs(this.elements[0],a,4)+" "+c.nfs(this.elements[1],a,4)+" "+c.nfs(this.elements[2],a,4)+" "+c.nfs(this.elements[3],a,4)+"\n"+c.nfs(this.elements[4],a,4)+" "+c.nfs(this.elements[5],a,4)+" "+c.nfs(this.elements[6],a,4)+" "+c.nfs(this.elements[7],a,4)+"\n"+c.nfs(this.elements[8],a,4)+" "+c.nfs(this.elements[9],a,4)+" "+c.nfs(this.elements[10],a,4)+" "+c.nfs(this.elements[11],a,4)+"\n"+c.nfs(this.elements[12], a,4)+" "+c.nfs(this.elements[13],a,4)+" "+c.nfs(this.elements[14],a,4)+" "+c.nfs(this.elements[15],a,4)+"\n\n";c.println(a)},invTranslate:function(a,b,f){this.preApply(1,0,0,-a,0,1,0,-b,0,0,1,-f,0,0,0,1)},invRotateX:function(a){var b=j.cos(-a),a=j.sin(-a);this.preApply([1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1])},invRotateY:function(a){var b=j.cos(-a),a=j.sin(-a);this.preApply([b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1])},invRotateZ:function(a){var b=j.cos(-a),a=j.sin(-a);this.preApply([b,-a,0,0,a,b,0,0,0,0,1,0,0, 0,0,1])},invScale:function(a,b,f){this.preApply([1/a,0,0,0,0,1/b,0,0,0,0,1/f,0,0,0,0,1])}};var Qa=c.PMatrixStack=function(){this.matrixStack=[]};Qa.prototype.load=function(){var a=$.$newPMatrix();arguments.length===1?a.set(arguments[0]):a.set(arguments);this.matrixStack.push(a)};v.prototype.$newPMatrix=function(){return new Pa};B.prototype.$newPMatrix=function(){return new w};Qa.prototype.push=function(){this.matrixStack.push(this.peek())};Qa.prototype.pop=function(){return this.matrixStack.pop()}; Qa.prototype.peek=function(){var a=$.$newPMatrix();a.set(this.matrixStack[this.matrixStack.length-1]);return a};Qa.prototype.mult=function(a){this.matrixStack[this.matrixStack.length-1].apply(a)};c.split=function(a,b){return a.split(b)};c.splitTokens=function(a,b){arguments.length===1&&(b="\n\t\r\u000c ");for(var b="["+b+"]",f=[],c=0,e=a.search(b);e>=0;)e===0?a=a.substring(1):(f[c]=a.substring(0,e),c++,a=a.substring(e)),e=a.search(b);a.length>0&&(f[c]=a);f.length===0&&(f=q);return f};c.append=function(a, b){a[a.length]=b;return a};c.concat=function(a,b){return a.concat(b)};c.sort=function(a,b){var f=[];if(a.length>0){for(var c=b>0?b:a.length,e=0;e0)for(c=f.length;c>8)};c.peg=function(a){return a<0?0:a>255?255:a};c.modes={replace:function(a,b){return b},blend:function(a,b){var f=(b&d.ALPHA_MASK)>>>24;return j.min(((a&d.ALPHA_MASK)>>>24)+f,255)<<24|c.mix(a&d.RED_MASK,b&d.RED_MASK,f)&d.RED_MASK| c.mix(a&d.GREEN_MASK,b&d.GREEN_MASK,f)&d.GREEN_MASK|c.mix(a&d.BLUE_MASK,b&d.BLUE_MASK,f)},add:function(a,b){var c=(b&d.ALPHA_MASK)>>>24;return j.min(((a&d.ALPHA_MASK)>>>24)+c,255)<<24|j.min((a&d.RED_MASK)+((b&d.RED_MASK)>>8)*c,d.RED_MASK)&d.RED_MASK|j.min((a&d.GREEN_MASK)+((b&d.GREEN_MASK)>>8)*c,d.GREEN_MASK)&d.GREEN_MASK|j.min((a&d.BLUE_MASK)+((b&d.BLUE_MASK)*c>>8),d.BLUE_MASK)},subtract:function(a,b){var c=(b&d.ALPHA_MASK)>>>24;return j.min(((a&d.ALPHA_MASK)>>>24)+c,255)<<24|j.max((a&d.RED_MASK)- ((b&d.RED_MASK)>>8)*c,d.GREEN_MASK)&d.RED_MASK|j.max((a&d.GREEN_MASK)-((b&d.GREEN_MASK)>>8)*c,d.BLUE_MASK)&d.GREEN_MASK|j.max((a&d.BLUE_MASK)-((b&d.BLUE_MASK)*c>>8),0)},lightest:function(a,b){var c=(b&d.ALPHA_MASK)>>>24;return j.min(((a&d.ALPHA_MASK)>>>24)+c,255)<<24|j.max(a&d.RED_MASK,((b&d.RED_MASK)>>8)*c)&d.RED_MASK|j.max(a&d.GREEN_MASK,((b&d.GREEN_MASK)>>8)*c)&d.GREEN_MASK|j.max(a&d.BLUE_MASK,(b&d.BLUE_MASK)*c>>8)},darkest:function(a,b){var f=(b&d.ALPHA_MASK)>>>24;return j.min(((a&d.ALPHA_MASK)>>> 24)+f,255)<<24|c.mix(a&d.RED_MASK,j.min(a&d.RED_MASK,((b&d.RED_MASK)>>8)*f),f)&d.RED_MASK|c.mix(a&d.GREEN_MASK,j.min(a&d.GREEN_MASK,((b&d.GREEN_MASK)>>8)*f),f)&d.GREEN_MASK|c.mix(a&d.BLUE_MASK,j.min(a&d.BLUE_MASK,(b&d.BLUE_MASK)*f>>8),f)},difference:function(a,b){var f=(b&d.ALPHA_MASK)>>>24,l=(a&d.RED_MASK)>>16,e=(a&d.GREEN_MASK)>>8,g=a&d.BLUE_MASK,i=(b&d.RED_MASK)>>16,k=(b&d.GREEN_MASK)>>8,m=b&d.BLUE_MASK,i=l>i?l-i:i-l,k=e>k?e-k:k-e,m=g>m?g-m:m-g;return j.min(((a&d.ALPHA_MASK)>>>24)+f,255)<<24|c.peg(l+ ((i-l)*f>>8))<<16|c.peg(e+((k-e)*f>>8))<<8|c.peg(g+((m-g)*f>>8))},exclusion:function(a,b){var f=(b&d.ALPHA_MASK)>>>24,l=(a&d.RED_MASK)>>16,e=(a&d.GREEN_MASK)>>8,g=a&d.BLUE_MASK,i=(b&d.RED_MASK)>>16,k=(b&d.GREEN_MASK)>>8,m=b&d.BLUE_MASK,i=l+i-(l*i>>7),k=e+k-(e*k>>7),m=g+m-(g*m>>7);return j.min(((a&d.ALPHA_MASK)>>>24)+f,255)<<24|c.peg(l+((i-l)*f>>8))<<16|c.peg(e+((k-e)*f>>8))<<8|c.peg(g+((m-g)*f>>8))},multiply:function(a,b){var f=(b&d.ALPHA_MASK)>>>24,l=(a&d.RED_MASK)>>16,e=(a&d.GREEN_MASK)>>8,g=a& d.BLUE_MASK,i=l*((b&d.RED_MASK)>>16)>>8,k=e*((b&d.GREEN_MASK)>>8)>>8,m=g*(b&d.BLUE_MASK)>>8;return j.min(((a&d.ALPHA_MASK)>>>24)+f,255)<<24|c.peg(l+((i-l)*f>>8))<<16|c.peg(e+((k-e)*f>>8))<<8|c.peg(g+((m-g)*f>>8))},screen:function(a,b){var f=(b&d.ALPHA_MASK)>>>24,l=(a&d.RED_MASK)>>16,e=(a&d.GREEN_MASK)>>8,g=a&d.BLUE_MASK,i=255-((255-l)*(255-((b&d.RED_MASK)>>16))>>8),k=255-((255-e)*(255-((b&d.GREEN_MASK)>>8))>>8),m=255-((255-g)*(255-(b&d.BLUE_MASK))>>8);return j.min(((a&d.ALPHA_MASK)>>>24)+f,255)<< 24|c.peg(l+((i-l)*f>>8))<<16|c.peg(e+((k-e)*f>>8))<<8|c.peg(g+((m-g)*f>>8))},hard_light:function(a,b){var f=(b&d.ALPHA_MASK)>>>24,l=(a&d.RED_MASK)>>16,e=(a&d.GREEN_MASK)>>8,g=a&d.BLUE_MASK,i=(b&d.RED_MASK)>>16,k=(b&d.GREEN_MASK)>>8,m=b&d.BLUE_MASK,i=i<128?l*i>>7:255-((255-l)*(255-i)>>7),k=k<128?e*k>>7:255-((255-e)*(255-k)>>7),m=m<128?g*m>>7:255-((255-g)*(255-m)>>7);return j.min(((a&d.ALPHA_MASK)>>>24)+f,255)<<24|c.peg(l+((i-l)*f>>8))<<16|c.peg(e+((k-e)*f>>8))<<8|c.peg(g+((m-g)*f>>8))},soft_light:function(a, b){var f=(b&d.ALPHA_MASK)>>>24,l=(a&d.RED_MASK)>>16,e=(a&d.GREEN_MASK)>>8,g=a&d.BLUE_MASK,i=(b&d.RED_MASK)>>16,k=(b&d.GREEN_MASK)>>8,m=b&d.BLUE_MASK,i=(l*i>>7)+(l*l>>8)-(l*l*i>>15),k=(e*k>>7)+(e*e>>8)-(e*e*k>>15),m=(g*m>>7)+(g*g>>8)-(g*g*m>>15);return j.min(((a&d.ALPHA_MASK)>>>24)+f,255)<<24|c.peg(l+((i-l)*f>>8))<<16|c.peg(e+((k-e)*f>>8))<<8|c.peg(g+((m-g)*f>>8))},overlay:function(a,b){var f=(b&d.ALPHA_MASK)>>>24,l=(a&d.RED_MASK)>>16,e=(a&d.GREEN_MASK)>>8,g=a&d.BLUE_MASK,i=(b&d.RED_MASK)>>16,k=(b& d.GREEN_MASK)>>8,m=b&d.BLUE_MASK,i=l<128?l*i>>7:255-((255-l)*(255-i)>>7),k=e<128?e*k>>7:255-((255-e)*(255-k)>>7),m=g<128?g*m>>7:255-((255-g)*(255-m)>>7);return j.min(((a&d.ALPHA_MASK)>>>24)+f,255)<<24|c.peg(l+((i-l)*f>>8))<<16|c.peg(e+((k-e)*f>>8))<<8|c.peg(g+((m-g)*f>>8))},dodge:function(a,b){var f=(b&d.ALPHA_MASK)>>>24,l=(a&d.RED_MASK)>>16,e=(a&d.GREEN_MASK)>>8,g=a&d.BLUE_MASK,i=(b&d.RED_MASK)>>16,k=(b&d.GREEN_MASK)>>8,m=b&d.BLUE_MASK,i=i===255?255:c.peg((l<<8)/(255-i)),k=k===255?255:c.peg((e<< 8)/(255-k)),m=m===255?255:c.peg((g<<8)/(255-m));return j.min(((a&d.ALPHA_MASK)>>>24)+f,255)<<24|c.peg(l+((i-l)*f>>8))<<16|c.peg(e+((k-e)*f>>8))<<8|c.peg(g+((m-g)*f>>8))},burn:function(a,b){var f=(b&d.ALPHA_MASK)>>>24,l=(a&d.RED_MASK)>>16,e=(a&d.GREEN_MASK)>>8,g=a&d.BLUE_MASK,i=(b&d.RED_MASK)>>16,k=(b&d.GREEN_MASK)>>8,m=b&d.BLUE_MASK,i=i===0?0:255-c.peg((255-l<<8)/i),k=k===0?0:255-c.peg((255-e<<8)/k),m=m===0?0:255-c.peg((255-g<<8)/m);return j.min(((a&d.ALPHA_MASK)>>>24)+f,255)<<24|c.peg(l+((i-l)*f>> 8))<<16|c.peg(e+((k-e)*f>>8))<<8|c.peg(g+((m-g)*f>>8))}};c.color=function(a,b,c,l){if(a!==q&&b!==q&&c!==q&&l!==q)return J(a,b,c,l);if(a!==q&&b!==q&&c!==q)return J(a,b,c,fa);if(a!==q&&b!==q){var e;a&d.ALPHA_MASK?(b=j.round(255*(b/fa)),e=a-(a&d.ALPHA_MASK)+((b>255?255:b)<<24&d.ALPHA_MASK)):Ta===d.RGB?e=J(a,a,a,b):Ta===d.HSB&&(e=J(0,0,a/ja*na,b));return e}if(typeof a==="number"){var g;a<=ja&&a>=0?Ta===d.RGB?g=J(a,a,a,fa):Ta===d.HSB&&(g=J(0,0,a/ja*na,fa)):a&&(g=a);return g}return J(ja,wa,na,fa)};c.color.toString= function(a){return"rgba("+((a&d.RED_MASK)>>>16)+","+((a&d.GREEN_MASK)>>>8)+","+(a&d.BLUE_MASK)+","+((a&d.ALPHA_MASK)>>>24)/255+")"};c.color.toInt=function(a,b,c,l){return l<<24&d.ALPHA_MASK|a<<16&d.RED_MASK|b<<8&d.GREEN_MASK|c&d.BLUE_MASK};c.color.toArray=function(a){return[(a&d.RED_MASK)>>>16,(a&d.GREEN_MASK)>>>8,a&d.BLUE_MASK,(a&d.ALPHA_MASK)>>>24]};c.color.toGLArray=function(a){return[((a&d.RED_MASK)>>>16)/255,((a&d.GREEN_MASK)>>>8)/255,(a&d.BLUE_MASK)/255,((a&d.ALPHA_MASK)>>>24)/255]};c.color.toRGB= function(a,b,c){var a=a>ja?ja:a,b=b>wa?wa:b,c=c>na?na:c,a=a/ja*360,b=b/wa*100,c=c/na*100,d=j.round(c/100*255);if(b===0)return[d,d,d];else{a%=360;var e=a%60,g=j.round(c*(100-b)/1E4*255),i=j.round(c*(6E3-b*e)/6E5*255),b=j.round(c*(6E3-b*(60-e))/6E5*255);switch(j.floor(a/60)){case 0:return[d,b,g];case 1:return[i,d,g];case 2:return[g,d,b];case 3:return[g,i,d];case 4:return[b,g,d];case 5:return[d,g,i]}}};c.color.toHSB=function(a){var b,f,l;b=((a&d.RED_MASK)>>>16)/255;f=((a&d.GREEN_MASK)>>>8)/255;l=(a& d.BLUE_MASK)/255;var a=c.max(c.max(b,f),l),e=c.min(c.min(b,f),l);if(e===a)return[0,0,a];else b=b===a?(f-l)/(a-e):f===a?2+(l-b)/(a-e):4+(b-f)/(a-e),b/=6,b<0?b+=1:b>1&&(b-=1);return[b*ja,(a-e)/a*wa,a*na]};c.brightness=function(a){return c.color.toHSB(a)[2]};c.saturation=function(a){return c.color.toHSB(a)[1]};c.hue=function(a){return c.color.toHSB(a)[0]};c.red=function(a){return((a&d.RED_MASK)>>>16)/255*ja};c.green=function(a){return((a&d.GREEN_MASK)>>>8)/255*wa};c.blue=function(a){return(a&d.BLUE_MASK)/ 255*na};c.alpha=function(a){return((a&d.ALPHA_MASK)>>>24)/255*fa};c.lerpColor=function(a,b,f){var l=c.color(a),e=(l&d.RED_MASK)>>>16,g=(l&d.GREEN_MASK)>>>8,a=l&d.BLUE_MASK,l=((l&d.ALPHA_MASK)>>>24)/fa,i=c.color(b),k=(i&d.GREEN_MASK)>>>8,m=i&d.BLUE_MASK,b=((i&d.ALPHA_MASK)>>>24)/fa,e=parseInt(c.lerp(e,(i&d.RED_MASK)>>>16,f),10),g=parseInt(c.lerp(g,k,f),10),a=parseInt(c.lerp(a,m,f),10),f=parseFloat(c.lerp(l,b,f)*fa);return c.color.toInt(e,g,a,f)};c.colorMode=function(){Ta=arguments[0];arguments.length> 1&&(ja=arguments[1],wa=arguments[2]||arguments[1],na=arguments[3]||arguments[1],fa=arguments[4]||arguments[1])};c.blendColor=function(a,b,f){var l=0;switch(f){case d.REPLACE:l=c.modes.replace(a,b);break;case d.BLEND:l=c.modes.blend(a,b);break;case d.ADD:l=c.modes.add(a,b);break;case d.SUBTRACT:l=c.modes.subtract(a,b);break;case d.LIGHTEST:l=c.modes.lightest(a,b);break;case d.DARKEST:l=c.modes.darkest(a,b);break;case d.DIFFERENCE:l=c.modes.difference(a,b);break;case d.EXCLUSION:l=c.modes.exclusion(a, b);break;case d.MULTIPLY:l=c.modes.multiply(a,b);break;case d.SCREEN:l=c.modes.screen(a,b);break;case d.HARD_LIGHT:l=c.modes.hard_light(a,b);break;case d.SOFT_LIGHT:l=c.modes.soft_light(a,b);break;case d.OVERLAY:l=c.modes.overlay(a,b);break;case d.DODGE:l=c.modes.dodge(a,b);break;case d.BURN:l=c.modes.burn(a,b)}return l};c.printMatrix=function(){Q.print()};v.prototype.translate=function(a,b){ca.translate(a,b);da.invTranslate(a,b);h.translate(a,b)};B.prototype.translate=function(a,b,c){ca.translate(a, b,c);da.invTranslate(a,b,c)};v.prototype.scale=function(a,b){ca.scale(a,b);da.invScale(a,b);h.scale(a,b||a)};B.prototype.scale=function(a,b,c){ca.scale(a,b,c);da.invScale(a,b,c)};v.prototype.pushMatrix=function(){sb.load(Q);tb.load(Ia);h.save()};B.prototype.pushMatrix=function(){sb.load(Q);tb.load(Ia)};v.prototype.popMatrix=function(){Q.set(sb.pop());Ia.set(tb.pop());hb()};B.prototype.popMatrix=function(){Q.set(sb.pop());Ia.set(tb.pop())};v.prototype.resetMatrix=function(){ca.reset();da.reset();h.setTransform(1, 0,0,1,0,0)};B.prototype.resetMatrix=function(){ca.reset();da.reset()};F.prototype.applyMatrix=function(){var a=arguments;ca.apply(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15]);da.invApply(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15])};v.prototype.applyMatrix=function(){for(var a=arguments,b=a.length;b<16;b++)a[b]=0;a[10]=a[15]=1;F.prototype.applyMatrix.apply(this,a)};c.rotateX=function(a){ca.rotateX(a);da.invRotateX(a)}; v.prototype.rotateZ=function(){throw"rotateZ() is not supported in 2D mode. Use rotate(float) instead.";};B.prototype.rotateZ=function(a){ca.rotateZ(a);da.invRotateZ(a)};c.rotateY=function(a){ca.rotateY(a);da.invRotateY(a)};v.prototype.rotate=function(a){ca.rotateZ(a);da.invRotateZ(a);h.rotate(a)};B.prototype.rotate=function(a){c.rotateZ(a)};c.pushStyle=function(){h.save();c.pushMatrix();gd.push({doFill:R,currentFillColor:Na,doStroke:I,currentStrokeColor:ba,curTint:cb,curRectMode:bb,curColorMode:Ta, colorModeX:ja,colorModeZ:na,colorModeY:wa,colorModeA:fa,curTextFont:Y,curTextSize:M})};c.popStyle=function(){var a=gd.pop();if(a)hb(),c.popMatrix(),R=a.doFill,Na=a.currentFillColor,I=a.doStroke,ba=a.currentStrokeColor,cb=a.curTint,bb=a.curRectmode,Ta=a.curColorMode,ja=a.colorModeX,na=a.colorModeZ,wa=a.colorModeY,fa=a.colorModeA,Y=a.curTextFont,M=a.curTextSize;else throw"Too many popStyle() without enough pushStyle()";};c.year=function(){return(new Date).getFullYear()};c.month=function(){return(new Date).getMonth()+ 1};c.day=function(){return(new Date).getDate()};c.hour=function(){return(new Date).getHours()};c.minute=function(){return(new Date).getMinutes()};c.second=function(){return(new Date).getSeconds()};c.millis=function(){return(new Date).getTime()-Vc};F.prototype.redraw=function(){var a=((new Date).getTime()-nc)/1E3;Pb++;var b=Pb/a;if(a>0.5)nc=(new Date).getTime(),Pb=0,c.__frameRate=b;c.frameCount++};v.prototype.redraw=function(){F.prototype.redraw.apply(this,arguments);h.lineWidth=xa;h.save();c.draw(); hb()};B.prototype.redraw=function(){F.prototype.redraw.apply(this,arguments);h.clear(h.DEPTH_BUFFER_BIT);va={attributes:{},locations:{}};c.noLights();c.lightFalloff(1,0,0);c.shininess(1);c.ambient(255,255,255);c.specular(0,0,0);c.emissive(0,0,0);c.camera();c.draw()};c.noLoop=function(){Mb=ab=!1;clearInterval(Nb);T.onPause()};c.loop=function(){Mb||(nc=(new Date).getTime(),Pb=0,Nb=S.setInterval(function(){try{T.onFrameStart(),c.redraw(),T.onFrameEnd()}catch(a){throw S.clearInterval(Nb),a;}},Tc),Mb= ab=!0,T.onLoop())};c.frameRate=function(a){jc=a;Tc=1E3/jc;ab&&(c.noLoop(),c.loop())};var ib=[];c.exit=function(){S.clearInterval(Nb);var a=c.externals.canvas.id;La.splice(Hb[a],1);delete Hb[a];for(var b in A.lib)A.lib.hasOwnProperty(b)&&A.lib[b].hasOwnProperty("detach")&&A.lib[b].detach(c);for(a=ib.length;a--;)ia(ib[a]);T.onExit()};c.cursor=function(){if(arguments.length>1||arguments.length===1&&arguments[0]instanceof c.PImage){var a=arguments[0],b,f;if(arguments.length>=3){if(b=arguments[1],f=arguments[2], b<0||f<0||f>=a.height||b>=a.width)throw"x and y must be non-negative and less than the dimensions of the image";}else b=a.width>>>1,f=a.height>>>1;a='url("'+a.toDataURL()+'") '+b+" "+f+", default";p.style.cursor=a}else p.style.cursor=arguments.length===1?arguments[0]:yd};c.noCursor=function(){p.style.cursor=d.NOCURSOR};c.link=function(a,b){b!==q?S.open(a,b):S.location=a};c.beginDraw=bc;c.endDraw=bc;c.Import=function(){};c.status=function(a){S.status=a};c.binary=function(a,b){var c=32;if(typeof a=== "number")return b&&(c=b),Gc(a,c);a instanceof ka&&(a=a.toString().charCodeAt(0),c=b?32:16);c=Gc(a,c);b&&(c=c.substr(-b));return c};c.unbinary=function(a){var b=/^[0|1]{8}$/,f=0;if(a instanceof Array){f=[];for(b=0;b=d&&(c=c.substring(c.length-d,c.length));return c};c.unhex=function(a){if(a instanceof Array){for(var b= [],c=0;c0?c:null};c.__contains=function(a,b){if(typeof a!=="string")return a.contains.apply(a,Ba(arguments));return a!==null&&b!==null&&typeof b==="string"&&a.indexOf(b)>-1};c.__replaceAll=function(a,b,c){if(typeof a!=="string")return a.replaceAll.apply(a,Ba(arguments));return a.replace(RegExp(b,"g"),c)};c.__replaceFirst=function(a,b,c){if(typeof a!=="string")return a.replaceFirst.apply(a,Ba(arguments));return a.replace(RegExp(b,""),c)};c.__replace=function(a, b,c){if(typeof a!=="string")return a.replace.apply(a,Ba(arguments));if(b instanceof RegExp)return a.replace(b,c);typeof b!=="string"&&(b=b.toString());if(b==="")return a;var d=a.indexOf(b);if(d<0)return a;var e=0,g="";do g+=a.substring(e,d)+c,e=d+b.length;while((d=a.indexOf(b,e))>=0);return g+a.substring(e)};c.__equals=function(a,b){if(a.equals instanceof Function)return a.equals.apply(a,Ba(arguments));return a.valueOf()===b.valueOf()};c.__toCharArray=function(a){if(typeof a!=="string")return a.toCharArray.apply(a, Ba(arguments));for(var b=[],c=0,d=a.length;c0;){c=d.shift();if(c===b)return!0;c.$interfaces&& (d=d.concat(c.$interfaces))}return!1}for(;c.hasOwnProperty("$base");)if(c=c.$base,c===b)return!0;return!1};c.abs=j.abs;c.ceil=j.ceil;c.constrain=function(a,b,c){return a>c?c:a0))throw"Non-empty array is expected";for(var b=a[0],c=a.length,d=1;d0))throw"Non-empty array is expected";for(var b=a[0],c=a.length,d=1;da[d]&&(b=a[d]);return b}};c.norm=function(a,b,c){return(a-b)/(c-b)};c.pow=j.pow;c.round=j.round;c.sq=function(a){return a*a};c.sqrt=j.sqrt;c.acos=j.acos;c.asin=j.asin;c.atan=j.atan;c.atan2=j.atan2;c.cos=j.cos;c.degrees=function(a){return a*180/j.PI};c.radians=function(a){return a/180*j.PI};c.sin=j.sin; c.tan=j.tan;var $b=j.random;c.random=function(){if(arguments.length===0)return $b();else if(arguments.length===1)return $b()*arguments[0];else{var a=arguments[0],b=arguments[1];return $b()*(b-a)+a}};Z.createRandomized=function(){var a=new Date;return new Z(a/6E4&4294967295,a&4294967295)};c.randomSeed=function(a){$b=(new Z(a)).nextDouble};c.Random=function(a){var b=!1,c,d;this.nextGaussian=function(){if(b)return b=!1,c;else{var a,g,i;do a=2*d()-1,g=2*d()-1,i=a*a+g*g;while(i>=1||i===0);i=j.sqrt(-2* j.log(i)/i);c=g*i;b=!0;return a*i}};d=a===q?j.random:(new Z(a)).nextDouble};var Ja={generator:q,octaves:4,fallout:0.5,seed:q};c.noise=function(a,b,c){if(Ja.generator===q)Ja.generator=new ua(Ja.seed);for(var d=Ja.generator,e=1,g=1,i=0,k=0;k0&&(p.style.removeProperty("width"),p.style.removeProperty("height"));p.width=c.width=a||100;p.height=c.height=b||100;for(var l in f)f.hasOwnProperty(l)&&(h[l]=f[l]);c.textSize(M);c.background();cd=j.max(1E3,a*b*0.05);c.externals.context=h;for(f=0;f0?(b=new w,b.set(a),c=new w,c.set(d),b.mult(c),c=new w,c.set(b),c.invert(),c.transpose(),N("normalTransform3d",s,"normalTransform",!1,c.array()),t("normal3d",s,"Normal",3,rc)):ma("normal3d",s,"Normal"),t("vertex3d",s,"Vertex",3,qc),ma("aColor3d", s,"aColor"),ma("aTexture3d",s,"aTexture"),h.drawArrays(h.TRIANGLES,0,hd.length/3),h.disable(h.POLYGON_OFFSET_FILL));xa>0&&I&&(h.useProgram(x),N("model2d",x,"model",!1,d.array()),N("view2d",x,"view",!1,a.array()),z("color2d",x,"color",la),u("picktype2d",x,"picktype",0),t("vertex2d",x,"Vertex",3,sc),ma("aTextureCoord2d",x,"aTextureCoord"),h.drawArrays(h.LINES,0,id.length/3))};c.sphereDetail=function(a,b){var c;arguments.length===1&&(a=b=arguments[0]);a<3&&(a=3);b<2&&(b=2);if(!(a===db&&b===Ub)){var l= d.SINCOS_LENGTH/a,e=new P(a),g=new P(a);for(c=0;c0){var f=new w;f.set(a);var d=new w;d.set(b); f.mult(d);d=new w;d.set(f);d.invert();d.transpose();N("normalTransform3d",s,"normalTransform",!1,d.array());t("normal3d",s,"Normal",3,Ab)}else ma("normal3d",s,"Normal");h.useProgram(s);ma("aTexture3d",s,"aTexture");N("model3d",s,"model",!1,b.array());N("view3d",s,"view",!1,a.array());t("vertex3d",s,"Vertex",3,Ab);ma("aColor3d",s,"aColor");h.enable(h.POLYGON_OFFSET_FILL);h.polygonOffset(1,1);z("color3d",s,"color",oa);h.drawArrays(h.TRIANGLE_STRIP,0,H.length/3);h.disable(h.POLYGON_OFFSET_FILL)}xa>0&& I&&(h.useProgram(x),N("model2d",x,"model",!1,b.array()),N("view2d",x,"view",!1,a.array()),t("vertex2d",x,"Vertex",3,Ab),ma("aTextureCoord2d",x,"aTextureCoord"),z("color2d",x,"color",la),u("picktype2d",x,"picktype",0),h.drawArrays(h.LINE_STRIP,0,H.length/3))};c.modelX=function(a,b,c){var d=Q.array(),e=Ha.array(),g=d[0]*a+d[1]*b+d[2]*c+d[3],i=d[4]*a+d[5]*b+d[6]*c+d[7],k=d[8]*a+d[9]*b+d[10]*c+d[11],b=d[12]*a+d[13]*b+d[14]*c+d[15],a=e[0]*g+e[1]*i+e[2]*k+e[3]*b,e=e[12]*g+e[13]*i+e[14]*k+e[15]*b;return e!== 0?a/e:a};c.modelY=function(a,b,c){var d=Q.array(),e=Ha.array(),g=d[0]*a+d[1]*b+d[2]*c+d[3],i=d[4]*a+d[5]*b+d[6]*c+d[7],k=d[8]*a+d[9]*b+d[10]*c+d[11],b=d[12]*a+d[13]*b+d[14]*c+d[15],a=e[4]*g+e[5]*i+e[6]*k+e[7]*b,e=e[12]*g+e[13]*i+e[14]*k+e[15]*b;return e!==0?a/e:a};c.modelZ=function(a,b,c){var d=Q.array(),e=Ha.array(),g=d[0]*a+d[1]*b+d[2]*c+d[3],i=d[4]*a+d[5]*b+d[6]*c+d[7],k=d[8]*a+d[9]*b+d[10]*c+d[11],b=d[12]*a+d[13]*b+d[14]*c+d[15],a=e[8]*g+e[9]*i+e[10]*k+e[11]*b,e=e[12]*g+e[13]*i+e[14]*k+e[15]* b;return e!==0?a/e:a};v.prototype.ambient=F.prototype.a3DOnlyFunction;B.prototype.ambient=function(){var a=arguments;h.useProgram(s);u("usingMat3d",s,"usingMat",!0);a.length===1?typeof a[0]==="string"?(a=a[0].slice(5,-1).split(","),z("mat_ambient3d",s,"mat_ambient",[a[0]/255,a[1]/255,a[2]/255])):z("mat_ambient3d",s,"mat_ambient",[a[0]/255,a[0]/255,a[0]/255]):z("mat_ambient3d",s,"mat_ambient",[a[0]/255,a[1]/255,a[2]/255])};v.prototype.emissive=F.prototype.a3DOnlyFunction;B.prototype.emissive=function(){var a= arguments;h.useProgram(s);u("usingMat3d",s,"usingMat",!0);a.length===1?typeof a[0]==="string"?(a=a[0].slice(5,-1).split(","),z("mat_emissive3d",s,"mat_emissive",[a[0]/255,a[1]/255,a[2]/255])):z("mat_emissive3d",s,"mat_emissive",[a[0]/255,a[0]/255,a[0]/255]):z("mat_emissive3d",s,"mat_emissive",[a[0]/255,a[1]/255,a[2]/255])};v.prototype.shininess=F.prototype.a3DOnlyFunction;B.prototype.shininess=function(a){h.useProgram(s);u("usingMat3d",s,"usingMat",!0);z("shininess3d",s,"shininess",a)};v.prototype.specular= F.prototype.a3DOnlyFunction;B.prototype.specular=function(){var a=c.color.apply(this,arguments);h.useProgram(s);u("usingMat3d",s,"usingMat",!0);z("mat_specular3d",s,"mat_specular",c.color.toGLArray(a).slice(0,3))};c.screenX=function(a,b,f){var d=Q.array();if(d.length===16){var e=d[0]*a+d[1]*b+d[2]*f+d[3],g=d[4]*a+d[5]*b+d[6]*f+d[7],i=d[8]*a+d[9]*b+d[10]*f+d[11],b=d[12]*a+d[13]*b+d[14]*f+d[15],f=ya.array(),a=f[0]*e+f[1]*g+f[2]*i+f[3]*b,e=f[12]*e+f[13]*g+f[14]*i+f[15]*b;e!==0&&(a/=e);return c.width* (1+a)/2}else return Q.multX(a,b)};c.screenY=function(a,b,f){var d=Q.array();if(d.length===16){var e=d[0]*a+d[1]*b+d[2]*f+d[3],g=d[4]*a+d[5]*b+d[6]*f+d[7],i=d[8]*a+d[9]*b+d[10]*f+d[11],b=d[12]*a+d[13]*b+d[14]*f+d[15],f=ya.array(),a=f[4]*e+f[5]*g+f[6]*i+f[7]*b,e=f[12]*e+f[13]*g+f[14]*i+f[15]*b;e!==0&&(a/=e);return c.height*(1+a)/2}else return Q.multY(a,b)};c.screenZ=function(a,b,c){var d=Q.array();if(d.length!==16)return 0;var e=ya.array(),g=d[0]*a+d[1]*b+d[2]*c+d[3],i=d[4]*a+d[5]*b+d[6]*c+d[7],k=d[8]* a+d[9]*b+d[10]*c+d[11],b=d[12]*a+d[13]*b+d[14]*c+d[15],a=e[8]*g+e[9]*i+e[10]*k+e[11]*b,e=e[12]*g+e[13]*i+e[14]*k+e[15]*b;e!==0&&(a/=e);return(a+1)/2};F.prototype.fill=function(a,b,d,l){a=c.color(a,b,d,l);a===Na&&R||(R=!0,Na=a)};v.prototype.fill=function(){F.prototype.fill.apply(this,arguments);Ma=!0};B.prototype.fill=function(){F.prototype.fill.apply(this,arguments);oa=c.color.toGLArray(Na)};c.noFill=function(){R=!1};F.prototype.stroke=function(a,b,d,l){a=c.color(a,b,d,l);a===ba&&I||(I=!0,ba=a)}; v.prototype.stroke=function(){F.prototype.stroke.apply(this,arguments);Ib=!0};B.prototype.stroke=function(){F.prototype.stroke.apply(this,arguments);la=c.color.toGLArray(ba)};c.noStroke=function(){I=!1};F.prototype.strokeWeight=function(a){xa=a};v.prototype.strokeWeight=function(a){F.prototype.strokeWeight.apply(this,arguments);h.lineWidth=a};B.prototype.strokeWeight=function(a){F.prototype.strokeWeight.apply(this,arguments);h.useProgram(x);z("pointSize2d",x,"pointSize",a);h.useProgram(ga);z("pointSizeUnlitShape", ga,"pointSize",a);h.lineWidth(a)};c.strokeCap=function(a){$.$ensureContext().lineCap=a};c.strokeJoin=function(a){$.$ensureContext().lineJoin=a};F.prototype.smooth=function(){p.style.setProperty("image-rendering","optimizeQuality","important")};v.prototype.smooth=function(){F.prototype.smooth.apply(this,arguments);if("mozImageSmoothingEnabled"in h)h.mozImageSmoothingEnabled=!0};F.prototype.noSmooth=function(){p.style.setProperty("image-rendering","optimizeSpeed","important")};v.prototype.noSmooth= function(){F.prototype.noSmooth.apply(this,arguments);if("mozImageSmoothingEnabled"in h)h.mozImageSmoothingEnabled=!1};v.prototype.point=function(a,b){if(I)if(T.options.crispLines){var f=j.PI/4,l=c.get(a,b);c.set(a,b,ud(l,ba,f))}else xa>1?(h.fillStyle=c.color.toString(ba),Ma=!0,h.beginPath(),h.arc(a,b,xa/2,0,d.TWO_PI,!1),h.fill(),h.closePath()):(h.fillStyle=c.color.toString(ba),h.fillRect(j.round(a),j.round(b),1,1),Ma=!0)};B.prototype.point=function(a,b,c){var d=new w;d.translate(a,b,c||0);d.transpose(); a=new w;a.scale(1,-1,1);a.apply(Q.array());a.transpose();h.useProgram(x);N("model2d",x,"model",!1,d.array());N("view2d",x,"view",!1,a.array());xa>0&&I&&(z("color2d",x,"color",la),u("picktype2d",x,"picktype",0),t("vertex2d",x,"Vertex",3,Sb),ma("aTextureCoord2d",x,"aTextureCoord"),h.drawArrays(h.POINTS,0,1))};c.beginShape=function(a){U=a;o=[]};v.prototype.vertex=function(a,b,c,d){var e=[];Xa&&(Xa=!1);e.isVert=!0;e[0]=a;e[1]=b;e[2]=0;e[3]=c;e[4]=d;e[5]=Na;e[6]=ba;o.push(e)};B.prototype.vertex=function(a, b,c,d,e){var g=[];Xa&&(Xa=!1);g.isVert=!0;g[0]=a;g[1]=b;g[2]=c||0;g[3]=d||0;g[4]=e||0;g[5]=oa[0];g[6]=oa[1];g[7]=oa[2];g[8]=oa[3];g[9]=la[0];g[10]=la[1];g[11]=la[2];g[12]=la[3];g[13]=gc;g[14]=hc;g[15]=ic;o.push(g)};var ld=function(a,b){var c=new w;c.scale(1,-1,1);c.apply(Q.array());c.transpose();h.useProgram(ga);N("uViewUS",ga,"uView",!1,c.array());t("aVertexUS",ga,"aVertex",3,Sb);h.bufferData(h.ARRAY_BUFFER,new P(a),h.STREAM_DRAW);t("aColorUS",ga,"aColor",4,vc);h.bufferData(h.ARRAY_BUFFER,new P(b), h.STREAM_DRAW);h.drawArrays(h.POINTS,0,a.length/3)},sa=function(a,b,c){var b=b==="LINES"?h.LINES:b==="LINE_LOOP"?h.LINE_LOOP:h.LINE_STRIP,d=new w;d.scale(1,-1,1);d.apply(Q.array());d.transpose();h.useProgram(ga);N("uViewUS",ga,"uView",!1,d.array());t("aVertexUS",ga,"aVertex",3,uc);h.bufferData(h.ARRAY_BUFFER,new P(a),h.STREAM_DRAW);t("aColorUS",ga,"aColor",4,Xc);h.bufferData(h.ARRAY_BUFFER,new P(c),h.STREAM_DRAW);h.drawArrays(b,0,a.length/3)},Ra=function(a,b,c,l){var b=b==="TRIANGLES"?h.TRIANGLES: b==="TRIANGLE_FAN"?h.TRIANGLE_FAN:h.TRIANGLE_STRIP,e=new w;e.scale(1,-1,1);e.apply(Q.array());e.transpose();h.useProgram(s);N("model3d",s,"model",!1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);N("view3d",s,"view",!1,e.array());h.enable(h.POLYGON_OFFSET_FILL);h.polygonOffset(1,1);z("color3d",s,"color",[-1,0,0,0]);t("vertex3d",s,"Vertex",3,Wc);h.bufferData(h.ARRAY_BUFFER,new P(a),h.STREAM_DRAW);t("aColor3d",s,"aColor",4,vc);h.bufferData(h.ARRAY_BUFFER,new P(c),h.STREAM_DRAW);ma("normal3d",s,"Normal");if(pa){if(ad=== d.IMAGE)for(c=0;c1&&(l[c+0]-=l[c+0]-1),l[c+1]>1&&(l[c+1]-=l[c+1]-1);u("usingTexture3d",s,"usingTexture",pa);t("aTexture3d",s,"aTexture",2,Yc);h.bufferData(h.ARRAY_BUFFER,new P(l),h.STREAM_DRAW)}h.drawArrays(b,0,a.length/3);h.disable(h.POLYGON_OFFSET_FILL)};v.prototype.endShape=function(a){if(o.length!==0){var a=a===d.CLOSE,b=[],f=[],l=[],e=[],g;Xa=!0;var i,k,m=o.length;for(i=0;i3){b=[];f=1-kc;h.beginPath();h.moveTo(o[1][0],o[1][1]);for(i=1;i+22){h.beginPath();h.moveTo(o[0][0],o[0][1]);h.lineTo(o[1][0],o[1][1]);h.lineTo(o[2][0],o[2][1]);R&&(c.fill(o[2][5]),X());I&&(c.stroke(o[2][6]),V());h.closePath();for(i=3;i3)for(i=0;i+12)for(k=0;k+22)for(k=0;k+22){for(k=0;k<3;k++){i=o[k];for(m=0;m<3;m++)a.push(i[m])}for(k=0;k<3;k++){i=o[k];for(m=9;m<13;m++)e.push(i[m])}I&&sa(a,"LINE_LOOP",e);for(k=2;k+13){for(k=0;k<2;k++){i=o[k];for(m=0;m<3;m++)a.push(i[m])}for(k=0;k<2;k++){i=o[k];for(m=9;m<13;m++)e.push(i[m])}sa(a,"LINE_STRIP",e);j>4&&j%2>0&&(c.splice(c.length- 3),o.pop());for(k=0;k+33){var e=ha[ea-4][0],g=ha[ea-4][1],i=ha[ea-4][2],k=ha[ea-3][0],m=ha[ea-3][1],h=ha[ea- 3][2],j=ha[ea-2][0],o=ha[ea-2][1],n=ha[ea-2][2],p=ha[ea-1][0],q=ha[ea-1][1],s=ha[ea-1][2],a=k,b=m,d=h,r=ob.array(),l=r[4]*e+r[5]*k+r[6]*j+r[7]*p,t=r[8]*e+r[9]*k+r[10]*j+r[11]*p,e=r[12]*e+r[13]*k+r[14]*j+r[15]*p,k=r[4]*g+r[5]*m+r[6]*o+r[7]*q,j=r[8]*g+r[9]*m+r[10]*o+r[11]*q,g=r[12]*g+r[13]*m+r[14]*o+r[15]*q,m=r[4]*i+r[5]*h+r[6]*n+r[7]*s,o=r[8]*i+r[9]*h+r[10]*n+r[11]*s,i=r[12]*i+r[13]*h+r[14]*n+r[15]*s;c.vertex(a,b,d);for(h=0;hd.TWO_PI)e=0,g=d.TWO_PI; f/=2;l/=2;a+=f;b+=l;var e=0|-0.5+e/d.TWO_PI*d.SINCOS_LENGTH,g=0|0.5+g/d.TWO_PI*d.SINCOS_LENGTH,i,k;if(R){var m=I;I=!1;c.beginShape();c.vertex(a,b);for(k=i=e;i=d.SINCOS_LENGTH&&(k-=d.SINCOS_LENGTH),c.vertex(a+rb[k]*f,b+qb[k]*l);c.endShape(d.CLOSE);I=m}if(I){m=R;R=!1;c.beginShape();for(k=i=e;i=d.SINCOS_LENGTH&&(k-=d.SINCOS_LENGTH),c.vertex(a+rb[k]*f,b+qb[k]*l);k=g%d.SINCOS_LENGTH;c.vertex(a+rb[k]*f,b+qb[k]*l);c.endShape();R=m}}};v.prototype.line=function(a,b,d,l){if(a===d&& b===l)c.point(a,b);else if((a===d||b===l)&&xa<=1&&I&&T.options.crispLines){var e;if(a===d){b>l&&(e=b,b=l,l=e);for(;b<=l;++b)c.set(a,b,ba)}else{a>d&&(e=a,a=d,d=e);for(;a<=d;++a)c.set(a,b,ba)}}else I&&(h.beginPath(),h.moveTo(a||0,b||0),h.lineTo(d||0,l||0),V(),h.closePath())};B.prototype.line=function(a,b,d,l,e,g){if(e===q||g===q)g=0,e=l,l=d,d=0;a===l&&b===e&&d===g?c.point(a,b,d):(a=[a,b,d,l,e,g],b=new w,b.scale(1,-1,1),b.apply(Q.array()),b.transpose(),xa>0&&I&&(h.useProgram(x),N("model2d",x,"model", !1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),N("view2d",x,"view",!1,b.array()),z("color2d",x,"color",la),u("picktype2d",x,"picktype",0),t("vertex2d",x,"Vertex",3,uc),ma("aTextureCoord2d",x,"aTextureCoord"),h.bufferData(h.ARRAY_BUFFER,new P(a),h.STREAM_DRAW),h.drawArrays(h.LINES,0,2)))};v.prototype.bezier=function(){if(arguments.length!==8)throw"You must use 8 parameters for bezier() in 2D mode";c.beginShape();c.vertex(arguments[0],arguments[1]);c.bezierVertex(arguments[2],arguments[3],arguments[4],arguments[5], arguments[6],arguments[7]);c.endShape()};B.prototype.bezier=function(){if(arguments.length!==12)throw"You must use 12 parameters for bezier() in 3D mode";c.beginShape();c.vertex(arguments[0],arguments[1],arguments[2]);c.bezierVertex(arguments[3],arguments[4],arguments[5],arguments[6],arguments[7],arguments[8],arguments[9],arguments[10],arguments[11]);c.endShape()};c.bezierDetail=function(a){mc=a};c.bezierPoint=function(a,b,c,d,e){return(1-e)*(1-e)*(1-e)*a+3*(1-e)*(1-e)*e*b+3*(1-e)*e*e*c+e*e*e*d}; c.bezierTangent=function(a,b,c,d,e){return 3*e*e*(-a+3*b-3*c+d)+6*e*(a-2*b+c)+3*(-a+b)};c.curvePoint=function(a,b,c,d,e){return 0.5*(2*b+(-a+c)*e+(2*a-5*b+4*c-d)*e*e+(-a+3*b-3*c+d)*e*e*e)};c.curveTangent=function(a,b,c,d,e){return 0.5*(-a+c+2*(2*a-5*b+4*c-d)*e+3*(-a+3*b-3*c+d)*e*e)};c.triangle=function(a,b,f,l,e,g){c.beginShape(d.TRIANGLES);c.vertex(a,b,0);c.vertex(f,l,0);c.vertex(e,g,0);c.endShape()};c.quad=function(a,b,f,l,e,g,i,k){c.beginShape(d.QUADS);c.vertex(a,b,0);c.vertex(f,l,0);c.vertex(e, g,0);c.vertex(i,k,0);c.endShape()};v.prototype.rect=function(a,b,f,l){if(f||l)if(I&&!R&&xa<=1&&T.options.crispLines){var e,g=a+f-1,i=b+l-1;for(e=0;e0&&I&&(h.useProgram(x),N("model2d",x,"model",!1,e.array()),N("view2d",x,"view",!1,b.array()),z("color2d",x,"color",la),u("picktype2d",x,"picktype",0),t("vertex2d",x,"Vertex",3,Rb),ma("aTextureCoord2d",x,"aTextureCoord"),h.drawArrays(h.LINE_LOOP,0,Cc.length/3));R&&(h.useProgram(s),N("model3d",s,"model",!1,e.array()),N("view3d",s,"view",!1,b.array()),h.enable(h.POLYGON_OFFSET_FILL),h.polygonOffset(1,1),z("color3d", s,"color",oa),D>0?(a=new w,a.set(b),b=new w,b.set(e),a.mult(b),e=new w,e.set(a),e.invert(),e.transpose(),N("normalTransform3d",s,"normalTransform",!1,e.array()),t("normal3d",s,"Normal",3,tc)):ma("normal3d",s,"Normal"),t("vertex3d",s,"Vertex",3,Rb),h.drawArrays(h.TRIANGLE_FAN,0,Cc.length/3),h.disable(h.POLYGON_OFFSET_FILL))};F.prototype.ellipse=function(a,b,c,l){a=a||0;b=b||0;if(!(c<=0&&l<=0)){Wa===d.RADIUS&&(c*=2,l*=2);Wa===d.CORNERS&&(c-=a,l-=b);if(Wa===d.CORNER||Wa===d.CORNERS)a+=c/2,b+=l/2;return{x:a, y:b,width:c,height:l}}};v.prototype.ellipse=function(a,b,f,l){var e=F.prototype.ellipse.apply(this,arguments);if(e)if(a=e.x,b=e.y,f=e.width,l=e.height,f===l)h.beginPath(),h.arc(a-0,b-0,f/2,0,d.TWO_PI,!1),X(),V(),h.closePath();else{var e=f/2,g=l/2,i=0.5522847498307933*e,k=0.5522847498307933*g;c.beginShape();c.vertex(a+e,b);c.bezierVertex(a+e,b-k,a+i,b-g,a,b-g);c.bezierVertex(a-i,b-g,a-e,b-k,a-e,b);c.bezierVertex(a-e,b+k,a-i,b+g,a,b+g);c.bezierVertex(a+i,b+g,a+e,b+k,a+e,b);c.endShape()}};B.prototype.ellipse= function(a,b,d,l){var e=F.prototype.ellipse.apply(this,arguments);if(e){var a=e.x,b=e.y,d=e.width,l=e.height,e=d/2,g=l/2,i=0.5522847498307933*e,k=0.5522847498307933*g;c.beginShape();c.vertex(a+e,b);c.bezierVertex(a+e,b-k,0,a+i,b-g,0,a,b-g,0);c.bezierVertex(a-i,b-g,0,a-e,b-k,0,a-e,b,0);c.bezierVertex(a-e,b+k,0,a-i,b+g,0,a,b+g,0);c.bezierVertex(a+i,b+g,0,a+e,b+k,0,a+e,b,0);c.endShape();if(R){var k=i=0,m;for(m=0;m>>16;a.imageData.data[f+1]=(c&d.GREEN_MASK)>>>8;a.imageData.data[f+2]=c&d.BLUE_MASK;a.imageData.data[f+3]=(c&d.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&&b>=0&&b=0&&b>=0&&bcd&&Da()):d instanceof ta&&c.image(d,a,b);else if(arguments.length===4)if(l.isRemote)throw"Image is loaded remotely. Cannot set x,y."; else{var e=c.color.toArray(d),g=b*l.width*4+a*4,i=l.imageData.data;i[g]=e[0];i[g+1]=e[1];i[g+2]=e[2];i[g+3]=e[3]}};c.imageData={};c.pixels={getLength:function(){return c.imageData.data.length?c.imageData.data.length/4:0},getPixel:function(a){a*=4;return c.imageData.data[a+3]<<24&4278190080|c.imageData.data[a+0]<<16&16711680|c.imageData.data[a+1]<<8&65280|c.imageData.data[a+2]&255},setPixel:function(a,b){var d=a*4;c.imageData.data[d+0]=(b&16711680)>>>16;c.imageData.data[d+1]=(b&65280)>>>8;c.imageData.data[d+ 2]=b&255;c.imageData.data[d+3]=(b&4278190080)>>>24},set:function(a){for(var b=0,c=a.length;b0&&pd(a,b,d,l);var e=c.color.toGLArray(nb);h.clearColor(e[0],e[1],e[2],e[3]);h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT)};v.prototype.image=function(a,b,c,d,e){if(a.width>0){var g=Xb(b||0,c||0,d||a.width,e||a.height,arguments.length<4);if(a.sourceImg&&cb===null&&!a.__mask){var i=a.sourceImg;h.drawImage(i,0,0,i.width,i.height,g.x,g.y,g.w,g.h)}else{i=a.toImageData();if(a.__mask){var k,m;if(a.__mask instanceof ta){var j=a.__mask.toImageData();k=2;for(m=a.width*a.height*4;k0&&(l=l||a.width,e=e||a.height,c.beginShape(c.QUADS),c.texture(a.externals.canvas),c.vertex(b,d,0,0,0),c.vertex(b,d+e,0,0,e),c.vertex(b+l,d+e,0,l,e),c.vertex(b+l,d,0,l,0),c.endShape())};c.tint=function(){var a= c.color.apply(this,arguments),b=c.red(a)/ja,d=c.green(a)/wa,l=c.blue(a)/na,e=c.alpha(a)/fa;cb=function(a){for(var c=a.data,a=4*a.width*a.height,k=0;k=i&&(j=c),p<0&&(p=0),n>=d&&(n=c),p=b.pixels.getPixel(p),o=b.pixels.getPixel(o),n=b.pixels.getPixel(n),j=b.pixels.getPixel(j),k=77*(k>>16&255)+151*(k>>8&255)+28*(k&255),s=77*(o>>16&255)+151*(o>>8&255)+28*(o&255),q=77*(j>>16&255)+151*(j>>8&255)+28*(j&255),t=77*(p>>16&255)+151*(p>>8&255)+28*(p&255),r=77*(n>>16&255)+151*(n>>8&255)+28*(n&255),s=i&&(j=c),p<0&&(p=0),n>=d&&(n=c),p=b.pixels.getPixel(p),o=b.pixels.getPixel(o),n=b.pixels.getPixel(n),j=b.pixels.getPixel(j),k=77*(k>>16&255)+151*(k>>8&255)+28*(k&255),s=77*(o>>16&255)+151*(o>>8&255)+28*(o&255),q=77*(j>>16&255)+151*(j>>8&255)+28*(j&255),t=77*(p>>16&255)+151*(p>>8&255)+28*(p&255),r=77*(n>>16&255)+151*(n>>8&255)+28*(n&255),s>k&& (h=o,k=s),q>k&&(h=j,k=q),t>k&&(h=p,k=t),r>k&&(h=n),e[c++]=h}b.pixels.set(e)};c.filter=function(a,b,f){var l,e,g,i;arguments.length===3?(f.loadPixels(),l=f):(c.loadPixels(),l=c);b===q&&(b=null);if(l.isRemote)throw"Image is loaded remotely. Cannot filter image.";else{var k=l.pixels.getLength();switch(a){case d.BLUR:var h=b||1,j=l,o,p,n,s,t,L,r,u,z;g=j.pixels.getLength();i=new P(g);k=new P(g);e=new P(g);g=new P(g);var G=0,w,y,x,h=c.floor(h*3.5),v,h=h<1?1:h<248?h:248;if(c.shared.blurRadius!==h){c.shared.blurRadius= h;c.shared.blurKernelSize=1+(c.shared.blurRadius<<1);c.shared.blurKernel=new P(c.shared.blurKernelSize);var B=c.shared.blurKernel,A=c.shared.blurKernelSize;for(v=0;v=v)break;t=0}for(x=t;x=v)break;r=(L+G)*4;t=A[x];s+=t*C[r+3]; o+=t*C[r];p+=t*C[r+1];n+=t*C[r+2];j+=t;L++}r=G+w;g[r]=s/j;i[r]=o/j;k[r]=p/j;e[r]=n/j}G+=v}G=0;u=-u;z=u*v;for(y=0;y=h)break;t=0;r=u;L=w+z}for(x=t;x=h)break;t=A[x];s+=t*g[L];o+=t*i[L];p+=t*k[L];n+=t*e[L];j+=t;r++;L+=v}r=(w+G)*4;C[r]=o/j;C[r+1]=p/j;C[r+2]=n/j;C[r+3]=s/j}G+=v;z+=v;u++}break;case d.GRAY:if(l.format===d.ALPHA){for(i=0;i>16&255)+151*(e>>8&255)+28*(e&255)>>8,l.pixels.setPixel(i,e&d.ALPHA_MASK|g<<16|g<<8|g);break;case d.INVERT:for(i=0;i255)throw"Levels must be between 2 and 255 for filter(POSTERIZE, levels)";g=e-1;for(i=0;i>16&255,h=l.pixels.getPixel(i)>>8&255,v= l.pixels.getPixel(i)&255,G=(G*e>>8)*255/g,h=(h*e>>8)*255/g,v=(v*e>>8)*255/g,l.pixels.setPixel(i,4278190080&l.pixels.getPixel(i)|G<<16|h<<8|v);break;case d.OPAQUE:for(i=0;i1)throw"Level must be between 0 and 1 for filter(THRESHOLD, level)";e=c.floor(b*255);for(i=0;i>16,c.max((l.pixels.getPixel(i)&d.GREEN_MASK)>>8,l.pixels.getPixel(i)& d.BLUE_MASK)),l.pixels.setPixel(i,l.pixels.getPixel(i)&d.ALPHA_MASK|(gc&&(i=c)):(a=c+a-e,i>a&& (i=a));gd&&(k=d)):(b=d+b-g,k>b&&(k=b));return!(i<=0||k<=0)};c.filter_new_scanline=function(){c.shared.sX=c.shared.srcXOffset;c.shared.fracV=c.shared.srcYOffset&d.PREC_MAXVAL;c.shared.ifV=d.PREC_MAXVAL-c.shared.fracV;c.shared.v1=(c.shared.srcYOffset>>d.PRECISIONB)*c.shared.iw;c.shared.v2=j.min((c.shared.srcYOffset>>d.PRECISIONB)+1,c.shared.ih1)*c.shared.iw};c.filter_bilinear=function(){c.shared.fracU=c.shared.sX&d.PREC_MAXVAL;c.shared.ifU=d.PREC_MAXVAL-c.shared.fracU;c.shared.ul=c.shared.ifU* c.shared.ifV>>d.PRECISIONB;c.shared.ll=c.shared.ifU*c.shared.fracV>>d.PRECISIONB;c.shared.ur=c.shared.fracU*c.shared.ifV>>d.PRECISIONB;c.shared.lr=c.shared.fracU*c.shared.fracV>>d.PRECISIONB;c.shared.u1=c.shared.sX>>d.PRECISIONB;c.shared.u2=j.min(c.shared.u1+1,c.shared.iw1);var a=(c.shared.v1+c.shared.u1)*4,b=(c.shared.v1+c.shared.u2)*4,f=(c.shared.v2+c.shared.u1)*4,h=(c.shared.v2+c.shared.u2)*4;c.shared.cUL=c.color.toInt(c.shared.srcBuffer[a],c.shared.srcBuffer[a+1],c.shared.srcBuffer[a+2],c.shared.srcBuffer[a+ 3]);c.shared.cUR=c.color.toInt(c.shared.srcBuffer[b],c.shared.srcBuffer[b+1],c.shared.srcBuffer[b+2],c.shared.srcBuffer[b+3]);c.shared.cLL=c.color.toInt(c.shared.srcBuffer[f],c.shared.srcBuffer[f+1],c.shared.srcBuffer[f+2],c.shared.srcBuffer[f+3]);c.shared.cLR=c.color.toInt(c.shared.srcBuffer[h],c.shared.srcBuffer[h+1],c.shared.srcBuffer[h+2],c.shared.srcBuffer[h+3]);c.shared.r=c.shared.ul*((c.shared.cUL&d.RED_MASK)>>16)+c.shared.ll*((c.shared.cLL&d.RED_MASK)>>16)+c.shared.ur*((c.shared.cUR&d.RED_MASK)>> 16)+c.shared.lr*((c.shared.cLR&d.RED_MASK)>>16)<>>d.PRECISIONB&d.GREEN_MASK;c.shared.b=c.shared.ul*(c.shared.cUL&d.BLUE_MASK)+c.shared.ll*(c.shared.cLL&d.BLUE_MASK)+c.shared.ur*(c.shared.cUR&d.BLUE_MASK)+c.shared.lr*(c.shared.cLR&d.BLUE_MASK)>>>d.PRECISIONB;c.shared.a=c.shared.ul*((c.shared.cUL&d.ALPHA_MASK)>>> 24)+c.shared.ll*((c.shared.cLL&d.ALPHA_MASK)>>>24)+c.shared.ur*((c.shared.cUR&d.ALPHA_MASK)>>>24)+c.shared.lr*((c.shared.cLR&d.ALPHA_MASK)>>>24)<=a.width&&(h=a.width-1);e>=a.height&&(e=a.height-1);h-=b;e-=f;p-=m;q-=o;if(!(p<=0||q<=0||h<=0||e<=0||m>=i||o>=k||b>=a.width||f>=a.height))switch(h=j.floor(h/p*d.PRECISIONF),e=j.floor(e/q*d.PRECISIONF), c.shared.srcXOffset=j.floor(m<0?-m*h:b*d.PRECISIONF),c.shared.srcYOffset=j.floor(o<0?-o*e:f*d.PRECISIONF),m<0&&(p+=m,m=0),o<0&&(q+=o,o=0),p=j.min(p,i-m),q=j.min(q,k-o),b=o*i+m,c.shared.srcBuffer=a.imageData.data,c.shared.iw=a.width,c.shared.iw1=a.width-1,c.shared.ih1=a.height-1,n){case d.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[b]}}catch(c){A.debug(c)}};v.prototype.text$line=function(a,b,f,j,e){j=j=0;if(Y.glyph){j=c.glyphTable[Y.name];h.save();h.translate(b,f+M);(e===d.RIGHT||e===d.CENTER)&&j.width(a);b=1/j.units_per_em*M;h.scale(b,b);b=0;for(f=a.length;b< f;b++)try{c.glyphLook(j,a[b]).draw()}catch(g){A.debug(g)}hb()}else if(a&&"fillText"in h){if(Ma)h.fillStyle=c.color.toString(Na),Ma=!1;if(e===d.RIGHT||e===d.CENTER)j=h.measureText(a).width,j=e===d.RIGHT?-j:-j/2;h.fillText(a,b+j,f)}};B.prototype.text$line=function(a,b,c,j,e){ra===q&&(ra=E.createElement("canvas"));var g=h;h=ra.getContext("2d");h.font=M+"px "+Y.name;var i=h.measureText(a).width;ra.width=i;ra.height=M;h=ra.getContext("2d");h.font=M+"px "+Y.name;h.textBaseline="top";v.prototype.text$line(a, 0,0,0,d.LEFT);a=ra.width/ra.height;h=g;h.bindTexture(h.TEXTURE_2D,$c);wb(ra);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.LINEAR);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.LINEAR);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE);g=0;e===d.RIGHT?g=-i:e===d.CENTER&&(g=-i/2);e=new w;i=M*0.5;e.translate(b+g-i/2,c-i,j);e.scale(-a*i,-i,i);e.translate(-1,-1,-1);e.transpose();b=new w;b.scale(1,-1,1);b.apply(Q.array()); b.transpose();h.useProgram(x);t("vertex2d",x,"Vertex",3,wc);t("aTextureCoord2d",x,"aTextureCoord",2,xc);u("uSampler2d",x,"uSampler",[0]);u("picktype2d",x,"picktype",1);N("model2d",x,"model",!1,e.array());N("view2d",x,"view",!1,b.array());z("color2d",x,"color",oa);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,yc);h.drawElements(h.TRIANGLES,6,h.UNSIGNED_SHORT,0)};c.text=function(){if(zc===d.SCREEN){c.pushMatrix();c.resetMatrix();var a=c.textAscent(),b=c.textDescent(),f=c.textWidth(arguments[0]),h=a+b,b=c.loadFont(Y.origName), f=c.createGraphics(f,h);f.beginDraw();f.fill(Na);f.opaque=!1;f.background(0,0,0,0);f.textFont(b);f.textSize(M);f.text(arguments[0],0,a);f.endDraw();arguments.length===5||arguments.length===6?c.image(f,arguments[1],arguments[2]-a,arguments[3],arguments[4]):c.image(f,arguments[1],arguments[2]-a);c.popMatrix()}else zc!==d.SHAPE&&(arguments.length===3?Nc(Oa(arguments[0]),arguments[1],arguments[2],0):arguments.length===4?Nc(Oa(arguments[0]),arguments[1],arguments[2],arguments[3]):arguments.length===5? Oc(Oa(arguments[0]),arguments[1],arguments[2],arguments[3],arguments[4],0):arguments.length===6&&Oc(Oa(arguments[0]),arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]))};c.textMode=function(a){zc=a};c.loadGlyphs=function(a){var b,d,l,e,g,i,k,m,o,p,s,n,t=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},L=function(a){var c=t("[A-Za-z][0-9\\- ]+|Z",a);n="return {draw:function(){var curContext=beforePathDraw();curContext.beginPath();"; m=a=i=g=e=l=d=b=0;o="";p=c.length-1;for(var k=0;kj&&(d=j-p);Ka.height=d/j*100+"%";O.paddingBottom=Z.clientHeight+"px"},La=[W(j,"mousemove",function(d){if(qa)Oa(J.innerHeight-d.clientY),V.scrollTop=Aa}),W(j,"mouseup",function(){qa&&(qa=Aa=!1)}),W(X,"dblclick",function(d){d.preventDefault();Da?(Oa(Da),Da=!1):(Da=Z.clientHeight,Ka.height="0px")}),W(X,"mousedown",function(d){d.preventDefault();qa=!0;Aa=V.scrollTop}),W(X,"contextmenu",function(){qa=!1}),W(ua,"click",function(){za()})];za=function(){for(var j=La.length;j--;)aa.apply(d,La[j]); P.removeChild(Z);O.paddingBottom=Sa;ia(V);ia(Z);d.log=Ba};S(Z,q,V,z,X,u,ua,t);ua.title="Close Log";Ca(ua,j.createTextNode("\u2716"));X.title="Double-click to toggle log minimization";P.insertBefore(Z,P.firstChild);d.log=function(d){Za===512?V.removeChild(V.firstChild):Za++;var p=Ca(V,j.createElement("div")),q=Ca(p,j.createElement("div"));p.title=(new Date).toLocaleTimeString();S(p,A,q,N);Ca(q,j.createTextNode(d));V.scrollTop=V.scrollHeight};d.log(E);O.paddingBottom=Z.clientHeight+"px"}}():typeof print=== "function"&&(d.log=print);return d}();A.logger=Ka;A.version="1.2.3-API";A.lib={};A.registerLibrary=function(d,j){A.lib[d]=j;j.hasOwnProperty("init")&&j.init(W)};A.instances=La;A.getInstanceById=function(d){return La[Hb[d]]};A.Sketch=function(d){this.attachFunction=d;this.options={crispLines:!1,pauseOnBlur:!1,globalKeyEvents:!1};this.onExit=this.onFrameEnd=this.onFrameStart=this.onLoop=this.onPause=this.onSetup=this.onLoad=bc;this.params={};this.imageCache={pending:0,images:{},add:function(d){if(ua){var j= new Image;j.onload=function(d){return function(){d.pending--}}(this);this.pending++;this.images[d]=j;j.src=d}else this.images[d]=null}};this.fonts={template:function(){if(!ua)return null;var d=E.createElement("p");d.style.fontFamily="serif";d.style.fontSize="72px";d.style.visibility="hidden";d.innerHTML="This element is a text block for font loading";E.getElementsByTagName("body")[0].appendChild(d);return d}(),attempt:0,pending:function(){for(var d=!0,j=0;j=30){d=!0;for(j=0;j