Skip to content

Instantly share code, notes, and snippets.

@Lulkafe
Created December 12, 2014 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lulkafe/8d088685f18e1b6b4645 to your computer and use it in GitHub Desktop.
Save Lulkafe/8d088685f18e1b6b4645 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<script src="p5.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<title></title>
<style>
#slider {
width: 400px;
margin-top: 40px;
margin-left: 100px;
}
</style>
</head>
<body>
<div id="slider"></div>
<script>
var TABLE,
VALUES,
TITLES;
function preload(){
// Assume that the number of attributes is two
TABLE = loadTable("scatterPlot.csv", "header");
}
function setup(){
background(255,255,255);
createCanvas(1000,1000);
$(function() {
$("#slider").slider({
value: 100,
slide: function(event, ui){
$("#edit-varprice").val(ui.value + ".00");
}
});
});
var titles = [],
row_num = TABLE.getRowCount() - 1,
flts = [],
rows = TABLE.getRows().slice(1);
console.log(row_num);
console.log(rows.length);
var tmp = TABLE.getRows().slice(0, 1)[0];
for (var i = 0; ; i++){
var val = tmp.get(i);
if (val === undefined)
break;
else
titles[i] = val;
}
for (var i = 0; i < titles.length; i++){
flts[i] = [];
};
for (var i = 0; i < rows.length; i++) {
for (var j = 0; j < titles.length; j++) {
flts[j][i] = rows[i].getNum(j);
}
}
console.log(rows.length);
console.log(titles.length);
console.log("Done");
for (var i = 0; i < rows.length; i++) {
for (var j = 0; j < titles.length; j++) {
console.log(flts[j][i]);
}
}
VALUES = flts;
TITLES = titles;
}
function draw(){
background(255,255,255);
//Values are 0 - 100
var sliderVal = $("#slider").slider("option","value") / 100;
showScatterPlot(VALUES[0], VALUES[1], TITLES, sliderVal);
}
function showScatterPlot(xValues, yValues, titles, filterVal) {
//Assume that the number of xValues and yValues is the same
var config = {
x: 100,
y: 500,
w: 400,
h: 400
};
var scale = config.w,
recSize = config.w / 30,
initX = config.x,
initY = config.y,
tickLength = 10.0,
fontSize = config.w / 20,
ttPadX = 10.0,
ttPadY = 50.0,
ttWidth = 100.0,
ttHeight = 40.0,
ticks = 3;
line(initX, initY, initX + config.w, initY);
line(initX, initY, initX, initY - config.h);
textAlign(CENTER,CENTER);
fill(0, 0, 0);
textSize(16);
text(titles[0], initX + config.w / 2, initY - config.h - 16);
textAlign(LEFT, CENTER);
text(titles[1], initX + config.w + 16, initY - config.h / 2);
fill(0, 0, 0);
textSize(fontSize);
for (var i = 0; i <= ticks; i++) {
var newX = initX + (scale / ticks) * i,
newY = initY - (scale / ticks) * i,
tmpX = max(xValues) / ticks * i,
tmpY = max(yValues) / ticks * i;
var textX = Math.round(tmpX).toString(),
textY = Math.round(tmpY).toString();
line(newX, initY, newX, initY + tickLength);
textAlign(CENTER);
text(textX, newX, initY + tickLength * 1.5 + fontSize);
textAlign(RIGHT);
line(initX, newY, initX - tickLength, newY);
text(textY, initX - tickLength * 2, newY);
}
textSize(11);
for (var i = 0; i < xValues.length; i++) {
var normXVal = norm(xValues[i], 0, max(xValues)),
normYVal = norm(yValues[i], 0, max(yValues)),
posX = initX + normXVal * scale - recSize,
posY = initY - normYVal * scale;
var txt = "x: " + xValues[i].toString();
var txt2 = "y: " + yValues[i].toString();
if (filterVal < normXVal && filterVal < normYVal)
continue;
var curX = mouseX,
curY = mouseY;
if (posX <= curX && curX <= posX + recSize &&
posY <= curY && curY <= posY + recSize) {
fill(180, 220, 200, 255);
rect(posX + ttPadX - 7, posY - ttPadY - ttHeight / 2.5, ttWidth, ttHeight);
fill(0, 0, 0);
textAlign(LEFT);
text(txt, posX + ttPadX, posY - ttPadY);
text(txt2, posX + ttPadX, posY - ttPadY + fontSize / 1.5);
fill(200, 0, 0);
rect(posX, posY, recSize, recSize);
} else {
fill(0, 0, 0);
rect(posX, posY, recSize, recSize);
}
}
}
</script>
</body>
</html>
/*! p5.min.js v0.3.13 December 04, 2014 */
var shim=function(){window.requestDraw=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}()}({}),constants=function(){var t=Math.PI;return{ARROW:"default",CROSS:"crosshair",HAND:"pointer",MOVE:"move",TEXT:"text",WAIT:"wait",HALF_PI:t/2,PI:t,QUARTER_PI:t/4,TAU:2*t,TWO_PI:2*t,DEGREES:"degrees",RADIANS:"radians",CORNER:"corner",CORNERS:"corners",RADIUS:"radius",RIGHT:"right",LEFT:"left",CENTER:"center",POINTS:"points",LINES:"lines",TRIANGLES:"triangles",TRIANGLE_FAN:"triangles_fan",TRIANGLE_STRIP:"triangles_strip",QUADS:"quads",QUAD_STRIP:"quad_strip",CLOSE:"close",OPEN:"open",CHORD:"chord",PIE:"pie",PROJECT:"square",SQUARE:"butt",ROUND:"round",BEVEL:"bevel",MITER:"miter",RGB:"rgb",HSB:"hsb",AUTO:"auto",ALT:18,BACKSPACE:8,CONTROL:17,DELETE:46,DOWN_ARROW:40,ENTER:13,ESCAPE:27,LEFT_ARROW:37,OPTION:18,RETURN:13,RIGHT_ARROW:39,SHIFT:16,TAB:9,UP_ARROW:38,BLEND:"normal",ADD:"lighter",DARKEST:"darken",LIGHTEST:"lighten",DIFFERENCE:"difference",EXCLUSION:"exclusion",MULTIPLY:"multiply",SCREEN:"screen",REPLACE:"source-over",OVERLAY:"overlay",HARD_LIGHT:"hard-light",SOFT_LIGHT:"soft-light",DODGE:"color-dodge",BURN:"color-burn",NORMAL:"normal",ITALIC:"italic",BOLD:"bold",LINEAR:"linear",QUADRATIC:"quadratic",BEZIER:"bezier",CURVE:"curve"}}({}),core=function(t,e,r){"use strict";var r=r,o=function(t,e){this._setupDone=!1,this._pixelDensity=window.devicePixelRatio||1,this._startTime=(new Date).getTime(),this._userNode=e,this._curElement=null,this._elements=[],this._preloadCount=0,this._updateInterval=0,this._isGlobal=!1,this._loop=!0,this._styles=[],this._defaultCanvasSize={width:100,height:100},this._events={mousemove:null,mousedown:null,mouseup:null,click:null,mousewheel:null,mouseover:null,mouseout:null,keydown:null,keyup:null,keypress:null,touchstart:null,touchmove:null,touchend:null,resize:null},this._loadingScreenId="p5_loading",this._start=function(){if(this._userNode&&"string"==typeof this._userNode&&(this._userNode=document.getElementById(this._userNode)),this._loadingScreen=document.getElementById(this._loadingScreenId),!this._loadingScreen){this._loadingScreen=document.createElement("loadingDiv"),this._loadingScreen.innerHTML="loading...",this._loadingScreen.style.position="absolute";var t=this._userNode||document.body;t.appendChild(this._loadingScreen)}this.createCanvas(this._defaultCanvasSize.width,this._defaultCanvasSize.height,!0);var e=this.preload||window.preload,r=this._isGlobal?window:this;e?(this._preloadMethods.forEach(function(t){r[t]=function(e){return r._preload(t,e)}}),e(),0===this._preloadCount&&(this._setup(),this._runFrames(),this._draw())):(this._setup(),this._runFrames(),this._draw())}.bind(this),this._preload=function(t,e){var r=this._isGlobal?window:this;return r._setProperty("_preloadCount",r._preloadCount+1),o.prototype[t].call(r,e,function(){r._setProperty("_preloadCount",r._preloadCount-1),0===r._preloadCount&&(r._setup(),r._runFrames(),r._draw())})}.bind(this),this._setup=function(){var t=this._isGlobal?window:this;"function"==typeof t.preload&&this._preloadMethods.forEach(function(e){t[e]=o.prototype[e]}),"function"==typeof t.setup&&t.setup(),this.canvas.style.visibility="",this.canvas.className=this.canvas.className.replace("p5_hidden",""),this._setupDone=!0,this._loadingScreen.parentNode.removeChild(this._loadingScreen)}.bind(this),this._draw=function(){var t=this.setup||window.setup,e=(new Date).getTime();this._frameRate=1e3/(e-this._lastFrameTime),this._lastFrameTime=e;var r=this.draw||window.draw;this._loop&&(this._drawInterval&&clearInterval(this._drawInterval),this._drawInterval=setTimeout(function(){window.requestDraw(this._draw.bind(this))}.bind(this),1e3/this._targetFrameRate)),"function"==typeof r&&(this.push(),"undefined"==typeof t&&this.scale(this._pixelDensity,this._pixelDensity),this._registeredMethods.pre.forEach(function(t){t.call(this)}),r(),this._registeredMethods.post.forEach(function(t){t.call(this)}),this.pop()),this._updatePMouseCoords(),this._updatePTouchCoords()}.bind(this),this._runFrames=function(){this._updateInterval&&clearInterval(this._updateInterval),this._updateInterval=setInterval(function(){this._setProperty("frameCount",this.frameCount+1)}.bind(this),1e3/this._targetFrameRate)}.bind(this),this._setProperty=function(t,e){this[t]=e,this._isGlobal&&(window[t]=e)}.bind(this),this.remove=function(){if(this._curElement){this._loop=!1,this._drawInterval&&clearTimeout(this._drawInterval),this._updateInterval&&clearTimeout(this._updateInterval);for(var t in this._events)window.removeEventListener(t,this._events[t]);for(var e=0;e<this._elements.length;e++){var r=this._elements[e];r.elt.parentNode&&r.elt.parentNode.removeChild(r.elt);for(var n in r._events)r.elt.removeEventListener(n,r._events[n])}var i=this;if(this._registeredMethods.remove.forEach(function(t){"undefined"!=typeof t&&t.call(i)}),this._isGlobal){for(var s in o.prototype)try{delete window[s]}catch(a){window[s]=void 0}for(var h in this)if(this.hasOwnProperty(h))try{delete window[h]}catch(a){window[h]=void 0}}}}.bind(this);for(var n in r)o.prototype[n]=r[n];if(t)t(this);else{this._isGlobal=!0;for(var i in o.prototype)if("function"==typeof o.prototype[i]){var s=i.substring(2);this._events.hasOwnProperty(s)||(window[i]=o.prototype[i].bind(this))}else window[i]=o.prototype[i];for(var a in this)this.hasOwnProperty(a)&&(window[a]=this[a])}for(var h in this._events){var p=this["on"+h];if(p){var u=p.bind(this);window.addEventListener(h,u),this._events[h]=u}}var l=this;window.addEventListener("focus",function(){l._setProperty("focused",!0)}),window.addEventListener("blur",function(){l._setProperty("focused",!1)}),"complete"===document.readyState?this._start():window.addEventListener("load",this._start.bind(this),!1)};return o.prototype._preloadMethods=["loadJSON","loadImage","loadStrings","loadXML","loadShape","loadTable"],o.prototype._registeredMethods={pre:[],post:[],remove:[]},o.prototype.registerPreloadMethod=function(t){o.prototype._preloadMethods.push(t)}.bind(this),o.prototype.registerMethod=function(t,e){o.prototype._registeredMethods.hasOwnProperty(t)||(o.prototype._registeredMethods[t]=[]),o.prototype._registeredMethods[t].push(e)}.bind(this),o}({},shim,constants),p5Color=function(t,e,r){var o=e,r=r;return o.Color=function(t,e){if(e instanceof Array)this.rgba=e;else{var n=o.Color._getFormattedColor.apply(t,e);t._colorMode===r.HSB?(this.hsba=n,this.rgba=o.Color._getRGB(n)):this.rgba=n}var i=o.Color._normalizeColorArray.call(t,this.rgba);return this.colorString=o.Color._getColorString(i),this},o.Color._getFormattedColor=function(){if(arguments[0]instanceof Array)return o.Color.getNormalizedColor.apply(this,arguments[0]);var t,e,n,i;return arguments.length>=3?(t=arguments[0],e=arguments[1],n=arguments[2],i="number"==typeof arguments[3]?arguments[3]:255):(this._colorMode===r.RGB?t=e=n=arguments[0]:(t=n=arguments[0],e=0),i="number"==typeof arguments[1]?arguments[1]:255),[t,e,n,i]},o.Color._normalizeColorArray=function(t){var e=this._colorMode===r.RGB,o=e?this._maxRGB:this._maxHSB;return t[0]*=255/o[0],t[1]*=255/o[1],t[2]*=255/o[2],t[3]*=255/o[3],t},o.Color._getRGB=function(t){var e=t[0],r=t[1],o=t[2];e/=255,r/=255,o/=255;var n=[];if(0===r)n=[Math.round(255*o),Math.round(255*o),Math.round(255*o),t[3]];else{var i=6*e;6===i&&(i=0);var s,a,h,p=Math.floor(i),u=o*(1-r),l=o*(1-r*(i-p)),c=o*(1-r*(1-(i-p)));0===p?(s=o,a=c,h=u):1===p?(s=l,a=o,h=u):2===p?(s=u,a=o,h=c):3===p?(s=u,a=l,h=o):4===p?(s=c,a=u,h=o):(s=o,a=u,h=l),n=[Math.round(255*s),Math.round(255*a),Math.round(255*h),t[3]]}return n},o.Color._getHSB=function(t){var e,r,o=t[0]/255,n=t[1]/255,i=t[2]/255,s=Math.min(o,n,i),a=Math.max(o,n,i),h=a-s,p=a;if(0===h)e=0,r=0;else{r=h/a;var u=((a-o)/6+h/2)/h,l=((a-n)/6+h/2)/h,c=((a-i)/6+h/2)/h;o===a?e=c-l:n===a?e=1/3+u-c:i===a&&(e=2/3+l-u),0>e&&(e+=1),e>1&&(e-=1)}return[Math.round(255*e),Math.round(255*r),Math.round(255*p),t[3]]},o.Color._getColorString=function(t){for(var e=0;3>e;e++)t[e]=Math.floor(t[e]);var r="undefined"!=typeof t[3]?t[3]/255:1;return"rgba("+t[0]+","+t[1]+","+t[2]+","+r+")"},o.Color._getCanvasColor=function(){if(arguments[0]instanceof o.Color){if(1===arguments.length)return arguments[0].colorString;var t=arguments[0].rgba;return t[3]=arguments[1],t=o.Color._normalizeColorArray.call(this,t),o.Color._getColorString(t)}if(arguments[0]instanceof Array){if(1===arguments.length)return o.Color._getColorString(arguments[0]);var e=this._colorMode===r.RGB,n=e?this._maxRGB[3]:this._maxHSB[3];return arguments[0][3]=255*arguments[1]/n,o.Color._getColorString(arguments[0])}var i=o.Color._getFormattedColor.apply(this,arguments);return i=o.Color._normalizeColorArray.call(this,i),this._colorMode===r.HSB&&(i=o.Color._getRGB(i)),o.Color._getColorString(i)},o.Color}({},core,constants),p5Element=function(t,e){function r(t,e,r){var o=e.bind(r);r.elt.addEventListener(t,o,!1),r._events[t]=o}var o=e;return o.Element=function(t,e){this.elt=t,this._pInst=e,this._events={},this.width=this.elt.offsetWidth,this.height=this.elt.offsetHeight},o.Element.prototype.parent=function(t){return"string"==typeof t?t=document.getElementById(t):t instanceof o.Element&&(t=t.elt),t.appendChild(this.elt),this},o.Element.prototype.id=function(t){return this.elt.id=t,this},o.Element.prototype.class=function(t){return this.elt.className+=" "+t,this},o.Element.prototype.mousePressed=function(t){return r("mousedown",t,this),this},o.Element.prototype.mouseWheel=function(t){return r("mousewheel",t,this),this},o.Element.prototype.mouseReleased=function(t){return r("mouseup",t,this),this},o.Element.prototype.mouseClicked=function(t){return r("click",t,this),this},o.Element.prototype.mouseMoved=function(t){return r("mousemove",t,this),this},o.Element.prototype.mouseOver=function(t){return r("mouseover",t,this),this},o.Element.prototype.mouseOut=function(t){return r("mouseout",t,this),this},o.Element.prototype._setProperty=function(t,e){this[t]=e},o.Element}({},core),p5Graphics=function(t,e,r){var o=e,r=r;return o.Graphics=function(t,e,r){o.Element.call(this,t,e),this.canvas=t,this.drawingContext=this.canvas.getContext("2d"),this._pInst=e,r?(this._isMainCanvas=!0,this._pInst._setProperty("_curElement",this),this._pInst._setProperty("canvas",this.canvas),this._pInst._setProperty("drawingContext",this.drawingContext),this._pInst._setProperty("width",this.width),this._pInst._setProperty("height",this.height)):(this.canvas.style.display="none",this._styles=[])},o.Graphics.prototype=Object.create(o.Element.prototype),o.Graphics.prototype._applyDefaults=function(){this.drawingContext.fillStyle="#FFFFFF",this.drawingContext.strokeStyle="#000000",this.drawingContext.lineCap=r.ROUND,this.drawingContext.font="normal 12px sans-serif"},o.Graphics.prototype.resize=function(t,e){this.width=t,this.height=e,this.elt.width=t*this._pInst._pixelDensity,this.elt.height=e*this._pInst._pixelDensity,this.elt.style.width=t+"px",this.elt.style.height=e+"px",this._isMainCanvas&&(this._pInst._setProperty("width",this.width),this._pInst._setProperty("height",this.height)),this.drawingContext.scale(this._pInst._pixelDensity,this._pInst._pixelDensity)},o.Graphics}({},core,constants),filters=function(){"use strict";function t(t){var e=3.5*t|0;if(e=1>e?1:248>e?e:248,o!==e){o=e,n=1+o<<1,i=new Int32Array(n),s=new Array(n);for(var r=0;n>r;r++)s[r]=new Int32Array(256);for(var a,h,p,u,l=1,c=e-1;e>l;l++){i[e+l]=i[c]=h=c*c,p=s[e+l],u=s[c--];for(var d=0;256>d;d++)p[d]=u[d]=h*d}a=i[e]=e*e,p=s[e];for(var f=0;256>f;f++)p[f]=a*f}}function e(e,a){for(var h=r._toPixels(e),p=e.width,u=e.height,l=p*u,c=new Int32Array(l),d=0;l>d;d++)c[d]=r._getARGB(h,d);var f,g,y,m,w,v,_,x,C,b,S=new Int32Array(l),R=new Int32Array(l),T=new Int32Array(l),E=new Int32Array(l),M=0;t(a);var P,A,I,k;for(A=0;u>A;A++){for(P=0;p>P;P++){if(m=y=g=w=f=0,v=P-o,0>v)b=-v,v=0;else{if(v>=p)break;b=0}for(I=b;n>I&&!(v>=p);I++){var D=c[v+M];k=s[I],w+=k[(-16777216&D)>>>24],g+=k[(16711680&D)>>16],y+=k[(65280&D)>>8],m+=k[255&D],f+=i[I],v++}_=M+P,S[_]=w/f,R[_]=g/f,T[_]=y/f,E[_]=m/f}M+=p}for(M=0,x=-o,C=x*p,A=0;u>A;A++){for(P=0;p>P;P++){if(m=y=g=w=f=0,0>x)b=_=-x,v=P;else{if(x>=u)break;b=0,_=x,v=P+C}for(I=b;n>I&&!(_>=u);I++)k=s[I],w+=k[S[v]],g+=k[R[v]],y+=k[T[v]],m+=k[E[v]],f+=i[I],_++,v+=p;c[P+M]=w/f<<24|g/f<<16|y/f<<8|m/f}M+=p,C+=p,x++}r._setPixels(h,c)}var r={};r._toPixels=function(t){return t instanceof ImageData?t.data:t.getContext("2d").getImageData(0,0,t.width,t.height).data},r._getARGB=function(t,e){var r=4*e;return t[r+3]<<24&4278190080|t[r]<<16&16711680|t[r+1]<<8&65280|255&t[r+2]},r._setPixels=function(t,e){for(var r=0,o=0,n=t.length;n>o;o++)r=4*o,t[r+0]=(16711680&e[o])>>>16,t[r+1]=(65280&e[o])>>>8,t[r+2]=255&e[o],t[r+3]=(4278190080&e[o])>>>24},r._toImageData=function(t){return t instanceof ImageData?t:t.getContext("2d").getImageData(0,0,t.width,t.height)},r._createImageData=function(t,e){return r._tmpCanvas=document.createElement("canvas"),r._tmpCtx=r._tmpCanvas.getContext("2d"),this._tmpCtx.createImageData(t,e)},r.apply=function(t,e,r){var o=t.getContext("2d"),n=o.getImageData(0,0,t.width,t.height),i=e(n,r);i instanceof ImageData?o.putImageData(i,0,0,0,0,t.width,t.height):o.putImageData(n,0,0,0,0,t.width,t.height)},r.threshold=function(t,e){var o=r._toPixels(t);void 0===e&&(e=.5);for(var n=Math.floor(255*e),i=0;i<o.length;i+=4){var s,a=o[i],h=o[i+1],p=o[i+2],u=.2126*a+.7152*h+.0722*p;s=u>=n?255:0,o[i]=o[i+1]=o[i+2]=s}},r.gray=function(t){for(var e=r._toPixels(t),o=0;o<e.length;o+=4){var n=e[o],i=e[o+1],s=e[o+2],a=.2126*n+.7152*i+.0722*s;e[o]=e[o+1]=e[o+2]=a}},r.opaque=function(t){for(var e=r._toPixels(t),o=0;o<e.length;o+=4)e[o+3]=255;return e},r.invert=function(t){for(var e=r._toPixels(t),o=0;o<e.length;o+=4)e[o]=255-e[o],e[o+1]=255-e[o+1],e[o+2]=255-e[o+2]},r.posterize=function(t,e){var o=r._toPixels(t);if(2>e||e>255)throw new Error("Level must be greater than 2 and less than 255 for posterize");for(var n=e-1,i=0;i<o.length;i+=4){var s=o[i],a=o[i+1],h=o[i+2];o[i]=255*(s*e>>8)/n,o[i+1]=255*(a*e>>8)/n,o[i+2]=255*(h*e>>8)/n}},r.dilate=function(t){for(var e,o,n,i,s,a,h,p,u,l,c,d,f,g,y,m,w,v=r._toPixels(t),_=0,x=v.length?v.length/4:0,C=new Int32Array(x);x>_;)for(e=_,o=_+t.width;o>_;)n=i=r._getARGB(v,_),h=_-1,a=_+1,p=_-t.width,u=_+t.width,e>h&&(h=_),a>=o&&(a=_),0>p&&(p=0),u>=x&&(u=_),d=r._getARGB(v,p),c=r._getARGB(v,h),f=r._getARGB(v,u),l=r._getARGB(v,a),s=77*(n>>16&255)+151*(n>>8&255)+28*(255&n),y=77*(c>>16&255)+151*(c>>8&255)+28*(255&c),g=77*(l>>16&255)+151*(l>>8&255)+28*(255&l),m=77*(d>>16&255)+151*(d>>8&255)+28*(255&d),w=77*(f>>16&255)+151*(f>>8&255)+28*(255&f),y>s&&(i=c,s=y),g>s&&(i=l,s=g),m>s&&(i=d,s=m),w>s&&(i=f,s=w),C[_++]=i;r._setPixels(v,C)},r.erode=function(t){for(var e,o,n,i,s,a,h,p,u,l,c,d,f,g,y,m,w,v=r._toPixels(t),_=0,x=v.length?v.length/4:0,C=new Int32Array(x);x>_;)for(e=_,o=_+t.width;o>_;)n=i=r._getARGB(v,_),h=_-1,a=_+1,p=_-t.width,u=_+t.width,e>h&&(h=_),a>=o&&(a=_),0>p&&(p=0),u>=x&&(u=_),d=r._getARGB(v,p),c=r._getARGB(v,h),f=r._getARGB(v,u),l=r._getARGB(v,a),s=77*(n>>16&255)+151*(n>>8&255)+28*(255&n),y=77*(c>>16&255)+151*(c>>8&255)+28*(255&c),g=77*(l>>16&255)+151*(l>>8&255)+28*(255&l),m=77*(d>>16&255)+151*(d>>8&255)+28*(255&d),w=77*(f>>16&255)+151*(f>>8&255)+28*(255&f),s>y&&(i=c,s=y),s>g&&(i=l,s=g),s>m&&(i=d,s=m),s>w&&(i=f,s=w),C[_++]=i;r._setPixels(v,C)};var o,n,i,s;return r.blur=function(t,r){e(t,r)},r}({}),p5Image=function(t,e,r){"use strict";var o=e,n=r;return o.Image=function(t,e){this.width=t,this.height=e,this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.drawingContext=this.canvas.getContext("2d"),this.pixels=[]},o.Image.prototype._setProperty=function(t,e){this[t]=e},o.Image.prototype.loadPixels=function(){o.prototype.loadPixels.call(this)},o.Image.prototype.updatePixels=function(t,e,r,n){o.prototype.updatePixels.call(this,t,e,r,n)},o.Image.prototype.get=function(t,e,r,n){return o.prototype.get.call(this,t,e,r,n)},o.Image.prototype.set=function(t,e,r){o.prototype.set.call(this,t,e,r)},o.Image.prototype.resize=function(t,e){t=t||this.canvas.width,e=t||this.canvas.height;var r=document.createElement("canvas");r.width=t,r.height=e,r.getContext("2d").drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height,0,0,r.width,r.width),this.canvas.width=this.width=t,this.canvas.height=this.height=e,this.drawingContext.drawImage(r,0,0,t,e,0,0,t,e),this.pixels.length>0&&this.loadPixels()},o.Image.prototype.copy=function(){o.prototype.copy.apply(this,arguments)},o.Image.prototype.mask=function(t){void 0===t&&(t=this);var e=this.drawingContext.globalCompositeOperation,r=1;t instanceof o.Graphics&&(r=t._pInst._pixelDensity);var n=[t,0,0,r*t.width,r*t.height,0,0,this.width,this.height];this.drawingContext.globalCompositeOperation="destination-out",this.copy.apply(this,n),this.drawingContext.globalCompositeOperation=e},o.Image.prototype.filter=function(t,e){n.apply(this.canvas,n[t.toLowerCase()],e)},o.Image.prototype.blend=function(){o.prototype.blend.apply(this,arguments)},o.Image.prototype.save=function(t,e){var r;if(e)switch(e.toLowerCase()){case"png":r="image/png";break;case"jpeg":r="image/jpeg";break;case"jpg":r="image/jpeg";break;default:r="image/png"}else e="png",r="image/png";var n="image/octet-stream",i=this.canvas.toDataURL(r);i=i.replace(r,n),o.prototype.downloadFile(i,t,e)},o.Image}({},core,filters),polargeometry=function(){return{degreesToRadians:function(t){return 2*Math.PI*t/360},radiansToDegrees:function(t){return 360*t/(2*Math.PI)}}}({}),p5Vector=function(t,e,r,o){"use strict";var n=e,i=r,o=o;return n.Vector=function(){var t,e,r;arguments[0]instanceof n?(this.p5=arguments[0],t=arguments[1][0]||0,e=arguments[1][1]||0,r=arguments[1][2]||0):(t=arguments[0]||0,e=arguments[1]||0,r=arguments[2]||0),this.x=t,this.y=e,this.z=r},n.Vector.prototype.set=function(t,e,r){return t instanceof n.Vector?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this):t instanceof Array?(this.x=t[0]||0,this.y=t[1]||0,this.z=t[2]||0,this):(this.x=t||0,this.y=e||0,this.z=r||0,this)},n.Vector.prototype.get=function(){return this.p5?new n.Vector(this.p5,[this.x,this.y,this.z]):new n.Vector(this.x,this.y,this.z)},n.Vector.prototype.add=function(t,e,r){return t instanceof n.Vector?(this.x+=t.x||0,this.y+=t.y||0,this.z+=t.z||0,this):t instanceof Array?(this.x+=t[0]||0,this.y+=t[1]||0,this.z+=t[2]||0,this):(this.x+=t||0,this.y+=e||0,this.z+=r||0,this)},n.Vector.prototype.sub=function(t,e,r){return t instanceof n.Vector?(this.x-=t.x||0,this.y-=t.y||0,this.z-=t.z||0,this):t instanceof Array?(this.x-=t[0]||0,this.y-=t[1]||0,this.z-=t[2]||0,this):(this.x-=t||0,this.y-=e||0,this.z-=r||0,this)},n.Vector.prototype.mult=function(t){return this.x*=t||0,this.y*=t||0,this.z*=t||0,this},n.Vector.prototype.div=function(t){return this.x/=t,this.y/=t,this.z/=t,this},n.Vector.prototype.mag=function(){return Math.sqrt(this.magSq())},n.Vector.prototype.magSq=function(){var t=this.x,e=this.y,r=this.z;return t*t+e*e+r*r},n.Vector.prototype.dot=function(t,e,r){return t instanceof n.Vector?this.dot(t.x,t.y,t.z):this.x*(t||0)+this.y*(e||0)+this.z*(r||0)},n.Vector.prototype.cross=function(t){var e=this.y*t.z-this.z*t.y,r=this.z*t.x-this.x*t.z,o=this.x*t.y-this.y*t.x;return this.p5?new n.Vector(this.p5,[e,r,o]):new n.Vector(e,r,o)},n.Vector.prototype.dist=function(t){var e=t.get().sub(this);return e.mag()},n.Vector.prototype.normalize=function(){return this.div(this.mag())},n.Vector.prototype.limit=function(t){var e=this.magSq();return e>t*t&&(this.div(Math.sqrt(e)),this.mult(t)),this},n.Vector.prototype.setMag=function(t){return this.normalize().mult(t)},n.Vector.prototype.heading=function(){var t=Math.atan2(this.y,this.x);return this.p5?this.p5._angleMode===o.RADIANS?t:i.radiansToDegrees(t):t},n.Vector.prototype.rotate=function(t){this.p5&&this.p5._angleMode===o.DEGREES&&(t=i.degreesToRadians(t));var e=this.heading()+t,r=this.mag();return this.x=Math.cos(e)*r,this.y=Math.sin(e)*r,this},n.Vector.prototype.lerp=function(t,e,r,o){return t instanceof n.Vector?this.lerp(t.x,t.y,t.z,e):(this.x+=(t-this.x)*o||0,this.y+=(e-this.y)*o||0,this.z+=(r-this.z)*o||0,this)},n.Vector.prototype.array=function(){return[this.x||0,this.y||0,this.z||0]},n.Vector.fromAngle=function(t){return this.p5&&this.p5._angleMode===o.DEGREES&&(t=i.degreesToRadians(t)),this.p5?new n.Vector(this.p5,[Math.cos(t),Math.sin(t),0]):new n.Vector(Math.cos(t),Math.sin(t),0)},n.Vector.random2D=function(){var t;return t=this.p5?this.p5.random(this.p5._angleMode===o.DEGREES?360:o.TWO_PI):Math.random()*Math.PI*2,this.fromAngle(t)},n.Vector.random3D=function(){var t,e;this.p5?(t=this.p5.random(0,o.TWO_PI),e=this.p5.random(-1,1)):(t=Math.random()*Math.PI*2,e=2*Math.random()-1);var r=Math.sqrt(1-e*e)*Math.cos(t),i=Math.sqrt(1-e*e)*Math.sin(t);return this.p5?new n.Vector(this.p5,[r,i,e]):new n.Vector(r,i,e)},n.Vector.add=function(t,e){return t.get().add(e)},n.Vector.sub=function(t,e){return t.get().sub(e)},n.Vector.mult=function(t,e){return t.get().mult(e)},n.Vector.div=function(t,e){return t.get().div(e)},n.Vector.dot=function(t,e){return t.dot(e)},n.Vector.cross=function(t,e){return t.cross(e)},n.Vector.dist=function(t,e){return t.dist(e)},n.Vector.lerp=function(t,e,r){return t.get().lerp(e,r)},n.Vector.angleBetween=function(t,e){var r=Math.acos(t.dot(e)/(t.mag()*e.mag()));return this.p5&&this.p5._angleMode===o.DEGREES&&(r=i.radiansToDegrees(r)),r},n.Vector}({},core,polargeometry,constants),p5TableRow=function(t,e){"use strict";var r=e;return r.TableRow=function(t,e){var r=[],o={};t&&(e=e||",",r=t.split(e));for(var n=0;n<r.length;n++){var i=n,s=r[n];o[i]=s}this.arr=r,this.obj=o,this.table=null},r.TableRow.prototype.set=function(t,e){if("string"==typeof t){var r=this.table.columns.indexOf(t);if(!(r>=0))throw'This table has no column named "'+t+'"';this.obj[t]=e,this.arr[r]=e}else{if(!(t<this.table.columns.length))throw"Column #"+t+" is out of the range of this table";this.arr[t]=e;var o=this.table.columns[t];this.obj[o]=e}},r.TableRow.prototype.setNum=function(t,e){var r=parseFloat(e,10);this.set(t,r)},r.TableRow.prototype.setString=function(t,e){var r=e.toString();this.set(t,r)},r.TableRow.prototype.get=function(t){return"string"==typeof t?this.obj[t]:this.arr[t]},r.TableRow.prototype.getNum=function(t){var e;if(e="string"==typeof t?parseFloat(this.obj[t],10):parseFloat(this.arr[t],10),"NaN"===e.toString())throw"Error: "+this.obj[t]+" is NaN (Not a Number)";return e},r.TableRow.prototype.getString=function(t){return"string"==typeof t?this.obj[t].toString():this.arr[t].toString()},r.TableRow}({},core),p5Table=function(t,e){"use strict";var r=e;return r.Table=function(){this.columns=[],this.rows=[]},r.Table.prototype.addRow=function(t){var e=t||new r.TableRow;if("undefined"==typeof e.arr||"undefined"==typeof e.obj)throw"invalid TableRow: "+e;return e.table=this,this.rows.push(e),e},r.Table.prototype.removeRow=function(t){this.rows[t].table=null;var e=this.rows.splice(t+1,this.rows.length);this.rows.pop(),this.rows=this.rows.concat(e)},r.Table.prototype.getRow=function(t){return this.rows[t]},r.Table.prototype.getRows=function(){return this.rows},r.Table.prototype.findRow=function(t,e){if("string"==typeof e){for(var r=0;r<this.rows.length;r++)if(this.rows[r].obj[e]===t)return this.rows[r]}else for(var o=0;o<this.rows.length;o++)if(this.rows[o].arr[e]===t)return this.rows[o];return null},r.Table.prototype.findRows=function(t,e){var r=[];if("string"==typeof e)for(var o=0;o<this.rows.length;o++)this.rows[o].obj[e]===t&&r.push(this.rows[o]);else for(var n=0;n<this.rows.length;n++)this.rows[n].arr[e]===t&&r.push(this.rows[n]);return r},r.Table.prototype.matchRow=function(t,e){if("number"==typeof e){for(var r=0;r<this.rows.length;r++)if(this.rows[r].arr[e].match(t))return this.rows[r]}else for(var o=0;o<this.rows.length;o++)if(this.rows[o].obj[e].match(t))return this.rows[o];return null},r.Table.prototype.matchRows=function(t,e){var r=[];if("number"==typeof e)for(var o=0;o<this.rows.length;o++)this.rows[o].arr[e].match(t)&&r.push(this.rows[o]);else for(var n=0;n<this.rows.length;n++)this.rows[n].obj[e].match(t)&&r.push(this.rows[n]);return r},r.Table.prototype.getColumn=function(t){var e=[];if("string"==typeof t)for(var r=0;r<this.rows.length;r++)e.push(this.rows[r].obj[t]);else for(var o=0;o<this.rows.length;o++)e.push(this.rows[o].arr[t]);return e},r.Table.prototype.clearRows=function(){delete this.rows,this.rows=[]},r.Table.prototype.addColumn=function(t){var e=t||null;this.columns.push(e)},r.Table.prototype.getColumnCount=function(){return this.columns.length},r.Table.prototype.getRowCount=function(){return this.rows.length},r.Table.prototype.removeTokens=function(t,e){for(var r=function(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")},o=[],n=0;n<t.length;n++)o.push(r(t.charAt(n)));var i=new RegExp(o.join("|"),"g");if("undefined"==typeof e)for(var s=0;s<this.columns.length;s++)for(var a=0;a<this.rows.length;a++){var h=this.rows[a].arr[s];h=h.replace(i,""),this.rows[a].arr[s]=h,this.rows[a].obj[this.columns[s]]=h}else if("string"==typeof e)for(var p=0;p<this.rows.length;p++){var u=this.rows[p].obj[e];u=u.replace(i,""),this.rows[p].obj[e]=u;var l=this.columns.indexOf(e);this.rows[p].arr[l]=u}else for(var c=0;c<this.rows.length;c++){var d=this.rows[c].arr[e];d=d.replace(i,""),this.rows[c].arr[e]=d,this.rows[c].obj[this.columns[e]]=d}},r.Table.prototype.trim=function(t){var e=new RegExp(" ","g");if("undefined"==typeof t)for(var r=0;r<this.columns.length;r++)for(var o=0;o<this.rows.length;o++){var n=this.rows[o].arr[r];n=n.replace(e,""),this.rows[o].arr[r]=n,this.rows[o].obj[this.columns[r]]=n}else if("string"==typeof t)for(var i=0;i<this.rows.length;i++){var s=this.rows[i].obj[t];s=s.replace(e,""),this.rows[i].obj[t]=s;var a=this.columns.indexOf(t);this.rows[i].arr[a]=s}else for(var h=0;h<this.rows.length;h++){var p=this.rows[h].arr[t];p=p.replace(e,""),this.rows[h].arr[t]=p,this.rows[h].obj[this.columns[t]]=p}},r.Table.prototype.removeColumn=function(t){var e,r;"string"==typeof t?(e=t,r=this.columns.indexOf(t),console.log("string")):(r=t,e=this.columns[t]);var o=this.columns.splice(r+1,this.columns.length);this.columns.pop(),this.columns=this.columns.concat(o);for(var n=0;n<this.rows.length;n++){var i=this.rows[n].arr,s=i.splice(r+1,i.length);i.pop(),this.rows[n].arr=i.concat(s),delete this.rows[n].obj[e]}},r.Table}({},core),colorcreating_reading=function(t,e){"use strict";var r=e;return r.prototype.alpha=function(t){if(t instanceof r.Color)return t.rgba[3];if(t instanceof Array)return t[3];throw new Error("Needs p5.Color or pixel array as argument.")},r.prototype.blue=function(t){if(t instanceof Array)return t[2];if(t instanceof r.Color)return t.rgba[2];throw new Error("Needs p5.Color or pixel array as argument.")},r.prototype.brightness=function(t){if(!t instanceof r.Color)throw new Error("Needs p5.Color as argument.");return t.hsba||(t.hsba=r.Color.getRGB(t.rgba),t.hsba=t.hsba.concat(t.rgba[3])),t.hsba[2]},r.prototype.color=function(){return arguments[0]instanceof Array?new r.Color(this,arguments[0],!0):new r.Color(this,arguments)},r.prototype.green=function(t){if(t instanceof Array)return t[1];if(t instanceof r.Color)return t.rgba[1];throw new Error("Needs p5.Color or pixel array as argument.")},r.prototype.hue=function(t){if(!t instanceof r.Color)throw new Error("Needs p5.Color as argument.");return t.hsba||(t.hsba=r.Color.getRGB(t.rgba)),t.hsba[0]},r.prototype.lerpColor=function(t,e,o){if(t instanceof Array){for(var n=[],i=0;i<t.length;i++)n.push(r.prototype.lerp(t[i],e[i],o));return n}if(t instanceof r.Color){for(var s=[],a=0;4>a;a++)s.push(r.prototype.lerp(t.rgba[a],e.rgba[a],o));return new r.Color(this,s)}return r.prototype.lerp(t,e,o)},r.prototype.red=function(t){if(t instanceof Array)return t[0];if(t instanceof r.Color)return t.rgba[0];throw new Error("Needs p5.Color or pixel array as argument.")},r.prototype.saturation=function(t){if(!t instanceof r.Color)throw new Error("Needs p5.Color as argument.");return t.hsba||(t.hsba=r.Color.getRGB(t.rgba),t.hsba=t.hsba.concat(t.rgba[3])),t.hsba[1]},r}({},core,p5Color),colorsetting=function(t,e,r){"use strict";var o=e,r=r;return o.prototype._doStroke=!0,o.prototype._doFill=!0,o.prototype._colorMode=r.RGB,o.prototype._maxRGB=[255,255,255,255],o.prototype._maxHSB=[255,255,255,255],o.prototype.background=function(){if(arguments[0]instanceof o.Image)this.image(arguments[0],0,0,this.width,this.height);else{var t=this.drawingContext.fillStyle,e=this.drawingContext;e.fillStyle=o.Color._getCanvasColor.apply(this,arguments),e.fillRect(0,0,this.width,this.height),e.fillStyle=t}},o.prototype.clear=function(){this.drawingContext.clearRect(0,0,this.width,this.height)},o.prototype.colorMode=function(){if(arguments[0]===r.RGB||arguments[0]===r.HSB){this._colorMode=arguments[0];var t=this._colorMode===r.RGB,e=t?this._maxRGB:this._maxHSB;2===arguments.length?(e[0]=arguments[1],e[1]=arguments[1],e[2]=arguments[1]):arguments.length>2&&(e[0]=arguments[1],e[1]=arguments[2],e[2]=arguments[3]),5===arguments.length&&(e[3]=arguments[4])}},o.prototype.fill=function(){this._setProperty("_doFill",!0);var t=this.drawingContext;t.fillStyle=o.Color._getCanvasColor.apply(this,arguments)},o.prototype.noFill=function(){this._setProperty("_doFill",!1)},o.prototype.noStroke=function(){this._setProperty("_doStroke",!1)},o.prototype.stroke=function(){this._setProperty("_doStroke",!0);var t=this.drawingContext;t.strokeStyle=o.Color._getCanvasColor.apply(this,arguments)},o}({},core,constants,p5Color),dataconversion=function(t,e){"use strict";var r=e;return r.prototype.float=function(t){return parseFloat(t)},r.prototype.int=function(t,e){return"string"==typeof t?(e=e||10,parseInt(t,e)):"number"==typeof t?0|t:"boolean"==typeof t?t?1:0:t instanceof Array?t.map(r.prototype.int):void 0},r}({},core),dataarray_functions=function(t,e){"use strict";var r=e;return r.prototype.append=function(t,e){return t.push(e),t},r.prototype.arrayCopy=function(t,e,r,o,n){var i,s;"undefined"!=typeof n?(s=Math.min(n,t.length),i=o,t=t.slice(e,s+e)):("undefined"!=typeof r?(s=r,s=Math.min(s,t.length)):s=t.length,i=0,r=e,t=t.slice(0,s)),Array.prototype.splice.apply(r,[i,s].concat(t))},r.prototype.concat=function(t,e){return t.concat(e)},r.prototype.reverse=function(t){return t.reverse()},r.prototype.shorten=function(t){return t.pop(),t},r.prototype.sort=function(t,e){var r=e?t.slice(0,Math.min(e,t.length)):t,o=e?t.slice(Math.min(e,t.length)):[];return r="string"==typeof r[0]?r.sort():r.sort(function(t,e){return t-e}),r.concat(o)},r.prototype.splice=function(t,e,r){return Array.prototype.splice.apply(t,[r,0].concat(e)),t},r.prototype.subset=function(t,e,r){return"undefined"!=typeof r?t.slice(e,e+r):t.slice(e,t.length)},r}({},core),datastring_functions=function(t,e){"use strict";function r(){var t=arguments[0],e=0>t,r=e?t.toString().substring(1):t.toString(),o=r.indexOf("."),n=-1!==o?r.substring(0,o):r,i=-1!==o?r.substring(o+1):"",s=e?"-":"";if(3===arguments.length){for(var a=0;a<arguments[1]-n.length;a++)s+="0";s+=n,s+=".",s+=i;for(var h=0;h<arguments[2]-i.length;h++)s+="0";return s}for(var p=0;p<Math.max(arguments[1]-n.length,0);p++)s+="0";return s+=r}function o(){var t=arguments[0].toString(),e=t.indexOf("."),r=-1!==e?t.substring(e):"",o=-1!==e?t.substring(0,e):t;return o=o.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),arguments.length>1&&(r=r.substring(0,arguments[1]+1)),o+r}function n(){return parseFloat(arguments[0])>0?"+"+arguments[0].toString():arguments[0].toString()}function i(){return parseFloat(arguments[0])>0?" "+arguments[0].toString():arguments[0].toString()}var s=e;return s.prototype.join=function(t,e){return t.join(e)},s.prototype.match=function(t,e){return t.match(e)},s.prototype.matchAll=function(t,e){for(var r=new RegExp(e,"g"),o=r.exec(t),n=[];null!==o;)n.push(o),o=r.exec(t);return n},s.prototype.nf=function(){if(arguments[0]instanceof Array){var t=arguments[1],e=arguments[2];
return arguments[0].map(function(o){return r(o,t,e)})}return r.apply(this,arguments)},s.prototype.nfc=function(){if(arguments[0]instanceof Array){var t=arguments[1];return arguments[0].map(function(e){return o(e,t)})}return o.apply(this,arguments)},s.prototype.nfp=function(){var t=this.nf(arguments);return t instanceof Array?t.map(n):n(t)},s.prototype.nfs=function(){var t=this.nf(arguments);return t instanceof Array?t.map(i):i(t)},s.prototype.split=function(t,e){return t.split(e)},s.prototype.splitTokens=function(){var t=arguments.length>0?arguments[1]:/\s/g;return arguments[0].split(t).filter(function(t){return t})},s.prototype.trim=function(t){return t instanceof Array?t.map(this.trim):t.trim()},s}({},core),environment=function(t,e,r){"use strict";function o(t){var e=document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled;if(!e)throw new Error("Fullscreen not enabled in this browser.");t.requestFullscreen?t.requestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.msRequestFullscreen&&t.msRequestFullscreen()}function n(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}var i=e,s=r,a=[s.ARROW,s.CROSS,s.HAND,s.MOVE,s.TEXT,s.WAIT];return i.prototype._frameRate=0,i.prototype._lastFrameTime=(new Date).getTime(),i.prototype._targetFrameRate=60,i.prototype.frameCount=0,i.prototype.focused=!0,i.prototype.cursor=function(t,e,r){var o="auto",n=this._curElement.elt;if(a.indexOf(t)>-1)o=t;else if("string"==typeof t){var i="";e&&r&&"number"==typeof e&&"number"==typeof r&&(i=e+" "+r),o="http://"!==t.substring(0,6)?"url("+t+") "+i+", auto":/\.(cur|jpg|jpeg|gif|png|CUR|JPG|JPEG|GIF|PNG)$/.test(t)?"url("+t+") "+i+", auto":t}n.style.cursor=o},i.prototype.frameRate=function(t){return"undefined"==typeof t?this._frameRate:(this._setProperty("_targetFrameRate",t),this._runFrames(),this)},i.prototype.getFrameRate=function(){return this.frameRate()},i.prototype.setFrameRate=function(t){return this.frameRate(t)},i.prototype.noCursor=function(){this._curElement.elt.style.cursor="none"},i.prototype.displayWidth=screen.width,i.prototype.displayHeight=screen.height,i.prototype.windowWidth=window.innerWidth,i.prototype.windowHeight=window.innerHeight,i.prototype.onresize=function(t){this._setProperty("windowWidth",window.innerWidth),this._setProperty("windowHeight",window.innerHeight);var e,r=this._isGlobal?window:this;"function"==typeof r.windowResized&&(e=r.windowResized(t),void 0===e||e||t.preventDefault())},i.prototype.width=0,i.prototype.height=0,i.prototype.fullscreen=function(t){return"undefined"==typeof t?document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement:void(t?o(document.documentElement):n())},i}({},core,constants),imageimage=function(t,e,r){"use strict";var o=e,r=r;return o.prototype._imageMode=r.CORNER,o.prototype._tint=null,o.prototype.createImage=function(t,e){return new o.Image(t,e)},o}({},core,constants),canvas=function(t,e){var e=e;return{modeAdjust:function(t,r,o,n,i){return i===e.CORNER?{x:t,y:r,w:o,h:n}:i===e.CORNERS?{x:t,y:r,w:o-t,h:n-r}:i===e.RADIUS?{x:t-o,y:r-n,w:2*o,h:2*n}:i===e.CENTER?{x:t-.5*o,y:r-.5*n,w:o,h:n}:void 0},arcModeAdjust:function(t,r,o,n,i){return i===e.CORNER?{x:t+.5*o,y:r+.5*n,w:o,h:n}:i===e.CORNERS?{x:t,y:r,w:o+t,h:n+r}:i===e.RADIUS?{x:t,y:r,w:2*o,h:2*n}:i===e.CENTER?{x:t,y:r,w:o,h:n}:void 0}}}({},constants),imageloading_displaying=function(t,e,r,o,n){"use strict";var i=e,s=r,o=o,n=n;return i.prototype.loadImage=function(t,e){var r=new Image,o=new i.Image(1,1,this);return r.onload=function(){o.width=o.canvas.width=r.width,o.height=o.canvas.height=r.height,o.canvas.getContext("2d").drawImage(r,0,0),"undefined"!=typeof e&&e(o)},0!==t.indexOf("data:image/")&&(r.crossOrigin="Anonymous"),r.src=t,o},i.prototype.image=function(t,e,r,n,i){var s=t.canvas||t.elt;e=e||0,r=r||0,n=n||t.width,i=i||t.height;var a=o.modeAdjust(e,r,n,i,this._imageMode);this._tint&&t.canvas?this.drawingContext.drawImage(this._getTintedImageCanvas(t),a.x,a.y,a.w,a.h):this.drawingContext.drawImage(s,a.x,a.y,a.w,a.h)},i.prototype.tint=function(){var t=i.Color._getFormattedColor.apply(this,arguments);t=i.Color._normalizeColorArray.call(this,t),this._tint=t},i.prototype.noTint=function(){this._tint=null},i.prototype._getTintedImageCanvas=function(t){if(!t.canvas)return t;var e=s._toPixels(t.canvas),r=document.createElement("canvas");r.width=t.canvas.width,r.height=t.canvas.height;for(var o=r.getContext("2d"),n=o.createImageData(t.canvas.width,t.canvas.height),i=n.data,a=0;a<e.length;a+=4){var h=e[a],p=e[a+1],u=e[a+2],l=e[a+3];i[a]=h*this._tint[0]/255,i[a+1]=p*this._tint[1]/255,i[a+2]=u*this._tint[2]/255,i[a+3]=l*this._tint[3]/255}return o.putImageData(n,0,0),r},i.prototype.imageMode=function(t){(t===n.CORNER||t===n.CORNERS||t===n.CENTER)&&(this._imageMode=t)},i}({},core,filters,canvas,constants),imagepixels=function(t,e,r){"use strict";var o=e,n=r;return o.prototype.pixels=[],o.prototype.blend=function(){var t=this.drawingContext.globalCompositeOperation,e=arguments[arguments.length-1],r=Array.prototype.slice.call(arguments,0,arguments.length-1);this.drawingContext.globalCompositeOperation=e,this.copy.apply(this,r),this.drawingContext.globalCompositeOperation=t},o.prototype.copy=function(){var t,e,r,o,n,i,s,a,h;if(9===arguments.length)t=arguments[0],e=arguments[1],r=arguments[2],o=arguments[3],n=arguments[4],i=arguments[5],s=arguments[6],a=arguments[7],h=arguments[8];else{if(8!==arguments.length)throw new Error("Signature not supported");e=arguments[0],r=arguments[1],o=arguments[2],n=arguments[3],i=arguments[4],s=arguments[5],a=arguments[6],h=arguments[7],t=this}this.drawingContext.drawImage(t.canvas,e,r,o,n,i,s,a,h)},o.prototype.filter=function(t,e){n.apply(this.canvas,n[t.toLowerCase()],e)},o.prototype.get=function(t,e,r,n){if(void 0===t&&void 0===e&&void 0===r&&void 0===n?(t=0,e=0,r=this.width,n=this.height):void 0===r&&void 0===n&&(r=1,n=1),t>this.width||e>this.height||0>t||0>e)return[0,0,0,255];var i=this.drawingContext.getImageData(t,e,r,n),s=i.data;if(1===r&&1===n){for(var a=[],h=0;h<s.length;h+=4)a.push(s[h],s[h+1],s[h+2],s[h+3]);return a}r=Math.min(r,this.width),n=Math.min(n,this.height);var p=new o.Image(r,n);return p.canvas.getContext("2d").putImageData(i,0,0,0,0,r,n),p},o.prototype.loadPixels=function(){var t=this.width,e=this.height,r=this.drawingContext.getImageData(0,0,t,e);this._setProperty("imageData",r),this._setProperty("pixels",r.data)},o.prototype.set=function(t,e,r){if(r instanceof o.Image)this.drawingContext.drawImage(r.canvas,t,e),this.loadPixels.call(this);else{var n=4*(e*this.width+t);if(this.imageData||this.loadPixels.call(this),"number"==typeof r)n<this.pixels.length&&(this.pixels[n]=r,this.pixels[n+1]=r,this.pixels[n+2]=r,this.pixels[n+3]=255);else if(r instanceof Array){if(r.length<4)throw new Error("pixel array must be of the form [R, G, B, A]");n<this.pixels.length&&(this.pixels[n]=r[0],this.pixels[n+1]=r[1],this.pixels[n+2]=r[2],this.pixels[n+3]=r[3])}else r instanceof o.Color&&n<this.pixels.length&&(this.pixels[n]=r.rgba[0],this.pixels[n+1]=r.rgba[1],this.pixels[n+2]=r.rgba[2],this.pixels[n+3]=r.rgba[3])}},o.prototype.updatePixels=function(t,e,r,o){void 0===t&&void 0===e&&void 0===r&&void 0===o&&(t=0,e=0,r=this.width,o=this.height),this.drawingContext.putImageData(this.imageData,t,e,0,0,r,o)},o}({},core,filters,p5Color);!function(t,e,r){"undefined"!=typeof module&&module.exports?module.exports=r():"function"==typeof define&&define.amd?define("reqwest",r):e[t]=r()}("reqwest",this,function(){function handleReadyState(t,e,r){return function(){return t._aborted?r(t.request):void(t.request&&4==t.request[readyState]&&(t.request.onreadystatechange=noop,twoHundo.test(t.request.status)?e(t.request):r(t.request)))}}function setHeaders(t,e){var r,o=e.headers||{};o.Accept=o.Accept||defaultHeaders.accept[e.type]||defaultHeaders.accept["*"],e.crossOrigin||o[requestedWith]||(o[requestedWith]=defaultHeaders.requestedWith),o[contentType]||(o[contentType]=e.contentType||defaultHeaders.contentType);for(r in o)o.hasOwnProperty(r)&&"setRequestHeader"in t&&t.setRequestHeader(r,o[r])}function setCredentials(t,e){"undefined"!=typeof e.withCredentials&&"undefined"!=typeof t.withCredentials&&(t.withCredentials=!!e.withCredentials)}function generalCallback(t){lastValue=t}function urlappend(t,e){return t+(/\?/.test(t)?"&":"?")+e}function handleJsonp(t,e,r,o){var n=uniqid++,i=t.jsonpCallback||"callback",s=t.jsonpCallbackName||reqwest.getcallbackPrefix(n),a=new RegExp("((^|\\?|&)"+i+")=([^&]+)"),h=o.match(a),p=doc.createElement("script"),u=0,l=-1!==navigator.userAgent.indexOf("MSIE 10.0");return h?"?"===h[3]?o=o.replace(a,"$1="+s):s=h[3]:o=urlappend(o,i+"="+s),win[s]=generalCallback,p.type="text/javascript",p.src=o,p.async=!0,"undefined"==typeof p.onreadystatechange||l||(p.event="onclick",p.htmlFor=p.id="_reqwest_"+n),p.onload=p.onreadystatechange=function(){return p[readyState]&&"complete"!==p[readyState]&&"loaded"!==p[readyState]||u?!1:(p.onload=p.onreadystatechange=null,p.onclick&&p.onclick(),e(lastValue),lastValue=void 0,head.removeChild(p),void(u=1))},head.appendChild(p),{abort:function(){p.onload=p.onreadystatechange=null,r({},"Request is aborted: timeout",{}),lastValue=void 0,head.removeChild(p),u=1}}}function getRequest(t,e){var r,o=this.o,n=(o.method||"GET").toUpperCase(),i="string"==typeof o?o:o.url,s=o.processData!==!1&&o.data&&"string"!=typeof o.data?reqwest.toQueryString(o.data):o.data||null,a=!1;return"jsonp"!=o.type&&"GET"!=n||!s||(i=urlappend(i,s),s=null),"jsonp"==o.type?handleJsonp(o,t,e,i):(r=o.xhr&&o.xhr(o)||xhr(o),r.open(n,i,o.async===!1?!1:!0),setHeaders(r,o),setCredentials(r,o),win[xDomainRequest]&&r instanceof win[xDomainRequest]?(r.onload=t,r.onerror=e,r.onprogress=function(){},a=!0):r.onreadystatechange=handleReadyState(this,t,e),o.before&&o.before(r),a?setTimeout(function(){r.send(s)},200):r.send(s),r)}function Reqwest(t,e){this.o=t,this.fn=e,init.apply(this,arguments)}function setType(t){var e=t.match(/\.(json|jsonp|html|xml)(\?|$)/);return e?e[1]:"js"}function init(o,fn){function complete(t){for(o.timeout&&clearTimeout(self.timeout),self.timeout=null;self._completeHandlers.length>0;)self._completeHandlers.shift()(t)}function success(resp){resp="jsonp"!==type?self.request:resp;var filteredResponse=globalSetupOptions.dataFilter(resp.responseText,type),r=filteredResponse;try{resp.responseText=r}catch(e){}if(r)switch(type){case"json":try{resp=win.JSON?win.JSON.parse(r):eval("("+r+")")}catch(err){return error(resp,"Could not parse JSON in response",err)}break;case"js":resp=eval(r);break;case"html":resp=r;break;case"xml":resp=resp.responseXML&&resp.responseXML.parseError&&resp.responseXML.parseError.errorCode&&resp.responseXML.parseError.reason?null:resp.responseXML}for(self._responseArgs.resp=resp,self._fulfilled=!0,fn(resp),self._successHandler(resp);self._fulfillmentHandlers.length>0;)resp=self._fulfillmentHandlers.shift()(resp);complete(resp)}function error(t,e,r){for(t=self.request,self._responseArgs.resp=t,self._responseArgs.msg=e,self._responseArgs.t=r,self._erred=!0;self._errorHandlers.length>0;)self._errorHandlers.shift()(t,e,r);complete(t)}this.url="string"==typeof o?o:o.url,this.timeout=null,this._fulfilled=!1,this._successHandler=function(){},this._fulfillmentHandlers=[],this._errorHandlers=[],this._completeHandlers=[],this._erred=!1,this._responseArgs={};var self=this,type=o.type||setType(this.url);fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){self.abort()},o.timeout)),o.success&&(this._successHandler=function(){o.success.apply(o,arguments)}),o.error&&this._errorHandlers.push(function(){o.error.apply(o,arguments)}),o.complete&&this._completeHandlers.push(function(){o.complete.apply(o,arguments)}),this.request=getRequest.call(this,success,error)}function reqwest(t,e){return new Reqwest(t,e)}function normalize(t){return t?t.replace(/\r?\n/g,"\r\n"):""}function serial(t,e){var r,o,n,i,s=t.name,a=t.tagName.toLowerCase(),h=function(t){t&&!t.disabled&&e(s,normalize(t.attributes.value&&t.attributes.value.specified?t.value:t.text))};if(!t.disabled&&s)switch(a){case"input":/reset|button|image|file/i.test(t.type)||(r=/checkbox/i.test(t.type),o=/radio/i.test(t.type),n=t.value,(!(r||o)||t.checked)&&e(s,normalize(r&&""===n?"on":n)));break;case"textarea":e(s,normalize(t.value));break;case"select":if("select-one"===t.type.toLowerCase())h(t.selectedIndex>=0?t.options[t.selectedIndex]:null);else for(i=0;t.length&&i<t.length;i++)t.options[i].selected&&h(t.options[i])}}function eachFormElement(){var t,e,r=this,o=function(t,e){var o,n,i;for(o=0;o<e.length;o++)for(i=t[byTag](e[o]),n=0;n<i.length;n++)serial(i[n],r)};for(e=0;e<arguments.length;e++)t=arguments[e],/input|select|textarea/i.test(t.tagName)&&serial(t,r),o(t,["input","select","textarea"])}function serializeQueryString(){return reqwest.toQueryString(reqwest.serializeArray.apply(null,arguments))}function serializeHash(){var t={};return eachFormElement.apply(function(e,r){e in t?(t[e]&&!isArray(t[e])&&(t[e]=[t[e]]),t[e].push(r)):t[e]=r},arguments),t}function buildParams(t,e,r,o){var n,i,s,a=/\[\]$/;if(isArray(e))for(i=0;e&&i<e.length;i++)s=e[i],r||a.test(t)?o(t,s):buildParams(t+"["+("object"==typeof s?i:"")+"]",s,r,o);else if(e&&"[object Object]"===e.toString())for(n in e)buildParams(t+"["+n+"]",e[n],r,o);else o(t,e)}var win=window,doc=document,twoHundo=/^(20\d|1223)$/,byTag="getElementsByTagName",readyState="readyState",contentType="Content-Type",requestedWith="X-Requested-With",head=doc[byTag]("head")[0],uniqid=0,callbackPrefix="reqwest_"+ +new Date,lastValue,xmlHttpRequest="XMLHttpRequest",xDomainRequest="XDomainRequest",noop=function(){},isArray="function"==typeof Array.isArray?Array.isArray:function(t){return t instanceof Array},defaultHeaders={contentType:"application/x-www-form-urlencoded",requestedWith:xmlHttpRequest,accept:{"*":"text/javascript, text/html, application/xml, text/xml, */*",xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript",js:"application/javascript, text/javascript"}},xhr=function(t){if(t.crossOrigin===!0){var e=win[xmlHttpRequest]?new XMLHttpRequest:null;if(e&&"withCredentials"in e)return e;if(win[xDomainRequest])return new XDomainRequest;throw new Error("Browser does not support cross-origin requests")}return win[xmlHttpRequest]?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP")},globalSetupOptions={dataFilter:function(t){return t}};return Reqwest.prototype={abort:function(){this._aborted=!0,this.request.abort()},retry:function(){init.call(this,this.o,this.fn)},then:function(t,e){return t=t||function(){},e=e||function(){},this._fulfilled?this._responseArgs.resp=t(this._responseArgs.resp):this._erred?e(this._responseArgs.resp,this._responseArgs.msg,this._responseArgs.t):(this._fulfillmentHandlers.push(t),this._errorHandlers.push(e)),this},always:function(t){return this._fulfilled||this._erred?t(this._responseArgs.resp):this._completeHandlers.push(t),this},fail:function(t){return this._erred?t(this._responseArgs.resp,this._responseArgs.msg,this._responseArgs.t):this._errorHandlers.push(t),this}},reqwest.serializeArray=function(){var t=[];return eachFormElement.apply(function(e,r){t.push({name:e,value:r})},arguments),t},reqwest.serialize=function(){if(0===arguments.length)return"";var t,e,r=Array.prototype.slice.call(arguments,0);return t=r.pop(),t&&t.nodeType&&r.push(t)&&(t=null),t&&(t=t.type),e="map"==t?serializeHash:"array"==t?reqwest.serializeArray:serializeQueryString,e.apply(null,r)},reqwest.toQueryString=function(t,e){var r,o,n=e||!1,i=[],s=encodeURIComponent,a=function(t,e){e="function"==typeof e?e():null==e?"":e,i[i.length]=s(t)+"="+s(e)};if(isArray(t))for(o=0;t&&o<t.length;o++)a(t[o].name,t[o].value);else for(r in t)t.hasOwnProperty(r)&&buildParams(r,t[r],n,a);return i.join("&").replace(/%20/g,"+")},reqwest.getcallbackPrefix=function(){return callbackPrefix},reqwest.compat=function(t,e){return t&&(t.type&&(t.method=t.type)&&delete t.type,t.dataType&&(t.type=t.dataType),t.jsonpCallback&&(t.jsonpCallbackName=t.jsonpCallback)&&delete t.jsonpCallback,t.jsonp&&(t.jsonpCallback=t.jsonp)),new Reqwest(t,e)},reqwest.ajaxSetup=function(t){t=t||{};for(var e in t)globalSetupOptions[e]=t[e]},reqwest});var inputfiles=function(t,e,r){"use strict";function o(t,e){var r={};if(e=e||[],"undefined"==typeof e)for(var o=0;o<t.length;o++)e[o.toString()]=o;for(var n=0;n<e.length;n++){var i=e[n],s=t[n];r[i]=s}return r}var n=e,r=r;return n.prototype.createInput=function(){throw"not yet implemented"},n.prototype.createReader=function(){throw"not yet implemented"},n.prototype.loadBytes=function(){throw"not yet implemented"},n.prototype.loadJSON=function(t,e){var o=[],n=-1===t.indexOf("http")?"json":"jsonp";return"string"==typeof arguments[2]&&("jsonp"===arguments[2]||"json"===arguments[2])&&(n=arguments[2]),r({url:t,type:n,crossOrigin:!0}).then(function(t){for(var r in t)o[r]=t[r];"undefined"!=typeof e&&e(t)}),o},n.prototype.loadStrings=function(t,e){var r=[],o=new XMLHttpRequest;return o.open("GET",t,!0),o.onreadystatechange=function(){if(4===o.readyState&&(200===o.status||0===o.status)){var t=o.responseText.match(/[^\r\n]+/g);for(var n in t)r[n]=t[n];"undefined"!=typeof e&&e(r)}},o.send(null),r},n.prototype.loadTable=function(t){for(var e=null,r=[],i=!1,s=",",a=1;a<arguments.length;a++)"function"==typeof arguments[a]?e=arguments[a]:"string"==typeof arguments[a]&&(r.push(arguments[a]),"header"===arguments[a]&&(i=!0),"csv"===arguments[a]?s=",":"tsv"===arguments[a]&&(s=" "));var h=[],p=new n.Table,u=new XMLHttpRequest;return u.open("GET",t,!0),u.onreadystatechange=function(){if(4===u.readyState&&(200===u.status||0===u.status)){var t=u.responseText.match(/[^\r\n]+/g);for(var r in t)h[r]=t[r];if("undefined"!=typeof e){var a,l;if(i)for(p.columns=new n.TableRow(h[0]).arr,a=1;a<h.length;a++)l=new n.TableRow(h[a],s),l.obj=o(l.arr,p.columns),p.addRow(l);else{for(a=0;a<h[0].split(s).length;a++)p.columns[a]=a.toString();for(a=0;a<h.length;a++)l=new n.TableRow(h[a],s),p.addRow(l)}e(p)}}},u.send(null),p},n.prototype.loadXML=function(t,e){var o=[];return r({url:t,type:"xml",crossOrigin:!0}).then(function(t){e(t)}),o},n.prototype.parseXML=function(){throw"not yet implemented"},n.prototype.selectFolder=function(){throw"not yet implemented"},n.prototype.selectInput=function(){throw"not yet implemented"},n}({},core,reqwest),inputkeyboard=function(t,e){"use strict";var r=e,o={};return r.prototype.isKeyPressed=!1,r.prototype.keyIsPressed=!1,r.prototype.key="",r.prototype.keyCode=0,r.prototype.onkeydown=function(t){this._setProperty("isKeyPressed",!0),this._setProperty("keyIsPressed",!0),this._setProperty("keyCode",t.which),o[t.which]=!0;var e=String.fromCharCode(t.which);e||(e=t.which),this._setProperty("key",e);var r=this.keyPressed||window.keyPressed;if("function"==typeof r&&!t.charCode){var n=r(t);n===!1&&t.preventDefault()}},r.prototype.onkeyup=function(t){var e=this.keyReleased||window.keyReleased;this._setProperty("isKeyPressed",!1),this._setProperty("keyIsPressed",!1),o[t.which]=!1;var r=String.fromCharCode(t.which);if(r||(r=t.which),this._setProperty("key",r),this._setProperty("keyCode",t.which),"function"==typeof e){var n=e(t);n===!1&&t.preventDefault()}},r.prototype.onkeypress=function(t){this._setProperty("keyCode",t.which),this._setProperty("key",String.fromCharCode(t.which));var e=this.keyTyped||window.keyTyped;if("function"==typeof e){var r=e(t);r===!1&&t.preventDefault()}},r.prototype.keyIsDown=function(t){return o[t]},r}({},core),inputmouse=function(t,e,r){"use strict";function o(t,e){var r=t.getBoundingClientRect();return{x:e.clientX-r.left,y:e.clientY-r.top}}var n=e,r=r;return n.prototype.mouseX=0,n.prototype.mouseY=0,n.prototype.pmouseX=0,n.prototype.pmouseY=0,n.prototype.winMouseX=0,n.prototype.winMouseY=0,n.prototype.pwinMouseX=0,n.prototype.pwinMouseY=0,n.prototype.mouseButton=0,n.prototype.mouseIsPressed=!1,n.prototype.isMousePressed=!1,n.prototype._updateMouseCoords=function(t){if("touchstart"===t.type||"touchmove"===t.type||"touchend"===t.type)this._setProperty("mouseX",this.touchX),this._setProperty("mouseY",this.touchY);else if(null!==this._curElement){var e=o(this._curElement.elt,t);this._setProperty("mouseX",e.x),this._setProperty("mouseY",e.y)}this._setProperty("winMouseX",t.pageX),this._setProperty("winMouseY",t.pageY)},n.prototype._updatePMouseCoords=function(){this._setProperty("pmouseX",this.mouseX),this._setProperty("pmouseY",this.mouseY),this._setProperty("pwinMouseX",this.winMouseX),this._setProperty("pwinMouseY",this.winMouseY)},n.prototype._setMouseButton=function(t){1===t.button?this._setProperty("mouseButton",r.CENTER):2===t.button?this._setProperty("mouseButton",r.RIGHT):(this._setProperty("mouseButton",r.LEFT),("touchstart"===t.type||"touchmove"===t.type)&&(this._setProperty("mouseX",this.touchX),this._setProperty("mouseY",this.touchY)))},n.prototype.onmousemove=function(t){var e,r=this._isGlobal?window:this;this._updateMouseCoords(t),this.isMousePressed?"function"==typeof r.mouseDragged?(e=r.mouseDragged(t),e===!1&&t.preventDefault()):"function"==typeof r.touchMoved&&(e=r.touchMoved(t),e===!1&&t.preventDefault(),this._updateTouchCoords(t)):"function"==typeof r.mouseMoved&&(e=r.mouseMoved(t),e===!1&&t.preventDefault())},n.prototype.onmousedown=function(t){var e,r=this._isGlobal?window:this;this._setProperty("isMousePressed",!0),this._setProperty("mouseIsPressed",!0),this._setMouseButton(t),this._updateMouseCoords(t),"function"==typeof r.mousePressed?(e=r.mousePressed(t),e===!1&&t.preventDefault()):"function"==typeof r.touchStarted&&(e=r.touchStarted(t),e===!1&&t.preventDefault(),this._updateTouchCoords(t))},n.prototype.onmouseup=function(t){var e,r=this._isGlobal?window:this;this._setProperty("isMousePressed",!1),this._setProperty("mouseIsPressed",!1),"function"==typeof r.mouseReleased?(e=r.mouseReleased(t),e===!1&&t.preventDefault()):"function"==typeof r.touchEnded&&(e=r.touchEnded(t),e===!1&&t.preventDefault(),this._updateTouchCoords(t))},n.prototype.onclick=function(t){var e=this._isGlobal?window:this;if("function"==typeof e.mouseClicked){var r=e.mouseClicked(t);r===!1&&t.preventDefault()}},n.prototype.onmousewheel=function(t){var e=this._isGlobal?window:this;if("function"==typeof e.mouseWheel){var r=e.mouseWheel(t);r===!1&&t.preventDefault()}},n}({},core,constants),inputtime_date=function(t,e){"use strict";var r=e;return r.prototype.day=function(){return(new Date).getDate()},r.prototype.hour=function(){return(new Date).getHours()},r.prototype.minute=function(){return(new Date).getMinutes()},r.prototype.millis=function(){return(new Date).getTime()-this._startTime},r.prototype.month=function(){return(new Date).getMonth()+1},r.prototype.second=function(){return(new Date).getSeconds()},r.prototype.year=function(){return(new Date).getFullYear()},r}({},core),inputtouch=function(t,e){"use strict";function r(t,e,r){r=r||0;var o=t.getBoundingClientRect();return{x:e.changedTouches[r].pageX-o.left,y:e.changedTouches[r].pageY-o.top}}var o=e;return o.prototype.touchX=0,o.prototype.touchY=0,o.prototype.ptouchX=0,o.prototype.ptouchY=0,o.prototype.touches=[],o.prototype._updateTouchCoords=function(t){if("mousedown"===t.type||"mousemove"===t.type||"mouseup"===t.type)this._setProperty("touchX",this.mouseX),this._setProperty("touchY",this.mouseY);else{var e=r(this._curElement.elt,t,0);this._setProperty("touchX",e.x),this._setProperty("touchY",e.y);for(var o=[],n=0;n<t.changedTouches.length;n++){var i=r(this._curElement.elt,t,n);o[n]={x:i.x,y:i.y}}this._setProperty("touches",o)}},o.prototype._updatePTouchCoords=function(){this._setProperty("ptouchX",this.touchX),this._setProperty("ptouchY",this.touchY)},o.prototype.ontouchstart=function(t){var e,r=this._isGlobal?window:this;this._updateTouchCoords(t),"function"==typeof r.touchStarted?(e=r.touchStarted(t),e===!1&&t.preventDefault()):"function"==typeof r.mousePressed&&(e=r.mousePressed(t),e===!1&&t.preventDefault())},o.prototype.ontouchmove=function(t){var e,r=this._isGlobal?window:this;this._updateTouchCoords(t),"function"==typeof r.touchMoved?(e=r.touchMoved(t),e===!1&&t.preventDefault()):"function"==typeof r.mouseDragged&&(e=r.mouseDragged(t),e===!1&&t.preventDefault(),this._updateMouseCoords(t))},o.prototype.ontouchend=function(t){this._updateTouchCoords(t);var e,r=this._isGlobal?window:this;"function"==typeof r.touchEnded?(e=r.touchEnded(t),e===!1&&t.preventDefault()):"function"==typeof r.mouseReleased&&(e=r.mouseReleased(t),e===!1&&t.preventDefault(),this._updateMouseCoords(t))},o}({},core),mathmath=function(t,e){"use strict";var r=e;return r.prototype.createVector=function(){return new r.Vector(this,arguments)},r}({},core),mathcalculation=function(t,e){"use strict";var r=e;return r.prototype.abs=Math.abs,r.prototype.ceil=Math.ceil,r.prototype.constrain=function(t,e,r){return Math.max(Math.min(t,r),e)},r.prototype.dist=function(t,e,r,o){return Math.sqrt((r-t)*(r-t)+(o-e)*(o-e))},r.prototype.exp=Math.exp,r.prototype.floor=Math.floor,r.prototype.lerp=function(t,e,r){return r*(e-t)+t},r.prototype.log=Math.log,r.prototype.mag=function(t,e){return Math.sqrt(t*t+e*e)},r.prototype.map=function(t,e,r,o,n){return(t-e)/(r-e)*(n-o)+o},r.prototype.max=function(){return arguments[0]instanceof Array?Math.max.apply(null,arguments[0]):Math.max.apply(null,arguments)},r.prototype.min=function(){return arguments[0]instanceof Array?Math.min.apply(null,arguments[0]):Math.min.apply(null,arguments)},r.prototype.norm=function(t,e,r){return this.map(t,e,r,0,1)},r.prototype.pow=Math.pow,r.prototype.round=Math.round,r.prototype.sq=function(t){return t*t},r.prototype.sqrt=Math.sqrt,r}({},core),mathrandom=function(t,e){"use strict";var r=e,o=!1,n=function(){var t,e,r=4294967296,o=1664525,n=1013904223;return{setSeed:function(o){e=t=o||Math.round(Math.random()*r)},getSeed:function(){return t},rand:function(){return e=(o*e+n)%r,e/r}}}();r.prototype.randomSeed=function(t){n.setSeed(t),o=!0},r.prototype.random=function(t,e){var r;if(r=o?n.rand():Math.random(),0===arguments.length)return r;if(1===arguments.length)return r*t;if(t>e){var i=t;t=e,e=i}return r*(e-t)+t};var i,s=!1;return r.prototype.randomGaussian=function(t,e){var r,o,n,a;if(s)r=i,s=!1;else{do o=this.random(2)-1,n=this.random(2)-1,a=o*o+n*n;while(a>=1);a=Math.sqrt(-2*Math.log(a)/a),r=o*a,i=n*a,s=!0}var h=t||0,p=e||1;return r*p+h},r}({},core),mathnoise=function(t,e){"use strict";for(var r=e,o=4,n=1<<o,i=8,s=1<<i,a=4095,h=4,p=.5,u=.5,l=Math.floor(360/u),c=new Array(l),d=new Array(l),f=Math.PI/180,g=0;l>g;g++)c[g]=Math.sin(g*f*u),d[g]=Math.cos(g*f*u);var y=l;y>>=1;var m;return r.prototype.noise=function(t,e,r){if(e=e||0,r=r||0,null==m){m=new Array(a+1);for(var u=0;a+1>u;u++)m[u]=Math.random()}0>t&&(t=-t),0>e&&(e=-e),0>r&&(r=-r);for(var c,f,g,w,v,_=Math.floor(t),x=Math.floor(e),C=Math.floor(r),b=t-_,S=e-x,R=r-C,T=0,E=.5,M=function(t){return.5*(1-d[Math.floor(t*y)%l])},P=0;h>P;P++){var A=_+(x<<o)+(C<<i);c=M(b),f=M(S),g=m[A&a],g+=c*(m[A+1&a]-g),w=m[A+n&a],w+=c*(m[A+n+1&a]-w),g+=f*(w-g),A+=s,w=m[A&a],w+=c*(m[A+1&a]-w),v=m[A+n&a],v+=c*(m[A+n+1&a]-v),w+=f*(v-w),g+=M(R)*(w-g),T+=g*E,E*=p,_<<=1,b*=2,x<<=1,S*=2,C<<=1,R*=2,b>=1&&(_++,b--),S>=1&&(x++,S--),R>=1&&(C++,R--)}return T},r.prototype.noiseDetail=function(t,e){t>0&&(h=t),e>0&&(p=e)},r.prototype.noiseSeed=function(t){var e=function(){var t,e,r=4294967296,o=1664525,n=1013904223;return{setSeed:function(o){e=t=o||Math.round(Math.random()*r)},getSeed:function(){return t},rand:function(){return e=(o*e+n)%r,e/r}}}();e.setSeed(t),m=new Array(a+1);for(var r=0;a+1>r;r++)m[r]=e.rand()},r}({},core),mathtrigonometry=function(t,e,r,o){"use strict";var n=e,i=r,o=o;return n.prototype._angleMode=o.RADIANS,n.prototype.acos=function(t){return this._angleMode===o.RADIANS?Math.acos(t):i.radiansToDegrees(Math.acos(t))},n.prototype.asin=function(t){return this._angleMode===o.RADIANS?Math.asin(t):i.radiansToDegrees(Math.asin(t))},n.prototype.atan=function(t){return this._angleMode===o.RADIANS?Math.atan(t):i.radiansToDegrees(Math.atan(t))},n.prototype.atan2=function(t,e){return this._angleMode===o.RADIANS?Math.atan2(t,e):i.radiansToDegrees(Math.atan2(t,e))},n.prototype.cos=function(t){return Math.cos(this._angleMode===o.RADIANS?t:this.radians(t))},n.prototype.sin=function(t){return Math.sin(this._angleMode===o.RADIANS?t:this.radians(t))},n.prototype.tan=function(t){return Math.tan(this._angleMode===o.RADIANS?t:this.radians(t))},n.prototype.degrees=function(t){return i.radiansToDegrees(t)},n.prototype.radians=function(t){return i.degreesToRadians(t)},n.prototype.angleMode=function(t){(t===o.DEGREES||t===o.RADIANS)&&(this._angleMode=t)},n}({},core,polargeometry,constants),outputfiles=function(t,e){"use strict";function r(t,e){e||(e=""),t||(t="untitled");var r="";return t&&t.indexOf(".")>-1&&(r=t.split(".").pop()),e&&r!==e&&(r=e,t=t+"."+r),[t,r]}function o(t){document.body.removeChild(t.target)}var n=e;return window.URL=window.URL||window.webkitURL,n.prototype._pWriters=[],n.prototype.beginRaw=function(){throw"not yet implemented"},n.prototype.beginRecord=function(){throw"not yet implemented"},n.prototype.createOutput=function(){throw"not yet implemented"},n.prototype.createWriter=function(t,e){var r;for(var o in n.prototype._pWriters)if(n.prototype._pWriters[o].name===t)return r=new n.PrintWriter(t+window.millis(),e),n.prototype._pWriters.push(r),r;return r=new n.PrintWriter(t,e),n.prototype._pWriters.push(r),r},n.prototype.endRaw=function(){throw"not yet implemented"},n.prototype.endRecord=function(){throw"not yet implemented"},n.prototype.escape=function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")},n.PrintWriter=function(t,e){var r=this;this.name=t,this.content="",this.print=function(t){this.content+=t},this.println=function(t){this.content+=t+"\n"},this.flush=function(){this.content=""},this.close=function(){var o=[];o.push(this.content),n.prototype.writeFile(o,t,e);for(var i in n.prototype._pWriters)n.prototype._pWriters[i].name===this.name&&n.prototype._pWriters.splice(i,1);r.flush(),r={}}},n.prototype.saveBytes=function(){throw"not yet implemented"},n.prototype.save=function(){var t=arguments,e=this._curElement.elt;if(0===t.length)return void n.prototype.saveCanvas(e);if(t[0]instanceof n.Graphics)return void n.prototype.saveCanvas(t[0].elt,t[1],t[2]);if("string"==typeof t[0])n.prototype.saveCanvas(e,t[0]);else{var o=r(t[1],t[2])[1];switch(o){case"json":n.prototype.saveJSON(t[0],t[1],t[2]);break;case"txt":n.prototype.saveStrings(t[0],t[1],t[2]);break;default:t[0]instanceof Array?n.prototype.saveStrings(t[0],t[1],t[2]):t[0]instanceof n.Table?n.prototype.saveTable(t[0],t[1],t[2],t[3]):t[0]instanceof n.Image?n.prototype.saveCanvas(t[0].canvas,t[1]):t[0]instanceof n.SoundFile?n.prototype.saveSound(t[0],t[1],t[2],t[3]):t[0]instanceof Object&&n.prototype.saveJSON(t[0],t[1],t[2])}}},n.prototype.saveJSON=function(t,e,r){var o;o=r?JSON.stringify(t):JSON.stringify(t,void 0,2),this.saveStrings(o.split("\n"),e,"json")},n.prototype.saveJSONObject=n.prototype.saveJSON,n.prototype.saveJSONArray=n.prototype.saveJSON,n.prototype.saveStream=function(){throw"not yet implemented"},n.prototype.saveStrings=function(t,e,r){var o=r||"txt",n=this.createWriter(e,o);for(var i in t)i<t.length-1?n.println(t[i]):n.print(t[i]);n.close(),n.flush()},n.prototype.saveXML=function(){throw"not yet implemented"},n.prototype.selectOutput=function(){throw"not yet implemented"},n.prototype.saveTable=function(t,e,r){var o=this.createWriter(e,r),i=t.columns,s=",";if("tsv"===r&&(s=" "),"html"!==r){if("0"!==i[0])for(var a=0;a<i.length;a++)a<i.length-1?o.print(i[a]+s):o.println(i[a]);for(var h=0;h<t.rows.length;h++){var p;for(p=0;p<t.rows[h].arr.length;p++)p<t.rows[h].arr.length-1?o.print(t.rows[h].arr[p]+s):h<t.rows.length-1?o.println(t.rows[h].arr[p]):o.print(t.rows[h].arr[p])
}}else{o.println("<html>"),o.println("<head>");var u=' <meta http-equiv="content-type" content';if(u+='="text/html;charset=utf-8" />',o.println(u),o.println("</head>"),o.println("<body>"),o.println(" <table>"),"0"!==i[0]){o.println(" <tr>");for(var l=0;l<i.length;l++){var c=n.prototype.escape(i[l]);o.println(" <td>"+c),o.println(" </td>")}o.println(" </tr>")}for(var d=0;d<t.rows.length;d++){o.println(" <tr>");for(var f=0;f<t.columns.length;f++){var g=t.rows[d].getString(f),y=n.prototype.escape(g);o.println(" <td>"+y),o.println(" </td>")}o.println(" </tr>")}o.println(" </table>"),o.println("</body>"),o.print("</html>")}o.close(),o.flush()},n.prototype.writeFile=function(t,e,r){var o="application/octet-stream";n.prototype._isSafari()&&(o="text/plain");var i=new Blob(t,{type:o}),s=window.URL.createObjectURL(i);n.prototype.downloadFile(s,e,r)},n.prototype.downloadFile=function(t,e,i){var s=r(e,i),a=s[0],h=s[1],p=document.createElement("a");if(p.href=t,p.download=a,p.onclick=o,p.style.display="none",document.body.appendChild(p),n.prototype._isSafari()){var u="Hello, Safari user! To download this file...\n";u+="1. Go to File --> Save As.\n",u+='2. Choose "Page Source" as the Format.\n',u+='3. Name it with this extension: ."'+h+'"',alert(u)}p.click(),t=null},n.prototype._checkFileExtension=r,n.prototype._isSafari=function(){var t=Object.prototype.toString.call(window.HTMLElement);return t.indexOf("Constructor")>0},n}({},core),outputimage=function(t,e){"use strict";var r=e,o=[];return r.prototype.saveCanvas=function(t,e,o){o||(o=r.prototype._checkFileExtension(e,o)[1],""===o&&(o="png"));var n;if(t?n=t:this._curElement&&this._curElement.elt&&(n=this._curElement.elt),r.prototype._isSafari()){var i="Hello, Safari user!\n";i+="Now capturing a screenshot...\n",i+="To save this image,\n",i+="go to File --> Save As.\n",alert(i),window.location.href=n.toDataURL()}else{var s;if("undefined"==typeof o)o="png",s="image/png";else switch(o){case"png":s="image/png";break;case"jpeg":s="image/jpeg";break;case"jpg":s="image/jpeg";break;default:s="image/png"}var a="image/octet-stream",h=n.toDataURL(s);h=h.replace(s,a),r.prototype.downloadFile(h,e,o)}},r.prototype.saveFrames=function(t,e,n,i,s){var a=n||3;a=r.prototype.constrain(a,0,15),a=1e3*a;var h=i||15;h=r.prototype.constrain(h,0,22);var p=0,u=r.prototype._makeFrame,l=this._curElement.elt,c=setInterval(function(){u(t+p,e,l),p++},1e3/h);setTimeout(function(){if(clearInterval(c),s)s(o);else for(var t=0;t<o.length;t++){var e=o[t];r.prototype.downloadFile(e.imageData,e.filename,e.ext)}o=[]},a+.01)},r.prototype._makeFrame=function(t,e,r){var n;n=this?this._curElement.elt:r;var i;if(e)switch(e.toLowerCase()){case"png":i="image/png";break;case"jpeg":i="image/jpeg";break;case"jpg":i="image/jpeg";break;default:i="image/png"}else e="png",i="image/png";var s="image/octet-stream",a=n.toDataURL(i);a=a.replace(i,s);var h={};h.imageData=a,h.filename=t,h.ext=e,o.push(h)},r}({},core),outputtext_area=function(t,e){"use strict";var r=e;return r.prototype.print=window.console&&console.log?console.log.bind(console):function(){},r.prototype.println=r.prototype.print,r}({},core),renderingrendering=function(t,e,r){var o=e,r=r;return o.prototype.createCanvas=function(t,e,r){var n;return r?(n=document.createElement("canvas"),n.id="defaultCanvas"):n=this.canvas,this._setupDone||(n.className+=" p5_hidden",n.style.visibility="hidden"),this._userNode?this._userNode.appendChild(n):document.body.appendChild(n),this._defaultGraphics||(this._defaultGraphics=new o.Graphics(n,this,!0),this._elements.push(this._defaultGraphics)),this._defaultGraphics.resize(t,e),this._defaultGraphics._applyDefaults(),this._defaultGraphics},o.prototype.resizeCanvas=function(t,e){this._defaultGraphics&&(this._defaultGraphics.resize(t,e),this._defaultGraphics._applyDefaults(),this.redraw())},o.prototype.noCanvas=function(){this.canvas&&this.canvas.parentNode.removeChild(this.canvas)},o.prototype.createGraphics=function(t,e){var r=document.createElement("canvas"),n=this._userNode||document.body;n.appendChild(r);var i=new o.Graphics(r,this,!1);this._elements.push(i);for(var s in o.prototype)i.hasOwnProperty(s)||(i[s]="function"==typeof o.prototype[s]?o.prototype[s].bind(i):o.prototype[s]);return i.resize(t,e),i._applyDefaults(),i},o.prototype.blendMode=function(t){if(t!==r.BLEND&&t!==r.DARKEST&&t!==r.LIGHTEST&&t!==r.DIFFERENCE&&t!==r.MULTIPLY&&t!==r.EXCLUSION&&t!==r.SCREEN&&t!==r.REPLACE&&t!==r.OVERLAY&&t!==r.HARD_LIGHT&&t!==r.SOFT_LIGHT&&t!==r.DODGE&&t!==r.BURN&&t!==r.ADD&&t!==r.NORMAL)throw new Error("Mode "+t+" not recognized.");this.drawingContext.globalCompositeOperation=t},o}({},core,constants),shape2d_primitives=function(t,e,r,o){"use strict";var n=e,r=r,o=o;return n.prototype.arc=function(t,e,n,i,s,a,h){if(this._doStroke||this._doFill){this._angleMode===o.DEGREES&&(s=this.radians(s),a=this.radians(a));var p=this.drawingContext,u=r.arcModeAdjust(t,e,n,i,this._ellipseMode),l=u.h>u.w?u.h/2:u.w/2,c=u.h>u.w?u.w/u.h:1,d=u.h>u.w?1:u.h/u.w;return p.scale(c,d),p.beginPath(),p.arc(u.x,u.y,l,s,a),this._doStroke&&p.stroke(),h===o.CHORD||h===o.OPEN?p.closePath():(h===o.PIE||void 0===h)&&(p.lineTo(u.x,u.y),p.closePath()),this._doFill&&p.fill(),this._doStroke&&h!==o.OPEN&&void 0!==h&&p.stroke(),this}},n.prototype.ellipse=function(t,e,o,n){if(this._doStroke||this._doFill){o=Math.abs(o),n=Math.abs(n);var i=this.drawingContext,s=r.modeAdjust(t,e,o,n,this._ellipseMode);if(i.beginPath(),o===n)i.arc(s.x+s.w/2,s.y+s.w/2,s.w/2,0,2*Math.PI,!1);else{var a=.5522848,h=s.w/2*a,p=s.h/2*a,u=s.x+s.w,l=s.y+s.h,c=s.x+s.w/2,d=s.y+s.h/2;i.moveTo(s.x,d),i.bezierCurveTo(s.x,d-p,c-h,s.y,c,s.y),i.bezierCurveTo(c+h,s.y,u,d-p,u,d),i.bezierCurveTo(u,d+p,c+h,l,c,l),i.bezierCurveTo(c-h,l,s.x,d+p,s.x,d),i.closePath()}return this._doFill&&i.fill(),this._doStroke&&i.stroke(),this}},n.prototype.line=function(t,e,r,o){if(this._doStroke){var n=this.drawingContext;if("rgba(0,0,0,0)"!==n.strokeStyle)return n.beginPath(),n.moveTo(t,e),n.lineTo(r,o),n.stroke(),this}},n.prototype.point=function(t,e){if(this._doStroke){var r=this.drawingContext,n=r.strokeStyle,i=r.fillStyle;if("rgba(0,0,0,0)"!==n)return t=Math.round(t),e=Math.round(e),r.fillStyle=n,r.lineWidth>1?(r.beginPath(),r.arc(t,e,r.lineWidth/2,0,o.TWO_PI,!1),r.fill()):r.fillRect(t,e,1,1),r.fillStyle=i,this}},n.prototype.quad=function(t,e,r,o,n,i,s,a){if(this._doStroke||this._doFill){var h=this.drawingContext;return h.beginPath(),h.moveTo(t,e),h.lineTo(r,o),h.lineTo(n,i),h.lineTo(s,a),h.closePath(),this._doFill&&h.fill(),this._doStroke&&h.stroke(),this}},n.prototype.rect=function(t,e,o,n){if(this._doStroke||this._doFill){var i=r.modeAdjust(t,e,o,n,this._rectMode),s=this.drawingContext;return this._doStroke&&s.lineWidth%2===1&&s.translate(.5,.5),s.beginPath(),s.rect(i.x,i.y,i.w,i.h),this._doFill&&s.fill(),this._doStroke&&s.stroke(),this._doStroke&&s.lineWidth%2===1&&s.translate(-.5,-.5),this}},n.prototype.triangle=function(t,e,r,o,n,i){if(this._doStroke||this._doFill){var s=this.drawingContext;return s.beginPath(),s.moveTo(t,e),s.lineTo(r,o),s.lineTo(n,i),s.closePath(),this._doFill&&s.fill(),this._doStroke&&s.stroke(),this}},n}({},core,canvas,constants),shapeattributes=function(t,e,r){"use strict";var o=e,r=r;return o.prototype._rectMode=r.CORNER,o.prototype._ellipseMode=r.CENTER,o.prototype.ellipseMode=function(t){return(t===r.CORNER||t===r.CORNERS||t===r.RADIUS||t===r.CENTER)&&(this._ellipseMode=t),this},o.prototype.noSmooth=function(){return this.drawingContext.mozImageSmoothingEnabled=!1,this.drawingContext.webkitImageSmoothingEnabled=!1,this},o.prototype.rectMode=function(t){return(t===r.CORNER||t===r.CORNERS||t===r.RADIUS||t===r.CENTER)&&(this._rectMode=t),this},o.prototype.smooth=function(){return this.drawingContext.mozImageSmoothingEnabled=!0,this.drawingContext.webkitImageSmoothingEnabled=!0,this},o.prototype.strokeCap=function(t){return(t===r.ROUND||t===r.SQUARE||t===r.PROJECT)&&(this.drawingContext.lineCap=t),this},o.prototype.strokeJoin=function(t){return(t===r.ROUND||t===r.BEVEL||t===r.MITER)&&(this.drawingContext.lineJoin=t),this},o.prototype.strokeWeight=function(t){return this.drawingContext.lineWidth="undefined"==typeof t||0===t?1e-4:t,this},o}({},core,constants),shapecurves=function(t,e){"use strict";var r=e,o=20,n=20;return r.prototype._curveTightness=0,r.prototype.bezier=function(t,e,r,o,n,i,s,a){return this._doStroke?(this.beginShape(),this.vertex(t,e),this.bezierVertex(r,o,n,i,s,a),this.endShape(),this.stroke(),this):void 0},r.prototype.bezierDetail=function(t){return o=t,this},r.prototype.bezierPoint=function(t,e,r,o,n){var i=1-n;return Math.pow(i,3)*t+3*Math.pow(i,2)*n*e+3*i*Math.pow(n,2)*r+Math.pow(n,3)*o},r.prototype.bezierTangent=function(t,e,r,o,n){var i=1-n;return 3*o*Math.pow(n,2)-3*r*Math.pow(n,2)+6*r*i*n-6*e*i*n+3*e*Math.pow(i,2)-3*t*Math.pow(i,2)},r.prototype.curve=function(t,e,r,o,n,i,s,a){return this._doStroke?(this.beginShape(),this.curveVertex(t,e),this.curveVertex(r,o),this.curveVertex(n,i),this.curveVertex(s,a),this.endShape(),this.stroke(),this):void 0},r.prototype.curveDetail=function(t){return n=t,this},r.prototype.curveTightness=function(t){this._setProperty("_curveTightness",t)},r.prototype.curvePoint=function(t,e,r,o,n){var i=n*n*n,s=n*n,a=-.5*i+s-.5*n,h=1.5*i-2.5*s+1,p=-1.5*i+2*s+.5*n,u=.5*i-.5*s;return t*a+e*h+r*p+o*u},r.prototype.curveTangent=function(t,e,r,o,n){var i=n*n,s=-3*i/2+2*n-.5,a=9*i/2-5*n,h=-9*i/2+4*n+.5,p=3*i/2-n;return t*s+e*a+r*h+o*p},r.prototype.curveTightness=function(){throw"not yet implemented"},r}({},core),shapevertex=function(t,e,r){"use strict";var o=e,r=r,n=null,i=[],s=[],a=!1,h=!1,p=!1,u=!1;return o.prototype._doFillStrokeClose=function(){this._doFill&&this.drawingContext.fill(),this._doStroke&&this.drawingContext.stroke(),this.drawingContext.closePath()},o.prototype.beginContour=function(){return s=[],u=!0,this},o.prototype.beginShape=function(t){return n=t===r.POINTS||t===r.LINES||t===r.TRIANGLES||t===r.TRIANGLE_FAN||t===r.TRIANGLE_STRIP||t===r.QUADS||t===r.QUAD_STRIP?t:null,i=[],s=[],this},o.prototype.bezierVertex=function(){if(0===i.length)throw"vertex() must be used once before calling bezierVertex()";a=!0;for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.isVert=!1,u?s.push(t):i.push(t),this},o.prototype.curveVertex=function(t,e){return h=!0,this.vertex(t,e),this},o.prototype.endContour=function(){var t=s[0].slice();t.isVert=s[0].isVert,t.moveTo=!1,s.push(t),i.push(i[0]);for(var e=0;e<s.length;e++)i.push(s[e]);return this},o.prototype.endShape=function(t){if(0===i.length)return this;if(!this._doStroke&&!this._doFill)return this;var e,o=t===r.CLOSE;o&&!u&&i.push(i[0]);var s,l,c=i.length;if(!h||n!==r.POLYGON&&null!==n)if(!a||n!==r.POLYGON&&null!==n)if(!p||n!==r.POLYGON&&null!==n)if(n===r.POINTS)for(s=0;c>s;s++)e=i[s],this._doStroke&&this.stroke(e[6]),this.point(e[0],e[1]);else if(n===r.LINES)for(s=0;c>s+1;s+=2)e=i[s],this._doStroke&&this.stroke(i[s+1][6]),this.line(e[0],e[1],i[s+1][0],i[s+1][1]);else if(n===r.TRIANGLES)for(s=0;c>s+2;s+=3)e=i[s],this.drawingContext.beginPath(),this.drawingContext.moveTo(e[0],e[1]),this.drawingContext.lineTo(i[s+1][0],i[s+1][1]),this.drawingContext.lineTo(i[s+2][0],i[s+2][1]),this.drawingContext.lineTo(e[0],e[1]),this._doFill&&(this.fill(i[s+2][5]),this.drawingContext.fill()),this._doStroke&&(this.stroke(i[s+2][6]),this.drawingContext.stroke()),this.drawingContext.closePath();else if(n===r.TRIANGLE_STRIP)for(s=0;c>s+1;s++)e=i[s],this.drawingContext.beginPath(),this.drawingContext.moveTo(i[s+1][0],i[s+1][1]),this.drawingContext.lineTo(e[0],e[1]),this._doStroke&&this.stroke(i[s+1][6]),this._doFill&&this.fill(i[s+1][5]),c>s+2&&(this.drawingContext.lineTo(i[s+2][0],i[s+2][1]),this._doStroke&&this.stroke(i[s+2][6]),this._doFill&&this.fill(i[s+2][5])),this._doFillStrokeClose();else if(n===r.TRIANGLE_FAN){if(c>2)for(this.drawingContext.beginPath(),this.drawingContext.moveTo(i[0][0],i[0][1]),this.drawingContext.lineTo(i[1][0],i[1][1]),this.drawingContext.lineTo(i[2][0],i[2][1]),this._doFill&&this.fill(i[2][5]),this._doStroke&&this.stroke(i[2][6]),this._doFillStrokeClose(),s=3;c>s;s++)e=i[s],this.drawingContext.beginPath(),this.drawingContext.moveTo(i[0][0],i[0][1]),this.drawingContext.lineTo(i[s-1][0],i[s-1][1]),this.drawingContext.lineTo(e[0],e[1]),this._doFill&&this.fill(e[5]),this._doStroke&&this.stroke(e[6]),this._doFillStrokeClose()}else if(n===r.QUADS)for(s=0;c>s+3;s+=4){for(e=i[s],this.drawingContext.beginPath(),this.drawingContext.moveTo(e[0],e[1]),l=1;4>l;l++)this.drawingContext.lineTo(i[s+l][0],i[s+l][1]);this.drawingContext.lineTo(e[0],e[1]),this._doFill&&this.fill(i[s+3][5]),this._doStroke&&this.stroke(i[s+3][6]),this._doFillStrokeClose()}else if(n===r.QUAD_STRIP){if(c>3)for(s=0;c>s+1;s+=2)e=i[s],this.drawingContext.beginPath(),c>s+3?(this.drawingContext.moveTo(i[s+2][0],i[s+2][1]),this.drawingContext.lineTo(e[0],e[1]),this.drawingContext.lineTo(i[s+1][0],i[s+1][1]),this.drawingContext.lineTo(i[s+3][0],i[s+3][1]),this._doFill&&this.fill(i[s+3][5]),this._doStroke&&this.stroke(i[s+3][6])):(this.drawingContext.moveTo(e[0],e[1]),this.drawingContext.lineTo(i[s+1][0],i[s+1][1])),this._doFillStrokeClose()}else{for(this.drawingContext.beginPath(),this.drawingContext.moveTo(i[0][0],i[0][1]),s=1;c>s;s++)e=i[s],e.isVert&&(e.moveTo?this.drawingContext.moveTo(e[0],e[1]):this.drawingContext.lineTo(e[0],e[1]));this._doFillStrokeClose()}else{for(this.drawingContext.beginPath(),s=0;c>s;s++)i[s].isVert?i[s].moveTo?this.drawingContext.moveTo([0],i[s][1]):this.drawingContext.lineTo(i[s][0],i[s][1]):this.drawingContext.quadraticCurveTo(i[s][0],i[s][1],i[s][2],i[s][3]);this._doFillStrokeClose()}else{for(this.drawingContext.beginPath(),s=0;c>s;s++)i[s].isVert?i[s].moveTo?this.drawingContext.moveTo(i[s][0],i[s][1]):this.drawingContext.lineTo(i[s][0],i[s][1]):this.drawingContext.bezierCurveTo(i[s][0],i[s][1],i[s][2],i[s][3],i[s][4],i[s][5]);this._doFillStrokeClose()}else if(c>3){var d=[],f=1-this._curveTightness;for(this.drawingContext.beginPath(),this.drawingContext.moveTo(i[1][0],i[1][1]),s=1;c>s+2;s++)e=i[s],d[0]=[e[0],e[1]],d[1]=[e[0]+(f*i[s+1][0]-f*i[s-1][0])/6,e[1]+(f*i[s+1][1]-f*i[s-1][1])/6],d[2]=[i[s+1][0]+(f*i[s][0]-f*i[s+2][0])/6,i[s+1][1]+(f*i[s][1]-f*i[s+2][1])/6],d[3]=[i[s+1][0],i[s+1][1]],this.drawingContext.bezierCurveTo(d[1][0],d[1][1],d[2][0],d[2][1],d[3][0],d[3][1]);this._doFillStrokeClose()}return h=!1,a=!1,p=!1,u=!1,o&&i.pop(),this},o.prototype.quadraticVertex=function(t,e,o,n){if(this._contourInited){var a={};return a.x=t,a.y=e,a.x3=o,a.y3=n,a.type=r.QUADRATIC,this._contourVertices.push(a),this}if(!(i.length>0))throw"vertex() must be used once before calling quadraticVertex()";p=!0;for(var h=[],l=0;l<arguments.length;l++)h[l]=arguments[l];return h.isVert=!1,u?s.push(h):i.push(h),this},o.prototype.vertex=function(t,e,r){var o=[];return o.isVert=!0,o[0]=t,o[1]=e,o[2]=0,o[3]=0,o[4]=0,o[5]=this.drawingContext.fillStyle,o[6]=this.drawingContext.strokeStyle,r&&(o.moveTo=r),u?(0===s.length&&(o.moveTo=!0),s.push(o)):i.push(o),this},o}({},core,constants),structure=function(t,e){"use strict";var r=e;return r.prototype.exit=function(){throw"exit() not implemented, see remove()"},r.prototype.noLoop=function(){this._loop=!1,this._drawInterval&&clearInterval(this._drawInterval)},r.prototype.loop=function(){this._loop=!0,this._draw()},r.prototype.push=function(){this.drawingContext.save(),this._styles.push({doStroke:this._doStroke,doFill:this._doFill,tint:this._tint,imageMode:this._imageMode,rectMode:this._rectMode,ellipseMode:this._ellipseMode,colorMode:this._colorMode,textFont:this.textFont,textLeading:this.textLeading,textSize:this.textSize,textStyle:this.textStyle})},r.prototype.pop=function(){this.drawingContext.restore();var t=this._styles.pop();this._doStroke=t.doStroke,this._doFill=t.doFill,this._tint=t.tint,this._imageMode=t.imageMode,this._rectMode=t.rectMode,this._ellipseMode=t.ellipseMode,this._colorMode=t.colorMode,this.textFont=t.textFont,this.textLeading=t.textLeading,this.textSize=t.textSize,this.textStyle=t.textStyle},r.prototype.pushStyle=function(){throw new Error("pushStyle() not used, see push()")},r.prototype.popStyle=function(){throw new Error("popStyle() not used, see pop()")},r.prototype.redraw=function(){var t=this._isGlobal?window:this;t.draw&&t.draw()},r.prototype.size=function(){throw"size() not implemented, see createCanvas()"},r}({},core),transform=function(t,e,r){"use strict";var o=e,r=r;return o.prototype.applyMatrix=function(t,e,r,o,n,i){return this.drawingContext.transform(t,e,r,o,n,i),this},o.prototype.popMatrix=function(){throw new Error("popMatrix() not used, see pop()")},o.prototype.printMatrix=function(){throw new Error("printMatrix() not implemented")},o.prototype.pushMatrix=function(){throw new Error("pushMatrix() not used, see push()")},o.prototype.resetMatrix=function(){return this.drawingContext.setTransform(),this},o.prototype.rotate=function(t){return this._angleMode===r.DEGREES&&(t=this.radians(t)),this.drawingContext.rotate(t),this},o.prototype.rotateX=function(){throw"not yet implemented"},o.prototype.rotateY=function(){throw"not yet implemented"},o.prototype.scale=function(){var t=1,e=1;return 1===arguments.length?t=e=arguments[0]:(t=arguments[0],e=arguments[1]),this.drawingContext.scale(t,e),this},o.prototype.shearX=function(t){return this._angleMode===r.DEGREES&&(t=this.radians(t)),this.drawingContext.transform(1,0,this.tan(t),1,0,0),this},o.prototype.shearY=function(t){return this._angleMode===r.DEGREES&&(t=this.radians(t)),this.drawingContext.transform(1,this.tan(t),0,1,0,0),this},o.prototype.translate=function(t,e){return this.drawingContext.translate(t,e),this},o}({},core,constants,outputtext_area),typographyattributes=function(t,e,r){"use strict";var o=e,r=r;return o.prototype._textLeading=15,o.prototype._textFont="sans-serif",o.prototype._textSize=12,o.prototype._textStyle=r.NORMAL,o.prototype._textAscent=null,o.prototype._textDescent=null,o.prototype.textAlign=function(t){(t===r.LEFT||t===r.RIGHT||t===r.CENTER)&&(this.drawingContext.textAlign=t)},o.prototype.textLeading=function(t){this._setProperty("_textLeading",t)},o.prototype.textSize=function(t){this._setProperty("_textSize",t),this._applyTextProperties()},o.prototype.textStyle=function(t){(t===r.NORMAL||t===r.ITALIC||t===r.BOLD)&&(this._setProperty("_textStyle",t),this._applyTextProperties())},o.prototype.textWidth=function(t){return this.drawingContext.measureText(t).width},o.prototype.textAscent=function(){return null==this._textAscent&&this._updateTextMetrics(),this._textAscent},o.prototype.textDescent=function(){return null==this._textDescent&&this._updateTextMetrics(),this._textDescent},o.prototype._applyTextProperties=function(){this._setProperty("_textAscent",null),this._setProperty("_textDescent",null);var t=this._textStyle+" "+this._textSize+"px "+this._textFont;this.drawingContext.font=t},o.prototype._updateTextMetrics=function(){var t=document.createElement("span");t.style.fontFamily=this._textFont,t.style.fontSize=this._textSize+"px",t.innerHTML="ABCjgq|";var e=document.createElement("div");e.style.display="inline-block",e.style.width="1px",e.style.height="0px";var r=document.createElement("div");r.appendChild(t),r.appendChild(e),r.style.height="0px",r.style.overflow="hidden",document.body.appendChild(r),e.style.verticalAlign="baseline";var o=this._calculateOffset(e),n=this._calculateOffset(t),i=o[1]-n[1];e.style.verticalAlign="bottom",o=this._calculateOffset(e),n=this._calculateOffset(t);var s=o[1]-n[1],a=s-i;document.body.removeChild(r),this._setProperty("_textAscent",i),this._setProperty("_textDescent",a)},o.prototype._calculateOffset=function(t){var e=0,r=0;if(t.offsetParent){do e+=t.offsetLeft,r+=t.offsetTop;while(t=t.offsetParent)}else e+=t.offsetLeft,r+=t.offsetTop;return[e,r]},o}({},core,constants),typographyloading_displaying=function(t,e,r){"use strict";var o=e,r=r;return o.prototype.text=function(){if(3===arguments.length)this._doFill&&this.drawingContext.fillText(arguments[0],arguments[1],arguments[2]),this._doStroke&&this.drawingContext.strokeText(arguments[0],arguments[1],arguments[2]);else if(5===arguments.length){for(var t=arguments[0].split(" "),e="",o=r.modeAdjust(arguments[1],arguments[2],arguments[3],arguments[4],this._rectMode),n=o.y+this._textLeading,i=0;i<t.length;i++){var s=e+t[i]+" ",a=this.drawingContext.measureText(s),h=a.width;if(n>o.y+o.h)break;h>o.w&&i>0?(this._doFill&&this.drawingContext.fillText(e,o.x,n),this._doStroke&&this.drawingContext.strokeText(e,o.x,n),e=t[i]+" ",n+=this._textLeading):e=s}n<=o.y+o.h&&(this._doFill&&this.drawingContext.fillText(e,o.x,n),this._doStroke&&this.drawingContext.strokeText(e,o.x,n))}},o.prototype.textFont=function(t){this._setProperty("_textFont",t),this._applyTextProperties()},o}({},core,canvas),src_app=function(t,e){"use strict";var r=e,o=function(){window.PHANTOMJS||(window.setup&&"function"==typeof window.setup||window.draw&&"function"==typeof window.draw)&&new r};return"complete"===document.readyState?o():window.addEventListener("load",o,!1),window.p5=r,r}({},core,p5Color,p5Element,p5Graphics,p5Image,p5Vector,p5TableRow,p5Table,colorcreating_reading,colorsetting,constants,dataconversion,dataarray_functions,datastring_functions,environment,imageimage,imageloading_displaying,imagepixels,inputfiles,inputkeyboard,inputmouse,inputtime_date,inputtouch,mathmath,mathcalculation,mathrandom,mathnoise,mathtrigonometry,outputfiles,outputimage,outputtext_area,renderingrendering,shape2d_primitives,shapeattributes,shapecurves,shapevertex,structure,transform,typographyattributes,typographyloading_displaying);
column1 column2
26 111
56 87
47 47
87 41
9 88
97 4
4 66
89 34
41 32
15 22
44 81
43 87
62 26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment