diff --git a/docs/js/p5.js b/docs/js/p5.js index 0eddf1870e..7ea38959bb 100644 --- a/docs/js/p5.js +++ b/docs/js/p5.js @@ -1731,17 +1731,17 @@ var colorcreating_reading = function (require, core, p5Color) { if (c1 instanceof Array) { var c = []; for (var i = 0; i < c1.length; i++) { - c.push(p5.prototype.lerp(c1[i], c2[i], amt)); + c.push(Math.sqrt(p5.prototype.lerp(c1[i]*c1[i], c2[i]*c2[i], amt))); } return c; } else if (c1 instanceof p5.Color) { var pc = []; for (var j = 0; j < 4; j++) { - pc.push(p5.prototype.lerp(c1.rgba[j], c2.rgba[j], amt)); + pc.push(Math.sqrt(p5.prototype.lerp(c1.rgba[j]*c1.rgba[j], c2.rgba[j]*c2.rgba[j], amt))); } return new p5.Color(this, pc); } else { - return p5.prototype.lerp(c1, c2, amt); + return Math.sqrt(p5.prototype.lerp(c1*c1, c2*c2, amt)); } }; p5.prototype.red = function (c) { diff --git a/lib/p5.js b/lib/p5.js index 5e53d2569e..2c0b43d10c 100644 --- a/lib/p5.js +++ b/lib/p5.js @@ -1,4 +1,4 @@ -/*! p5.js v0.4.4 April 30, 2015 */ +/*! p5.js v0.4.4 May 12, 2015 */ (function (root, factory) { if (typeof define === 'function' && define.amd) define('p5', [], function () { return (root.returnExportsGlobal = factory());}); @@ -2104,17 +2104,17 @@ amdclean['colorcreating_reading'] = function (require, core, p5Color) { if (c1 instanceof Array) { var c = []; for (var i = 0; i < c1.length; i++) { - c.push(Math.sqrt(p5.prototype.lerp(c1[i]*c1[i], c2[i]*c2[i], amt))); + c.push(Math.sqrt(p5.prototype.lerp(c1[i] * c1[i], c2[i] * c2[i], amt))); } return c; } else if (c1 instanceof p5.Color) { var pc = []; for (var j = 0; j < 4; j++) { - pc.push(Math.sqrt(p5.prototype.lerp(c1.rgba[j]*c1.rgba[j], c2.rgba[j]*c2.rgba[j], amt))); + pc.push(Math.sqrt(p5.prototype.lerp(c1.rgba[j] * c1.rgba[j], c2.rgba[j] * c2.rgba[j], amt))); } return new p5.Color(this, pc); } else { - return Math.sqrt(p5.prototype.lerp(c1*c1, c2*c2, amt)); + return Math.sqrt(p5.prototype.lerp(c1 * c1, c2 * c2, amt)); } }; p5.prototype.red = function (c) { @@ -2225,7 +2225,78 @@ amdclean['dataconversion'] = function (require, core) { } else if (typeof n === 'boolean') { return n ? 1 : 0; } else if (n instanceof Array) { - return n.map(p5.prototype.int); + return n.map(function (n) { + return p5.prototype.int(n, radix); + }); + } + }; + p5.prototype.str = function (n) { + if (n instanceof Array) { + return n.map(p5.prototype.str); + } else { + return String(n); + } + }; + p5.prototype.boolean = function (n) { + if (typeof n === 'number') { + return n !== 0; + } else if (typeof n === 'string') { + return n.toLowerCase() === 'true'; + } else if (typeof n === 'boolean') { + return n; + } else if (n instanceof Array) { + return n.map(p5.prototype.boolean); + } + }; + p5.prototype.byte = function (n) { + var nn = p5.prototype.int(n, 10); + if (typeof nn === 'number') { + return (nn + 128) % 256 - 128; + } else if (nn instanceof Array) { + return nn.map(p5.prototype.byte); + } + }; + p5.prototype.char = function (n) { + if (typeof n === 'number' && !isNaN(n)) { + return String.fromCharCode(n); + } else if (n instanceof Array) { + return n.map(p5.prototype.char); + } else if (typeof n === 'string') { + return p5.prototype.char(parseInt(n, 10)); + } + }; + p5.prototype.unchar = function (n) { + if (typeof n === 'string' && n.length === 1) { + return n.charCodeAt(0); + } else if (n instanceof Array) { + return n.map(p5.prototype.unchar); + } + }; + p5.prototype.hex = function (n, digits) { + digits = digits === undefined || digits === null ? digits = 8 : digits; + if (n instanceof Array) { + return n.map(function (n) { + return p5.prototype.hex(n, digits); + }); + } else if (typeof n === 'number') { + if (n < 0) { + n = 4294967295 + n + 1; + } + var hex = Number(n).toString(16).toUpperCase(); + while (hex.length < digits) { + hex = '0' + hex; + } + if (hex.length >= digits) { + hex = hex.substring(hex.length - digits, hex.length); + } + return hex; + } + }; + p5.prototype.unhex = function (n) { + if (n instanceof Array) { + return n.map(p5.prototype.unhex); + } else { + return parseInt('0x' + n, 16); } }; return p5; diff --git a/lib/p5.min.js b/lib/p5.min.js index 0995550428..529b73e305 100644 --- a/lib/p5.min.js +++ b/lib/p5.min.js @@ -1,5 +1,4 @@ -/*! p5.js v0.4.4 April 30, 2015 */!function(a,b){"function"==typeof define&&define.amd?define("p5",[],function(){return a.returnExportsGlobal=b()}):"object"==typeof exports?module.exports=b():a.p5=b()}(this,function(){var amdclean={};return amdclean.shim=function(a){window.requestDraw=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a,b){window.setTimeout(a,1e3/60)}}()}({}),amdclean.constants=function(a){var b=Math.PI;return{ARROW:"default",CROSS:"crosshair",HAND:"pointer",MOVE:"move",TEXT:"text",WAIT:"wait",HALF_PI:b/2,PI:b,QUARTER_PI:b/4,TAU:2*b,TWO_PI:2*b,DEGREES:"degrees",RADIANS:"radians",CORNER:"corner",CORNERS:"corners",RADIUS:"radius",RIGHT:"right",LEFT:"left",CENTER:"center",TOP:"top",BOTTOM:"bottom",BASELINE:"alphabetic",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",THRESHOLD:"threshold",GRAY:"gray",OPAQUE:"opaque",INVERT:"invert",POSTERIZE:"posterize",DILATE:"dilate",ERODE:"erode",BLUR:"blur",NORMAL:"normal",ITALIC:"italic",BOLD:"bold",LINEAR:"linear",QUADRATIC:"quadratic",BEZIER:"bezier",CURVE:"curve"}}({}),amdclean.core=function(a,b,c){"use strict";var c=c,d=function(a,b,e){2===arguments.length&&"boolean"==typeof b&&(e=b,b=void 0),this._setupDone=!1,this._pixelDensity=window.devicePixelRatio||1,this._startTime=(new Date).getTime(),this._userNode=b,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,mouseover:null,mouseout:null,keydown:null,keyup:null,keypress:null,touchstart:null,touchmove:null,touchend:null,resize:null,blur:null},window.DeviceOrientationEvent?this._events.deviceorientation=null:window.DeviceMotionEvent?this._events.devicemotion=null:this._events.MozOrientation=null,/Firefox/i.test(navigator.userAgent)?this._events.DOMMouseScroll=null:this._events.mousewheel=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 a=this._userNode||document.body;a.appendChild(this._loadingScreen)}this.createCanvas(this._defaultCanvasSize.width,this._defaultCanvasSize.height,!0);var b=this.preload||window.preload,c=this._isGlobal?window:this;b?(this._preloadMethods.forEach(function(a){c[a]=function(){var b=Array.prototype.slice.call(arguments);return c._preload(a,b)}}),b(),0===this._preloadCount&&(this._setup(),this._runFrames(),this._draw())):(this._setup(),this._runFrames(),this._draw())}.bind(this),this._preload=function(a,b){var c=this._isGlobal?window:this;c._setProperty("_preloadCount",c._preloadCount+1);var e=function(a){c._setProperty("_preloadCount",c._preloadCount-1),0===c._preloadCount&&(c._setup(),c._runFrames(),c._draw())};return b.push(e),d.prototype[a].apply(c,b)}.bind(this),this._setup=function(){var a=this._isGlobal?window:this;"function"==typeof a.preload&&this._preloadMethods.forEach(function(b){a[b]=d.prototype[b]}),"function"==typeof a.setup&&a.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 a=(new Date).getTime();this._frameRate=1e3/(a-this._lastFrameTime),this._lastFrameTime=a,this._setProperty("frameCount",this.frameCount+1),this._loop&&(this._drawInterval&&clearInterval(this._drawInterval),this._drawInterval=setTimeout(function(){window.requestDraw(this._draw.bind(this))}.bind(this),1e3/this._targetFrameRate)),this.redraw(),this._updatePAccelerations(),this._updatePMouseCoords(),this._updatePTouchCoords()}.bind(this),this._runFrames=function(){this._updateInterval&&clearInterval(this._updateInterval)}.bind(this),this._setProperty=function(a,b){this[a]=b,this._isGlobal&&(window[a]=b)}.bind(this),this.remove=function(){if(this._curElement){this._loop=!1,this._drawInterval&&clearTimeout(this._drawInterval),this._updateInterval&&clearTimeout(this._updateInterval);for(var a in this._events)window.removeEventListener(a,this._events[a]);for(var b=0;bb&&(b+=1),b>1&&(b-=1)}return[Math.round(255*b),Math.round(255*c),Math.round(255*j),a[3]]},c.ColorUtils}({},amdclean.core),amdclean.p5Color=function(a,b,c,d){var e=b,f=c,d=d;e.Color=function(a,b){return this.color_array=e.Color._getFormattedColor.apply(a,b),this._normalizeColorArray(a),a._colorMode===d.HSB?(this.hsba=this.color_array,this.rgba=f.hsbaToRGBA(this.hsba)):(this.rgba=this.color_array,this.hsba=f.rgbaToHSBA(this.rgba)),this},e.Color.prototype._normalizeColorArray=function(a){var b=a._colorMode===d.RGB,c=b?a._maxRGB:a._maxHSB,e=this.color_array;return e[0]*=255/c[0],e[1]*=255/c[1],e[2]*=255/c[2],e[3]*=255/c[3],e},e.Color.prototype.getHue=function(){return this.hsba[0]},e.Color.prototype.getSaturation=function(){return this.hsba[1]},e.Color.prototype.getBrightness=function(){return this.hsba[2]},e.Color.prototype.getRed=function(){return this.rgba[0]},e.Color.prototype.getGreen=function(){return this.rgba[1]},e.Color.prototype.getBlue=function(){return this.rgba[2]},e.Color.prototype.getAlpha=function(){return this.rgba[3]},e.Color.prototype.toString=function(){for(var a=this.rgba,b=0;3>b;b++)a[b]=Math.floor(a[b]);var c="undefined"!=typeof a[3]?a[3]/255:1;return"rgba("+a[0]+","+a[1]+","+a[2]+","+c+")"};var g=/\s*/,h=/(\d{1,3})/,i=/((?:\d+(?:\.\d+)?)|(?:\.\d+))/,j=new RegExp(i.source+"%"),k={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},l={HEX3:/^#([a-f0-9])([a-f0-9])([a-f0-9])$/i,HEX6:/^#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i,RGB:new RegExp(["^rgb\\(",h.source,",",h.source,",",h.source,"\\)$"].join(g.source),"i"),RGB_PERCENT:new RegExp(["^rgb\\(",j.source,",",j.source,",",j.source,"\\)$"].join(g.source),"i"),RGBA:new RegExp(["^rgba\\(",h.source,",",h.source,",",h.source,",",i.source,"\\)$"].join(g.source),"i"),RGBA_PERCENT:new RegExp(["^rgba\\(",j.source,",",j.source,",",j.source,",",i.source,"\\)$"].join(g.source),"i")};return e.Color._getFormattedColor=function(){var a,b,c,f,g,h;if(arguments.length>=3)a=arguments[0],b=arguments[1],c=arguments[2],f="number"==typeof arguments[3]?arguments[3]:255;else{if("string"==typeof arguments[0])return g=arguments[0].trim().toLowerCase(),k[g]?e.Color._getFormattedColor.apply(this,[k[g]]):(h=l.HEX3.test(g)?l.HEX3.exec(g).slice(1).map(function(a){return parseInt(a+a,16)}):l.HEX6.test(g)?l.HEX6.exec(g).slice(1).map(function(a){return parseInt(a,16)}):l.RGB.test(g)?l.RGB.exec(g).slice(1).map(function(a){return parseInt(a,10)}):l.RGB_PERCENT.test(g)?l.RGB_PERCENT.exec(g).slice(1).map(function(a){return parseInt(parseFloat(a)/100*255,10)}):l.RGBA.test(g)?l.RGBA.exec(g).slice(1).map(function(a,b){return 3===b?parseInt(255*parseFloat(a),10):parseInt(a,10)}):l.RGBA_PERCENT.test(g)?l.RGBA_PERCENT.exec(g).slice(1).map(function(a,b){return 3===b?parseInt(255*parseFloat(a),10):parseInt(parseFloat(a)/100*255,10)}):[255],e.Color._getFormattedColor.apply(this,h));this._colorMode===d.RGB?a=b=c=arguments[0]:(a=c=arguments[0],b=0),f="number"==typeof arguments[1]?arguments[1]:255}return[a,b,c,f]},e.Color}({},amdclean.core,amdclean.utilscolor_utils,amdclean.constants),amdclean.p5Element=function(a,b){function c(a,b,c){var d=b.bind(c);c.elt.addEventListener(a,d,!1),c._events[a]=d}var d=b;return d.Element=function(a,b){this.elt=a,this._pInst=b,this._events={},this.width=this.elt.offsetWidth,this.height=this.elt.offsetHeight},d.Element.prototype.parent=function(a){return"string"==typeof a?a=document.getElementById(a):a instanceof d.Element&&(a=a.elt),a.appendChild(this.elt),this},d.Element.prototype.id=function(a){return this.elt.id=a,this},d.Element.prototype["class"]=function(a){return this.elt.className+=" "+a,this},d.Element.prototype.mousePressed=function(a){return c("mousedown",a,this),c("touchstart",a,this),this},d.Element.prototype.mouseWheel=function(a){return c("mousewheel",a,this),this},d.Element.prototype.mouseReleased=function(a){return c("mouseup",a,this),c("touchend",a,this),this},d.Element.prototype.mouseClicked=function(a){return c("click",a,this),this},d.Element.prototype.mouseMoved=function(a){return c("mousemove",a,this),c("touchmove",a,this),this},d.Element.prototype.mouseOver=function(a){return c("mouseover",a,this),this},d.Element.prototype.mouseOut=function(a){return c("mouseout",a,this),this},d.Element.prototype.touchStarted=function(a){return c("touchstart",a,this),c("mousedown",a,this),this},d.Element.prototype.touchMoved=function(a){return c("touchmove",a,this),c("mousemove",a,this),this},d.Element.prototype.touchEnded=function(a){return c("touchend",a,this),c("mouseup",a,this),this},d.Element.prototype.dragOver=function(a){return c("dragover",a,this),this},d.Element.prototype.dragLeave=function(a){return c("dragleave",a,this),this},d.Element.prototype.drop=function(a,b){function e(b){var c=new d.File(b);return function(b){c.data=b.target.result,a(c)}}return window.File&&window.FileReader&&window.FileList&&window.Blob?(c("dragover",function(a){a.stopPropagation(),a.preventDefault()},this),c("dragleave",function(a){a.stopPropagation(),a.preventDefault()},this),arguments.length>1&&c("drop",b,this),c("drop",function(a){a.stopPropagation(),a.preventDefault();for(var b=a.dataTransfer.files,c=0;cb?1:248>b?b:248,e!==b){e=b,f=1+e<<1,g=new Int32Array(f),h=new Array(f);for(var c=0;f>c;c++)h[c]=new Int32Array(256);for(var d,i,j,k,l=1,m=b-1;b>l;l++){g[b+l]=g[m]=i=m*m,j=h[b+l],k=h[m--];for(var n=0;256>n;n++)j[n]=k[n]=i*n}d=g[b]=b*b,j=h[b];for(var o=0;256>o;o++)j[o]=d*o}}function c(a,c){for(var i=d._toPixels(a),j=a.width,k=a.height,l=j*k,m=new Int32Array(l),n=0;l>n;n++)m[n]=d._getARGB(i,n);var o,p,q,r,s,t,u,v,w,x,y=new Int32Array(l),z=new Int32Array(l),A=new Int32Array(l),B=new Int32Array(l),C=0;b(c);var D,E,F,G;for(E=0;k>E;E++){for(D=0;j>D;D++){if(r=q=p=s=o=0,t=D-e,0>t)x=-t,t=0;else{if(t>=j)break;x=0}for(F=x;f>F&&!(t>=j);F++){var H=m[t+C];G=h[F],s+=G[(-16777216&H)>>>24],p+=G[(16711680&H)>>16],q+=G[(65280&H)>>8],r+=G[255&H],o+=g[F],t++}u=C+D,y[u]=s/o,z[u]=p/o,A[u]=q/o,B[u]=r/o}C+=j}for(C=0,v=-e,w=v*j,E=0;k>E;E++){for(D=0;j>D;D++){if(r=q=p=s=o=0,0>v)x=u=-v,t=D;else{if(v>=k)break;x=0,u=v,t=D+w}for(F=x;f>F&&!(u>=k);F++)G=h[F],s+=G[y[t]],p+=G[z[t]],q+=G[A[t]],r+=G[B[t]],o+=g[F],u++,t+=j;m[D+C]=s/o<<24|p/o<<16|q/o<<8|r/o}C+=j,w+=j,v++}d._setPixels(i,m)}var d={};d._toPixels=function(a){return a instanceof ImageData?a.data:a.getContext("2d").getImageData(0,0,a.width,a.height).data},d._getARGB=function(a,b){var c=4*b;return a[c+3]<<24&4278190080|a[c]<<16&16711680|a[c+1]<<8&65280|255&a[c+2]},d._setPixels=function(a,b){for(var c=0,d=0,e=a.length;e>d;d++)c=4*d,a[c+0]=(16711680&b[d])>>>16,a[c+1]=(65280&b[d])>>>8,a[c+2]=255&b[d],a[c+3]=(4278190080&b[d])>>>24},d._toImageData=function(a){return a instanceof ImageData?a:a.getContext("2d").getImageData(0,0,a.width,a.height)},d._createImageData=function(a,b){return d._tmpCanvas=document.createElement("canvas"),d._tmpCtx=d._tmpCanvas.getContext("2d"),this._tmpCtx.createImageData(a,b)},d.apply=function(a,b,c){var d=a.getContext("2d"),e=d.getImageData(0,0,a.width,a.height),f=b(e,c);f instanceof ImageData?d.putImageData(f,0,0,0,0,a.width,a.height):d.putImageData(e,0,0,0,0,a.width,a.height)},d.threshold=function(a,b){var c=d._toPixels(a);void 0===b&&(b=.5);for(var e=Math.floor(255*b),f=0;f=e?255:0,c[f]=c[f+1]=c[f+2]=g}},d.gray=function(a){for(var b=d._toPixels(a),c=0;cb||b>255)throw new Error("Level must be greater than 2 and less than 255 for posterize");for(var e=b-1,f=0;f>8)/e,c[f+1]=255*(h*b>>8)/e,c[f+2]=255*(i*b>>8)/e}},d.dilate=function(a){for(var b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t=d._toPixels(a),u=0,v=t.length?t.length/4:0,w=new Int32Array(v);v>u;)for(b=u,c=u+a.width;c>u;)e=f=d._getARGB(t,u),i=u-1,h=u+1,j=u-a.width,k=u+a.width,b>i&&(i=u),h>=c&&(h=u),0>j&&(j=0),k>=v&&(k=u),n=d._getARGB(t,j),m=d._getARGB(t,i),o=d._getARGB(t,k),l=d._getARGB(t,h),g=77*(e>>16&255)+151*(e>>8&255)+28*(255&e),q=77*(m>>16&255)+151*(m>>8&255)+28*(255&m),p=77*(l>>16&255)+151*(l>>8&255)+28*(255&l),r=77*(n>>16&255)+151*(n>>8&255)+28*(255&n),s=77*(o>>16&255)+151*(o>>8&255)+28*(255&o),q>g&&(f=m,g=q),p>g&&(f=l,g=p),r>g&&(f=n,g=r),s>g&&(f=o,g=s),w[u++]=f;d._setPixels(t,w)},d.erode=function(a){for(var b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t=d._toPixels(a),u=0,v=t.length?t.length/4:0,w=new Int32Array(v);v>u;)for(b=u,c=u+a.width;c>u;)e=f=d._getARGB(t,u),i=u-1,h=u+1,j=u-a.width,k=u+a.width,b>i&&(i=u),h>=c&&(h=u),0>j&&(j=0),k>=v&&(k=u),n=d._getARGB(t,j),m=d._getARGB(t,i),o=d._getARGB(t,k),l=d._getARGB(t,h),g=77*(e>>16&255)+151*(e>>8&255)+28*(255&e),q=77*(m>>16&255)+151*(m>>8&255)+28*(255&m),p=77*(l>>16&255)+151*(l>>8&255)+28*(255&l),r=77*(n>>16&255)+151*(n>>8&255)+28*(255&n),s=77*(o>>16&255)+151*(o>>8&255)+28*(255&o),g>q&&(f=m,g=q),g>p&&(f=l,g=p),g>r&&(f=n,g=r),g>s&&(f=o,g=s),w[u++]=f;d._setPixels(t,w)};var e,f,g,h;return d.blur=function(a,b){c(a,b)},d}({}),amdclean.p5Image=function(a,b,c){"use strict";var d=b,e=c;return d.Image=function(a,b){this.width=a,this.height=b,this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.drawingContext=this.canvas.getContext("2d"),this.pixels=[]},d.Image.prototype._setProperty=function(a,b){this[a]=b},d.Image.prototype.loadPixels=function(){d.prototype.loadPixels.call(this)},d.Image.prototype.updatePixels=function(a,b,c,e){d.prototype.updatePixels.call(this,a,b,c,e)},d.Image.prototype.get=function(a,b,c,e){return d.prototype.get.call(this,a,b,c,e)},d.Image.prototype.set=function(a,b,c){d.prototype.set.call(this,a,b,c)},d.Image.prototype.resize=function(a,b){a=a||this.canvas.width,b=b||this.canvas.height;var c=document.createElement("canvas");c.width=a,c.height=b,c.getContext("2d").drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height,0,0,c.width,c.height),this.canvas.width=this.width=a,this.canvas.height=this.height=b,this.drawingContext.drawImage(c,0,0,a,b,0,0,a,b),this.pixels.length>0&&this.loadPixels()},d.Image.prototype.copy=function(){d.prototype.copy.apply(this,arguments)},d.Image.prototype.mask=function(a){void 0===a&&(a=this);var b=this.drawingContext.globalCompositeOperation,c=1;a instanceof d.Graphics&&(c=a._pInst._pixelDensity);var e=[a,0,0,c*a.width,c*a.height,0,0,this.width,this.height];this.drawingContext.globalCompositeOperation="destination-in",this.copy.apply(this,e),this.drawingContext.globalCompositeOperation=b},d.Image.prototype.filter=function(a,b){e.apply(this.canvas,e[a.toLowerCase()],b)},d.Image.prototype.blend=function(){d.prototype.blend.apply(this,arguments)},d.Image.prototype.save=function(a,b){var c;if(b)switch(b.toLowerCase()){case"png":c="image/png";break;case"jpeg":c="image/jpeg";break;case"jpg":c="image/jpeg";break;default:c="image/png"}else b="png",c="image/png";var e="image/octet-stream",f=this.canvas.toDataURL(c);f=f.replace(c,e),d.prototype.downloadFile(f,a,b)},d.Image}({},amdclean.core,amdclean.filters),amdclean.p5File=function(a,b){var c=b;return c.File=function(a,b){this.file=a,this._pInst=b;var c=a.type.split("/");this.type=c[0],this.subtype=c[1],this.name=a.name,this.size=a.size,this.data=void 0},c.File}({},amdclean.core),amdclean.polargeometry=function(a){return{degreesToRadians:function(a){return 2*Math.PI*a/360},radiansToDegrees:function(a){return 360*a/(2*Math.PI)}}}({}),amdclean.p5Vector=function(a,b,c,d){"use strict";var e=b,f=c,d=d;return e.Vector=function(){var a,b,c;arguments[0]instanceof e?(this.p5=arguments[0],a=arguments[1][0]||0,b=arguments[1][1]||0,c=arguments[1][2]||0):(a=arguments[0]||0,b=arguments[1]||0,c=arguments[2]||0),this.x=a,this.y=b,this.z=c},e.Vector.prototype.set=function(a,b,c){return a instanceof e.Vector?(this.x=a.x||0,this.y=a.y||0,this.z=a.z||0,this):a instanceof Array?(this.x=a[0]||0,this.y=a[1]||0,this.z=a[2]||0,this):(this.x=a||0,this.y=b||0,this.z=c||0,this)},e.Vector.prototype.copy=function(){return this.p5?new e.Vector(this.p5,[this.x,this.y,this.z]):new e.Vector(this.x,this.y,this.z)},e.Vector.prototype.add=function(a,b,c){return a instanceof e.Vector?(this.x+=a.x||0,this.y+=a.y||0,this.z+=a.z||0,this):a instanceof Array?(this.x+=a[0]||0,this.y+=a[1]||0,this.z+=a[2]||0,this):(this.x+=a||0,this.y+=b||0,this.z+=c||0,this)},e.Vector.prototype.sub=function(a,b,c){return a instanceof e.Vector?(this.x-=a.x||0,this.y-=a.y||0,this.z-=a.z||0,this):a instanceof Array?(this.x-=a[0]||0,this.y-=a[1]||0,this.z-=a[2]||0,this):(this.x-=a||0,this.y-=b||0,this.z-=c||0,this)},e.Vector.prototype.mult=function(a){return this.x*=a||0,this.y*=a||0,this.z*=a||0,this},e.Vector.prototype.div=function(a){return this.x/=a,this.y/=a,this.z/=a,this},e.Vector.prototype.mag=function(){return Math.sqrt(this.magSq())},e.Vector.prototype.magSq=function(){var a=this.x,b=this.y,c=this.z;return a*a+b*b+c*c},e.Vector.prototype.dot=function(a,b,c){return a instanceof e.Vector?this.dot(a.x,a.y,a.z):this.x*(a||0)+this.y*(b||0)+this.z*(c||0)},e.Vector.prototype.cross=function(a){var b=this.y*a.z-this.z*a.y,c=this.z*a.x-this.x*a.z,d=this.x*a.y-this.y*a.x;return this.p5?new e.Vector(this.p5,[b,c,d]):new e.Vector(b,c,d)},e.Vector.prototype.dist=function(a){var b=a.copy().sub(this);return b.mag()},e.Vector.prototype.normalize=function(){return this.div(this.mag())},e.Vector.prototype.limit=function(a){var b=this.magSq();return b>a*a&&(this.div(Math.sqrt(b)),this.mult(a)),this},e.Vector.prototype.setMag=function(a){return this.normalize().mult(a)},e.Vector.prototype.heading=function(){var a=Math.atan2(this.y,this.x);return this.p5?this.p5._angleMode===d.RADIANS?a:f.radiansToDegrees(a):a},e.Vector.prototype.rotate=function(a){this.p5&&this.p5._angleMode===d.DEGREES&&(a=f.degreesToRadians(a));var b=this.heading()+a,c=this.mag();return this.x=Math.cos(b)*c,this.y=Math.sin(b)*c,this},e.Vector.prototype.lerp=function(a,b,c,d){return a instanceof e.Vector?this.lerp(a.x,a.y,a.z,b):(this.x+=(a-this.x)*d||0,this.y+=(b-this.y)*d||0,this.z+=(c-this.z)*d||0,this)},e.Vector.prototype.array=function(){return[this.x||0,this.y||0,this.z||0]},e.Vector.prototype.equals=function(a,b,c){return a instanceof e.Vector?(a=a.x||0,b=a.y||0,c=a.z||0):a instanceof Array?(a=a[0]||0,b=a[1]||0,c=a[2]||0):(a=a||0,b=b||0,c=c||0),this.x===a&&this.y===b&&this.z===c},e.Vector.fromAngle=function(a){return this.p5&&this.p5._angleMode===d.DEGREES&&(a=f.degreesToRadians(a)),this.p5?new e.Vector(this.p5,[Math.cos(a),Math.sin(a),0]):new e.Vector(Math.cos(a),Math.sin(a),0)},e.Vector.random2D=function(){var a;return a=this.p5?this.p5.random(this.p5._angleMode===d.DEGREES?360:d.TWO_PI):Math.random()*Math.PI*2,this.fromAngle(a)},e.Vector.random3D=function(){var a,b;this.p5?(a=this.p5.random(0,d.TWO_PI),b=this.p5.random(-1,1)):(a=Math.random()*Math.PI*2,b=2*Math.random()-1);var c=Math.sqrt(1-b*b)*Math.cos(a),f=Math.sqrt(1-b*b)*Math.sin(a);return this.p5?new e.Vector(this.p5,[c,f,b]):new e.Vector(c,f,b)},e.Vector.add=function(a,b,c){return c?c.set(a):c=a.copy(),c.add(b),c},e.Vector.sub=function(a,b,c){return c?c.set(a):c=a.copy(),c.sub(b),c},e.Vector.mult=function(a,b,c){return c?c.set(a):c=a.copy(),c.mult(b),c},e.Vector.div=function(a,b,c){return c?c.set(a):c=a.copy(),c.div(b),c},e.Vector.dot=function(a,b){return a.dot(b)},e.Vector.cross=function(a,b){return a.cross(b)},e.Vector.dist=function(a,b){return a.dist(b)},e.Vector.lerp=function(a,b,c,d){return d?d.set(a):d=a.copy(),d.lerp(b,c),d},e.Vector.angleBetween=function(a,b){var c=Math.acos(a.dot(b)/(a.mag()*b.mag()));return this.p5&&this.p5._angleMode===d.DEGREES&&(c=f.radiansToDegrees(c)),c},e.Vector}({},amdclean.core,amdclean.polargeometry,amdclean.constants),amdclean.p5TableRow=function(a,b){"use strict";var c=b;return c.TableRow=function(a,b){var c=[],d={};a&&(b=b||",",c=a.split(b));for(var e=0;e=0))throw'This table has no column named "'+a+'"';this.obj[a]=b,this.arr[c]=b}else{if(!(ah;h++)g.push(d.prototype.lerp(a.rgba[h],b.rgba[h],c));return new d.Color(this,g)}return d.prototype.lerp(a,b,c)},d.prototype.red=function(a){if(a instanceof d.Color||a instanceof Array)return this.color(a).getRed();throw new Error("Needs p5.Color or pixel array as argument.")},d.prototype.saturation=function(a){if(!a instanceof d.Color)throw new Error("Needs p5.Color as argument.");return a.getSaturation()},d}({},amdclean.core,amdclean.p5Color),amdclean.colorsetting=function(a,b,c,d){"use strict";var e=b,c=c;return e.prototype._doStroke=!0,e.prototype._doFill=!0,e.prototype._colorMode=c.RGB,e.prototype._maxRGB=[255,255,255,255],e.prototype._maxHSB=[255,255,255,255],e.prototype.background=function(){if(this.drawingContext.save(),this.drawingContext.setTransform(1,0,0,1,0,0),this.drawingContext.scale(this._pixelDensity,this._pixelDensity),arguments[0]instanceof e.Image)this.image(arguments[0],0,0,this.width,this.height);else{var a=this.drawingContext.fillStyle,b=this.color.apply(this,arguments),c=b.toString();this.drawingContext.fillStyle=c,this.drawingContext.fillRect(0,0,this.width,this.height),this.drawingContext.fillStyle=a}this.drawingContext.restore()},e.prototype.clear=function(){this.drawingContext.clearRect(0,0,this.width,this.height)},e.prototype.colorMode=function(){if(arguments[0]===c.RGB||arguments[0]===c.HSB){this._colorMode=arguments[0];var a=this._colorMode===c.RGB,b=a?this._maxRGB:this._maxHSB;2===arguments.length?(b[0]=arguments[1],b[1]=arguments[1],b[2]=arguments[1],b[3]=arguments[1]):arguments.length>2&&(b[0]=arguments[1],b[1]=arguments[2],b[2]=arguments[3]),5===arguments.length&&(b[3]=arguments[4])}},e.prototype.fill=function(){this._setProperty("_doFill",!0);var a=this.drawingContext,b=this.color.apply(this,arguments);a.fillStyle=b.toString()},e.prototype.noFill=function(){this._setProperty("_doFill",!1)},e.prototype.noStroke=function(){this._setProperty("_doStroke",!1)},e.prototype.stroke=function(){this._setProperty("_doStroke",!0);var a=this.drawingContext,b=this.color.apply(this,arguments);a.strokeStyle=b.toString()},e}({},amdclean.core,amdclean.constants,amdclean.p5Color),amdclean.dataconversion=function(a,b){"use strict";var c=b;return c.prototype["float"]=function(a){return parseFloat(a)},c.prototype["int"]=function(a,b){return"string"==typeof a?(b=b||10,parseInt(a,b)):"number"==typeof a?0|a:"boolean"==typeof a?a?1:0:a instanceof Array?a.map(c.prototype["int"]):void 0},c}({},amdclean.core),amdclean.dataarray_functions=function(a,b){"use strict";var c=b;return c.prototype.append=function(a,b){return a.push(b),a},c.prototype.arrayCopy=function(a,b,c,d,e){var f,g;"undefined"!=typeof e?(g=Math.min(e,a.length),f=d,a=a.slice(b,g+b)):("undefined"!=typeof c?(g=c,g=Math.min(g,a.length)):g=a.length,f=0,c=b,a=a.slice(0,g)),Array.prototype.splice.apply(c,[f,g].concat(a))},c.prototype.concat=function(a,b){return a.concat(b)},c.prototype.reverse=function(a){return a.reverse()},c.prototype.shorten=function(a){return a.pop(),a},c.prototype.shuffle=function(a,b){a=b||ArrayBuffer.isView(a)?a:a.slice();for(var c,d,e=a.length;e>1;)c=Math.random()*e|0,d=a[--e],a[e]=a[c],a[c]=d;return a},c.prototype.sort=function(a,b){var c=b?a.slice(0,Math.min(b,a.length)):a,d=b?a.slice(Math.min(b,a.length)):[];return c="string"==typeof c[0]?c.sort():c.sort(function(a,b){return a-b}),c.concat(d)},c.prototype.splice=function(a,b,c){return Array.prototype.splice.apply(a,[c,0].concat(b)),a},c.prototype.subset=function(a,b,c){return"undefined"!=typeof c?a.slice(b,b+c):a.slice(b,a.length)},c}({},amdclean.core),amdclean.datastring_functions=function(a,b){"use strict";function c(){var a=arguments[0],b=0>a,c=b?a.toString().substring(1):a.toString(),d=c.indexOf("."),e=-1!==d?c.substring(0,d):c,f=-1!==d?c.substring(d+1):"",g=b?"-":"";if(3===arguments.length){for(var h=0;h1&&(c=c.substring(0,arguments[1]+1)),d+c}function e(){return parseFloat(arguments[0])>0?"+"+arguments[0].toString():arguments[0].toString()}function f(){return parseFloat(arguments[0])>0?" "+arguments[0].toString():arguments[0].toString()}var g=b;return g.prototype.join=function(a,b){return a.join(b)},g.prototype.match=function(a,b){return a.match(b)},g.prototype.matchAll=function(a,b){for(var c=new RegExp(b,"g"),d=c.exec(a),e=[];null!==d;)e.push(d),d=c.exec(a);return e},g.prototype.nf=function(){if(arguments[0]instanceof Array){var a=arguments[1],b=arguments[2];return arguments[0].map(function(d){return c(d,a,b)})}return c.apply(this,arguments)},g.prototype.nfc=function(){if(arguments[0]instanceof Array){var a=arguments[1];return arguments[0].map(function(b){return d(b,a)})}return d.apply(this,arguments)},g.prototype.nfp=function(){var a=this.nf(arguments);return a instanceof Array?a.map(e):e(a)},g.prototype.nfs=function(){var a=this.nf(arguments);return a instanceof Array?a.map(f):f(a)},g.prototype.split=function(a,b){return a.split(b)},g.prototype.splitTokens=function(){var a=arguments.length>0?arguments[1]:/\s/g;return arguments[0].split(a).filter(function(a){return a})},g.prototype.trim=function(a){return a instanceof Array?a.map(this.trim):a.trim()},g}({},amdclean.core),amdclean.environment=function(a,b,c){"use strict";function d(a){var b=document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled;if(!b)throw new Error("Fullscreen not enabled in this browser.");a.requestFullscreen?a.requestFullscreen():a.mozRequestFullScreen?a.mozRequestFullScreen():a.webkitRequestFullscreen?a.webkitRequestFullscreen():a.msRequestFullscreen&&a.msRequestFullscreen()}function e(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen()}var f=b,g=c,h=[g.ARROW,g.CROSS,g.HAND,g.MOVE,g.TEXT,g.WAIT];return f.prototype._frameRate=0,f.prototype._lastFrameTime=(new Date).getTime(),f.prototype._targetFrameRate=60,f.prototype.frameCount=0,f.prototype.focused=!0,f.prototype.cursor=function(a,b,c){var d="auto",e=this._curElement.elt;if(h.indexOf(a)>-1)d=a;else if("string"==typeof a){var f="";b&&c&&"number"==typeof b&&"number"==typeof c&&(f=b+" "+c),d="http://"!==a.substring(0,6)?"url("+a+") "+f+", auto":/\.(cur|jpg|jpeg|gif|png|CUR|JPG|JPEG|GIF|PNG)$/.test(a)?"url("+a+") "+f+", auto":a}e.style.cursor=d},f.prototype.frameRate=function(a){return"undefined"==typeof a?this._frameRate:(this._setProperty("_targetFrameRate",a),this._runFrames(),this)},f.prototype.getFrameRate=function(){return this.frameRate()},f.prototype.setFrameRate=function(a){return this.frameRate(a)},f.prototype.noCursor=function(){this._curElement.elt.style.cursor="none"},f.prototype.displayWidth=screen.width,f.prototype.displayHeight=screen.height,f.prototype.windowWidth=window.innerWidth,f.prototype.windowHeight=window.innerHeight,f.prototype._onresize=function(a){this._setProperty("windowWidth",window.innerWidth),this._setProperty("windowHeight",window.innerHeight);var b,c=this._isGlobal?window:this;"function"==typeof c.windowResized&&(b=c.windowResized(a),void 0===b||b||a.preventDefault())},f.prototype.width=0,f.prototype.height=0,f.prototype.fullscreen=function(a){return"undefined"==typeof a?document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement:void(a?d(document.documentElement):e())},f.prototype.devicePixelScaling=function(a){a?"number"==typeof a?this._pixelDensity=a:this._pixelDensity=window.devicePixelRatio||1:this._pixelDensity=1,this.resizeCanvas(this.width,this.height,!0)},f.prototype.getURL=function(){return location.href},f.prototype.getURLPath=function(){return location.pathname.split("/").filter(function(a){return""!==a})},f.prototype.getURLParams=function(){for(var a,b=/[?&]([^&=]+)(?:[&=])([^&=]+)/gim,c={};null!=(a=b.exec(location.search));)a.index===b.lastIndex&&b.lastIndex++,c[a[1]]=a[2];return c},f}({},amdclean.core,amdclean.constants),amdclean.imageimage=function(a,b,c){"use strict";var d=b,c=c;return d.prototype._imageMode=c.CORNER,d.prototype._tint=null,d.prototype.createImage=function(a,b){return new d.Image(a,b)},d}({},amdclean.core,amdclean.constants),amdclean.canvas=function(a,b){var b=b;return{modeAdjust:function(a,c,d,e,f){return f===b.CORNER?{x:a,y:c,w:d,h:e}:f===b.CORNERS?{x:a,y:c,w:d-a,h:e-c}:f===b.RADIUS?{x:a-d,y:c-e,w:2*d,h:2*e}:f===b.CENTER?{x:a-.5*d,y:c-.5*e,w:d,h:e}:void 0},arcModeAdjust:function(a,c,d,e,f){return f===b.CORNER?{x:a+.5*d,y:c+.5*e,w:d,h:e}:f===b.CORNERS?{x:a,y:c,w:d+a,h:e+c}:f===b.RADIUS?{x:a,y:c,w:2*d,h:2*e}:f===b.CENTER?{x:a,y:c,w:d,h:e}:void 0}}}({},amdclean.constants),amdclean.imageloading_displaying=function(a,b,c,d,e){"use strict";var f=b,g=c,d=d,e=e;return f.prototype.loadImage=function(a,b,c){var d=new Image,e=new f.Image(1,1,this);return d.onload=function(){e.width=e.canvas.width=d.width,e.height=e.canvas.height=d.height,e.canvas.getContext("2d").drawImage(d,0,0),"function"==typeof b&&b(e)},d.onerror=function(a){"function"==typeof c&&c(a)},0!==a.indexOf("data:image/")&&(d.crossOrigin="Anonymous"),d.src=a,e},f.prototype.image=function(a,b,c,e,f){var g=a.canvas||a.elt;b=b||0,c=c||0,e=e||a.width,f=f||a.height;var h=d.modeAdjust(b,c,e,f,this._imageMode);try{this._tint&&a.canvas?this.drawingContext.drawImage(this._getTintedImageCanvas(a),h.x,h.y,h.w,h.h):this.drawingContext.drawImage(g,h.x,h.y,h.w,h.h)}catch(i){if("NS_ERROR_NOT_AVAILABLE"!==i.name)throw i}},f.prototype.tint=function(){var a=this.color.apply(this,arguments);this._tint=a.rgba},f.prototype.noTint=function(){this._tint=null},f.prototype._getTintedImageCanvas=function(a){if(!a.canvas)return a;var b=g._toPixels(a.canvas),c=document.createElement("canvas");c.width=a.canvas.width,c.height=a.canvas.height;for(var d=c.getContext("2d"),e=d.createImageData(a.canvas.width,a.canvas.height),f=e.data,h=0;hthis.width||b>this.height||0>a||0>b)return[0,0,0,255];var f=this.drawingContext.getImageData(a,b,c,d),g=f.data;if(1===c&&1===d){for(var h=[],i=0;i0;)self._completeHandlers.shift()(a)}function success(resp){var type=o.type||resp&&setType(resp.getResponseHeader("Content-Type"));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 timedOut(){self._timedOut=!0,self.request.abort()}function error(a,b,c){for(a=self.request,self._responseArgs.resp=a,self._responseArgs.msg=b,self._responseArgs.t=c,self._erred=!0;self._errorHandlers.length>0;)self._errorHandlers.shift()(a,b,c);complete(a)}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;fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){timedOut()},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(a,b){return new Reqwest(a,b)}function normalize(a){return a?a.replace(/\r?\n/g,"\r\n"):""}function serial(a,b){var c,d,e,f,g=a.name,h=a.tagName.toLowerCase(),i=function(a){a&&!a.disabled&&b(g,normalize(a.attributes.value&&a.attributes.value.specified?a.value:a.text))};if(!a.disabled&&g)switch(h){case"input":/reset|button|image|file/i.test(a.type)||(c=/checkbox/i.test(a.type),d=/radio/i.test(a.type),e=a.value,(!(c||d)||a.checked)&&b(g,normalize(c&&""===e?"on":e)));break;case"textarea":b(g,normalize(a.value));break;case"select":if("select-one"===a.type.toLowerCase())i(a.selectedIndex>=0?a.options[a.selectedIndex]:null);else for(f=0;a.length&&fd||Math.abs(this.accelerationY-this.pAccelerationY)>d||Math.abs(this.accelerationZ-this.pAccelerationZ)>d)&&a();var b=this.onDeviceTurn||window.onDeviceTurn;if("function"==typeof b){var c=0;Math.abs(this.accelerationX)>c&&(c=this.accelerationX,f="x"),Math.abs(this.accelerationY)>c&&(c=this.accelerationY,f="y"),Math.abs(this.accelerationZ)>c&&(f="z"),""!==e&&e!==f&&b(f),e=f}},c}({},amdclean.core),amdclean.inputmouse=function(a,b,c){ -"use strict";function d(a,b){var c=a.getBoundingClientRect();return{x:b.clientX-c.left,y:b.clientY-c.top}}var e=b,c=c;return e.prototype.mouseX=0,e.prototype.mouseY=0,e.prototype.pmouseX=0,e.prototype.pmouseY=0,e.prototype.winMouseX=0,e.prototype.winMouseY=0,e.prototype.pwinMouseX=0,e.prototype.pwinMouseY=0,e.prototype.mouseButton=0,e.prototype.mouseIsPressed=!1,e.prototype.isMousePressed=!1,e.prototype._updateMouseCoords=function(a){if("touchstart"===a.type||"touchmove"===a.type||"touchend"===a.type)this._setProperty("mouseX",this.touchX),this._setProperty("mouseY",this.touchY);else if(null!==this._curElement){var b=d(this._curElement.elt,a);this._setProperty("mouseX",b.x),this._setProperty("mouseY",b.y)}this._setProperty("winMouseX",a.pageX),this._setProperty("winMouseY",a.pageY)},e.prototype._updatePMouseCoords=function(a){this._setProperty("pmouseX",this.mouseX),this._setProperty("pmouseY",this.mouseY),this._setProperty("pwinMouseX",this.winMouseX),this._setProperty("pwinMouseY",this.winMouseY)},e.prototype._setMouseButton=function(a){1===a.button?this._setProperty("mouseButton",c.CENTER):2===a.button?this._setProperty("mouseButton",c.RIGHT):(this._setProperty("mouseButton",c.LEFT),("touchstart"===a.type||"touchmove"===a.type)&&(this._setProperty("mouseX",this.touchX),this._setProperty("mouseY",this.touchY)))},e.prototype._onmousemove=function(a){var b,c=this._isGlobal?window:this;this._updateMouseCoords(a),this.isMousePressed?"function"==typeof c.mouseDragged?(b=c.mouseDragged(a),b===!1&&a.preventDefault()):"function"==typeof c.touchMoved&&(b=c.touchMoved(a),b===!1&&a.preventDefault(),this._updateTouchCoords(a)):"function"==typeof c.mouseMoved&&(b=c.mouseMoved(a),b===!1&&a.preventDefault())},e.prototype._onmousedown=function(a){var b,c=this._isGlobal?window:this;this._setProperty("isMousePressed",!0),this._setProperty("mouseIsPressed",!0),this._setMouseButton(a),this._updateMouseCoords(a),"function"==typeof c.mousePressed?(b=c.mousePressed(a),b===!1&&a.preventDefault()):"function"==typeof c.touchStarted&&(b=c.touchStarted(a),b===!1&&a.preventDefault(),this._updateTouchCoords(a))},e.prototype._onmouseup=function(a){var b,c=this._isGlobal?window:this;this._setProperty("isMousePressed",!1),this._setProperty("mouseIsPressed",!1),"function"==typeof c.mouseReleased?(b=c.mouseReleased(a),b===!1&&a.preventDefault()):"function"==typeof c.touchEnded&&(b=c.touchEnded(a),b===!1&&a.preventDefault(),this._updateTouchCoords(a))},e.prototype._onclick=function(a){var b=this._isGlobal?window:this;if("function"==typeof b.mouseClicked){var c=b.mouseClicked(a);c===!1&&a.preventDefault()}},e.prototype._onmousewheel=e.prototype._onDOMMouseScroll=function(a){var b=this._isGlobal?window:this;if("function"==typeof b.mouseWheel){var c=b.mouseWheel(a);c===!1&&a.preventDefault()}},e}({},amdclean.core,amdclean.constants),amdclean.inputtime_date=function(a,b){"use strict";var c=b;return c.prototype.day=function(){return(new Date).getDate()},c.prototype.hour=function(){return(new Date).getHours()},c.prototype.minute=function(){return(new Date).getMinutes()},c.prototype.millis=function(){return(new Date).getTime()-this._startTime},c.prototype.month=function(){return(new Date).getMonth()+1},c.prototype.second=function(){return(new Date).getSeconds()},c.prototype.year=function(){return(new Date).getFullYear()},c}({},amdclean.core),amdclean.inputtouch=function(a,b){"use strict";function c(a,b,c){c=c||0;var d=a.getBoundingClientRect(),e=b.touches[c]||b.changedTouches[c];return{x:e.clientX-d.left,y:e.clientY-d.top}}var d=b;return d.prototype.touchX=0,d.prototype.touchY=0,d.prototype.ptouchX=0,d.prototype.ptouchY=0,d.prototype.touches=[],d.prototype.touchIsDown=!1,d.prototype._updateTouchCoords=function(a){if("mousedown"===a.type||"mousemove"===a.type||"mouseup"===a.type)this._setProperty("touchX",this.mouseX),this._setProperty("touchY",this.mouseY);else{var b=c(this._curElement.elt,a,0);this._setProperty("touchX",b.x),this._setProperty("touchY",b.y);for(var d=[],e=0;e>>0},getSeed:function(){return a},rand:function(){return b=(d*b+e)%c,b/c}}}();c.prototype.randomSeed=function(a){e.setSeed(a),d=!0},c.prototype.random=function(a,b){var c;if(c=d?e.rand():Math.random(),0===arguments.length)return c;if(1===arguments.length)return c*a;if(a>b){var f=a;a=b,b=f}return c*(b-a)+a};var f,g=!1;return c.prototype.randomGaussian=function(a,b){var c,d,e,h;if(g)c=f,g=!1;else{do d=this.random(2)-1,e=this.random(2)-1,h=d*d+e*e;while(h>=1);h=Math.sqrt(-2*Math.log(h)/h),c=d*h,f=e*h,g=!0}var i=a||0,j=b||1;return c*j+i},c}({},amdclean.core),amdclean.mathnoise=function(a,b){"use strict";for(var c=b,d=4,e=1<p;p++)m[p]=Math.sin(p*o*k),n[p]=Math.cos(p*o*k);var q=l;q>>=1;var r;return c.prototype.noise=function(a,b,c){if(b=b||0,c=c||0,null==r){r=new Array(h+1);for(var k=0;h+1>k;k++)r[k]=Math.random()}0>a&&(a=-a),0>b&&(b=-b),0>c&&(c=-c);for(var m,o,p,s,t,u=Math.floor(a),v=Math.floor(b),w=Math.floor(c),x=a-u,y=b-v,z=c-w,A=0,B=.5,C=function(a){return.5*(1-n[Math.floor(a*q)%l])},D=0;i>D;D++){var E=u+(v<=1&&(u++,x--),y>=1&&(v++,y--),z>=1&&(w++,z--)}return A},c.prototype.noiseDetail=function(a,b){a>0&&(i=a),b>0&&(j=b)},c.prototype.noiseSeed=function(a){var b=function(){var a,b,c=4294967296,d=1664525,e=1013904223;return{setSeed:function(d){b=a=(null==d?Math.random()*c:d)>>>0},getSeed:function(){return a},rand:function(){return b=(d*b+e)%c,b/c}}}();b.setSeed(a),r=new Array(h+1);for(var c=0;h+1>c;c++)r[c]=b.rand()},c}({},amdclean.core),amdclean.mathtrigonometry=function(a,b,c,d){"use strict";var e=b,f=c,d=d;return e.prototype._angleMode=d.RADIANS,e.prototype.acos=function(a){return this._angleMode===d.RADIANS?Math.acos(a):f.radiansToDegrees(Math.acos(a))},e.prototype.asin=function(a){return this._angleMode===d.RADIANS?Math.asin(a):f.radiansToDegrees(Math.asin(a))},e.prototype.atan=function(a){return this._angleMode===d.RADIANS?Math.atan(a):f.radiansToDegrees(Math.atan(a))},e.prototype.atan2=function(a,b){return this._angleMode===d.RADIANS?Math.atan2(a,b):f.radiansToDegrees(Math.atan2(a,b))},e.prototype.cos=function(a){return Math.cos(this._angleMode===d.RADIANS?a:this.radians(a))},e.prototype.sin=function(a){return Math.sin(this._angleMode===d.RADIANS?a:this.radians(a))},e.prototype.tan=function(a){return Math.tan(this._angleMode===d.RADIANS?a:this.radians(a))},e.prototype.degrees=function(a){return f.radiansToDegrees(a)},e.prototype.radians=function(a){return f.degreesToRadians(a)},e.prototype.angleMode=function(a){(a===d.DEGREES||a===d.RADIANS)&&(this._angleMode=a)},e}({},amdclean.core,amdclean.polargeometry,amdclean.constants),amdclean.outputfiles=function(a,b){"use strict";function c(a,b){b&&b!==!0&&"true"!==b||(b=""),a||(a="untitled");var c="";return a&&a.indexOf(".")>-1&&(c=a.split(".").pop()),b&&c!==b&&(c=b,a=a+"."+c),[a,c]}function d(a){document.body.removeChild(a.target)}var e=b;window.URL=window.URL||window.webkitURL,e.prototype._pWriters=[],e.prototype.beginRaw=function(){throw"not yet implemented"},e.prototype.beginRecord=function(){throw"not yet implemented"},e.prototype.createOutput=function(){throw"not yet implemented"},e.prototype.createWriter=function(a,b){var c;for(var d in e.prototype._pWriters)if(e.prototype._pWriters[d].name===a)return c=new e.PrintWriter(a+window.millis(),b),e.prototype._pWriters.push(c),c;return c=new e.PrintWriter(a,b),e.prototype._pWriters.push(c),c},e.prototype.endRaw=function(){throw"not yet implemented"},e.prototype.endRecord=function(){throw"not yet implemented"},e.PrintWriter=function(a,b){var c=this;this.name=a,this.content="",this.print=function(a){this.content+=a},this.println=function(a){this.content+=a+"\n"},this.flush=function(){this.content=""},this.close=function(){var d=[];d.push(this.content),e.prototype.writeFile(d,a,b);for(var f in e.prototype._pWriters)e.prototype._pWriters[f].name===this.name&&e.prototype._pWriters.splice(f,1);c.flush(),c={}}},e.prototype.saveBytes=function(){throw"not yet implemented"},e.prototype.save=function(a,b,d){var f=arguments,g=this._curElement.elt;if(0===f.length)return void e.prototype.saveCanvas(g);if(f[0]instanceof e.Graphics)return void e.prototype.saveCanvas(f[0].elt,f[1],f[2]);if(1===f.length&&"string"==typeof f[0])e.prototype.saveCanvas(g,f[0]);else{var h=c(f[1],f[2])[1];switch(h){case"json":return void e.prototype.saveJSON(f[0],f[1],f[2]);case"txt":return void e.prototype.saveStrings(f[0],f[1],f[2]);default:f[0]instanceof Array?e.prototype.saveStrings(f[0],f[1],f[2]):f[0]instanceof e.Table?e.prototype.saveTable(f[0],f[1],f[2],f[3]):f[0]instanceof e.Image?e.prototype.saveCanvas(f[0].canvas,f[1]):f[0]instanceof e.SoundFile&&e.prototype.saveSound(f[0],f[1],f[2],f[3])}}},e.prototype.saveJSON=function(a,b,c){var d;d=c?JSON.stringify(a):JSON.stringify(a,void 0,2),console.log(d),this.saveStrings(d.split("\n"),b,"json")},e.prototype.saveJSONObject=e.prototype.saveJSON,e.prototype.saveJSONArray=e.prototype.saveJSON,e.prototype.saveStream=function(){throw"not yet implemented"},e.prototype.saveStrings=function(a,b,c){var d=c||"txt",e=this.createWriter(b,d);for(var f in a)f"),d.println("");var k=' "),d.println(""),d.println(" "),"0"!==e[0]){d.println(" ");for(var l=0;l"+m),d.println(" ")}d.println(" ")}for(var n=0;n");for(var o=0;o"+q),d.println(" ")}d.println(" ")}d.println("
"),d.println(""),d.print("")}d.close(),d.flush()};var f=function(a){return a.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")};return e.prototype.writeFile=function(a,b,c){var d="application/octet-stream";e.prototype._isSafari()&&(d="text/plain");var f=new Blob(a,{type:d}),g=window.URL.createObjectURL(f);e.prototype.downloadFile(g,b,c)},e.prototype.downloadFile=function(a,b,f){var g=c(b,f),h=g[0],i=g[1],j=document.createElement("a");if(j.href=a,j.download=h,j.onclick=d,j.style.display="none",document.body.appendChild(j),e.prototype._isSafari()){var k="Hello, Safari user! To download this file...\n";k+="1. Go to File --> Save As.\n",k+='2. Choose "Page Source" as the Format.\n',k+='3. Name it with this extension: ."'+i+'"',alert(k)}j.click(),a=null},e.prototype._checkFileExtension=c,e.prototype._isSafari=function(){var a=Object.prototype.toString.call(window.HTMLElement);return a.indexOf("Constructor")>0},e}({},amdclean.core),amdclean.outputimage=function(a,b){"use strict";var c=b,d=[];return c.prototype.saveCanvas=function(a,b,d){d||(d=c.prototype._checkFileExtension(b,d)[1],""===d&&(d="png"));var e;if(a?e=a:this._curElement&&this._curElement.elt&&(e=this._curElement.elt),c.prototype._isSafari()){var f="Hello, Safari user!\n";f+="Now capturing a screenshot...\n",f+="To save this image,\n",f+="go to File --> Save As.\n",alert(f),window.location.href=e.toDataURL()}else{var g;if("undefined"==typeof d)d="png",g="image/png";else switch(d){case"png":g="image/png";break;case"jpeg":g="image/jpeg";break;case"jpg":g="image/jpeg";break;default:g="image/png"}var h="image/octet-stream",i=e.toDataURL(g);i=i.replace(g,h),c.prototype.downloadFile(i,b,d)}},c.prototype.saveFrames=function(a,b,e,f,g){var h=e||3;h=c.prototype.constrain(h,0,15),h=1e3*h;var i=f||15;i=c.prototype.constrain(i,0,22);var j=0,k=c.prototype._makeFrame,l=this._curElement.elt,m=setInterval(function(){k(a+j,b,l),j++},1e3/i);setTimeout(function(){if(clearInterval(m),g)g(d);else for(var a=0;ab?1:-1,j=b,k=Math.min(d,Math.abs(c-b));k>h;){var l=j+i*Math.min(k,g);e.push(f(a,j,l)),k-=Math.abs(l-j),j=l}return e}function f(a,b,c){var d=(c-b)/2,e=a*Math.cos(d),f=a*Math.sin(d),g=e,h=-f,i=.5522847498,j=i*Math.tan(d),k=g+j*f,l=h+j*e,m=k,n=-l,o=d+b,p=Math.cos(o),q=Math.sin(o);return{x1:a*Math.cos(b),y1:a*Math.sin(b),x2:k*p-l*q,y2:k*q+l*p,x3:m*p-n*q,y3:m*q+n*p,x4:a*Math.cos(c),y4:a*Math.sin(c)}}var g=b,c=c,d=d,h=1e-5;return g.prototype.arc=function(a,b,f,g,h,i,j){if(this._doStroke||this._doFill){this._angleMode===d.DEGREES&&(h=this.radians(h),i=this.radians(i));var k=this.drawingContext,l=c.arcModeAdjust(a,b,f,g,this._ellipseMode),m=e(1,h,i),n=l.w/2,o=l.h/2;return k.beginPath(),m.forEach(function(a,b){0===b&&k.moveTo(l.x+a.x1*n,l.y+a.y1*o),k.bezierCurveTo(l.x+a.x2*n,l.y+a.y2*o,l.x+a.x3*n,l.y+a.y3*o,l.x+a.x4*n,l.y+a.y4*o)}),this._doFill&&((j===d.PIE||null==j)&&k.lineTo(l.x,l.y),k.closePath(),k.fill(),this._doStroke&&(j===d.CHORD||j===d.PIE))?(k.stroke(),this):(this._doStroke&&(j===d.OPEN||null==j)&&(k.beginPath(),m.forEach(function(a,b){0===b&&k.moveTo(l.x+a.x1*n,l.y+a.y1*o),k.bezierCurveTo(l.x+a.x2*n,l.y+a.y2*o,l.x+a.x3*n,l.y+a.y3*o,l.x+a.x4*n,l.y+a.y4*o)}),k.stroke()),this)}},g.prototype.ellipse=function(a,b,d,e){if(this._doStroke||this._doFill){d=Math.abs(d),e=Math.abs(e);var f=this.drawingContext,g=c.modeAdjust(a,b,d,e,this._ellipseMode);if(f.beginPath(),d===e)f.arc(g.x+g.w/2,g.y+g.w/2,g.w/2,0,2*Math.PI,!1);else{var h=.5522848,i=g.w/2*h,j=g.h/2*h,k=g.x+g.w,l=g.y+g.h,m=g.x+g.w/2,n=g.y+g.h/2;f.moveTo(g.x,n),f.bezierCurveTo(g.x,n-j,m-i,g.y,m,g.y),f.bezierCurveTo(m+i,g.y,k,n-j,k,n),f.bezierCurveTo(k,n+j,m+i,l,m,l),f.bezierCurveTo(m-i,l,g.x,n+j,g.x,n),f.closePath()}return this._doFill&&f.fill(),this._doStroke&&f.stroke(),this}},g.prototype.line=function(a,b,c,d){if(this._doStroke){var e=this.drawingContext;if("rgba(0,0,0,0)"!==e.strokeStyle)return e.beginPath(),e.moveTo(a,b),e.lineTo(c,d),e.stroke(),this}},g.prototype.point=function(a,b){if(this._doStroke){var c=this.drawingContext,e=c.strokeStyle,f=c.fillStyle;if("rgba(0,0,0,0)"!==e)return a=Math.round(a),b=Math.round(b),c.fillStyle=e,c.lineWidth>1?(c.beginPath(),c.arc(a,b,c.lineWidth/2,0,d.TWO_PI,!1),c.fill()):c.fillRect(a,b,1,1),c.fillStyle=f,this}},g.prototype.quad=function(a,b,c,d,e,f,g,h){if(this._doStroke||this._doFill){var i=this.drawingContext;return i.beginPath(),i.moveTo(a,b),i.lineTo(c,d),i.lineTo(e,f),i.lineTo(g,h),i.closePath(),this._doFill&&i.fill(),this._doStroke&&i.stroke(),this}},g.prototype.rect=function(a,b,d,e,f,g,h,i){if(this._doStroke||this._doFill){var j=c.modeAdjust(a,b,d,e,this._rectMode),k=this.drawingContext;if(this._doStroke&&k.lineWidth%2===1&&k.translate(.5,.5),k.beginPath(),"undefined"==typeof f)k.rect(j.x,j.y,j.w,j.h);else{"undefined"==typeof g&&(g=f),"undefined"==typeof h&&(h=g),"undefined"==typeof i&&(i=h);var l=j.x,m=j.y,n=j.w,o=j.h,p=n/2,q=o/2;2*f>n&&(f=p),2*f>o&&(f=q),2*g>n&&(g=p),2*g>o&&(g=q),2*h>n&&(h=p),2*h>o&&(h=q),2*i>n&&(i=p),2*i>o&&(i=q),k.beginPath(),k.moveTo(l+f,m),k.arcTo(l+n,m,l+n,m+o,g),k.arcTo(l+n,m+o,l,m+o,h),k.arcTo(l,m+o,l,m,i),k.arcTo(l,m,l+n,m,f),k.closePath()}return this._doFill&&k.fill(),this._doStroke&&k.stroke(),this._doStroke&&k.lineWidth%2===1&&k.translate(-.5,-.5),this}},g.prototype.triangle=function(a,b,c,d,e,f){if(this._doStroke||this._doFill){var g=this.drawingContext;return g.beginPath(),g.moveTo(a,b),g.lineTo(c,d),g.lineTo(e,f),g.closePath(),this._doFill&&g.fill(),this._doStroke&&g.stroke(),this}},g}({},amdclean.core,amdclean.canvas,amdclean.constants),amdclean.shapeattributes=function(a,b,c){"use strict";var d=b,c=c;return d.prototype._rectMode=c.CORNER,d.prototype._ellipseMode=c.CENTER,d.prototype.ellipseMode=function(a){return(a===c.CORNER||a===c.CORNERS||a===c.RADIUS||a===c.CENTER)&&(this._ellipseMode=a),this},d.prototype.noSmooth=function(){return this.drawingContext.mozImageSmoothingEnabled=!1,this.drawingContext.webkitImageSmoothingEnabled=!1,this},d.prototype.rectMode=function(a){return(a===c.CORNER||a===c.CORNERS||a===c.RADIUS||a===c.CENTER)&&(this._rectMode=a),this},d.prototype.smooth=function(){return this.drawingContext.mozImageSmoothingEnabled=!0,this.drawingContext.webkitImageSmoothingEnabled=!0,this},d.prototype.strokeCap=function(a){return(a===c.ROUND||a===c.SQUARE||a===c.PROJECT)&&(this.drawingContext.lineCap=a),this},d.prototype.strokeJoin=function(a){return(a===c.ROUND||a===c.BEVEL||a===c.MITER)&&(this.drawingContext.lineJoin=a),this},d.prototype.strokeWeight=function(a){return"undefined"==typeof a||0===a?this.drawingContext.lineWidth=1e-4:this.drawingContext.lineWidth=a,this},d}({},amdclean.core,amdclean.constants),amdclean.shapecurves=function(a,b){"use strict";var c=b,d=20,e=20;return c.prototype._curveTightness=0,c.prototype.bezier=function(a,b,c,d,e,f,g,h){return this._doStroke?(this.beginShape(),this.vertex(a,b),this.bezierVertex(c,d,e,f,g,h),this.endShape(),this.stroke(),this):void 0},c.prototype.bezierDetail=function(a){return d=a,this},c.prototype.bezierPoint=function(a,b,c,d,e){var f=1-e;return Math.pow(f,3)*a+3*Math.pow(f,2)*e*b+3*f*Math.pow(e,2)*c+Math.pow(e,3)*d},c.prototype.bezierTangent=function(a,b,c,d,e){var f=1-e;return 3*d*Math.pow(e,2)-3*c*Math.pow(e,2)+6*c*f*e-6*b*f*e+3*b*Math.pow(f,2)-3*a*Math.pow(f,2)},c.prototype.curve=function(a,b,c,d,e,f,g,h){return this._doStroke?(this.beginShape(),this.curveVertex(a,b),this.curveVertex(c,d),this.curveVertex(e,f),this.curveVertex(g,h),this.endShape(),this.stroke(),this):void 0},c.prototype.curveDetail=function(a){return e=a,this},c.prototype.curveTightness=function(a){this._setProperty("_curveTightness",a)},c.prototype.curvePoint=function(a,b,c,d,e){var f=e*e*e,g=e*e,h=-.5*f+g-.5*e,i=1.5*f-2.5*g+1,j=-1.5*f+2*g+.5*e,k=.5*f-.5*g;return a*h+b*i+c*j+d*k},c.prototype.curveTangent=function(a,b,c,d,e){var f=e*e,g=-3*f/2+2*e-.5,h=9*f/2-5*e,i=-9*f/2+4*e+.5,j=3*f/2-e;return a*g+b*h+c*i+d*j},c}({},amdclean.core),amdclean.shapevertex=function(a,b,c){"use strict";var d=b,c=c,e=null,f=[],g=[],h=!1,i=!1,j=!1,k=!1;return d.prototype._doFillStrokeClose=function(){this._doFill&&this.drawingContext.fill(),this._doStroke&&this.drawingContext.stroke(),this.drawingContext.closePath()},d.prototype.beginContour=function(){return g=[],k=!0,this},d.prototype.beginShape=function(a){return e=a===c.POINTS||a===c.LINES||a===c.TRIANGLES||a===c.TRIANGLE_FAN||a===c.TRIANGLE_STRIP||a===c.QUADS||a===c.QUAD_STRIP?a:null,f=[],g=[],this},d.prototype.bezierVertex=function(a,b,c,d,e,i){if(0===f.length)throw"vertex() must be used once before calling bezierVertex()";h=!0;for(var j=[],l=0;lg;g++)b=f[g],this._doStroke&&this.stroke(b[6]),this.point(b[0],b[1]);else if(e===c.LINES)for(g=0;m>g+1;g+=2)b=f[g],this._doStroke&&this.stroke(f[g+1][6]),this.line(b[0],b[1],f[g+1][0],f[g+1][1]);else if(e===c.TRIANGLES)for(g=0;m>g+2;g+=3)b=f[g],this.drawingContext.beginPath(),this.drawingContext.moveTo(b[0],b[1]),this.drawingContext.lineTo(f[g+1][0],f[g+1][1]),this.drawingContext.lineTo(f[g+2][0],f[g+2][1]),this.drawingContext.lineTo(b[0],b[1]),this._doFill&&(this.fill(f[g+2][5]),this.drawingContext.fill()),this._doStroke&&(this.stroke(f[g+2][6]),this.drawingContext.stroke()),this.drawingContext.closePath();else if(e===c.TRIANGLE_STRIP)for(g=0;m>g+1;g++)b=f[g],this.drawingContext.beginPath(),this.drawingContext.moveTo(f[g+1][0],f[g+1][1]),this.drawingContext.lineTo(b[0],b[1]),this._doStroke&&this.stroke(f[g+1][6]),this._doFill&&this.fill(f[g+1][5]),m>g+2&&(this.drawingContext.lineTo(f[g+2][0],f[g+2][1]),this._doStroke&&this.stroke(f[g+2][6]),this._doFill&&this.fill(f[g+2][5])),this._doFillStrokeClose();else if(e===c.TRIANGLE_FAN){if(m>2)for(this.drawingContext.beginPath(),this.drawingContext.moveTo(f[0][0],f[0][1]),this.drawingContext.lineTo(f[1][0],f[1][1]),this.drawingContext.lineTo(f[2][0],f[2][1]),this._doFill&&this.fill(f[2][5]),this._doStroke&&this.stroke(f[2][6]),this._doFillStrokeClose(),g=3;m>g;g++)b=f[g],this.drawingContext.beginPath(),this.drawingContext.moveTo(f[0][0],f[0][1]),this.drawingContext.lineTo(f[g-1][0],f[g-1][1]),this.drawingContext.lineTo(b[0],b[1]),this._doFill&&this.fill(b[5]),this._doStroke&&this.stroke(b[6]),this._doFillStrokeClose()}else if(e===c.QUADS)for(g=0;m>g+3;g+=4){for(b=f[g],this.drawingContext.beginPath(),this.drawingContext.moveTo(b[0],b[1]),l=1;4>l;l++)this.drawingContext.lineTo(f[g+l][0],f[g+l][1]);this.drawingContext.lineTo(b[0],b[1]),this._doFill&&this.fill(f[g+3][5]),this._doStroke&&this.stroke(f[g+3][6]),this._doFillStrokeClose()}else if(e===c.QUAD_STRIP){if(m>3)for(g=0;m>g+1;g+=2)b=f[g],this.drawingContext.beginPath(),m>g+3?(this.drawingContext.moveTo(f[g+2][0],f[g+2][1]),this.drawingContext.lineTo(b[0],b[1]),this.drawingContext.lineTo(f[g+1][0],f[g+1][1]),this.drawingContext.lineTo(f[g+3][0],f[g+3][1]),this._doFill&&this.fill(f[g+3][5]),this._doStroke&&this.stroke(f[g+3][6])):(this.drawingContext.moveTo(b[0],b[1]),this.drawingContext.lineTo(f[g+1][0],f[g+1][1])),this._doFillStrokeClose()}else{for(this.drawingContext.beginPath(),this.drawingContext.moveTo(f[0][0],f[0][1]),g=1;m>g;g++)b=f[g],b.isVert&&(b.moveTo?this.drawingContext.moveTo(b[0],b[1]):this.drawingContext.lineTo(b[0],b[1]));this._doFillStrokeClose()}else{for(this.drawingContext.beginPath(),g=0;m>g;g++)f[g].isVert?f[g].moveTo?this.drawingContext.moveTo([0],f[g][1]):this.drawingContext.lineTo(f[g][0],f[g][1]):this.drawingContext.quadraticCurveTo(f[g][0],f[g][1],f[g][2],f[g][3]);this._doFillStrokeClose()}else{for(this.drawingContext.beginPath(),g=0;m>g;g++)f[g].isVert?f[g].moveTo?this.drawingContext.moveTo(f[g][0],f[g][1]):this.drawingContext.lineTo(f[g][0],f[g][1]):this.drawingContext.bezierCurveTo(f[g][0],f[g][1],f[g][2],f[g][3],f[g][4],f[g][5]);this._doFillStrokeClose()}else if(m>3){var n=[],o=1-this._curveTightness;for(this.drawingContext.beginPath(),this.drawingContext.moveTo(f[1][0],f[1][1]),g=1;m>g+2;g++)b=f[g],n[0]=[b[0],b[1]],n[1]=[b[0]+(o*f[g+1][0]-o*f[g-1][0])/6,b[1]+(o*f[g+1][1]-o*f[g-1][1])/6],n[2]=[f[g+1][0]+(o*f[g][0]-o*f[g+2][0])/6,f[g+1][1]+(o*f[g][1]-o*f[g+2][1])/6],n[3]=[f[g+1][0],f[g+1][1]],this.drawingContext.bezierCurveTo(n[1][0],n[1][1],n[2][0],n[2][1],n[3][0],n[3][1]);d&&this.drawingContext.lineTo(f[g+1][0],f[g+1][1]),this._doFillStrokeClose()}return i=!1,h=!1,j=!1,k=!1,d&&f.pop(),this},d.prototype.quadraticVertex=function(a,b,d,e){if(this._contourInited){var h={};return h.x=a,h.y=b,h.x3=d,h.y3=e,h.type=c.QUADRATIC,this._contourVertices.push(h),this}if(!(f.length>0))throw"vertex() must be used once before calling quadraticVertex()";j=!0;for(var i=[],l=0;ld?(this._doFill&&this.drawingContext.fillText(h,b,c),this._doStroke&&this.drawingContext.strokeText(h,b,c),h=i[j]+" ",c+=this._textLeading):h=k}this._doFill&&this.drawingContext.fillText(h,b,c),this._doStroke&&this.drawingContext.strokeText(h,b,c),c+=this._textLeading}},c.prototype.textFont=function(a){this._setProperty("_textFont",a),this._applyTextProperties()},c}({},amdclean.core),amdclean.src_app=function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q){"use strict";var R=b,S=function(){window.PHANTOMJS||window.mocha||(window.setup&&"function"==typeof window.setup||window.draw&&"function"==typeof window.draw)&&new R};return"complete"===document.readyState?S():window.addEventListener("load",S,!1),R}({},amdclean.core,amdclean.p5Color,amdclean.p5Element,amdclean.p5Graphics,amdclean.p5Image,amdclean.p5File,amdclean.p5Vector,amdclean.p5TableRow,amdclean.p5Table,amdclean.colorcreating_reading,amdclean.colorsetting,amdclean.constants,amdclean.dataconversion,amdclean.dataarray_functions,amdclean.datastring_functions,amdclean.environment,amdclean.imageimage,amdclean.imageloading_displaying,amdclean.imagepixels,amdclean.inputfiles,amdclean.inputkeyboard,amdclean.inputacceleration,amdclean.inputmouse,amdclean.inputtime_date,amdclean.inputtouch,amdclean.mathmath,amdclean.mathcalculation,amdclean.mathrandom,amdclean.mathnoise,amdclean.mathtrigonometry,amdclean.outputfiles,amdclean.outputimage,amdclean.outputtext_area,amdclean.renderingrendering,amdclean.shape2d_primitives,amdclean.shapeattributes,amdclean.shapecurves,amdclean.shapevertex,amdclean.structure,amdclean.transform,amdclean.typographyattributes,amdclean.typographyloading_displaying),amdclean.src_app}); \ No newline at end of file +/*! p5.js v0.4.4 May 12, 2015 */!function(a,b){"function"==typeof define&&define.amd?define("p5",[],function(){return a.returnExportsGlobal=b()}):"object"==typeof exports?module.exports=b():a.p5=b()}(this,function(){var amdclean={};return amdclean.shim=function(a){window.requestDraw=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a,b){window.setTimeout(a,1e3/60)}}()}({}),amdclean.constants=function(a){var b=Math.PI;return{ARROW:"default",CROSS:"crosshair",HAND:"pointer",MOVE:"move",TEXT:"text",WAIT:"wait",HALF_PI:b/2,PI:b,QUARTER_PI:b/4,TAU:2*b,TWO_PI:2*b,DEGREES:"degrees",RADIANS:"radians",CORNER:"corner",CORNERS:"corners",RADIUS:"radius",RIGHT:"right",LEFT:"left",CENTER:"center",TOP:"top",BOTTOM:"bottom",BASELINE:"alphabetic",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",THRESHOLD:"threshold",GRAY:"gray",OPAQUE:"opaque",INVERT:"invert",POSTERIZE:"posterize",DILATE:"dilate",ERODE:"erode",BLUR:"blur",NORMAL:"normal",ITALIC:"italic",BOLD:"bold",LINEAR:"linear",QUADRATIC:"quadratic",BEZIER:"bezier",CURVE:"curve"}}({}),amdclean.core=function(a,b,c){"use strict";var c=c,d=function(a,b,e){2===arguments.length&&"boolean"==typeof b&&(e=b,b=void 0),this._setupDone=!1,this._pixelDensity=window.devicePixelRatio||1,this._startTime=(new Date).getTime(),this._userNode=b,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,mouseover:null,mouseout:null,keydown:null,keyup:null,keypress:null,touchstart:null,touchmove:null,touchend:null,resize:null,blur:null},window.DeviceOrientationEvent?this._events.deviceorientation=null:window.DeviceMotionEvent?this._events.devicemotion=null:this._events.MozOrientation=null,/Firefox/i.test(navigator.userAgent)?this._events.DOMMouseScroll=null:this._events.mousewheel=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 a=this._userNode||document.body;a.appendChild(this._loadingScreen)}this.createCanvas(this._defaultCanvasSize.width,this._defaultCanvasSize.height,!0);var b=this.preload||window.preload,c=this._isGlobal?window:this;b?(this._preloadMethods.forEach(function(a){c[a]=function(){var b=Array.prototype.slice.call(arguments);return c._preload(a,b)}}),b(),0===this._preloadCount&&(this._setup(),this._runFrames(),this._draw())):(this._setup(),this._runFrames(),this._draw())}.bind(this),this._preload=function(a,b){var c=this._isGlobal?window:this;c._setProperty("_preloadCount",c._preloadCount+1);var e=function(a){c._setProperty("_preloadCount",c._preloadCount-1),0===c._preloadCount&&(c._setup(),c._runFrames(),c._draw())};return b.push(e),d.prototype[a].apply(c,b)}.bind(this),this._setup=function(){var a=this._isGlobal?window:this;"function"==typeof a.preload&&this._preloadMethods.forEach(function(b){a[b]=d.prototype[b]}),"function"==typeof a.setup&&a.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 a=(new Date).getTime();this._frameRate=1e3/(a-this._lastFrameTime),this._lastFrameTime=a,this._setProperty("frameCount",this.frameCount+1),this._loop&&(this._drawInterval&&clearInterval(this._drawInterval),this._drawInterval=setTimeout(function(){window.requestDraw(this._draw.bind(this))}.bind(this),1e3/this._targetFrameRate)),this.redraw(),this._updatePAccelerations(),this._updatePMouseCoords(),this._updatePTouchCoords()}.bind(this),this._runFrames=function(){this._updateInterval&&clearInterval(this._updateInterval)}.bind(this),this._setProperty=function(a,b){this[a]=b,this._isGlobal&&(window[a]=b)}.bind(this),this.remove=function(){if(this._curElement){this._loop=!1,this._drawInterval&&clearTimeout(this._drawInterval),this._updateInterval&&clearTimeout(this._updateInterval);for(var a in this._events)window.removeEventListener(a,this._events[a]);for(var b=0;bb&&(b+=1),b>1&&(b-=1)}return[Math.round(255*b),Math.round(255*c),Math.round(255*j),a[3]]},c.ColorUtils}({},amdclean.core),amdclean.p5Color=function(a,b,c,d){var e=b,f=c,d=d;e.Color=function(a,b){return this.color_array=e.Color._getFormattedColor.apply(a,b),this._normalizeColorArray(a),a._colorMode===d.HSB?(this.hsba=this.color_array,this.rgba=f.hsbaToRGBA(this.hsba)):(this.rgba=this.color_array,this.hsba=f.rgbaToHSBA(this.rgba)),this},e.Color.prototype._normalizeColorArray=function(a){var b=a._colorMode===d.RGB,c=b?a._maxRGB:a._maxHSB,e=this.color_array;return e[0]*=255/c[0],e[1]*=255/c[1],e[2]*=255/c[2],e[3]*=255/c[3],e},e.Color.prototype.getHue=function(){return this.hsba[0]},e.Color.prototype.getSaturation=function(){return this.hsba[1]},e.Color.prototype.getBrightness=function(){return this.hsba[2]},e.Color.prototype.getRed=function(){return this.rgba[0]},e.Color.prototype.getGreen=function(){return this.rgba[1]},e.Color.prototype.getBlue=function(){return this.rgba[2]},e.Color.prototype.getAlpha=function(){return this.rgba[3]},e.Color.prototype.toString=function(){for(var a=this.rgba,b=0;3>b;b++)a[b]=Math.floor(a[b]);var c="undefined"!=typeof a[3]?a[3]/255:1;return"rgba("+a[0]+","+a[1]+","+a[2]+","+c+")"};var g=/\s*/,h=/(\d{1,3})/,i=/((?:\d+(?:\.\d+)?)|(?:\.\d+))/,j=new RegExp(i.source+"%"),k={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},l={HEX3:/^#([a-f0-9])([a-f0-9])([a-f0-9])$/i,HEX6:/^#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i,RGB:new RegExp(["^rgb\\(",h.source,",",h.source,",",h.source,"\\)$"].join(g.source),"i"),RGB_PERCENT:new RegExp(["^rgb\\(",j.source,",",j.source,",",j.source,"\\)$"].join(g.source),"i"),RGBA:new RegExp(["^rgba\\(",h.source,",",h.source,",",h.source,",",i.source,"\\)$"].join(g.source),"i"),RGBA_PERCENT:new RegExp(["^rgba\\(",j.source,",",j.source,",",j.source,",",i.source,"\\)$"].join(g.source),"i")};return e.Color._getFormattedColor=function(){var a,b,c,f,g,h;if(arguments.length>=3)a=arguments[0],b=arguments[1],c=arguments[2],f="number"==typeof arguments[3]?arguments[3]:255;else{if("string"==typeof arguments[0])return g=arguments[0].trim().toLowerCase(),k[g]?e.Color._getFormattedColor.apply(this,[k[g]]):(h=l.HEX3.test(g)?l.HEX3.exec(g).slice(1).map(function(a){return parseInt(a+a,16)}):l.HEX6.test(g)?l.HEX6.exec(g).slice(1).map(function(a){return parseInt(a,16)}):l.RGB.test(g)?l.RGB.exec(g).slice(1).map(function(a){return parseInt(a,10)}):l.RGB_PERCENT.test(g)?l.RGB_PERCENT.exec(g).slice(1).map(function(a){return parseInt(parseFloat(a)/100*255,10)}):l.RGBA.test(g)?l.RGBA.exec(g).slice(1).map(function(a,b){return 3===b?parseInt(255*parseFloat(a),10):parseInt(a,10)}):l.RGBA_PERCENT.test(g)?l.RGBA_PERCENT.exec(g).slice(1).map(function(a,b){return 3===b?parseInt(255*parseFloat(a),10):parseInt(parseFloat(a)/100*255,10)}):[255],e.Color._getFormattedColor.apply(this,h));this._colorMode===d.RGB?a=b=c=arguments[0]:(a=c=arguments[0],b=0),f="number"==typeof arguments[1]?arguments[1]:255}return[a,b,c,f]},e.Color}({},amdclean.core,amdclean.utilscolor_utils,amdclean.constants),amdclean.p5Element=function(a,b){function c(a,b,c){var d=b.bind(c);c.elt.addEventListener(a,d,!1),c._events[a]=d}var d=b;return d.Element=function(a,b){this.elt=a,this._pInst=b,this._events={},this.width=this.elt.offsetWidth,this.height=this.elt.offsetHeight},d.Element.prototype.parent=function(a){return"string"==typeof a?a=document.getElementById(a):a instanceof d.Element&&(a=a.elt),a.appendChild(this.elt),this},d.Element.prototype.id=function(a){return this.elt.id=a,this},d.Element.prototype["class"]=function(a){return this.elt.className+=" "+a,this},d.Element.prototype.mousePressed=function(a){return c("mousedown",a,this),c("touchstart",a,this),this},d.Element.prototype.mouseWheel=function(a){return c("mousewheel",a,this),this},d.Element.prototype.mouseReleased=function(a){return c("mouseup",a,this),c("touchend",a,this),this},d.Element.prototype.mouseClicked=function(a){return c("click",a,this),this},d.Element.prototype.mouseMoved=function(a){return c("mousemove",a,this),c("touchmove",a,this),this},d.Element.prototype.mouseOver=function(a){return c("mouseover",a,this),this},d.Element.prototype.mouseOut=function(a){return c("mouseout",a,this),this},d.Element.prototype.touchStarted=function(a){return c("touchstart",a,this),c("mousedown",a,this),this},d.Element.prototype.touchMoved=function(a){return c("touchmove",a,this),c("mousemove",a,this),this},d.Element.prototype.touchEnded=function(a){return c("touchend",a,this),c("mouseup",a,this),this},d.Element.prototype.dragOver=function(a){return c("dragover",a,this),this},d.Element.prototype.dragLeave=function(a){return c("dragleave",a,this),this},d.Element.prototype.drop=function(a,b){function e(b){var c=new d.File(b);return function(b){c.data=b.target.result,a(c)}}return window.File&&window.FileReader&&window.FileList&&window.Blob?(c("dragover",function(a){a.stopPropagation(),a.preventDefault()},this),c("dragleave",function(a){a.stopPropagation(),a.preventDefault()},this),arguments.length>1&&c("drop",b,this),c("drop",function(a){a.stopPropagation(),a.preventDefault();for(var b=a.dataTransfer.files,c=0;cb?1:248>b?b:248,e!==b){e=b,f=1+e<<1,g=new Int32Array(f),h=new Array(f);for(var c=0;f>c;c++)h[c]=new Int32Array(256);for(var d,i,j,k,l=1,m=b-1;b>l;l++){g[b+l]=g[m]=i=m*m,j=h[b+l],k=h[m--];for(var n=0;256>n;n++)j[n]=k[n]=i*n}d=g[b]=b*b,j=h[b];for(var o=0;256>o;o++)j[o]=d*o}}function c(a,c){for(var i=d._toPixels(a),j=a.width,k=a.height,l=j*k,m=new Int32Array(l),n=0;l>n;n++)m[n]=d._getARGB(i,n);var o,p,q,r,s,t,u,v,w,x,y=new Int32Array(l),z=new Int32Array(l),A=new Int32Array(l),B=new Int32Array(l),C=0;b(c);var D,E,F,G;for(E=0;k>E;E++){for(D=0;j>D;D++){if(r=q=p=s=o=0,t=D-e,0>t)x=-t,t=0;else{if(t>=j)break;x=0}for(F=x;f>F&&!(t>=j);F++){var H=m[t+C];G=h[F],s+=G[(-16777216&H)>>>24],p+=G[(16711680&H)>>16],q+=G[(65280&H)>>8],r+=G[255&H],o+=g[F],t++}u=C+D,y[u]=s/o,z[u]=p/o,A[u]=q/o,B[u]=r/o}C+=j}for(C=0,v=-e,w=v*j,E=0;k>E;E++){for(D=0;j>D;D++){if(r=q=p=s=o=0,0>v)x=u=-v,t=D;else{if(v>=k)break;x=0,u=v,t=D+w}for(F=x;f>F&&!(u>=k);F++)G=h[F],s+=G[y[t]],p+=G[z[t]],q+=G[A[t]],r+=G[B[t]],o+=g[F],u++,t+=j;m[D+C]=s/o<<24|p/o<<16|q/o<<8|r/o}C+=j,w+=j,v++}d._setPixels(i,m)}var d={};d._toPixels=function(a){return a instanceof ImageData?a.data:a.getContext("2d").getImageData(0,0,a.width,a.height).data},d._getARGB=function(a,b){var c=4*b;return a[c+3]<<24&4278190080|a[c]<<16&16711680|a[c+1]<<8&65280|255&a[c+2]},d._setPixels=function(a,b){for(var c=0,d=0,e=a.length;e>d;d++)c=4*d,a[c+0]=(16711680&b[d])>>>16,a[c+1]=(65280&b[d])>>>8,a[c+2]=255&b[d],a[c+3]=(4278190080&b[d])>>>24},d._toImageData=function(a){return a instanceof ImageData?a:a.getContext("2d").getImageData(0,0,a.width,a.height)},d._createImageData=function(a,b){return d._tmpCanvas=document.createElement("canvas"),d._tmpCtx=d._tmpCanvas.getContext("2d"),this._tmpCtx.createImageData(a,b)},d.apply=function(a,b,c){var d=a.getContext("2d"),e=d.getImageData(0,0,a.width,a.height),f=b(e,c);f instanceof ImageData?d.putImageData(f,0,0,0,0,a.width,a.height):d.putImageData(e,0,0,0,0,a.width,a.height)},d.threshold=function(a,b){var c=d._toPixels(a);void 0===b&&(b=.5);for(var e=Math.floor(255*b),f=0;f=e?255:0,c[f]=c[f+1]=c[f+2]=g}},d.gray=function(a){for(var b=d._toPixels(a),c=0;cb||b>255)throw new Error("Level must be greater than 2 and less than 255 for posterize");for(var e=b-1,f=0;f>8)/e,c[f+1]=255*(h*b>>8)/e,c[f+2]=255*(i*b>>8)/e}},d.dilate=function(a){for(var b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t=d._toPixels(a),u=0,v=t.length?t.length/4:0,w=new Int32Array(v);v>u;)for(b=u,c=u+a.width;c>u;)e=f=d._getARGB(t,u),i=u-1,h=u+1,j=u-a.width,k=u+a.width,b>i&&(i=u),h>=c&&(h=u),0>j&&(j=0),k>=v&&(k=u),n=d._getARGB(t,j),m=d._getARGB(t,i),o=d._getARGB(t,k),l=d._getARGB(t,h),g=77*(e>>16&255)+151*(e>>8&255)+28*(255&e),q=77*(m>>16&255)+151*(m>>8&255)+28*(255&m),p=77*(l>>16&255)+151*(l>>8&255)+28*(255&l),r=77*(n>>16&255)+151*(n>>8&255)+28*(255&n),s=77*(o>>16&255)+151*(o>>8&255)+28*(255&o),q>g&&(f=m,g=q),p>g&&(f=l,g=p),r>g&&(f=n,g=r),s>g&&(f=o,g=s),w[u++]=f;d._setPixels(t,w)},d.erode=function(a){for(var b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t=d._toPixels(a),u=0,v=t.length?t.length/4:0,w=new Int32Array(v);v>u;)for(b=u,c=u+a.width;c>u;)e=f=d._getARGB(t,u),i=u-1,h=u+1,j=u-a.width,k=u+a.width,b>i&&(i=u),h>=c&&(h=u),0>j&&(j=0),k>=v&&(k=u),n=d._getARGB(t,j),m=d._getARGB(t,i),o=d._getARGB(t,k),l=d._getARGB(t,h),g=77*(e>>16&255)+151*(e>>8&255)+28*(255&e),q=77*(m>>16&255)+151*(m>>8&255)+28*(255&m),p=77*(l>>16&255)+151*(l>>8&255)+28*(255&l),r=77*(n>>16&255)+151*(n>>8&255)+28*(255&n),s=77*(o>>16&255)+151*(o>>8&255)+28*(255&o),g>q&&(f=m,g=q),g>p&&(f=l,g=p),g>r&&(f=n,g=r),g>s&&(f=o,g=s),w[u++]=f;d._setPixels(t,w)};var e,f,g,h;return d.blur=function(a,b){c(a,b)},d}({}),amdclean.p5Image=function(a,b,c){"use strict";var d=b,e=c;return d.Image=function(a,b){this.width=a,this.height=b,this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.drawingContext=this.canvas.getContext("2d"),this.pixels=[]},d.Image.prototype._setProperty=function(a,b){this[a]=b},d.Image.prototype.loadPixels=function(){d.prototype.loadPixels.call(this)},d.Image.prototype.updatePixels=function(a,b,c,e){d.prototype.updatePixels.call(this,a,b,c,e)},d.Image.prototype.get=function(a,b,c,e){return d.prototype.get.call(this,a,b,c,e)},d.Image.prototype.set=function(a,b,c){d.prototype.set.call(this,a,b,c)},d.Image.prototype.resize=function(a,b){a=a||this.canvas.width,b=b||this.canvas.height;var c=document.createElement("canvas");c.width=a,c.height=b,c.getContext("2d").drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height,0,0,c.width,c.height),this.canvas.width=this.width=a,this.canvas.height=this.height=b,this.drawingContext.drawImage(c,0,0,a,b,0,0,a,b),this.pixels.length>0&&this.loadPixels()},d.Image.prototype.copy=function(){d.prototype.copy.apply(this,arguments)},d.Image.prototype.mask=function(a){void 0===a&&(a=this);var b=this.drawingContext.globalCompositeOperation,c=1;a instanceof d.Graphics&&(c=a._pInst._pixelDensity);var e=[a,0,0,c*a.width,c*a.height,0,0,this.width,this.height];this.drawingContext.globalCompositeOperation="destination-in",this.copy.apply(this,e),this.drawingContext.globalCompositeOperation=b},d.Image.prototype.filter=function(a,b){e.apply(this.canvas,e[a.toLowerCase()],b)},d.Image.prototype.blend=function(){d.prototype.blend.apply(this,arguments)},d.Image.prototype.save=function(a,b){var c;if(b)switch(b.toLowerCase()){case"png":c="image/png";break;case"jpeg":c="image/jpeg";break;case"jpg":c="image/jpeg";break;default:c="image/png"}else b="png",c="image/png";var e="image/octet-stream",f=this.canvas.toDataURL(c);f=f.replace(c,e),d.prototype.downloadFile(f,a,b)},d.Image}({},amdclean.core,amdclean.filters),amdclean.p5File=function(a,b){var c=b;return c.File=function(a,b){this.file=a,this._pInst=b;var c=a.type.split("/");this.type=c[0],this.subtype=c[1],this.name=a.name,this.size=a.size,this.data=void 0},c.File}({},amdclean.core),amdclean.polargeometry=function(a){return{degreesToRadians:function(a){return 2*Math.PI*a/360},radiansToDegrees:function(a){return 360*a/(2*Math.PI)}}}({}),amdclean.p5Vector=function(a,b,c,d){"use strict";var e=b,f=c,d=d;return e.Vector=function(){var a,b,c;arguments[0]instanceof e?(this.p5=arguments[0],a=arguments[1][0]||0,b=arguments[1][1]||0,c=arguments[1][2]||0):(a=arguments[0]||0,b=arguments[1]||0,c=arguments[2]||0),this.x=a,this.y=b,this.z=c},e.Vector.prototype.set=function(a,b,c){return a instanceof e.Vector?(this.x=a.x||0,this.y=a.y||0,this.z=a.z||0,this):a instanceof Array?(this.x=a[0]||0,this.y=a[1]||0,this.z=a[2]||0,this):(this.x=a||0,this.y=b||0,this.z=c||0,this)},e.Vector.prototype.copy=function(){return this.p5?new e.Vector(this.p5,[this.x,this.y,this.z]):new e.Vector(this.x,this.y,this.z)},e.Vector.prototype.add=function(a,b,c){return a instanceof e.Vector?(this.x+=a.x||0,this.y+=a.y||0,this.z+=a.z||0,this):a instanceof Array?(this.x+=a[0]||0,this.y+=a[1]||0,this.z+=a[2]||0,this):(this.x+=a||0,this.y+=b||0,this.z+=c||0,this)},e.Vector.prototype.sub=function(a,b,c){return a instanceof e.Vector?(this.x-=a.x||0,this.y-=a.y||0,this.z-=a.z||0,this):a instanceof Array?(this.x-=a[0]||0,this.y-=a[1]||0,this.z-=a[2]||0,this):(this.x-=a||0,this.y-=b||0,this.z-=c||0,this)},e.Vector.prototype.mult=function(a){return this.x*=a||0,this.y*=a||0,this.z*=a||0,this},e.Vector.prototype.div=function(a){return this.x/=a,this.y/=a,this.z/=a,this},e.Vector.prototype.mag=function(){return Math.sqrt(this.magSq())},e.Vector.prototype.magSq=function(){var a=this.x,b=this.y,c=this.z;return a*a+b*b+c*c},e.Vector.prototype.dot=function(a,b,c){return a instanceof e.Vector?this.dot(a.x,a.y,a.z):this.x*(a||0)+this.y*(b||0)+this.z*(c||0)},e.Vector.prototype.cross=function(a){var b=this.y*a.z-this.z*a.y,c=this.z*a.x-this.x*a.z,d=this.x*a.y-this.y*a.x;return this.p5?new e.Vector(this.p5,[b,c,d]):new e.Vector(b,c,d)},e.Vector.prototype.dist=function(a){var b=a.copy().sub(this);return b.mag()},e.Vector.prototype.normalize=function(){return this.div(this.mag())},e.Vector.prototype.limit=function(a){var b=this.magSq();return b>a*a&&(this.div(Math.sqrt(b)),this.mult(a)),this},e.Vector.prototype.setMag=function(a){return this.normalize().mult(a)},e.Vector.prototype.heading=function(){var a=Math.atan2(this.y,this.x);return this.p5?this.p5._angleMode===d.RADIANS?a:f.radiansToDegrees(a):a},e.Vector.prototype.rotate=function(a){this.p5&&this.p5._angleMode===d.DEGREES&&(a=f.degreesToRadians(a));var b=this.heading()+a,c=this.mag();return this.x=Math.cos(b)*c,this.y=Math.sin(b)*c,this},e.Vector.prototype.lerp=function(a,b,c,d){return a instanceof e.Vector?this.lerp(a.x,a.y,a.z,b):(this.x+=(a-this.x)*d||0,this.y+=(b-this.y)*d||0,this.z+=(c-this.z)*d||0,this)},e.Vector.prototype.array=function(){return[this.x||0,this.y||0,this.z||0]},e.Vector.prototype.equals=function(a,b,c){return a instanceof e.Vector?(a=a.x||0,b=a.y||0,c=a.z||0):a instanceof Array?(a=a[0]||0,b=a[1]||0,c=a[2]||0):(a=a||0,b=b||0,c=c||0),this.x===a&&this.y===b&&this.z===c},e.Vector.fromAngle=function(a){return this.p5&&this.p5._angleMode===d.DEGREES&&(a=f.degreesToRadians(a)),this.p5?new e.Vector(this.p5,[Math.cos(a),Math.sin(a),0]):new e.Vector(Math.cos(a),Math.sin(a),0)},e.Vector.random2D=function(){var a;return a=this.p5?this.p5.random(this.p5._angleMode===d.DEGREES?360:d.TWO_PI):Math.random()*Math.PI*2,this.fromAngle(a)},e.Vector.random3D=function(){var a,b;this.p5?(a=this.p5.random(0,d.TWO_PI),b=this.p5.random(-1,1)):(a=Math.random()*Math.PI*2,b=2*Math.random()-1);var c=Math.sqrt(1-b*b)*Math.cos(a),f=Math.sqrt(1-b*b)*Math.sin(a);return this.p5?new e.Vector(this.p5,[c,f,b]):new e.Vector(c,f,b)},e.Vector.add=function(a,b,c){return c?c.set(a):c=a.copy(),c.add(b),c},e.Vector.sub=function(a,b,c){return c?c.set(a):c=a.copy(),c.sub(b),c},e.Vector.mult=function(a,b,c){return c?c.set(a):c=a.copy(),c.mult(b),c},e.Vector.div=function(a,b,c){return c?c.set(a):c=a.copy(),c.div(b),c},e.Vector.dot=function(a,b){return a.dot(b)},e.Vector.cross=function(a,b){return a.cross(b)},e.Vector.dist=function(a,b){return a.dist(b)},e.Vector.lerp=function(a,b,c,d){return d?d.set(a):d=a.copy(),d.lerp(b,c),d},e.Vector.angleBetween=function(a,b){var c=Math.acos(a.dot(b)/(a.mag()*b.mag()));return this.p5&&this.p5._angleMode===d.DEGREES&&(c=f.radiansToDegrees(c)),c},e.Vector}({},amdclean.core,amdclean.polargeometry,amdclean.constants),amdclean.p5TableRow=function(a,b){"use strict";var c=b;return c.TableRow=function(a,b){var c=[],d={};a&&(b=b||",",c=a.split(b));for(var e=0;e=0))throw'This table has no column named "'+a+'"';this.obj[a]=b,this.arr[c]=b}else{if(!(ah;h++)g.push(Math.sqrt(d.prototype.lerp(a.rgba[h]*a.rgba[h],b.rgba[h]*b.rgba[h],c)));return new d.Color(this,g)}return Math.sqrt(d.prototype.lerp(a*a,b*b,c))},d.prototype.red=function(a){if(a instanceof d.Color||a instanceof Array)return this.color(a).getRed();throw new Error("Needs p5.Color or pixel array as argument.")},d.prototype.saturation=function(a){if(!a instanceof d.Color)throw new Error("Needs p5.Color as argument.");return a.getSaturation()},d}({},amdclean.core,amdclean.p5Color),amdclean.colorsetting=function(a,b,c,d){"use strict";var e=b,c=c;return e.prototype._doStroke=!0,e.prototype._doFill=!0,e.prototype._colorMode=c.RGB,e.prototype._maxRGB=[255,255,255,255],e.prototype._maxHSB=[255,255,255,255],e.prototype.background=function(){if(this.drawingContext.save(),this.drawingContext.setTransform(1,0,0,1,0,0),this.drawingContext.scale(this._pixelDensity,this._pixelDensity),arguments[0]instanceof e.Image)this.image(arguments[0],0,0,this.width,this.height);else{var a=this.drawingContext.fillStyle,b=this.color.apply(this,arguments),c=b.toString();this.drawingContext.fillStyle=c,this.drawingContext.fillRect(0,0,this.width,this.height),this.drawingContext.fillStyle=a}this.drawingContext.restore()},e.prototype.clear=function(){this.drawingContext.clearRect(0,0,this.width,this.height)},e.prototype.colorMode=function(){if(arguments[0]===c.RGB||arguments[0]===c.HSB){this._colorMode=arguments[0];var a=this._colorMode===c.RGB,b=a?this._maxRGB:this._maxHSB;2===arguments.length?(b[0]=arguments[1],b[1]=arguments[1],b[2]=arguments[1],b[3]=arguments[1]):arguments.length>2&&(b[0]=arguments[1],b[1]=arguments[2],b[2]=arguments[3]),5===arguments.length&&(b[3]=arguments[4])}},e.prototype.fill=function(){this._setProperty("_doFill",!0);var a=this.drawingContext,b=this.color.apply(this,arguments);a.fillStyle=b.toString()},e.prototype.noFill=function(){this._setProperty("_doFill",!1)},e.prototype.noStroke=function(){this._setProperty("_doStroke",!1)},e.prototype.stroke=function(){this._setProperty("_doStroke",!0);var a=this.drawingContext,b=this.color.apply(this,arguments);a.strokeStyle=b.toString()},e}({},amdclean.core,amdclean.constants,amdclean.p5Color),amdclean.dataconversion=function(a,b){"use strict";var c=b;return c.prototype["float"]=function(a){return parseFloat(a)},c.prototype["int"]=function(a,b){return"string"==typeof a?(b=b||10,parseInt(a,b)):"number"==typeof a?0|a:"boolean"==typeof a?a?1:0:a instanceof Array?a.map(function(a){return c.prototype["int"](a,b)}):void 0},c.prototype.str=function(a){return a instanceof Array?a.map(c.prototype.str):String(a)},c.prototype["boolean"]=function(a){return"number"==typeof a?0!==a:"string"==typeof a?"true"===a.toLowerCase():"boolean"==typeof a?a:a instanceof Array?a.map(c.prototype["boolean"]):void 0},c.prototype["byte"]=function(a){var b=c.prototype["int"](a,10);return"number"==typeof b?(b+128)%256-128:b instanceof Array?b.map(c.prototype["byte"]):void 0},c.prototype["char"]=function(a){return"number"!=typeof a||isNaN(a)?a instanceof Array?a.map(c.prototype["char"]):"string"==typeof a?c.prototype["char"](parseInt(a,10)):void 0:String.fromCharCode(a)},c.prototype.unchar=function(a){return"string"==typeof a&&1===a.length?a.charCodeAt(0):a instanceof Array?a.map(c.prototype.unchar):void 0},c.prototype.hex=function(a,b){if(b=void 0===b||null===b?b=8:b,a instanceof Array)return a.map(function(a){return c.prototype.hex(a,b)});if("number"==typeof a){0>a&&(a=4294967295+a+1);for(var d=Number(a).toString(16).toUpperCase();d.length=b&&(d=d.substring(d.length-b,d.length)),d}},c.prototype.unhex=function(a){return a instanceof Array?a.map(c.prototype.unhex):parseInt("0x"+a,16)},c}({},amdclean.core),amdclean.dataarray_functions=function(a,b){"use strict";var c=b;return c.prototype.append=function(a,b){return a.push(b),a},c.prototype.arrayCopy=function(a,b,c,d,e){var f,g;"undefined"!=typeof e?(g=Math.min(e,a.length),f=d,a=a.slice(b,g+b)):("undefined"!=typeof c?(g=c,g=Math.min(g,a.length)):g=a.length,f=0,c=b,a=a.slice(0,g)),Array.prototype.splice.apply(c,[f,g].concat(a))},c.prototype.concat=function(a,b){return a.concat(b)},c.prototype.reverse=function(a){return a.reverse()},c.prototype.shorten=function(a){return a.pop(),a},c.prototype.shuffle=function(a,b){a=b||ArrayBuffer.isView(a)?a:a.slice();for(var c,d,e=a.length;e>1;)c=Math.random()*e|0,d=a[--e],a[e]=a[c],a[c]=d;return a},c.prototype.sort=function(a,b){var c=b?a.slice(0,Math.min(b,a.length)):a,d=b?a.slice(Math.min(b,a.length)):[];return c="string"==typeof c[0]?c.sort():c.sort(function(a,b){return a-b}),c.concat(d)},c.prototype.splice=function(a,b,c){return Array.prototype.splice.apply(a,[c,0].concat(b)),a},c.prototype.subset=function(a,b,c){return"undefined"!=typeof c?a.slice(b,b+c):a.slice(b,a.length)},c}({},amdclean.core),amdclean.datastring_functions=function(a,b){"use strict";function c(){var a=arguments[0],b=0>a,c=b?a.toString().substring(1):a.toString(),d=c.indexOf("."),e=-1!==d?c.substring(0,d):c,f=-1!==d?c.substring(d+1):"",g=b?"-":"";if(3===arguments.length){for(var h=0;h1&&(c=c.substring(0,arguments[1]+1)),d+c}function e(){return parseFloat(arguments[0])>0?"+"+arguments[0].toString():arguments[0].toString()}function f(){return parseFloat(arguments[0])>0?" "+arguments[0].toString():arguments[0].toString()}var g=b;return g.prototype.join=function(a,b){return a.join(b)},g.prototype.match=function(a,b){return a.match(b)},g.prototype.matchAll=function(a,b){for(var c=new RegExp(b,"g"),d=c.exec(a),e=[];null!==d;)e.push(d),d=c.exec(a);return e},g.prototype.nf=function(){if(arguments[0]instanceof Array){var a=arguments[1],b=arguments[2];return arguments[0].map(function(d){return c(d,a,b)})}return c.apply(this,arguments)},g.prototype.nfc=function(){if(arguments[0]instanceof Array){var a=arguments[1];return arguments[0].map(function(b){return d(b,a)})}return d.apply(this,arguments)},g.prototype.nfp=function(){var a=this.nf(arguments);return a instanceof Array?a.map(e):e(a)},g.prototype.nfs=function(){var a=this.nf(arguments);return a instanceof Array?a.map(f):f(a)},g.prototype.split=function(a,b){return a.split(b)},g.prototype.splitTokens=function(){var a=arguments.length>0?arguments[1]:/\s/g;return arguments[0].split(a).filter(function(a){return a})},g.prototype.trim=function(a){return a instanceof Array?a.map(this.trim):a.trim()},g}({},amdclean.core),amdclean.environment=function(a,b,c){"use strict";function d(a){var b=document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled;if(!b)throw new Error("Fullscreen not enabled in this browser.");a.requestFullscreen?a.requestFullscreen():a.mozRequestFullScreen?a.mozRequestFullScreen():a.webkitRequestFullscreen?a.webkitRequestFullscreen():a.msRequestFullscreen&&a.msRequestFullscreen()}function e(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen()}var f=b,g=c,h=[g.ARROW,g.CROSS,g.HAND,g.MOVE,g.TEXT,g.WAIT];return f.prototype._frameRate=0,f.prototype._lastFrameTime=(new Date).getTime(),f.prototype._targetFrameRate=60,f.prototype.frameCount=0,f.prototype.focused=!0,f.prototype.cursor=function(a,b,c){var d="auto",e=this._curElement.elt;if(h.indexOf(a)>-1)d=a;else if("string"==typeof a){var f="";b&&c&&"number"==typeof b&&"number"==typeof c&&(f=b+" "+c),d="http://"!==a.substring(0,6)?"url("+a+") "+f+", auto":/\.(cur|jpg|jpeg|gif|png|CUR|JPG|JPEG|GIF|PNG)$/.test(a)?"url("+a+") "+f+", auto":a}e.style.cursor=d},f.prototype.frameRate=function(a){return"undefined"==typeof a?this._frameRate:(this._setProperty("_targetFrameRate",a),this._runFrames(),this)},f.prototype.getFrameRate=function(){return this.frameRate()},f.prototype.setFrameRate=function(a){return this.frameRate(a)},f.prototype.noCursor=function(){this._curElement.elt.style.cursor="none"},f.prototype.displayWidth=screen.width,f.prototype.displayHeight=screen.height,f.prototype.windowWidth=window.innerWidth,f.prototype.windowHeight=window.innerHeight,f.prototype._onresize=function(a){this._setProperty("windowWidth",window.innerWidth),this._setProperty("windowHeight",window.innerHeight);var b,c=this._isGlobal?window:this;"function"==typeof c.windowResized&&(b=c.windowResized(a),void 0===b||b||a.preventDefault())},f.prototype.width=0,f.prototype.height=0,f.prototype.fullscreen=function(a){return"undefined"==typeof a?document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement:void(a?d(document.documentElement):e())},f.prototype.devicePixelScaling=function(a){a?"number"==typeof a?this._pixelDensity=a:this._pixelDensity=window.devicePixelRatio||1:this._pixelDensity=1,this.resizeCanvas(this.width,this.height,!0)},f.prototype.getURL=function(){return location.href},f.prototype.getURLPath=function(){return location.pathname.split("/").filter(function(a){return""!==a})},f.prototype.getURLParams=function(){for(var a,b=/[?&]([^&=]+)(?:[&=])([^&=]+)/gim,c={};null!=(a=b.exec(location.search));)a.index===b.lastIndex&&b.lastIndex++,c[a[1]]=a[2];return c},f}({},amdclean.core,amdclean.constants),amdclean.imageimage=function(a,b,c){"use strict";var d=b,c=c;return d.prototype._imageMode=c.CORNER,d.prototype._tint=null,d.prototype.createImage=function(a,b){return new d.Image(a,b)},d}({},amdclean.core,amdclean.constants),amdclean.canvas=function(a,b){var b=b;return{modeAdjust:function(a,c,d,e,f){return f===b.CORNER?{x:a,y:c,w:d,h:e}:f===b.CORNERS?{x:a,y:c,w:d-a,h:e-c}:f===b.RADIUS?{x:a-d,y:c-e,w:2*d,h:2*e}:f===b.CENTER?{x:a-.5*d,y:c-.5*e,w:d,h:e}:void 0},arcModeAdjust:function(a,c,d,e,f){return f===b.CORNER?{x:a+.5*d,y:c+.5*e,w:d,h:e}:f===b.CORNERS?{x:a,y:c,w:d+a,h:e+c}:f===b.RADIUS?{x:a,y:c,w:2*d,h:2*e}:f===b.CENTER?{x:a,y:c,w:d,h:e}:void 0}}}({},amdclean.constants),amdclean.imageloading_displaying=function(a,b,c,d,e){"use strict";var f=b,g=c,d=d,e=e;return f.prototype.loadImage=function(a,b,c){var d=new Image,e=new f.Image(1,1,this);return d.onload=function(){e.width=e.canvas.width=d.width,e.height=e.canvas.height=d.height,e.canvas.getContext("2d").drawImage(d,0,0),"function"==typeof b&&b(e)},d.onerror=function(a){"function"==typeof c&&c(a)},0!==a.indexOf("data:image/")&&(d.crossOrigin="Anonymous"),d.src=a,e},f.prototype.image=function(a,b,c,e,f){var g=a.canvas||a.elt;b=b||0,c=c||0,e=e||a.width,f=f||a.height;var h=d.modeAdjust(b,c,e,f,this._imageMode);try{this._tint&&a.canvas?this.drawingContext.drawImage(this._getTintedImageCanvas(a),h.x,h.y,h.w,h.h):this.drawingContext.drawImage(g,h.x,h.y,h.w,h.h)}catch(i){if("NS_ERROR_NOT_AVAILABLE"!==i.name)throw i}},f.prototype.tint=function(){var a=this.color.apply(this,arguments);this._tint=a.rgba},f.prototype.noTint=function(){this._tint=null},f.prototype._getTintedImageCanvas=function(a){if(!a.canvas)return a;var b=g._toPixels(a.canvas),c=document.createElement("canvas");c.width=a.canvas.width,c.height=a.canvas.height;for(var d=c.getContext("2d"),e=d.createImageData(a.canvas.width,a.canvas.height),f=e.data,h=0;hthis.width||b>this.height||0>a||0>b)return[0,0,0,255];var f=this.drawingContext.getImageData(a,b,c,d),g=f.data;if(1===c&&1===d){for(var h=[],i=0;i0;)self._completeHandlers.shift()(a)}function success(resp){var type=o.type||resp&&setType(resp.getResponseHeader("Content-Type"));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 timedOut(){self._timedOut=!0,self.request.abort()}function error(a,b,c){for(a=self.request,self._responseArgs.resp=a,self._responseArgs.msg=b,self._responseArgs.t=c,self._erred=!0;self._errorHandlers.length>0;)self._errorHandlers.shift()(a,b,c);complete(a)}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;fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){timedOut()},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(a,b){return new Reqwest(a,b)}function normalize(a){return a?a.replace(/\r?\n/g,"\r\n"):""}function serial(a,b){var c,d,e,f,g=a.name,h=a.tagName.toLowerCase(),i=function(a){a&&!a.disabled&&b(g,normalize(a.attributes.value&&a.attributes.value.specified?a.value:a.text))};if(!a.disabled&&g)switch(h){case"input":/reset|button|image|file/i.test(a.type)||(c=/checkbox/i.test(a.type),d=/radio/i.test(a.type),e=a.value,(!(c||d)||a.checked)&&b(g,normalize(c&&""===e?"on":e)));break;case"textarea":b(g,normalize(a.value));break;case"select":if("select-one"===a.type.toLowerCase())i(a.selectedIndex>=0?a.options[a.selectedIndex]:null);else for(f=0;a.length&&fd||Math.abs(this.accelerationY-this.pAccelerationY)>d||Math.abs(this.accelerationZ-this.pAccelerationZ)>d)&&a();var b=this.onDeviceTurn||window.onDeviceTurn;if("function"==typeof b){var c=0;Math.abs(this.accelerationX)>c&&(c=this.accelerationX,f="x"),Math.abs(this.accelerationY)>c&&(c=this.accelerationY,f="y"),Math.abs(this.accelerationZ)>c&&(f="z"),""!==e&&e!==f&&b(f),e=f}},c}({},amdclean.core),amdclean.inputmouse=function(a,b,c){"use strict";function d(a,b){var c=a.getBoundingClientRect();return{x:b.clientX-c.left,y:b.clientY-c.top}}var e=b,c=c;return e.prototype.mouseX=0,e.prototype.mouseY=0,e.prototype.pmouseX=0,e.prototype.pmouseY=0,e.prototype.winMouseX=0,e.prototype.winMouseY=0,e.prototype.pwinMouseX=0,e.prototype.pwinMouseY=0,e.prototype.mouseButton=0,e.prototype.mouseIsPressed=!1,e.prototype.isMousePressed=!1,e.prototype._updateMouseCoords=function(a){if("touchstart"===a.type||"touchmove"===a.type||"touchend"===a.type)this._setProperty("mouseX",this.touchX),this._setProperty("mouseY",this.touchY);else if(null!==this._curElement){var b=d(this._curElement.elt,a);this._setProperty("mouseX",b.x),this._setProperty("mouseY",b.y)}this._setProperty("winMouseX",a.pageX),this._setProperty("winMouseY",a.pageY)},e.prototype._updatePMouseCoords=function(a){this._setProperty("pmouseX",this.mouseX),this._setProperty("pmouseY",this.mouseY),this._setProperty("pwinMouseX",this.winMouseX),this._setProperty("pwinMouseY",this.winMouseY)},e.prototype._setMouseButton=function(a){1===a.button?this._setProperty("mouseButton",c.CENTER):2===a.button?this._setProperty("mouseButton",c.RIGHT):(this._setProperty("mouseButton",c.LEFT),("touchstart"===a.type||"touchmove"===a.type)&&(this._setProperty("mouseX",this.touchX),this._setProperty("mouseY",this.touchY)))},e.prototype._onmousemove=function(a){var b,c=this._isGlobal?window:this;this._updateMouseCoords(a),this.isMousePressed?"function"==typeof c.mouseDragged?(b=c.mouseDragged(a),b===!1&&a.preventDefault()):"function"==typeof c.touchMoved&&(b=c.touchMoved(a),b===!1&&a.preventDefault(),this._updateTouchCoords(a)):"function"==typeof c.mouseMoved&&(b=c.mouseMoved(a),b===!1&&a.preventDefault())},e.prototype._onmousedown=function(a){var b,c=this._isGlobal?window:this;this._setProperty("isMousePressed",!0),this._setProperty("mouseIsPressed",!0),this._setMouseButton(a),this._updateMouseCoords(a),"function"==typeof c.mousePressed?(b=c.mousePressed(a),b===!1&&a.preventDefault()):"function"==typeof c.touchStarted&&(b=c.touchStarted(a),b===!1&&a.preventDefault(),this._updateTouchCoords(a))},e.prototype._onmouseup=function(a){var b,c=this._isGlobal?window:this;this._setProperty("isMousePressed",!1),this._setProperty("mouseIsPressed",!1),"function"==typeof c.mouseReleased?(b=c.mouseReleased(a),b===!1&&a.preventDefault()):"function"==typeof c.touchEnded&&(b=c.touchEnded(a),b===!1&&a.preventDefault(),this._updateTouchCoords(a))},e.prototype._onclick=function(a){var b=this._isGlobal?window:this;if("function"==typeof b.mouseClicked){var c=b.mouseClicked(a);c===!1&&a.preventDefault()}},e.prototype._onmousewheel=e.prototype._onDOMMouseScroll=function(a){var b=this._isGlobal?window:this;if("function"==typeof b.mouseWheel){var c=b.mouseWheel(a);c===!1&&a.preventDefault()}},e}({},amdclean.core,amdclean.constants),amdclean.inputtime_date=function(a,b){"use strict";var c=b;return c.prototype.day=function(){return(new Date).getDate()},c.prototype.hour=function(){return(new Date).getHours()},c.prototype.minute=function(){return(new Date).getMinutes()},c.prototype.millis=function(){return(new Date).getTime()-this._startTime},c.prototype.month=function(){return(new Date).getMonth()+1},c.prototype.second=function(){return(new Date).getSeconds()},c.prototype.year=function(){return(new Date).getFullYear()},c}({},amdclean.core),amdclean.inputtouch=function(a,b){"use strict";function c(a,b,c){c=c||0;var d=a.getBoundingClientRect(),e=b.touches[c]||b.changedTouches[c];return{x:e.clientX-d.left,y:e.clientY-d.top}}var d=b;return d.prototype.touchX=0,d.prototype.touchY=0,d.prototype.ptouchX=0,d.prototype.ptouchY=0,d.prototype.touches=[],d.prototype.touchIsDown=!1,d.prototype._updateTouchCoords=function(a){if("mousedown"===a.type||"mousemove"===a.type||"mouseup"===a.type)this._setProperty("touchX",this.mouseX),this._setProperty("touchY",this.mouseY);else{var b=c(this._curElement.elt,a,0);this._setProperty("touchX",b.x),this._setProperty("touchY",b.y);for(var d=[],e=0;e>>0},getSeed:function(){return a},rand:function(){return b=(d*b+e)%c,b/c}}}();c.prototype.randomSeed=function(a){e.setSeed(a),d=!0},c.prototype.random=function(a,b){var c;if(c=d?e.rand():Math.random(),0===arguments.length)return c;if(1===arguments.length)return c*a;if(a>b){var f=a;a=b,b=f}return c*(b-a)+a};var f,g=!1;return c.prototype.randomGaussian=function(a,b){var c,d,e,h;if(g)c=f,g=!1;else{do d=this.random(2)-1,e=this.random(2)-1,h=d*d+e*e;while(h>=1);h=Math.sqrt(-2*Math.log(h)/h),c=d*h,f=e*h,g=!0}var i=a||0,j=b||1;return c*j+i},c}({},amdclean.core),amdclean.mathnoise=function(a,b){"use strict";for(var c=b,d=4,e=1<p;p++)m[p]=Math.sin(p*o*k),n[p]=Math.cos(p*o*k);var q=l;q>>=1;var r;return c.prototype.noise=function(a,b,c){if(b=b||0,c=c||0,null==r){r=new Array(h+1);for(var k=0;h+1>k;k++)r[k]=Math.random()}0>a&&(a=-a),0>b&&(b=-b),0>c&&(c=-c);for(var m,o,p,s,t,u=Math.floor(a),v=Math.floor(b),w=Math.floor(c),x=a-u,y=b-v,z=c-w,A=0,B=.5,C=function(a){return.5*(1-n[Math.floor(a*q)%l])},D=0;i>D;D++){var E=u+(v<=1&&(u++,x--),y>=1&&(v++,y--),z>=1&&(w++,z--)}return A},c.prototype.noiseDetail=function(a,b){a>0&&(i=a),b>0&&(j=b)},c.prototype.noiseSeed=function(a){var b=function(){var a,b,c=4294967296,d=1664525,e=1013904223;return{setSeed:function(d){b=a=(null==d?Math.random()*c:d)>>>0},getSeed:function(){return a},rand:function(){return b=(d*b+e)%c,b/c}}}();b.setSeed(a),r=new Array(h+1);for(var c=0;h+1>c;c++)r[c]=b.rand()},c}({},amdclean.core),amdclean.mathtrigonometry=function(a,b,c,d){"use strict";var e=b,f=c,d=d;return e.prototype._angleMode=d.RADIANS,e.prototype.acos=function(a){return this._angleMode===d.RADIANS?Math.acos(a):f.radiansToDegrees(Math.acos(a))},e.prototype.asin=function(a){return this._angleMode===d.RADIANS?Math.asin(a):f.radiansToDegrees(Math.asin(a))},e.prototype.atan=function(a){return this._angleMode===d.RADIANS?Math.atan(a):f.radiansToDegrees(Math.atan(a))},e.prototype.atan2=function(a,b){return this._angleMode===d.RADIANS?Math.atan2(a,b):f.radiansToDegrees(Math.atan2(a,b))},e.prototype.cos=function(a){return Math.cos(this._angleMode===d.RADIANS?a:this.radians(a))},e.prototype.sin=function(a){return Math.sin(this._angleMode===d.RADIANS?a:this.radians(a))},e.prototype.tan=function(a){return Math.tan(this._angleMode===d.RADIANS?a:this.radians(a))},e.prototype.degrees=function(a){return f.radiansToDegrees(a)},e.prototype.radians=function(a){return f.degreesToRadians(a)},e.prototype.angleMode=function(a){(a===d.DEGREES||a===d.RADIANS)&&(this._angleMode=a)},e}({},amdclean.core,amdclean.polargeometry,amdclean.constants),amdclean.outputfiles=function(a,b){"use strict";function c(a,b){b&&b!==!0&&"true"!==b||(b=""),a||(a="untitled");var c="";return a&&a.indexOf(".")>-1&&(c=a.split(".").pop()),b&&c!==b&&(c=b,a=a+"."+c),[a,c]}function d(a){document.body.removeChild(a.target)}var e=b;window.URL=window.URL||window.webkitURL,e.prototype._pWriters=[],e.prototype.beginRaw=function(){throw"not yet implemented"},e.prototype.beginRecord=function(){throw"not yet implemented"},e.prototype.createOutput=function(){throw"not yet implemented"},e.prototype.createWriter=function(a,b){var c;for(var d in e.prototype._pWriters)if(e.prototype._pWriters[d].name===a)return c=new e.PrintWriter(a+window.millis(),b),e.prototype._pWriters.push(c),c;return c=new e.PrintWriter(a,b),e.prototype._pWriters.push(c),c},e.prototype.endRaw=function(){throw"not yet implemented"},e.prototype.endRecord=function(){throw"not yet implemented"},e.PrintWriter=function(a,b){var c=this;this.name=a,this.content="",this.print=function(a){this.content+=a},this.println=function(a){this.content+=a+"\n"},this.flush=function(){this.content=""},this.close=function(){var d=[];d.push(this.content),e.prototype.writeFile(d,a,b);for(var f in e.prototype._pWriters)e.prototype._pWriters[f].name===this.name&&e.prototype._pWriters.splice(f,1);c.flush(),c={}}},e.prototype.saveBytes=function(){throw"not yet implemented"},e.prototype.save=function(a,b,d){var f=arguments,g=this._curElement.elt;if(0===f.length)return void e.prototype.saveCanvas(g);if(f[0]instanceof e.Graphics)return void e.prototype.saveCanvas(f[0].elt,f[1],f[2]);if(1===f.length&&"string"==typeof f[0])e.prototype.saveCanvas(g,f[0]);else{var h=c(f[1],f[2])[1];switch(h){case"json":return void e.prototype.saveJSON(f[0],f[1],f[2]);case"txt":return void e.prototype.saveStrings(f[0],f[1],f[2]);default:f[0]instanceof Array?e.prototype.saveStrings(f[0],f[1],f[2]):f[0]instanceof e.Table?e.prototype.saveTable(f[0],f[1],f[2],f[3]):f[0]instanceof e.Image?e.prototype.saveCanvas(f[0].canvas,f[1]):f[0]instanceof e.SoundFile&&e.prototype.saveSound(f[0],f[1],f[2],f[3])}}},e.prototype.saveJSON=function(a,b,c){var d;d=c?JSON.stringify(a):JSON.stringify(a,void 0,2),console.log(d),this.saveStrings(d.split("\n"),b,"json")},e.prototype.saveJSONObject=e.prototype.saveJSON,e.prototype.saveJSONArray=e.prototype.saveJSON,e.prototype.saveStream=function(){throw"not yet implemented"},e.prototype.saveStrings=function(a,b,c){var d=c||"txt",e=this.createWriter(b,d);for(var f in a)f"),d.println("");var k=' "),d.println(""),d.println(" "),"0"!==e[0]){d.println(" ");for(var l=0;l"+m),d.println(" ")}d.println(" ")}for(var n=0;n");for(var o=0;o"+q),d.println(" ")}d.println(" ")}d.println("
"),d.println(""),d.print("")}d.close(),d.flush()};var f=function(a){return a.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")};return e.prototype.writeFile=function(a,b,c){var d="application/octet-stream";e.prototype._isSafari()&&(d="text/plain");var f=new Blob(a,{type:d}),g=window.URL.createObjectURL(f);e.prototype.downloadFile(g,b,c)},e.prototype.downloadFile=function(a,b,f){var g=c(b,f),h=g[0],i=g[1],j=document.createElement("a");if(j.href=a,j.download=h,j.onclick=d,j.style.display="none",document.body.appendChild(j),e.prototype._isSafari()){var k="Hello, Safari user! To download this file...\n";k+="1. Go to File --> Save As.\n",k+='2. Choose "Page Source" as the Format.\n',k+='3. Name it with this extension: ."'+i+'"',alert(k)}j.click(),a=null},e.prototype._checkFileExtension=c,e.prototype._isSafari=function(){var a=Object.prototype.toString.call(window.HTMLElement);return a.indexOf("Constructor")>0},e}({},amdclean.core),amdclean.outputimage=function(a,b){"use strict";var c=b,d=[];return c.prototype.saveCanvas=function(a,b,d){d||(d=c.prototype._checkFileExtension(b,d)[1],""===d&&(d="png"));var e;if(a?e=a:this._curElement&&this._curElement.elt&&(e=this._curElement.elt),c.prototype._isSafari()){var f="Hello, Safari user!\n";f+="Now capturing a screenshot...\n",f+="To save this image,\n",f+="go to File --> Save As.\n",alert(f),window.location.href=e.toDataURL()}else{var g;if("undefined"==typeof d)d="png",g="image/png";else switch(d){case"png":g="image/png";break;case"jpeg":g="image/jpeg";break;case"jpg":g="image/jpeg";break;default:g="image/png"}var h="image/octet-stream",i=e.toDataURL(g);i=i.replace(g,h),c.prototype.downloadFile(i,b,d)}},c.prototype.saveFrames=function(a,b,e,f,g){var h=e||3;h=c.prototype.constrain(h,0,15),h=1e3*h;var i=f||15;i=c.prototype.constrain(i,0,22);var j=0,k=c.prototype._makeFrame,l=this._curElement.elt,m=setInterval(function(){k(a+j,b,l),j++},1e3/i);setTimeout(function(){if(clearInterval(m),g)g(d);else for(var a=0;ab?1:-1,j=b,k=Math.min(d,Math.abs(c-b));k>h;){var l=j+i*Math.min(k,g);e.push(f(a,j,l)),k-=Math.abs(l-j),j=l}return e}function f(a,b,c){var d=(c-b)/2,e=a*Math.cos(d),f=a*Math.sin(d),g=e,h=-f,i=.5522847498,j=i*Math.tan(d),k=g+j*f,l=h+j*e,m=k,n=-l,o=d+b,p=Math.cos(o),q=Math.sin(o);return{x1:a*Math.cos(b),y1:a*Math.sin(b),x2:k*p-l*q,y2:k*q+l*p,x3:m*p-n*q,y3:m*q+n*p,x4:a*Math.cos(c),y4:a*Math.sin(c)}}var g=b,c=c,d=d,h=1e-5;return g.prototype.arc=function(a,b,f,g,h,i,j){if(this._doStroke||this._doFill){this._angleMode===d.DEGREES&&(h=this.radians(h),i=this.radians(i));var k=this.drawingContext,l=c.arcModeAdjust(a,b,f,g,this._ellipseMode),m=e(1,h,i),n=l.w/2,o=l.h/2;return k.beginPath(),m.forEach(function(a,b){0===b&&k.moveTo(l.x+a.x1*n,l.y+a.y1*o),k.bezierCurveTo(l.x+a.x2*n,l.y+a.y2*o,l.x+a.x3*n,l.y+a.y3*o,l.x+a.x4*n,l.y+a.y4*o)}),this._doFill&&((j===d.PIE||null==j)&&k.lineTo(l.x,l.y),k.closePath(),k.fill(),this._doStroke&&(j===d.CHORD||j===d.PIE))?(k.stroke(),this):(this._doStroke&&(j===d.OPEN||null==j)&&(k.beginPath(),m.forEach(function(a,b){0===b&&k.moveTo(l.x+a.x1*n,l.y+a.y1*o),k.bezierCurveTo(l.x+a.x2*n,l.y+a.y2*o,l.x+a.x3*n,l.y+a.y3*o,l.x+a.x4*n,l.y+a.y4*o)}),k.stroke()),this)}},g.prototype.ellipse=function(a,b,d,e){if(this._doStroke||this._doFill){d=Math.abs(d),e=Math.abs(e);var f=this.drawingContext,g=c.modeAdjust(a,b,d,e,this._ellipseMode);if(f.beginPath(),d===e)f.arc(g.x+g.w/2,g.y+g.w/2,g.w/2,0,2*Math.PI,!1);else{var h=.5522848,i=g.w/2*h,j=g.h/2*h,k=g.x+g.w,l=g.y+g.h,m=g.x+g.w/2,n=g.y+g.h/2;f.moveTo(g.x,n),f.bezierCurveTo(g.x,n-j,m-i,g.y,m,g.y),f.bezierCurveTo(m+i,g.y,k,n-j,k,n),f.bezierCurveTo(k,n+j,m+i,l,m,l),f.bezierCurveTo(m-i,l,g.x,n+j,g.x,n),f.closePath()}return this._doFill&&f.fill(),this._doStroke&&f.stroke(),this}},g.prototype.line=function(a,b,c,d){if(this._doStroke){var e=this.drawingContext;if("rgba(0,0,0,0)"!==e.strokeStyle)return e.beginPath(),e.moveTo(a,b),e.lineTo(c,d),e.stroke(),this}},g.prototype.point=function(a,b){if(this._doStroke){var c=this.drawingContext,e=c.strokeStyle,f=c.fillStyle;if("rgba(0,0,0,0)"!==e)return a=Math.round(a),b=Math.round(b),c.fillStyle=e,c.lineWidth>1?(c.beginPath(),c.arc(a,b,c.lineWidth/2,0,d.TWO_PI,!1),c.fill()):c.fillRect(a,b,1,1),c.fillStyle=f,this}},g.prototype.quad=function(a,b,c,d,e,f,g,h){if(this._doStroke||this._doFill){var i=this.drawingContext;return i.beginPath(),i.moveTo(a,b),i.lineTo(c,d),i.lineTo(e,f),i.lineTo(g,h),i.closePath(),this._doFill&&i.fill(),this._doStroke&&i.stroke(),this}},g.prototype.rect=function(a,b,d,e,f,g,h,i){if(this._doStroke||this._doFill){var j=c.modeAdjust(a,b,d,e,this._rectMode),k=this.drawingContext;if(this._doStroke&&k.lineWidth%2===1&&k.translate(.5,.5),k.beginPath(),"undefined"==typeof f)k.rect(j.x,j.y,j.w,j.h);else{"undefined"==typeof g&&(g=f),"undefined"==typeof h&&(h=g),"undefined"==typeof i&&(i=h);var l=j.x,m=j.y,n=j.w,o=j.h,p=n/2,q=o/2;2*f>n&&(f=p),2*f>o&&(f=q),2*g>n&&(g=p),2*g>o&&(g=q),2*h>n&&(h=p),2*h>o&&(h=q),2*i>n&&(i=p),2*i>o&&(i=q),k.beginPath(),k.moveTo(l+f,m),k.arcTo(l+n,m,l+n,m+o,g),k.arcTo(l+n,m+o,l,m+o,h),k.arcTo(l,m+o,l,m,i),k.arcTo(l,m,l+n,m,f),k.closePath()}return this._doFill&&k.fill(),this._doStroke&&k.stroke(),this._doStroke&&k.lineWidth%2===1&&k.translate(-.5,-.5),this}},g.prototype.triangle=function(a,b,c,d,e,f){if(this._doStroke||this._doFill){var g=this.drawingContext;return g.beginPath(),g.moveTo(a,b),g.lineTo(c,d),g.lineTo(e,f),g.closePath(),this._doFill&&g.fill(),this._doStroke&&g.stroke(),this}},g}({},amdclean.core,amdclean.canvas,amdclean.constants),amdclean.shapeattributes=function(a,b,c){"use strict";var d=b,c=c;return d.prototype._rectMode=c.CORNER,d.prototype._ellipseMode=c.CENTER,d.prototype.ellipseMode=function(a){return(a===c.CORNER||a===c.CORNERS||a===c.RADIUS||a===c.CENTER)&&(this._ellipseMode=a),this},d.prototype.noSmooth=function(){return this.drawingContext.mozImageSmoothingEnabled=!1,this.drawingContext.webkitImageSmoothingEnabled=!1,this},d.prototype.rectMode=function(a){return(a===c.CORNER||a===c.CORNERS||a===c.RADIUS||a===c.CENTER)&&(this._rectMode=a),this},d.prototype.smooth=function(){return this.drawingContext.mozImageSmoothingEnabled=!0,this.drawingContext.webkitImageSmoothingEnabled=!0,this},d.prototype.strokeCap=function(a){return(a===c.ROUND||a===c.SQUARE||a===c.PROJECT)&&(this.drawingContext.lineCap=a),this},d.prototype.strokeJoin=function(a){return(a===c.ROUND||a===c.BEVEL||a===c.MITER)&&(this.drawingContext.lineJoin=a),this},d.prototype.strokeWeight=function(a){return"undefined"==typeof a||0===a?this.drawingContext.lineWidth=1e-4:this.drawingContext.lineWidth=a,this},d}({},amdclean.core,amdclean.constants),amdclean.shapecurves=function(a,b){"use strict";var c=b,d=20,e=20;return c.prototype._curveTightness=0,c.prototype.bezier=function(a,b,c,d,e,f,g,h){return this._doStroke?(this.beginShape(),this.vertex(a,b),this.bezierVertex(c,d,e,f,g,h),this.endShape(),this.stroke(),this):void 0},c.prototype.bezierDetail=function(a){return d=a,this},c.prototype.bezierPoint=function(a,b,c,d,e){var f=1-e;return Math.pow(f,3)*a+3*Math.pow(f,2)*e*b+3*f*Math.pow(e,2)*c+Math.pow(e,3)*d},c.prototype.bezierTangent=function(a,b,c,d,e){var f=1-e;return 3*d*Math.pow(e,2)-3*c*Math.pow(e,2)+6*c*f*e-6*b*f*e+3*b*Math.pow(f,2)-3*a*Math.pow(f,2)},c.prototype.curve=function(a,b,c,d,e,f,g,h){return this._doStroke?(this.beginShape(),this.curveVertex(a,b),this.curveVertex(c,d),this.curveVertex(e,f),this.curveVertex(g,h),this.endShape(),this.stroke(),this):void 0},c.prototype.curveDetail=function(a){return e=a,this},c.prototype.curveTightness=function(a){this._setProperty("_curveTightness",a)},c.prototype.curvePoint=function(a,b,c,d,e){var f=e*e*e,g=e*e,h=-.5*f+g-.5*e,i=1.5*f-2.5*g+1,j=-1.5*f+2*g+.5*e,k=.5*f-.5*g;return a*h+b*i+c*j+d*k},c.prototype.curveTangent=function(a,b,c,d,e){var f=e*e,g=-3*f/2+2*e-.5,h=9*f/2-5*e,i=-9*f/2+4*e+.5,j=3*f/2-e;return a*g+b*h+c*i+d*j},c}({},amdclean.core),amdclean.shapevertex=function(a,b,c){"use strict";var d=b,c=c,e=null,f=[],g=[],h=!1,i=!1,j=!1,k=!1;return d.prototype._doFillStrokeClose=function(){this._doFill&&this.drawingContext.fill(),this._doStroke&&this.drawingContext.stroke(),this.drawingContext.closePath()},d.prototype.beginContour=function(){return g=[],k=!0,this},d.prototype.beginShape=function(a){return e=a===c.POINTS||a===c.LINES||a===c.TRIANGLES||a===c.TRIANGLE_FAN||a===c.TRIANGLE_STRIP||a===c.QUADS||a===c.QUAD_STRIP?a:null,f=[],g=[],this},d.prototype.bezierVertex=function(a,b,c,d,e,i){if(0===f.length)throw"vertex() must be used once before calling bezierVertex()";h=!0;for(var j=[],l=0;lg;g++)b=f[g],this._doStroke&&this.stroke(b[6]),this.point(b[0],b[1]);else if(e===c.LINES)for(g=0;m>g+1;g+=2)b=f[g],this._doStroke&&this.stroke(f[g+1][6]),this.line(b[0],b[1],f[g+1][0],f[g+1][1]);else if(e===c.TRIANGLES)for(g=0;m>g+2;g+=3)b=f[g],this.drawingContext.beginPath(),this.drawingContext.moveTo(b[0],b[1]),this.drawingContext.lineTo(f[g+1][0],f[g+1][1]),this.drawingContext.lineTo(f[g+2][0],f[g+2][1]),this.drawingContext.lineTo(b[0],b[1]),this._doFill&&(this.fill(f[g+2][5]),this.drawingContext.fill()),this._doStroke&&(this.stroke(f[g+2][6]),this.drawingContext.stroke()),this.drawingContext.closePath();else if(e===c.TRIANGLE_STRIP)for(g=0;m>g+1;g++)b=f[g],this.drawingContext.beginPath(),this.drawingContext.moveTo(f[g+1][0],f[g+1][1]),this.drawingContext.lineTo(b[0],b[1]),this._doStroke&&this.stroke(f[g+1][6]),this._doFill&&this.fill(f[g+1][5]),m>g+2&&(this.drawingContext.lineTo(f[g+2][0],f[g+2][1]),this._doStroke&&this.stroke(f[g+2][6]),this._doFill&&this.fill(f[g+2][5])),this._doFillStrokeClose();else if(e===c.TRIANGLE_FAN){if(m>2)for(this.drawingContext.beginPath(),this.drawingContext.moveTo(f[0][0],f[0][1]),this.drawingContext.lineTo(f[1][0],f[1][1]),this.drawingContext.lineTo(f[2][0],f[2][1]),this._doFill&&this.fill(f[2][5]),this._doStroke&&this.stroke(f[2][6]),this._doFillStrokeClose(),g=3;m>g;g++)b=f[g],this.drawingContext.beginPath(),this.drawingContext.moveTo(f[0][0],f[0][1]),this.drawingContext.lineTo(f[g-1][0],f[g-1][1]),this.drawingContext.lineTo(b[0],b[1]),this._doFill&&this.fill(b[5]),this._doStroke&&this.stroke(b[6]),this._doFillStrokeClose()}else if(e===c.QUADS)for(g=0;m>g+3;g+=4){for(b=f[g],this.drawingContext.beginPath(),this.drawingContext.moveTo(b[0],b[1]),l=1;4>l;l++)this.drawingContext.lineTo(f[g+l][0],f[g+l][1]);this.drawingContext.lineTo(b[0],b[1]),this._doFill&&this.fill(f[g+3][5]),this._doStroke&&this.stroke(f[g+3][6]),this._doFillStrokeClose()}else if(e===c.QUAD_STRIP){if(m>3)for(g=0;m>g+1;g+=2)b=f[g],this.drawingContext.beginPath(),m>g+3?(this.drawingContext.moveTo(f[g+2][0],f[g+2][1]),this.drawingContext.lineTo(b[0],b[1]),this.drawingContext.lineTo(f[g+1][0],f[g+1][1]),this.drawingContext.lineTo(f[g+3][0],f[g+3][1]),this._doFill&&this.fill(f[g+3][5]),this._doStroke&&this.stroke(f[g+3][6])):(this.drawingContext.moveTo(b[0],b[1]),this.drawingContext.lineTo(f[g+1][0],f[g+1][1])),this._doFillStrokeClose()}else{for(this.drawingContext.beginPath(),this.drawingContext.moveTo(f[0][0],f[0][1]),g=1;m>g;g++)b=f[g],b.isVert&&(b.moveTo?this.drawingContext.moveTo(b[0],b[1]):this.drawingContext.lineTo(b[0],b[1]));this._doFillStrokeClose()}else{for(this.drawingContext.beginPath(),g=0;m>g;g++)f[g].isVert?f[g].moveTo?this.drawingContext.moveTo([0],f[g][1]):this.drawingContext.lineTo(f[g][0],f[g][1]):this.drawingContext.quadraticCurveTo(f[g][0],f[g][1],f[g][2],f[g][3]);this._doFillStrokeClose()}else{for(this.drawingContext.beginPath(),g=0;m>g;g++)f[g].isVert?f[g].moveTo?this.drawingContext.moveTo(f[g][0],f[g][1]):this.drawingContext.lineTo(f[g][0],f[g][1]):this.drawingContext.bezierCurveTo(f[g][0],f[g][1],f[g][2],f[g][3],f[g][4],f[g][5]);this._doFillStrokeClose()}else if(m>3){var n=[],o=1-this._curveTightness;for(this.drawingContext.beginPath(),this.drawingContext.moveTo(f[1][0],f[1][1]),g=1;m>g+2;g++)b=f[g],n[0]=[b[0],b[1]],n[1]=[b[0]+(o*f[g+1][0]-o*f[g-1][0])/6,b[1]+(o*f[g+1][1]-o*f[g-1][1])/6],n[2]=[f[g+1][0]+(o*f[g][0]-o*f[g+2][0])/6,f[g+1][1]+(o*f[g][1]-o*f[g+2][1])/6],n[3]=[f[g+1][0],f[g+1][1]],this.drawingContext.bezierCurveTo(n[1][0],n[1][1],n[2][0],n[2][1],n[3][0],n[3][1]);d&&this.drawingContext.lineTo(f[g+1][0],f[g+1][1]),this._doFillStrokeClose()}return i=!1,h=!1,j=!1,k=!1,d&&f.pop(),this},d.prototype.quadraticVertex=function(a,b,d,e){if(this._contourInited){var h={};return h.x=a,h.y=b,h.x3=d,h.y3=e,h.type=c.QUADRATIC,this._contourVertices.push(h),this}if(!(f.length>0))throw"vertex() must be used once before calling quadraticVertex()";j=!0;for(var i=[],l=0;ld?(this._doFill&&this.drawingContext.fillText(h,b,c),this._doStroke&&this.drawingContext.strokeText(h,b,c),h=i[j]+" ",c+=this._textLeading):h=k}this._doFill&&this.drawingContext.fillText(h,b,c),this._doStroke&&this.drawingContext.strokeText(h,b,c),c+=this._textLeading}},c.prototype.textFont=function(a){this._setProperty("_textFont",a),this._applyTextProperties()},c}({},amdclean.core),amdclean.src_app=function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q){"use strict";var R=b,S=function(){window.PHANTOMJS||window.mocha||(window.setup&&"function"==typeof window.setup||window.draw&&"function"==typeof window.draw)&&new R};return"complete"===document.readyState?S():window.addEventListener("load",S,!1),R}({},amdclean.core,amdclean.p5Color,amdclean.p5Element,amdclean.p5Graphics,amdclean.p5Image,amdclean.p5File,amdclean.p5Vector,amdclean.p5TableRow,amdclean.p5Table,amdclean.colorcreating_reading,amdclean.colorsetting,amdclean.constants,amdclean.dataconversion,amdclean.dataarray_functions,amdclean.datastring_functions,amdclean.environment,amdclean.imageimage,amdclean.imageloading_displaying,amdclean.imagepixels,amdclean.inputfiles,amdclean.inputkeyboard,amdclean.inputacceleration,amdclean.inputmouse,amdclean.inputtime_date,amdclean.inputtouch,amdclean.mathmath,amdclean.mathcalculation,amdclean.mathrandom,amdclean.mathnoise,amdclean.mathtrigonometry,amdclean.outputfiles,amdclean.outputimage,amdclean.outputtext_area,amdclean.renderingrendering,amdclean.shape2d_primitives,amdclean.shapeattributes,amdclean.shapecurves,amdclean.shapevertex,amdclean.structure,amdclean.transform,amdclean.typographyattributes,amdclean.typographyloading_displaying),amdclean.src_app}); \ No newline at end of file diff --git a/src/color/creating_reading.js b/src/color/creating_reading.js index 59f85fac5b..791ae73f0d 100644 --- a/src/color/creating_reading.js +++ b/src/color/creating_reading.js @@ -257,7 +257,8 @@ define(function (require) { }; /** - * Calculates a color or colors between two color at a specific increment. + * Calculates a color or colors between two color at a specific increment, + * using gamma correction to blend colors in the linear RGB space. * The amt parameter is the amount to interpolate between the two values * where 0.0 equal to the first point, 0.1 is very near the first point, * 0.5 is halfway in between, etc. An amount below 0 will be treated as 0. @@ -265,6 +266,12 @@ define(function (require) { * the behavior of lerp(), but necessary because otherwise numbers outside * the range will produce strange and unexpected colors. * + * The regular RGB color representation stores the square root of the + * displayed color, not the value itself. Your monitor behaves as if it + * squares the color values before displaying it. lerpColor first transforms + * colors into the linear color space before blending, to correctly mix the + * colors as two rays of light. + * * @method lerpColor * @param {Array/Number} c1 interpolate from this color * @param {Array/Number} c2 interpolate to this color @@ -291,20 +298,24 @@ define(function (require) { * */ p5.prototype.lerpColor = function (c1, c2, amt) { + amt = Math.max(Math.min(amt, 1), 0); if (c1 instanceof Array) { var c = []; for (var i = 0; i < c1.length; i++) { - c.push(p5.prototype.lerp(c1[i], c2[i], amt)); + c.push(Math.sqrt(p5.prototype.lerp(c1[i]*c1[i], c2[i]*c2[i], amt))); } return c; } else if (c1 instanceof p5.Color) { var pc = []; for (var j = 0; j < 4; j++) { - pc.push(p5.prototype.lerp(c1.rgba[j], c2.rgba[j], amt)); + pc.push(Math.sqrt(p5.prototype.lerp( + c1.rgba[j]*c1.rgba[j], + c2.rgba[j]*c2.rgba[j], + amt))); } return new p5.Color(this, pc); } else { - return p5.prototype.lerp(c1, c2, amt); + return Math.sqrt(p5.prototype.lerp(c1*c1, c2*c2, amt)); } };