/*! p5.min.js v0.3.15 December 23, 2014 */ var shim=function(){window.requestDraw=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}()}({}),constants=function(){var t=Math.PI;return{ARROW:"default",CROSS:"crosshair",HAND:"pointer",MOVE:"move",TEXT:"text",WAIT:"wait",HALF_PI:t/2,PI:t,QUARTER_PI:t/4,TAU:2*t,TWO_PI:2*t,DEGREES:"degrees",RADIANS:"radians",CORNER:"corner",CORNERS:"corners",RADIUS:"radius",RIGHT:"right",LEFT:"left",CENTER:"center",POINTS:"points",LINES:"lines",TRIANGLES:"triangles",TRIANGLE_FAN:"triangles_fan",TRIANGLE_STRIP:"triangles_strip",QUADS:"quads",QUAD_STRIP:"quad_strip",CLOSE:"close",OPEN:"open",CHORD:"chord",PIE:"pie",PROJECT:"square",SQUARE:"butt",ROUND:"round",BEVEL:"bevel",MITER:"miter",RGB:"rgb",HSB:"hsb",AUTO:"auto",ALT:18,BACKSPACE:8,CONTROL:17,DELETE:46,DOWN_ARROW:40,ENTER:13,ESCAPE:27,LEFT_ARROW:37,OPTION:18,RETURN:13,RIGHT_ARROW:39,SHIFT:16,TAB:9,UP_ARROW:38,BLEND:"normal",ADD:"lighter",DARKEST:"darken",LIGHTEST:"lighten",DIFFERENCE:"difference",EXCLUSION:"exclusion",MULTIPLY:"multiply",SCREEN:"screen",REPLACE:"source-over",OVERLAY:"overlay",HARD_LIGHT:"hard-light",SOFT_LIGHT:"soft-light",DODGE:"color-dodge",BURN:"color-burn",NORMAL:"normal",ITALIC:"italic",BOLD:"bold",LINEAR:"linear",QUADRATIC:"quadratic",BEZIER:"bezier",CURVE:"curve"}}({}),core=function(t,e,r){"use strict";var r=r,o=function(t,e){this._setupDone=!1,this._pixelDensity=window.devicePixelRatio||1,this._startTime=(new Date).getTime(),this._userNode=e,this._curElement=null,this._elements=[],this._preloadCount=0,this._updateInterval=0,this._isGlobal=!1,this._loop=!0,this._styles=[],this._defaultCanvasSize={width:100,height:100},this._events={mousemove:null,mousedown:null,mouseup:null,click:null,mousewheel:null,mouseover:null,mouseout:null,keydown:null,keyup:null,keypress:null,touchstart:null,touchmove:null,touchend:null,resize:null,blur:null},this._loadingScreenId="p5_loading",this._start=function(){if(this._userNode&&"string"==typeof this._userNode&&(this._userNode=document.getElementById(this._userNode)),this._loadingScreen=document.getElementById(this._loadingScreenId),!this._loadingScreen){this._loadingScreen=document.createElement("loadingDiv"),this._loadingScreen.innerHTML="loading...",this._loadingScreen.style.position="absolute";var t=this._userNode||document.body;t.appendChild(this._loadingScreen)}this.createCanvas(this._defaultCanvasSize.width,this._defaultCanvasSize.height,!0);var e=this.preload||window.preload,r=this._isGlobal?window:this;e?(this._preloadMethods.forEach(function(t){r[t]=function(e){return r._preload(t,e)}}),e(),0===this._preloadCount&&(this._setup(),this._runFrames(),this._draw())):(this._setup(),this._runFrames(),this._draw())}.bind(this),this._preload=function(t,e){var r=this._isGlobal?window:this;return r._setProperty("_preloadCount",r._preloadCount+1),o.prototype[t].call(r,e,function(){r._setProperty("_preloadCount",r._preloadCount-1),0===r._preloadCount&&(r._setup(),r._runFrames(),r._draw())})}.bind(this),this._setup=function(){var t=this._isGlobal?window:this;"function"==typeof t.preload&&this._preloadMethods.forEach(function(e){t[e]=o.prototype[e]}),"function"==typeof t.setup&&t.setup(),this.canvas.style.visibility="",this.canvas.className=this.canvas.className.replace("p5_hidden",""),this._setupDone=!0,this._loadingScreen.parentNode.removeChild(this._loadingScreen)}.bind(this),this._draw=function(){var t=this.setup||window.setup,e=(new Date).getTime();this._frameRate=1e3/(e-this._lastFrameTime),this._lastFrameTime=e;var r=this.draw||window.draw;this._loop&&(this._drawInterval&&clearInterval(this._drawInterval),this._drawInterval=setTimeout(function(){window.requestDraw(this._draw.bind(this))}.bind(this),1e3/this._targetFrameRate)),"function"==typeof r&&(this.push(),"undefined"==typeof t&&this.scale(this._pixelDensity,this._pixelDensity),this._registeredMethods.pre.forEach(function(t){t.call(this)}),r(),this._registeredMethods.post.forEach(function(t){t.call(this)}),this.pop()),this._updatePMouseCoords(),this._updatePTouchCoords()}.bind(this),this._runFrames=function(){this._updateInterval&&clearInterval(this._updateInterval),this._updateInterval=setInterval(function(){this._setProperty("frameCount",this.frameCount+1)}.bind(this),1e3/this._targetFrameRate)}.bind(this),this._setProperty=function(t,e){this[t]=e,this._isGlobal&&(window[t]=e)}.bind(this),this.remove=function(){if(this._curElement){this._loop=!1,this._drawInterval&&clearTimeout(this._drawInterval),this._updateInterval&&clearTimeout(this._updateInterval);for(var t in this._events)window.removeEventListener(t,this._events[t]);for(var e=0;e=3?(t=arguments[0],e=arguments[1],n=arguments[2],i="number"==typeof arguments[3]?arguments[3]:255):(this._colorMode===r.RGB?t=e=n=arguments[0]:(t=n=arguments[0],e=0),i="number"==typeof arguments[1]?arguments[1]:255),[t,e,n,i]},o.Color._normalizeColorArray=function(t){var e=this._colorMode===r.RGB,o=e?this._maxRGB:this._maxHSB;return t[0]*=255/o[0],t[1]*=255/o[1],t[2]*=255/o[2],t[3]*=255/o[3],t},o.Color._getRGB=function(t){var e=t[0],r=t[1],o=t[2];e/=255,r/=255,o/=255;var n=[];if(0===r)n=[Math.round(255*o),Math.round(255*o),Math.round(255*o),t[3]];else{var i=6*e;6===i&&(i=0);var s,a,h,p=Math.floor(i),u=o*(1-r),l=o*(1-r*(i-p)),c=o*(1-r*(1-(i-p)));0===p?(s=o,a=c,h=u):1===p?(s=l,a=o,h=u):2===p?(s=u,a=o,h=c):3===p?(s=u,a=l,h=o):4===p?(s=c,a=u,h=o):(s=o,a=u,h=l),n=[Math.round(255*s),Math.round(255*a),Math.round(255*h),t[3]]}return n},o.Color._getHSB=function(t){var e,r,o=t[0]/255,n=t[1]/255,i=t[2]/255,s=Math.min(o,n,i),a=Math.max(o,n,i),h=a-s,p=a;if(0===h)e=0,r=0;else{r=h/a;var u=((a-o)/6+h/2)/h,l=((a-n)/6+h/2)/h,c=((a-i)/6+h/2)/h;o===a?e=c-l:n===a?e=1/3+u-c:i===a&&(e=2/3+l-u),0>e&&(e+=1),e>1&&(e-=1)}return[Math.round(255*e),Math.round(255*r),Math.round(255*p),t[3]]},o.Color._getColorString=function(t){for(var e=0;3>e;e++)t[e]=Math.floor(t[e]);var r="undefined"!=typeof t[3]?t[3]/255:1;return"rgba("+t[0]+","+t[1]+","+t[2]+","+r+")"},o.Color._getCanvasColor=function(){if(arguments[0]instanceof o.Color){if(1===arguments.length)return arguments[0].colorString;var t=arguments[0].rgba;return t[3]=arguments[1],t=o.Color._normalizeColorArray.call(this,t),o.Color._getColorString(t)}if(arguments[0]instanceof Array){if(1===arguments.length)return o.Color._getColorString(arguments[0]);var e=this._colorMode===r.RGB,n=e?this._maxRGB[3]:this._maxHSB[3];return arguments[0][3]=255*arguments[1]/n,o.Color._getColorString(arguments[0])}var i=o.Color._getFormattedColor.apply(this,arguments);return i=o.Color._normalizeColorArray.call(this,i),this._colorMode===r.HSB&&(i=o.Color._getRGB(i)),o.Color._getColorString(i)},o.Color}({},core,constants),p5Element=function(t,e){function r(t,e,r){var o=e.bind(r);r.elt.addEventListener(t,o,!1),r._events[t]=o}var o=e;return o.Element=function(t,e){this.elt=t,this._pInst=e,this._events={},this.width=this.elt.offsetWidth,this.height=this.elt.offsetHeight},o.Element.prototype.parent=function(t){return"string"==typeof t?t=document.getElementById(t):t instanceof o.Element&&(t=t.elt),t.appendChild(this.elt),this},o.Element.prototype.id=function(t){return this.elt.id=t,this},o.Element.prototype.class=function(t){return this.elt.className+=" "+t,this},o.Element.prototype.mousePressed=function(t){return r("mousedown",t,this),r("touchstart",t,this),this},o.Element.prototype.mouseWheel=function(t){return r("mousewheel",t,this),this},o.Element.prototype.mouseReleased=function(t){return r("mouseup",t,this),r("touchend",t,this),this},o.Element.prototype.mouseClicked=function(t){return r("click",t,this),this},o.Element.prototype.mouseMoved=function(t){return r("mousemove",t,this),r("touchmove",t,this),this},o.Element.prototype.mouseOver=function(t){return r("mouseover",t,this),this},o.Element.prototype.mouseOut=function(t){return r("mouseout",t,this),this},o.Element.prototype.touchStarted=function(t){return r("touchstart",t,this),r("mousedown",t,this),this},o.Element.prototype.touchMoved=function(t){return r("touchmove",t,this),r("mousemove",t,this),this},o.Element.prototype.touchEnded=function(t){return r("touchend",t,this),r("mouseup",t,this),this},o.Element.prototype._setProperty=function(t,e){this[t]=e},o.Element}({},core),p5Graphics=function(t,e,r){var o=e,r=r;return o.Graphics=function(t,e,r){o.Element.call(this,t,e),this.canvas=t,this.drawingContext=this.canvas.getContext("2d"),this._pInst=e,r?(this._isMainCanvas=!0,this._pInst._setProperty("_curElement",this),this._pInst._setProperty("canvas",this.canvas),this._pInst._setProperty("drawingContext",this.drawingContext),this._pInst._setProperty("width",this.width),this._pInst._setProperty("height",this.height)):(this.canvas.style.display="none",this._styles=[])},o.Graphics.prototype=Object.create(o.Element.prototype),o.Graphics.prototype._applyDefaults=function(){this.drawingContext.fillStyle="#FFFFFF",this.drawingContext.strokeStyle="#000000",this.drawingContext.lineCap=r.ROUND,this.drawingContext.font="normal 12px sans-serif"},o.Graphics.prototype.resize=function(t,e){this.width=t,this.height=e,this.elt.width=t*this._pInst._pixelDensity,this.elt.height=e*this._pInst._pixelDensity,this.elt.style.width=t+"px",this.elt.style.height=e+"px",this._isMainCanvas&&(this._pInst._setProperty("width",this.width),this._pInst._setProperty("height",this.height)),this.drawingContext.scale(this._pInst._pixelDensity,this._pInst._pixelDensity)},o.Graphics}({},core,constants),filters=function(){"use strict";function t(t){var e=3.5*t|0;if(e=1>e?1:248>e?e:248,o!==e){o=e,n=1+o<<1,i=new Int32Array(n),s=new Array(n);for(var r=0;n>r;r++)s[r]=new Int32Array(256);for(var a,h,p,u,l=1,c=e-1;e>l;l++){i[e+l]=i[c]=h=c*c,p=s[e+l],u=s[c--];for(var d=0;256>d;d++)p[d]=u[d]=h*d}a=i[e]=e*e,p=s[e];for(var f=0;256>f;f++)p[f]=a*f}}function e(e,a){for(var h=r._toPixels(e),p=e.width,u=e.height,l=p*u,c=new Int32Array(l),d=0;l>d;d++)c[d]=r._getARGB(h,d);var f,g,y,m,w,v,_,x,C,b,S=new Int32Array(l),R=new Int32Array(l),T=new Int32Array(l),E=new Int32Array(l),M=0;t(a);var P,A,I,D;for(A=0;u>A;A++){for(P=0;p>P;P++){if(m=y=g=w=f=0,v=P-o,0>v)b=-v,v=0;else{if(v>=p)break;b=0}for(I=b;n>I&&!(v>=p);I++){var k=c[v+M];D=s[I],w+=D[(-16777216&k)>>>24],g+=D[(16711680&k)>>16],y+=D[(65280&k)>>8],m+=D[255&k],f+=i[I],v++}_=M+P,S[_]=w/f,R[_]=g/f,T[_]=y/f,E[_]=m/f}M+=p}for(M=0,x=-o,C=x*p,A=0;u>A;A++){for(P=0;p>P;P++){if(m=y=g=w=f=0,0>x)b=_=-x,v=P;else{if(x>=u)break;b=0,_=x,v=P+C}for(I=b;n>I&&!(_>=u);I++)D=s[I],w+=D[S[v]],g+=D[R[v]],y+=D[T[v]],m+=D[E[v]],f+=i[I],_++,v+=p;c[P+M]=w/f<<24|g/f<<16|y/f<<8|m/f}M+=p,C+=p,x++}r._setPixels(h,c)}var r={};r._toPixels=function(t){return t instanceof ImageData?t.data:t.getContext("2d").getImageData(0,0,t.width,t.height).data},r._getARGB=function(t,e){var r=4*e;return t[r+3]<<24&4278190080|t[r]<<16&16711680|t[r+1]<<8&65280|255&t[r+2]},r._setPixels=function(t,e){for(var r=0,o=0,n=t.length;n>o;o++)r=4*o,t[r+0]=(16711680&e[o])>>>16,t[r+1]=(65280&e[o])>>>8,t[r+2]=255&e[o],t[r+3]=(4278190080&e[o])>>>24},r._toImageData=function(t){return t instanceof ImageData?t:t.getContext("2d").getImageData(0,0,t.width,t.height)},r._createImageData=function(t,e){return r._tmpCanvas=document.createElement("canvas"),r._tmpCtx=r._tmpCanvas.getContext("2d"),this._tmpCtx.createImageData(t,e)},r.apply=function(t,e,r){var o=t.getContext("2d"),n=o.getImageData(0,0,t.width,t.height),i=e(n,r);i instanceof ImageData?o.putImageData(i,0,0,0,0,t.width,t.height):o.putImageData(n,0,0,0,0,t.width,t.height)},r.threshold=function(t,e){var o=r._toPixels(t);void 0===e&&(e=.5);for(var n=Math.floor(255*e),i=0;i=n?255:0,o[i]=o[i+1]=o[i+2]=s}},r.gray=function(t){for(var e=r._toPixels(t),o=0;oe||e>255)throw new Error("Level must be greater than 2 and less than 255 for posterize");for(var n=e-1,i=0;i>8)/n,o[i+1]=255*(a*e>>8)/n,o[i+2]=255*(h*e>>8)/n}},r.dilate=function(t){for(var e,o,n,i,s,a,h,p,u,l,c,d,f,g,y,m,w,v=r._toPixels(t),_=0,x=v.length?v.length/4:0,C=new Int32Array(x);x>_;)for(e=_,o=_+t.width;o>_;)n=i=r._getARGB(v,_),h=_-1,a=_+1,p=_-t.width,u=_+t.width,e>h&&(h=_),a>=o&&(a=_),0>p&&(p=0),u>=x&&(u=_),d=r._getARGB(v,p),c=r._getARGB(v,h),f=r._getARGB(v,u),l=r._getARGB(v,a),s=77*(n>>16&255)+151*(n>>8&255)+28*(255&n),y=77*(c>>16&255)+151*(c>>8&255)+28*(255&c),g=77*(l>>16&255)+151*(l>>8&255)+28*(255&l),m=77*(d>>16&255)+151*(d>>8&255)+28*(255&d),w=77*(f>>16&255)+151*(f>>8&255)+28*(255&f),y>s&&(i=c,s=y),g>s&&(i=l,s=g),m>s&&(i=d,s=m),w>s&&(i=f,s=w),C[_++]=i;r._setPixels(v,C)},r.erode=function(t){for(var e,o,n,i,s,a,h,p,u,l,c,d,f,g,y,m,w,v=r._toPixels(t),_=0,x=v.length?v.length/4:0,C=new Int32Array(x);x>_;)for(e=_,o=_+t.width;o>_;)n=i=r._getARGB(v,_),h=_-1,a=_+1,p=_-t.width,u=_+t.width,e>h&&(h=_),a>=o&&(a=_),0>p&&(p=0),u>=x&&(u=_),d=r._getARGB(v,p),c=r._getARGB(v,h),f=r._getARGB(v,u),l=r._getARGB(v,a),s=77*(n>>16&255)+151*(n>>8&255)+28*(255&n),y=77*(c>>16&255)+151*(c>>8&255)+28*(255&c),g=77*(l>>16&255)+151*(l>>8&255)+28*(255&l),m=77*(d>>16&255)+151*(d>>8&255)+28*(255&d),w=77*(f>>16&255)+151*(f>>8&255)+28*(255&f),s>y&&(i=c,s=y),s>g&&(i=l,s=g),s>m&&(i=d,s=m),s>w&&(i=f,s=w),C[_++]=i;r._setPixels(v,C)};var o,n,i,s;return r.blur=function(t,r){e(t,r)},r}({}),p5Image=function(t,e,r){"use strict";var o=e,n=r;return o.Image=function(t,e){this.width=t,this.height=e,this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.drawingContext=this.canvas.getContext("2d"),this.pixels=[]},o.Image.prototype._setProperty=function(t,e){this[t]=e},o.Image.prototype.loadPixels=function(){o.prototype.loadPixels.call(this)},o.Image.prototype.updatePixels=function(t,e,r,n){o.prototype.updatePixels.call(this,t,e,r,n)},o.Image.prototype.get=function(t,e,r,n){return o.prototype.get.call(this,t,e,r,n)},o.Image.prototype.set=function(t,e,r){o.prototype.set.call(this,t,e,r)},o.Image.prototype.resize=function(t,e){t=t||this.canvas.width,e=e||this.canvas.height;var r=document.createElement("canvas");r.width=t,r.height=e,r.getContext("2d").drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height,0,0,r.width,r.height),this.canvas.width=this.width=t,this.canvas.height=this.height=e,this.drawingContext.drawImage(r,0,0,t,e,0,0,t,e),this.pixels.length>0&&this.loadPixels()},o.Image.prototype.copy=function(){o.prototype.copy.apply(this,arguments)},o.Image.prototype.mask=function(t){void 0===t&&(t=this);var e=this.drawingContext.globalCompositeOperation,r=1;t instanceof o.Graphics&&(r=t._pInst._pixelDensity);var n=[t,0,0,r*t.width,r*t.height,0,0,this.width,this.height];this.drawingContext.globalCompositeOperation="destination-out",this.copy.apply(this,n),this.drawingContext.globalCompositeOperation=e},o.Image.prototype.filter=function(t,e){n.apply(this.canvas,n[t.toLowerCase()],e)},o.Image.prototype.blend=function(){o.prototype.blend.apply(this,arguments)},o.Image.prototype.save=function(t,e){var r;if(e)switch(e.toLowerCase()){case"png":r="image/png";break;case"jpeg":r="image/jpeg";break;case"jpg":r="image/jpeg";break;default:r="image/png"}else e="png",r="image/png";var n="image/octet-stream",i=this.canvas.toDataURL(r);i=i.replace(r,n),o.prototype.downloadFile(i,t,e)},o.Image}({},core,filters),polargeometry=function(){return{degreesToRadians:function(t){return 2*Math.PI*t/360},radiansToDegrees:function(t){return 360*t/(2*Math.PI)}}}({}),p5Vector=function(t,e,r,o){"use strict";var n=e,i=r,o=o;return n.Vector=function(){var t,e,r;arguments[0]instanceof n?(this.p5=arguments[0],t=arguments[1][0]||0,e=arguments[1][1]||0,r=arguments[1][2]||0):(t=arguments[0]||0,e=arguments[1]||0,r=arguments[2]||0),this.x=t,this.y=e,this.z=r},n.Vector.prototype.set=function(t,e,r){return t instanceof n.Vector?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this):t instanceof Array?(this.x=t[0]||0,this.y=t[1]||0,this.z=t[2]||0,this):(this.x=t||0,this.y=e||0,this.z=r||0,this)},n.Vector.prototype.get=function(){return this.p5?new n.Vector(this.p5,[this.x,this.y,this.z]):new n.Vector(this.x,this.y,this.z)},n.Vector.prototype.add=function(t,e,r){return t instanceof n.Vector?(this.x+=t.x||0,this.y+=t.y||0,this.z+=t.z||0,this):t instanceof Array?(this.x+=t[0]||0,this.y+=t[1]||0,this.z+=t[2]||0,this):(this.x+=t||0,this.y+=e||0,this.z+=r||0,this)},n.Vector.prototype.sub=function(t,e,r){return t instanceof n.Vector?(this.x-=t.x||0,this.y-=t.y||0,this.z-=t.z||0,this):t instanceof Array?(this.x-=t[0]||0,this.y-=t[1]||0,this.z-=t[2]||0,this):(this.x-=t||0,this.y-=e||0,this.z-=r||0,this)},n.Vector.prototype.mult=function(t){return this.x*=t||0,this.y*=t||0,this.z*=t||0,this},n.Vector.prototype.div=function(t){return this.x/=t,this.y/=t,this.z/=t,this},n.Vector.prototype.mag=function(){return Math.sqrt(this.magSq())},n.Vector.prototype.magSq=function(){var t=this.x,e=this.y,r=this.z;return t*t+e*e+r*r},n.Vector.prototype.dot=function(t,e,r){return t instanceof n.Vector?this.dot(t.x,t.y,t.z):this.x*(t||0)+this.y*(e||0)+this.z*(r||0)},n.Vector.prototype.cross=function(t){var e=this.y*t.z-this.z*t.y,r=this.z*t.x-this.x*t.z,o=this.x*t.y-this.y*t.x;return this.p5?new n.Vector(this.p5,[e,r,o]):new n.Vector(e,r,o)},n.Vector.prototype.dist=function(t){var e=t.get().sub(this);return e.mag()},n.Vector.prototype.normalize=function(){return this.div(this.mag())},n.Vector.prototype.limit=function(t){var e=this.magSq();return e>t*t&&(this.div(Math.sqrt(e)),this.mult(t)),this},n.Vector.prototype.setMag=function(t){return this.normalize().mult(t)},n.Vector.prototype.heading=function(){var t=Math.atan2(this.y,this.x);return this.p5?this.p5._angleMode===o.RADIANS?t:i.radiansToDegrees(t):t},n.Vector.prototype.rotate=function(t){this.p5&&this.p5._angleMode===o.DEGREES&&(t=i.degreesToRadians(t));var e=this.heading()+t,r=this.mag();return this.x=Math.cos(e)*r,this.y=Math.sin(e)*r,this},n.Vector.prototype.lerp=function(t,e,r,o){return t instanceof n.Vector?this.lerp(t.x,t.y,t.z,e):(this.x+=(t-this.x)*o||0,this.y+=(e-this.y)*o||0,this.z+=(r-this.z)*o||0,this)},n.Vector.prototype.array=function(){return[this.x||0,this.y||0,this.z||0]},n.Vector.fromAngle=function(t){return this.p5&&this.p5._angleMode===o.DEGREES&&(t=i.degreesToRadians(t)),this.p5?new n.Vector(this.p5,[Math.cos(t),Math.sin(t),0]):new n.Vector(Math.cos(t),Math.sin(t),0)},n.Vector.random2D=function(){var t;return t=this.p5?this.p5.random(this.p5._angleMode===o.DEGREES?360:o.TWO_PI):Math.random()*Math.PI*2,this.fromAngle(t)},n.Vector.random3D=function(){var t,e;this.p5?(t=this.p5.random(0,o.TWO_PI),e=this.p5.random(-1,1)):(t=Math.random()*Math.PI*2,e=2*Math.random()-1);var r=Math.sqrt(1-e*e)*Math.cos(t),i=Math.sqrt(1-e*e)*Math.sin(t);return this.p5?new n.Vector(this.p5,[r,i,e]):new n.Vector(r,i,e)},n.Vector.add=function(t,e){return t.get().add(e)},n.Vector.sub=function(t,e){return t.get().sub(e)},n.Vector.mult=function(t,e){return t.get().mult(e)},n.Vector.div=function(t,e){return t.get().div(e)},n.Vector.dot=function(t,e){return t.dot(e)},n.Vector.cross=function(t,e){return t.cross(e)},n.Vector.dist=function(t,e){return t.dist(e)},n.Vector.lerp=function(t,e,r){return t.get().lerp(e,r)},n.Vector.angleBetween=function(t,e){var r=Math.acos(t.dot(e)/(t.mag()*e.mag()));return this.p5&&this.p5._angleMode===o.DEGREES&&(r=i.radiansToDegrees(r)),r},n.Vector}({},core,polargeometry,constants),p5TableRow=function(t,e){"use strict";var r=e;return r.TableRow=function(t,e){var r=[],o={};t&&(e=e||",",r=t.split(e));for(var n=0;n=0))throw'This table has no column named "'+t+'"';this.obj[t]=e,this.arr[r]=e}else{if(!(ta;a++)s.push(r.prototype.lerp(t.rgba[a],e.rgba[a],o));return new r.Color(this,s)}return r.prototype.lerp(t,e,o)},r.prototype.red=function(t){if(t instanceof Array)return t[0];if(t instanceof r.Color)return t.rgba[0];throw new Error("Needs p5.Color or pixel array as argument.")},r.prototype.saturation=function(t){if(!t instanceof r.Color)throw new Error("Needs p5.Color as argument.");return t.hsba||(t.hsba=r.Color.getRGB(t.rgba),t.hsba=t.hsba.concat(t.rgba[3])),t.hsba[1]},r}({},core,p5Color),colorsetting=function(t,e,r){"use strict";var o=e,r=r;return o.prototype._doStroke=!0,o.prototype._doFill=!0,o.prototype._colorMode=r.RGB,o.prototype._maxRGB=[255,255,255,255],o.prototype._maxHSB=[255,255,255,255],o.prototype.background=function(){if(arguments[0]instanceof o.Image)this.image(arguments[0],0,0,this.width,this.height);else{var t=this.drawingContext.fillStyle,e=this.drawingContext;e.fillStyle=o.Color._getCanvasColor.apply(this,arguments),e.fillRect(0,0,this.width,this.height),e.fillStyle=t}},o.prototype.clear=function(){this.drawingContext.clearRect(0,0,this.width,this.height)},o.prototype.colorMode=function(){if(arguments[0]===r.RGB||arguments[0]===r.HSB){this._colorMode=arguments[0];var t=this._colorMode===r.RGB,e=t?this._maxRGB:this._maxHSB;2===arguments.length?(e[0]=arguments[1],e[1]=arguments[1],e[2]=arguments[1]):arguments.length>2&&(e[0]=arguments[1],e[1]=arguments[2],e[2]=arguments[3]),5===arguments.length&&(e[3]=arguments[4])}},o.prototype.fill=function(){this._setProperty("_doFill",!0);var t=this.drawingContext;t.fillStyle=o.Color._getCanvasColor.apply(this,arguments)},o.prototype.noFill=function(){this._setProperty("_doFill",!1)},o.prototype.noStroke=function(){this._setProperty("_doStroke",!1)},o.prototype.stroke=function(){this._setProperty("_doStroke",!0);var t=this.drawingContext;t.strokeStyle=o.Color._getCanvasColor.apply(this,arguments)},o}({},core,constants,p5Color),dataconversion=function(t,e){"use strict";var r=e;return r.prototype.float=function(t){return parseFloat(t)},r.prototype.int=function(t,e){return"string"==typeof t?(e=e||10,parseInt(t,e)):"number"==typeof t?0|t:"boolean"==typeof t?t?1:0:t instanceof Array?t.map(r.prototype.int):void 0},r}({},core),dataarray_functions=function(t,e){"use strict";var r=e;return r.prototype.append=function(t,e){return t.push(e),t},r.prototype.arrayCopy=function(t,e,r,o,n){var i,s;"undefined"!=typeof n?(s=Math.min(n,t.length),i=o,t=t.slice(e,s+e)):("undefined"!=typeof r?(s=r,s=Math.min(s,t.length)):s=t.length,i=0,r=e,t=t.slice(0,s)),Array.prototype.splice.apply(r,[i,s].concat(t))},r.prototype.concat=function(t,e){return t.concat(e)},r.prototype.reverse=function(t){return t.reverse()},r.prototype.shorten=function(t){return t.pop(),t},r.prototype.sort=function(t,e){var r=e?t.slice(0,Math.min(e,t.length)):t,o=e?t.slice(Math.min(e,t.length)):[];return r="string"==typeof r[0]?r.sort():r.sort(function(t,e){return t-e}),r.concat(o)},r.prototype.splice=function(t,e,r){return Array.prototype.splice.apply(t,[r,0].concat(e)),t},r.prototype.subset=function(t,e,r){return"undefined"!=typeof r?t.slice(e,e+r):t.slice(e,t.length)},r}({},core),datastring_functions=function(t,e){"use strict";function r(){var t=arguments[0],e=0>t,r=e?t.toString().substring(1):t.toString(),o=r.indexOf("."),n=-1!==o?r.substring(0,o):r,i=-1!==o?r.substring(o+1):"",s=e?"-":"";if(3===arguments.length){for(var a=0;a1&&(r=r.substring(0,arguments[1]+1)),o+r}function n(){return parseFloat(arguments[0])>0?"+"+arguments[0].toString():arguments[0].toString()}function i(){return parseFloat(arguments[0])>0?" "+arguments[0].toString():arguments[0].toString() }var s=e;return s.prototype.join=function(t,e){return t.join(e)},s.prototype.match=function(t,e){return t.match(e)},s.prototype.matchAll=function(t,e){for(var r=new RegExp(e,"g"),o=r.exec(t),n=[];null!==o;)n.push(o),o=r.exec(t);return n},s.prototype.nf=function(){if(arguments[0]instanceof Array){var t=arguments[1],e=arguments[2];return arguments[0].map(function(o){return r(o,t,e)})}return r.apply(this,arguments)},s.prototype.nfc=function(){if(arguments[0]instanceof Array){var t=arguments[1];return arguments[0].map(function(e){return o(e,t)})}return o.apply(this,arguments)},s.prototype.nfp=function(){var t=this.nf(arguments);return t instanceof Array?t.map(n):n(t)},s.prototype.nfs=function(){var t=this.nf(arguments);return t instanceof Array?t.map(i):i(t)},s.prototype.split=function(t,e){return t.split(e)},s.prototype.splitTokens=function(){var t=arguments.length>0?arguments[1]:/\s/g;return arguments[0].split(t).filter(function(t){return t})},s.prototype.trim=function(t){return t instanceof Array?t.map(this.trim):t.trim()},s}({},core),environment=function(t,e,r){"use strict";function o(t){var e=document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled;if(!e)throw new Error("Fullscreen not enabled in this browser.");t.requestFullscreen?t.requestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.msRequestFullscreen&&t.msRequestFullscreen()}function n(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}var i=e,s=r,a=[s.ARROW,s.CROSS,s.HAND,s.MOVE,s.TEXT,s.WAIT];return i.prototype._frameRate=0,i.prototype._lastFrameTime=(new Date).getTime(),i.prototype._targetFrameRate=60,i.prototype.frameCount=0,i.prototype.focused=!0,i.prototype.cursor=function(t,e,r){var o="auto",n=this._curElement.elt;if(a.indexOf(t)>-1)o=t;else if("string"==typeof t){var i="";e&&r&&"number"==typeof e&&"number"==typeof r&&(i=e+" "+r),o="http://"!==t.substring(0,6)?"url("+t+") "+i+", auto":/\.(cur|jpg|jpeg|gif|png|CUR|JPG|JPEG|GIF|PNG)$/.test(t)?"url("+t+") "+i+", auto":t}n.style.cursor=o},i.prototype.frameRate=function(t){return"undefined"==typeof t?this._frameRate:(this._setProperty("_targetFrameRate",t),this._runFrames(),this)},i.prototype.getFrameRate=function(){return this.frameRate()},i.prototype.setFrameRate=function(t){return this.frameRate(t)},i.prototype.noCursor=function(){this._curElement.elt.style.cursor="none"},i.prototype.displayWidth=screen.width,i.prototype.displayHeight=screen.height,i.prototype.windowWidth=window.innerWidth,i.prototype.windowHeight=window.innerHeight,i.prototype.onresize=function(t){this._setProperty("windowWidth",window.innerWidth),this._setProperty("windowHeight",window.innerHeight);var e,r=this._isGlobal?window:this;"function"==typeof r.windowResized&&(e=r.windowResized(t),void 0===e||e||t.preventDefault())},i.prototype.width=0,i.prototype.height=0,i.prototype.fullscreen=function(t){return"undefined"==typeof t?document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement:void(t?o(document.documentElement):n())},i.prototype.devicePixelScaling=function(t){this._pixelDensity=t?window.devicePixelRatio||1:1,this.resizeCanvas(this.width,this.height)},i.prototype.getURL=function(){return location.href},i.prototype.getURLPath=function(){return location.pathname.split("/").filter(function(t){return""!==t})},i.prototype.getURLParams=function(){for(var t,e=/[?&]([^&=]+)(?:[&=])([^&=]+)/gim,r={};null!=(t=e.exec(location.search));)t.index===e.lastIndex&&e.lastIndex++,r[t[1]]=t[2];return r},i}({},core,constants),imageimage=function(t,e,r){"use strict";var o=e,r=r;return o.prototype._imageMode=r.CORNER,o.prototype._tint=null,o.prototype.createImage=function(t,e){return new o.Image(t,e)},o}({},core,constants),canvas=function(t,e){var e=e;return{modeAdjust:function(t,r,o,n,i){return i===e.CORNER?{x:t,y:r,w:o,h:n}:i===e.CORNERS?{x:t,y:r,w:o-t,h:n-r}:i===e.RADIUS?{x:t-o,y:r-n,w:2*o,h:2*n}:i===e.CENTER?{x:t-.5*o,y:r-.5*n,w:o,h:n}:void 0},arcModeAdjust:function(t,r,o,n,i){return i===e.CORNER?{x:t+.5*o,y:r+.5*n,w:o,h:n}:i===e.CORNERS?{x:t,y:r,w:o+t,h:n+r}:i===e.RADIUS?{x:t,y:r,w:2*o,h:2*n}:i===e.CENTER?{x:t,y:r,w:o,h:n}:void 0}}}({},constants),imageloading_displaying=function(t,e,r,o,n){"use strict";var i=e,s=r,o=o,n=n;return i.prototype.loadImage=function(t,e){var r=new Image,o=new i.Image(1,1,this);return r.onload=function(){o.width=o.canvas.width=r.width,o.height=o.canvas.height=r.height,o.canvas.getContext("2d").drawImage(r,0,0),"undefined"!=typeof e&&e(o)},0!==t.indexOf("data:image/")&&(r.crossOrigin="Anonymous"),r.src=t,o},i.prototype.image=function(t,e,r,n,i){var s=t.canvas||t.elt;e=e||0,r=r||0,n=n||t.width,i=i||t.height;var a=o.modeAdjust(e,r,n,i,this._imageMode);this._tint&&t.canvas?this.drawingContext.drawImage(this._getTintedImageCanvas(t),a.x,a.y,a.w,a.h):this.drawingContext.drawImage(s,a.x,a.y,a.w,a.h)},i.prototype.tint=function(){var t=i.Color._getFormattedColor.apply(this,arguments);t=i.Color._normalizeColorArray.call(this,t),this._tint=t},i.prototype.noTint=function(){this._tint=null},i.prototype._getTintedImageCanvas=function(t){if(!t.canvas)return t;var e=s._toPixels(t.canvas),r=document.createElement("canvas");r.width=t.canvas.width,r.height=t.canvas.height;for(var o=r.getContext("2d"),n=o.createImageData(t.canvas.width,t.canvas.height),i=n.data,a=0;athis.width||e>this.height||0>t||0>e)return[0,0,0,255];var i=this.drawingContext.getImageData(t,e,r,n),s=i.data;if(1===r&&1===n){for(var a=[],h=0;h0;)self._completeHandlers.shift()(t)}function success(resp){resp="jsonp"!==type?self.request:resp;var filteredResponse=globalSetupOptions.dataFilter(resp.responseText,type),r=filteredResponse;try{resp.responseText=r}catch(e){}if(r)switch(type){case"json":try{resp=win.JSON?win.JSON.parse(r):eval("("+r+")")}catch(err){return error(resp,"Could not parse JSON in response",err)}break;case"js":resp=eval(r);break;case"html":resp=r;break;case"xml":resp=resp.responseXML&&resp.responseXML.parseError&&resp.responseXML.parseError.errorCode&&resp.responseXML.parseError.reason?null:resp.responseXML}for(self._responseArgs.resp=resp,self._fulfilled=!0,fn(resp),self._successHandler(resp);self._fulfillmentHandlers.length>0;)resp=self._fulfillmentHandlers.shift()(resp);complete(resp)}function error(t,e,r){for(t=self.request,self._responseArgs.resp=t,self._responseArgs.msg=e,self._responseArgs.t=r,self._erred=!0;self._errorHandlers.length>0;)self._errorHandlers.shift()(t,e,r);complete(t)}this.url="string"==typeof o?o:o.url,this.timeout=null,this._fulfilled=!1,this._successHandler=function(){},this._fulfillmentHandlers=[],this._errorHandlers=[],this._completeHandlers=[],this._erred=!1,this._responseArgs={};var self=this,type=o.type||setType(this.url);fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){self.abort()},o.timeout)),o.success&&(this._successHandler=function(){o.success.apply(o,arguments)}),o.error&&this._errorHandlers.push(function(){o.error.apply(o,arguments)}),o.complete&&this._completeHandlers.push(function(){o.complete.apply(o,arguments)}),this.request=getRequest.call(this,success,error)}function reqwest(t,e){return new Reqwest(t,e)}function normalize(t){return t?t.replace(/\r?\n/g,"\r\n"):""}function serial(t,e){var r,o,n,i,s=t.name,a=t.tagName.toLowerCase(),h=function(t){t&&!t.disabled&&e(s,normalize(t.attributes.value&&t.attributes.value.specified?t.value:t.text))};if(!t.disabled&&s)switch(a){case"input":/reset|button|image|file/i.test(t.type)||(r=/checkbox/i.test(t.type),o=/radio/i.test(t.type),n=t.value,(!(r||o)||t.checked)&&e(s,normalize(r&&""===n?"on":n)));break;case"textarea":e(s,normalize(t.value));break;case"select":if("select-one"===t.type.toLowerCase())h(t.selectedIndex>=0?t.options[t.selectedIndex]:null);else for(i=0;t.length&&ie){var i=t;t=e,e=i}return r*(e-t)+t};var i,s=!1;return r.prototype.randomGaussian=function(t,e){var r,o,n,a;if(s)r=i,s=!1;else{do o=this.random(2)-1,n=this.random(2)-1,a=o*o+n*n;while(a>=1);a=Math.sqrt(-2*Math.log(a)/a),r=o*a,i=n*a,s=!0}var h=t||0,p=e||1;return r*p+h},r}({},core),mathnoise=function(t,e){"use strict";for(var r=e,o=4,n=1<g;g++)c[g]=Math.sin(g*f*u),d[g]=Math.cos(g*f*u);var y=l;y>>=1;var m;return r.prototype.noise=function(t,e,r){if(e=e||0,r=r||0,null==m){m=new Array(a+1);for(var u=0;a+1>u;u++)m[u]=Math.random()}0>t&&(t=-t),0>e&&(e=-e),0>r&&(r=-r);for(var c,f,g,w,v,_=Math.floor(t),x=Math.floor(e),C=Math.floor(r),b=t-_,S=e-x,R=r-C,T=0,E=.5,M=function(t){return.5*(1-d[Math.floor(t*y)%l])},P=0;h>P;P++){var A=_+(x<=1&&(_++,b--),S>=1&&(x++,S--),R>=1&&(C++,R--)}return T},r.prototype.noiseDetail=function(t,e){t>0&&(h=t),e>0&&(p=e)},r.prototype.noiseSeed=function(t){var e=function(){var t,e,r=4294967296,o=1664525,n=1013904223;return{setSeed:function(o){e=t=o||Math.round(Math.random()*r)},getSeed:function(){return t},rand:function(){return e=(o*e+n)%r,e/r}}}();e.setSeed(t),m=new Array(a+1);for(var r=0;a+1>r;r++)m[r]=e.rand()},r}({},core),mathtrigonometry=function(t,e,r,o){"use strict";var n=e,i=r,o=o;return n.prototype._angleMode=o.RADIANS,n.prototype.acos=function(t){return this._angleMode===o.RADIANS?Math.acos(t):i.radiansToDegrees(Math.acos(t))},n.prototype.asin=function(t){return this._angleMode===o.RADIANS?Math.asin(t):i.radiansToDegrees(Math.asin(t))},n.prototype.atan=function(t){return this._angleMode===o.RADIANS?Math.atan(t):i.radiansToDegrees(Math.atan(t))},n.prototype.atan2=function(t,e){return this._angleMode===o.RADIANS?Math.atan2(t,e):i.radiansToDegrees(Math.atan2(t,e))},n.prototype.cos=function(t){return Math.cos(this._angleMode===o.RADIANS?t:this.radians(t))},n.prototype.sin=function(t){return Math.sin(this._angleMode===o.RADIANS?t:this.radians(t))},n.prototype.tan=function(t){return Math.tan(this._angleMode===o.RADIANS?t:this.radians(t))},n.prototype.degrees=function(t){return i.radiansToDegrees(t)},n.prototype.radians=function(t){return i.degreesToRadians(t)},n.prototype.angleMode=function(t){(t===o.DEGREES||t===o.RADIANS)&&(this._angleMode=t)},n}({},core,polargeometry,constants),outputfiles=function(t,e){"use strict";function r(t,e){e||(e=""),t||(t="untitled");var r="";return t&&t.indexOf(".")>-1&&(r=t.split(".").pop()),e&&r!==e&&(r=e,t=t+"."+r),[t,r]}function o(t){document.body.removeChild(t.target)}var n=e;window.URL=window.URL||window.webkitURL,n.prototype._pWriters=[],n.prototype.beginRaw=function(){throw"not yet implemented"},n.prototype.beginRecord=function(){throw"not yet implemented"},n.prototype.createOutput=function(){throw"not yet implemented"},n.prototype.createWriter=function(t,e){var r;for(var o in n.prototype._pWriters)if(n.prototype._pWriters[o].name===t)return r=new n.PrintWriter(t+window.millis(),e),n.prototype._pWriters.push(r),r;return r=new n.PrintWriter(t,e),n.prototype._pWriters.push(r),r},n.prototype.endRaw=function(){throw"not yet implemented"},n.prototype.endRecord=function(){throw"not yet implemented"},n.PrintWriter=function(t,e){var r=this;this.name=t,this.content="",this.print=function(t){this.content+=t},this.println=function(t){this.content+=t+"\n"},this.flush=function(){this.content=""},this.close=function(){var o=[];o.push(this.content),n.prototype.writeFile(o,t,e);for(var i in n.prototype._pWriters)n.prototype._pWriters[i].name===this.name&&n.prototype._pWriters.splice(i,1);r.flush(),r={}}},n.prototype.saveBytes=function(){throw"not yet implemented"},n.prototype.save=function(){var t=arguments,e=this._curElement.elt;if(0===t.length)return void n.prototype.saveCanvas(e);if(t[0]instanceof n.Graphics)return void n.prototype.saveCanvas(t[0].elt,t[1],t[2]);if("string"==typeof t[0])n.prototype.saveCanvas(e,t[0]); else{var o=r(t[1],t[2])[1];switch(o){case"json":n.prototype.saveJSON(t[0],t[1],t[2]);break;case"txt":n.prototype.saveStrings(t[0],t[1],t[2]);break;default:t[0]instanceof Array?n.prototype.saveStrings(t[0],t[1],t[2]):t[0]instanceof n.Table?n.prototype.saveTable(t[0],t[1],t[2],t[3]):t[0]instanceof n.Image?n.prototype.saveCanvas(t[0].canvas,t[1]):t[0]instanceof n.SoundFile?n.prototype.saveSound(t[0],t[1],t[2],t[3]):t[0]instanceof Object&&n.prototype.saveJSON(t[0],t[1],t[2])}}},n.prototype.saveJSON=function(t,e,r){var o;o=r?JSON.stringify(t):JSON.stringify(t,void 0,2),this.saveStrings(o.split("\n"),e,"json")},n.prototype.saveJSONObject=n.prototype.saveJSON,n.prototype.saveJSONArray=n.prototype.saveJSON,n.prototype.saveStream=function(){throw"not yet implemented"},n.prototype.saveStrings=function(t,e,r){var o=r||"txt",n=this.createWriter(e,o);for(var i in t)i"),o.println("");var u=' "),o.println(""),o.println(" "),"0"!==n[0]){o.println(" ");for(var l=0;l"+c),o.println(" ")}o.println(" ")}for(var d=0;d");for(var f=0;f"+y),o.println(" ")}o.println(" ")}o.println("
"),o.println(""),o.print("")}o.close(),o.flush()};var i=function(t){return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")};return n.prototype.writeFile=function(t,e,r){var o="application/octet-stream";n.prototype._isSafari()&&(o="text/plain");var i=new Blob(t,{type:o}),s=window.URL.createObjectURL(i);n.prototype.downloadFile(s,e,r)},n.prototype.downloadFile=function(t,e,i){var s=r(e,i),a=s[0],h=s[1],p=document.createElement("a");if(p.href=t,p.download=a,p.onclick=o,p.style.display="none",document.body.appendChild(p),n.prototype._isSafari()){var u="Hello, Safari user! To download this file...\n";u+="1. Go to File --> Save As.\n",u+='2. Choose "Page Source" as the Format.\n',u+='3. Name it with this extension: ."'+h+'"',alert(u)}p.click(),t=null},n.prototype._checkFileExtension=r,n.prototype._isSafari=function(){var t=Object.prototype.toString.call(window.HTMLElement);return t.indexOf("Constructor")>0},n}({},core),outputimage=function(t,e){"use strict";var r=e,o=[];return r.prototype.saveCanvas=function(t,e,o){o||(o=r.prototype._checkFileExtension(e,o)[1],""===o&&(o="png"));var n;if(t?n=t:this._curElement&&this._curElement.elt&&(n=this._curElement.elt),r.prototype._isSafari()){var i="Hello, Safari user!\n";i+="Now capturing a screenshot...\n",i+="To save this image,\n",i+="go to File --> Save As.\n",alert(i),window.location.href=n.toDataURL()}else{var s;if("undefined"==typeof o)o="png",s="image/png";else switch(o){case"png":s="image/png";break;case"jpeg":s="image/jpeg";break;case"jpg":s="image/jpeg";break;default:s="image/png"}var a="image/octet-stream",h=n.toDataURL(s);h=h.replace(s,a),r.prototype.downloadFile(h,e,o)}},r.prototype.saveFrames=function(t,e,n,i,s){var a=n||3;a=r.prototype.constrain(a,0,15),a=1e3*a;var h=i||15;h=r.prototype.constrain(h,0,22);var p=0,u=r.prototype._makeFrame,l=this._curElement.elt,c=setInterval(function(){u(t+p,e,l),p++},1e3/h);setTimeout(function(){if(clearInterval(c),s)s(o);else for(var t=0;tu.w?u.h/2:u.w/2,c=u.h>u.w?u.w/u.h:1,d=u.h>u.w?1:u.h/u.w;return p.save(),p.scale(c,d),p.beginPath(),p.arc(u.x,u.y,l,s,a),this._doStroke&&p.stroke(),h===o.CHORD||h===o.OPEN?p.closePath():(h===o.PIE||void 0===h)&&(p.lineTo(u.x,u.y),p.closePath()),this._doFill&&p.fill(),this._doStroke&&h!==o.OPEN&&void 0!==h&&p.stroke(),p.restore(),this}},n.prototype.ellipse=function(t,e,o,n){if(this._doStroke||this._doFill){o=Math.abs(o),n=Math.abs(n);var i=this.drawingContext,s=r.modeAdjust(t,e,o,n,this._ellipseMode);if(i.beginPath(),o===n)i.arc(s.x+s.w/2,s.y+s.w/2,s.w/2,0,2*Math.PI,!1);else{var a=.5522848,h=s.w/2*a,p=s.h/2*a,u=s.x+s.w,l=s.y+s.h,c=s.x+s.w/2,d=s.y+s.h/2;i.moveTo(s.x,d),i.bezierCurveTo(s.x,d-p,c-h,s.y,c,s.y),i.bezierCurveTo(c+h,s.y,u,d-p,u,d),i.bezierCurveTo(u,d+p,c+h,l,c,l),i.bezierCurveTo(c-h,l,s.x,d+p,s.x,d),i.closePath()}return this._doFill&&i.fill(),this._doStroke&&i.stroke(),this}},n.prototype.line=function(t,e,r,o){if(this._doStroke){var n=this.drawingContext;if("rgba(0,0,0,0)"!==n.strokeStyle)return n.beginPath(),n.moveTo(t,e),n.lineTo(r,o),n.stroke(),this}},n.prototype.point=function(t,e){if(this._doStroke){var r=this.drawingContext,n=r.strokeStyle,i=r.fillStyle;if("rgba(0,0,0,0)"!==n)return t=Math.round(t),e=Math.round(e),r.fillStyle=n,r.lineWidth>1?(r.beginPath(),r.arc(t,e,r.lineWidth/2,0,o.TWO_PI,!1),r.fill()):r.fillRect(t,e,1,1),r.fillStyle=i,this}},n.prototype.quad=function(t,e,r,o,n,i,s,a){if(this._doStroke||this._doFill){var h=this.drawingContext;return h.beginPath(),h.moveTo(t,e),h.lineTo(r,o),h.lineTo(n,i),h.lineTo(s,a),h.closePath(),this._doFill&&h.fill(),this._doStroke&&h.stroke(),this}},n.prototype.rect=function(t,e,o,n){if(this._doStroke||this._doFill){var i=r.modeAdjust(t,e,o,n,this._rectMode),s=this.drawingContext;return this._doStroke&&s.lineWidth%2===1&&s.translate(.5,.5),s.beginPath(),s.rect(i.x,i.y,i.w,i.h),this._doFill&&s.fill(),this._doStroke&&s.stroke(),this._doStroke&&s.lineWidth%2===1&&s.translate(-.5,-.5),this}},n.prototype.triangle=function(t,e,r,o,n,i){if(this._doStroke||this._doFill){var s=this.drawingContext;return s.beginPath(),s.moveTo(t,e),s.lineTo(r,o),s.lineTo(n,i),s.closePath(),this._doFill&&s.fill(),this._doStroke&&s.stroke(),this}},n}({},core,canvas,constants),shapeattributes=function(t,e,r){"use strict";var o=e,r=r;return o.prototype._rectMode=r.CORNER,o.prototype._ellipseMode=r.CENTER,o.prototype.ellipseMode=function(t){return(t===r.CORNER||t===r.CORNERS||t===r.RADIUS||t===r.CENTER)&&(this._ellipseMode=t),this},o.prototype.noSmooth=function(){return this.drawingContext.mozImageSmoothingEnabled=!1,this.drawingContext.webkitImageSmoothingEnabled=!1,this},o.prototype.rectMode=function(t){return(t===r.CORNER||t===r.CORNERS||t===r.RADIUS||t===r.CENTER)&&(this._rectMode=t),this},o.prototype.smooth=function(){return this.drawingContext.mozImageSmoothingEnabled=!0,this.drawingContext.webkitImageSmoothingEnabled=!0,this},o.prototype.strokeCap=function(t){return(t===r.ROUND||t===r.SQUARE||t===r.PROJECT)&&(this.drawingContext.lineCap=t),this},o.prototype.strokeJoin=function(t){return(t===r.ROUND||t===r.BEVEL||t===r.MITER)&&(this.drawingContext.lineJoin=t),this},o.prototype.strokeWeight=function(t){return this.drawingContext.lineWidth="undefined"==typeof t||0===t?1e-4:t,this},o}({},core,constants),shapecurves=function(t,e){"use strict";var r=e,o=20,n=20;return r.prototype._curveTightness=0,r.prototype.bezier=function(t,e,r,o,n,i,s,a){return this._doStroke?(this.beginShape(),this.vertex(t,e),this.bezierVertex(r,o,n,i,s,a),this.endShape(),this.stroke(),this):void 0},r.prototype.bezierDetail=function(t){return o=t,this},r.prototype.bezierPoint=function(t,e,r,o,n){var i=1-n;return Math.pow(i,3)*t+3*Math.pow(i,2)*n*e+3*i*Math.pow(n,2)*r+Math.pow(n,3)*o},r.prototype.bezierTangent=function(t,e,r,o,n){var i=1-n;return 3*o*Math.pow(n,2)-3*r*Math.pow(n,2)+6*r*i*n-6*e*i*n+3*e*Math.pow(i,2)-3*t*Math.pow(i,2)},r.prototype.curve=function(t,e,r,o,n,i,s,a){return this._doStroke?(this.beginShape(),this.curveVertex(t,e),this.curveVertex(r,o),this.curveVertex(n,i),this.curveVertex(s,a),this.endShape(),this.stroke(),this):void 0},r.prototype.curveDetail=function(t){return n=t,this},r.prototype.curveTightness=function(t){this._setProperty("_curveTightness",t)},r.prototype.curvePoint=function(t,e,r,o,n){var i=n*n*n,s=n*n,a=-.5*i+s-.5*n,h=1.5*i-2.5*s+1,p=-1.5*i+2*s+.5*n,u=.5*i-.5*s;return t*a+e*h+r*p+o*u},r.prototype.curveTangent=function(t,e,r,o,n){var i=n*n,s=-3*i/2+2*n-.5,a=9*i/2-5*n,h=-9*i/2+4*n+.5,p=3*i/2-n;return t*s+e*a+r*h+o*p},r.prototype.curveTightness=function(){throw"not yet implemented"},r}({},core),shapevertex=function(t,e,r){"use strict";var o=e,r=r,n=null,i=[],s=[],a=!1,h=!1,p=!1,u=!1;return o.prototype._doFillStrokeClose=function(){this._doFill&&this.drawingContext.fill(),this._doStroke&&this.drawingContext.stroke(),this.drawingContext.closePath()},o.prototype.beginContour=function(){return s=[],u=!0,this},o.prototype.beginShape=function(t){return n=t===r.POINTS||t===r.LINES||t===r.TRIANGLES||t===r.TRIANGLE_FAN||t===r.TRIANGLE_STRIP||t===r.QUADS||t===r.QUAD_STRIP?t:null,i=[],s=[],this},o.prototype.bezierVertex=function(){if(0===i.length)throw"vertex() must be used once before calling bezierVertex()";a=!0;for(var t=[],e=0;es;s++)e=i[s],this._doStroke&&this.stroke(e[6]),this.point(e[0],e[1]);else if(n===r.LINES)for(s=0;c>s+1;s+=2)e=i[s],this._doStroke&&this.stroke(i[s+1][6]),this.line(e[0],e[1],i[s+1][0],i[s+1][1]);else if(n===r.TRIANGLES)for(s=0;c>s+2;s+=3)e=i[s],this.drawingContext.beginPath(),this.drawingContext.moveTo(e[0],e[1]),this.drawingContext.lineTo(i[s+1][0],i[s+1][1]),this.drawingContext.lineTo(i[s+2][0],i[s+2][1]),this.drawingContext.lineTo(e[0],e[1]),this._doFill&&(this.fill(i[s+2][5]),this.drawingContext.fill()),this._doStroke&&(this.stroke(i[s+2][6]),this.drawingContext.stroke()),this.drawingContext.closePath();else if(n===r.TRIANGLE_STRIP)for(s=0;c>s+1;s++)e=i[s],this.drawingContext.beginPath(),this.drawingContext.moveTo(i[s+1][0],i[s+1][1]),this.drawingContext.lineTo(e[0],e[1]),this._doStroke&&this.stroke(i[s+1][6]),this._doFill&&this.fill(i[s+1][5]),c>s+2&&(this.drawingContext.lineTo(i[s+2][0],i[s+2][1]),this._doStroke&&this.stroke(i[s+2][6]),this._doFill&&this.fill(i[s+2][5])),this._doFillStrokeClose();else if(n===r.TRIANGLE_FAN){if(c>2)for(this.drawingContext.beginPath(),this.drawingContext.moveTo(i[0][0],i[0][1]),this.drawingContext.lineTo(i[1][0],i[1][1]),this.drawingContext.lineTo(i[2][0],i[2][1]),this._doFill&&this.fill(i[2][5]),this._doStroke&&this.stroke(i[2][6]),this._doFillStrokeClose(),s=3;c>s;s++)e=i[s],this.drawingContext.beginPath(),this.drawingContext.moveTo(i[0][0],i[0][1]),this.drawingContext.lineTo(i[s-1][0],i[s-1][1]),this.drawingContext.lineTo(e[0],e[1]),this._doFill&&this.fill(e[5]),this._doStroke&&this.stroke(e[6]),this._doFillStrokeClose()}else if(n===r.QUADS)for(s=0;c>s+3;s+=4){for(e=i[s],this.drawingContext.beginPath(),this.drawingContext.moveTo(e[0],e[1]),l=1;4>l;l++)this.drawingContext.lineTo(i[s+l][0],i[s+l][1]);this.drawingContext.lineTo(e[0],e[1]),this._doFill&&this.fill(i[s+3][5]),this._doStroke&&this.stroke(i[s+3][6]),this._doFillStrokeClose()}else if(n===r.QUAD_STRIP){if(c>3)for(s=0;c>s+1;s+=2)e=i[s],this.drawingContext.beginPath(),c>s+3?(this.drawingContext.moveTo(i[s+2][0],i[s+2][1]),this.drawingContext.lineTo(e[0],e[1]),this.drawingContext.lineTo(i[s+1][0],i[s+1][1]),this.drawingContext.lineTo(i[s+3][0],i[s+3][1]),this._doFill&&this.fill(i[s+3][5]),this._doStroke&&this.stroke(i[s+3][6])):(this.drawingContext.moveTo(e[0],e[1]),this.drawingContext.lineTo(i[s+1][0],i[s+1][1])),this._doFillStrokeClose()}else{for(this.drawingContext.beginPath(),this.drawingContext.moveTo(i[0][0],i[0][1]),s=1;c>s;s++)e=i[s],e.isVert&&(e.moveTo?this.drawingContext.moveTo(e[0],e[1]):this.drawingContext.lineTo(e[0],e[1]));this._doFillStrokeClose()}else{for(this.drawingContext.beginPath(),s=0;c>s;s++)i[s].isVert?i[s].moveTo?this.drawingContext.moveTo([0],i[s][1]):this.drawingContext.lineTo(i[s][0],i[s][1]):this.drawingContext.quadraticCurveTo(i[s][0],i[s][1],i[s][2],i[s][3]);this._doFillStrokeClose()}else{for(this.drawingContext.beginPath(),s=0;c>s;s++)i[s].isVert?i[s].moveTo?this.drawingContext.moveTo(i[s][0],i[s][1]):this.drawingContext.lineTo(i[s][0],i[s][1]):this.drawingContext.bezierCurveTo(i[s][0],i[s][1],i[s][2],i[s][3],i[s][4],i[s][5]);this._doFillStrokeClose()}else if(c>3){var d=[],f=1-this._curveTightness;for(this.drawingContext.beginPath(),this.drawingContext.moveTo(i[1][0],i[1][1]),s=1;c>s+2;s++)e=i[s],d[0]=[e[0],e[1]],d[1]=[e[0]+(f*i[s+1][0]-f*i[s-1][0])/6,e[1]+(f*i[s+1][1]-f*i[s-1][1])/6],d[2]=[i[s+1][0]+(f*i[s][0]-f*i[s+2][0])/6,i[s+1][1]+(f*i[s][1]-f*i[s+2][1])/6],d[3]=[i[s+1][0],i[s+1][1]],this.drawingContext.bezierCurveTo(d[1][0],d[1][1],d[2][0],d[2][1],d[3][0],d[3][1]);o&&this.drawingContext.lineTo(i[s+1][0],i[s+1][1]),this._doFillStrokeClose()}return h=!1,a=!1,p=!1,u=!1,o&&i.pop(),this},o.prototype.quadraticVertex=function(t,e,o,n){if(this._contourInited){var a={};return a.x=t,a.y=e,a.x3=o,a.y3=n,a.type=r.QUADRATIC,this._contourVertices.push(a),this}if(!(i.length>0))throw"vertex() must be used once before calling quadraticVertex()";p=!0;for(var h=[],l=0;lo?(this._doFill&&this.drawingContext.fillText(a,e,r),this._doStroke&&this.drawingContext.strokeText(a,e,r),a=h[p]+" ",r+=this._textLeading):a=u}this._doFill&&this.drawingContext.fillText(a,e,r),this._doStroke&&this.drawingContext.strokeText(a,e,r),r+=this._textLeading}}},r.prototype.textFont=function(t){this._setProperty("_textFont",t),this._applyTextProperties()},r}({},core),src_app=function(t,e){"use strict";var r=e,o=function(){window.PHANTOMJS||(window.setup&&"function"==typeof window.setup||window.draw&&"function"==typeof window.draw)&&new r};return"complete"===document.readyState?o():window.addEventListener("load",o,!1),window.p5=r,r}({},core,p5Color,p5Element,p5Graphics,p5Image,p5Vector,p5TableRow,p5Table,colorcreating_reading,colorsetting,constants,dataconversion,dataarray_functions,datastring_functions,environment,imageimage,imageloading_displaying,imagepixels,inputfiles,inputkeyboard,inputmouse,inputtime_date,inputtouch,mathmath,mathcalculation,mathrandom,mathnoise,mathtrigonometry,outputfiles,outputimage,outputtext_area,renderingrendering,shape2d_primitives,shapeattributes,shapecurves,shapevertex,structure,transform,typographyattributes,typographyloading_displaying);