├── .DS_Store
├── addons
├── .DS_Store
├── p5.dom.js
├── p5.sound.js
└── p5.svg.js
├── empty-example
├── .DS_Store
├── index.html
└── sketch.js
├── p5.js
└── p5.min.js
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/runemadsen/p5-svg-test/5d7935461d1dfc3439ca3298b71c3132a40bc542/.DS_Store
--------------------------------------------------------------------------------
/addons/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/runemadsen/p5-svg-test/5d7935461d1dfc3439ca3298b71c3132a40bc542/addons/.DS_Store
--------------------------------------------------------------------------------
/addons/p5.dom.js:
--------------------------------------------------------------------------------
1 | /*! p5.dom.js v0.1.0 August 6, 2014 */
2 | /**
3 | *
The web is much more than just canvas and p5.dom makes it easy to interact
4 | * with other HTML5 objects, including text, hyperlink, image, input, video,
5 | * audio, and webcam.
6 | * There are a set of creation methods, and some other stuff... @TODO.
7 | *
8 | * Methods and properties shown in black are part of the p5.js core, items in
9 | * blue are part of the p5.dom library. See the
10 | * using a library
11 | * section for information on how to include this library. p5.dom comes with
12 | * p5 complete or you can download the single file
13 | *
14 | * here.
15 | *
16 | *
17 | * @module p5.dom
18 | * @submodule p5.dom
19 | * @for p5.dom
20 | * @main
21 | */
22 |
23 | var p5DOM = (function(){
24 |
25 | // =============================================================================
26 | // p5 additions
27 | // =============================================================================
28 |
29 | /**
30 | * Searches the page for an element with given ID and returns it as
31 | * a p5.Element. The DOM node itself can be accessed with .elt.
32 | * Returns null if none found.
33 | *
34 | * @method getElement
35 | * @param {String} id id of element to search for
36 | * @return {Object/p5.Element|Null} p5.Element containing node found
37 | */
38 | p5.prototype.getElement = function (e) {
39 | var res = document.getElementById(e);
40 | if (res) {
41 | return new p5.Element(res);
42 | } else {
43 | return null;
44 | }
45 | };
46 |
47 | /**
48 | * Searches the page for elements with given class and returns an
49 | * array of p5.Elements. The DOM nodes themselves can be accessed
50 | * with .elt. Returns an empty array if none found.
51 | *
52 | * @method getElements
53 | * @param {String} class class name of elements to search for
54 | * @return {Array} array of p5.Element wrapped nodes found
55 | */
56 | p5.prototype.getElements = function (e) {
57 | var arr = [];
58 | var res = document.getElementsByClassName(e);
59 | if (res) {
60 | for (var j = 0; j < res.length; j++) {
61 | var obj = new p5.Element(res[j]);
62 | arr.push(obj);
63 | }
64 | }
65 | return arr;
66 | };
67 |
68 | /**
69 | * Removes all elements created by p5, except any canvas / graphics
70 | * elements created by createCanvas or createGraphics.
71 | * Event handlers are removed, and element is removed from the DOM.
72 | *
73 | * @method removeElements
74 | */
75 | p5.prototype.removeElements = function (e) {
76 | for (var i=0; i 0) {
511 | this.elt.value = arguments[0];
512 | } else {
513 | if (this.elt.type === 'range') {
514 | return parseFloat(this.elt.value);
515 | }
516 | else return this.elt.value;
517 | }
518 | };
519 |
520 | /**
521 | *
522 | * Shows the current element. Essentially, setting display:block for the style.
523 | *
524 | * @method show
525 | */
526 | p5.Element.prototype.show = function() {
527 | this.elt.style.display = 'block';
528 | };
529 |
530 | /**
531 | * Hides the current element. Essentially, setting display:none for the style.
532 | *
533 | * @method hide
534 | */
535 | p5.Element.prototype.hide = function() {
536 | this.elt.style.display = 'none';
537 | };
538 |
539 | /**
540 | *
541 | * Sets the width and height of the element. AUTO can be used to
542 | * only adjust one dimension.
543 | *
544 | * @method size
545 | * @param {Number} w width of the element
546 | * @param {Number} h height of the element
547 | */
548 | p5.Element.prototype.size = function(w, h) {
549 | var aW = w;
550 | var aH = h;
551 | var AUTO = p5.prototype.AUTO;
552 |
553 | if (aW !== AUTO || aH !== AUTO) {
554 | if (aW === AUTO) {
555 | aW = h * this.elt.width / this.elt.height;
556 | } else if (aH === AUTO) {
557 | aH = w * this.elt.height / this.elt.width;
558 | }
559 | // set diff for cnv vs normal div
560 | if (this.elt instanceof HTMLCanvasElement) {
561 | this.elt.setAttribute('width', aW * this._pInst._pixelDensity);
562 | this.elt.setAttribute('height', aH * this._pInst._pixelDensity);
563 | this.elt.setAttribute('style', 'width:' + aW + 'px !important; height:' + aH + 'px !important;');
564 | } else {
565 | this.elt.style.width = aW+'px';
566 | this.elt.style.height = aH+'px';
567 | }
568 | this.width = this.elt.offsetWidth;
569 | this.height = this.elt.offsetHeight;
570 | if (this._pInst) { // main canvas associated with p5 instance
571 | if (this._pInst._curElement.elt === this.elt) {
572 | this._pInst._setProperty('width', this.elt.offsetWidth);
573 | this._pInst._setProperty('height', this.elt.offsetHeight);
574 | }
575 | }
576 | }
577 | };
578 |
579 | /**
580 | * Removes the element and deregisters all listeners.
581 | *
582 | * @method remove
583 | */
584 | p5.Element.prototype.remove = function() {
585 | // deregister events
586 | for (var ev in this._events) {
587 | this.elt.removeEventListener(ev, this._events[ev]);
588 | }
589 | if (this.elt.parentNode) {
590 | this.elt.parentNode.removeChild(this.elt);
591 | }
592 | delete(this);
593 | };
594 |
595 |
596 |
597 | // =============================================================================
598 | // p5.MediaElement additions
599 | // =============================================================================
600 |
601 |
602 | /**
603 | * Extends p5.Element to handle audio and video. In addition to the methods
604 | * of p5.Element, it also contains methods for controlling media. It is not
605 | * called directly, but p5.MediaElements are created by calling createVideo,
606 | * createAudio, and createCapture.
607 | *
608 | * @class p5.MediaElement
609 | * @constructor
610 | * @param {String} elt DOM node that is wrapped
611 | * @param {Object} [pInst] pointer to p5 instance
612 | */
613 | p5.MediaElement = function(elt, pInst) {
614 | p5.Element.call(this, elt, pInst);
615 | };
616 | p5.MediaElement.prototype = Object.create(p5.Element.prototype);
617 |
618 |
619 |
620 |
621 | /**
622 | * Play an HTML5 media element.
623 | *
624 | * @method play
625 | */
626 | p5.MediaElement.prototype.play = function() {
627 | if (this.elt.currentTime === this.elt.duration) {
628 | this.elt.currentTime = 0;
629 | }
630 | this.elt.play();
631 | };
632 |
633 | /**
634 | * Stops an HTML5 media element (sets current time to zero).
635 | *
636 | * @method stop
637 | */
638 | p5.MediaElement.prototype.stop = function() {
639 | this.elt.pause();
640 | this.elt.currentTime = 0;
641 | };
642 |
643 | /**
644 | * Pauses an HTML5 media element.
645 | *
646 | * @method pause
647 | */
648 | p5.MediaElement.prototype.pause = function() {
649 | this.elt.pause();
650 | };
651 |
652 | /**
653 | * Set 'loop' to true for an HTML5 media element, and starts playing.
654 | *
655 | * @method loop
656 | */
657 | p5.MediaElement.prototype.loop = function() {
658 | this.elt.setAttribute('loop', true);
659 | this.play();
660 | };
661 | /**
662 | * Set 'loop' to false for an HTML5 media element. Element will stop
663 | * when it reaches the end.
664 | *
665 | * @method noLoop
666 | */
667 | p5.MediaElement.prototype.noLoop = function() {
668 | this.elt.setAttribute('loop', false);
669 | };
670 |
671 |
672 | /**
673 | * Set HTML5 media element to autoplay or not.
674 | *
675 | * @method autoplay
676 | * @param {Boolean} autoplay whether the element should autoplay
677 | */
678 | p5.MediaElement.prototype.autoplay = function(val) {
679 | this.elt.setAttribute('autoplay', val);
680 | };
681 |
682 | /**
683 | * Sets volume for this HTML5 media element. If no argument is given,
684 | * returns the current volume;
685 | *
686 | * @param {Number} [val] volume between 0.0 and 1.0
687 | * @return {Number} current volume
688 | * @method volume
689 | */
690 | p5.MediaElement.prototype.volume = function(val) {
691 | if (typeof val === 'undefined') {
692 | return this.elt.volume;
693 | } else {
694 | this.elt.volume = val;
695 | }
696 | };
697 |
698 | /**
699 | * If no arguments are given, returns the current time of the elmeent.
700 | * If an argument is given the current time of the element is set to it.
701 | *
702 | * @method time
703 | * @param {Number} [time] time to jump to (in seconds)
704 | * @return {Number} current time (in seconds)
705 | */
706 | p5.MediaElement.prototype.time = function(val) {
707 | if (typeof val === 'undefined') {
708 | return this.elt.currentTime;
709 | } else {
710 | this.elt.currentTime = val;
711 | }
712 | };
713 |
714 | /**
715 | * Returns the duration of the HTML5 media element.
716 | *
717 | * @method duration
718 | * @return {Number} duration
719 | */
720 | p5.MediaElement.prototype.duration = function() {
721 | return this.elt.duration;
722 | };
723 | p5.MediaElement.prototype.stop = function() {
724 | this.elt.pause();
725 | this.elt.currentTime = 0;
726 | };
727 | p5.MediaElement.prototype.pixels = [];
728 | p5.MediaElement.prototype.loadPixels = function() {
729 | if (this.loadedmetadata) { // wait for metadata for w/h
730 | if (!this.canvas) {
731 | this.canvas = document.createElement('canvas');
732 | this.canvas.width = this.width;
733 | this.canvas.height = this.height;
734 | this.canvas.getContext('2d').drawImage(this.elt, 0, 0);
735 | p5.prototype.loadPixels.call(this);
736 | } else {
737 | this.canvas.getContext('2d').drawImage(this.elt, 0, 0);
738 | p5.prototype.loadPixels.call(this);
739 | }
740 | }
741 | }
742 | p5.MediaElement.prototype.updatePixels = function(x, y, w, h){
743 | if (this.loadedmetadata) { // wait for metadata
744 | p5.prototype.updatePixels.call(this, x, y, w, h);
745 | }
746 | }
747 | p5.MediaElement.prototype.get = function(x, y, w, h){
748 | if (this.loadedmetadata) { // wait for metadata
749 | return p5.prototype.get.call(this, x, y, w, h);
750 | } else return [0, 0, 0, 255];
751 | };
752 | p5.MediaElement.prototype.set = function(x, y, imgOrCol){
753 | if (this.loadedmetadata) { // wait for metadata
754 | p5.prototype.set.call(this, x, y, imgOrCol);
755 | }
756 | };
757 |
758 | })();
759 |
--------------------------------------------------------------------------------
/addons/p5.svg.js:
--------------------------------------------------------------------------------
1 | /*!!
2 | * Canvas 2 Svg v1.0.4
3 | * A low level canvas to SVG converter. Uses a mock canvas context to build an SVG document.
4 | *
5 | * Licensed under the MIT license:
6 | * http://www.opensource.org/licenses/mit-license.php
7 | *
8 | * Author:
9 | * Kerry Liu
10 | *
11 | * Copyright (c) 2014 Gliffy Inc.
12 | */
13 |
14 | ;(function() {
15 | "use strict";
16 |
17 | var STYLES, ctx, CanvasGradient, CanvasPattern, namedEntities;
18 |
19 | //helper function to format a string
20 | function format(str, args) {
21 | var keys = Object.keys(args), i;
22 | for (i=0; i 1) {
204 | options = defaultOptions;
205 | options.width = arguments[0];
206 | options.height = arguments[1];
207 | } else if( !o ) {
208 | options = defaultOptions;
209 | } else {
210 | options = o;
211 | }
212 |
213 | if(!(this instanceof ctx)) {
214 | //did someone call this without new?
215 | return new ctx(options);
216 | }
217 |
218 | //setup options
219 | this.width = options.width || defaultOptions.width;
220 | this.height = options.height || defaultOptions.height;
221 | this.enableMirroring = options.enableMirroring !== undefined ? options.enableMirroring : defaultOptions.enableMirroring;
222 |
223 | this.canvas = this; ///point back to this instance!
224 | this.__canvas = document.createElement("canvas");
225 | this.__ctx = this.__canvas.getContext("2d");
226 |
227 | this.__setDefaultStyles();
228 | this.__stack = [this.__getStyleState()];
229 | this.__groupStack = [];
230 |
231 | //the root svg element
232 | this.__root = document.createElementNS("http://www.w3.org/2000/svg", "svg");
233 | this.__root.setAttribute("version", 1.1);
234 | this.__root.setAttribute("xmlns", "http://www.w3.org/2000/svg");
235 | this.__root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink");
236 | this.__root.setAttribute("width", this.width);
237 | this.__root.setAttribute("height", this.height);
238 |
239 | //make sure we don't generate the same ids in defs
240 | this.__ids = {};
241 |
242 | //defs tag
243 | this.__defs = document.createElementNS("http://www.w3.org/2000/svg", "defs");
244 | this.__root.appendChild(this.__defs);
245 |
246 | //also add a group child. the svg element can't use the transform attribute
247 | this.__currentElement = document.createElementNS("http://www.w3.org/2000/svg", "g");
248 | this.__root.appendChild(this.__currentElement);
249 |
250 | };
251 |
252 | /**
253 | * Creates the specified svg element
254 | * @private
255 | */
256 | ctx.prototype.__createElement = function(elementName, properties, resetFill) {
257 | var element = document.createElementNS("http://www.w3.org/2000/svg", elementName),
258 | keys = Object.keys(properties), i, key;
259 | if(resetFill) {
260 | //if fill or stroke is not specified, the svg element should not display. By default SVG's fill is black.
261 | element.setAttribute("fill", "none");
262 | element.setAttribute("stroke", "none");
263 | }
264 | for(i=0; i Math.PI ? 0 : 1;
812 | } else {
813 | largeArcFlag = diff > Math.PI ? 1 : 0;
814 | }
815 |
816 | this.moveTo(startX, startY);
817 | this.__addPathCommand(format("A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",
818 | {rx:radius, ry:radius, xAxisRotation:0, largeArcFlag:largeArcFlag, sweepFlag:sweepFlag, endX:endX, endY:endY}));
819 |
820 | };
821 |
822 | /**
823 | * Generates a ClipPath from the clip command.
824 | */
825 | ctx.prototype.clip = function(){
826 | var group = this.__closestGroupOrSvg(),
827 | clipPath = document.createElementNS("http://www.w3.org/2000/svg", "clipPath"),
828 | id = randomString(this.__ids),
829 | newGroup = document.createElementNS("http://www.w3.org/2000/svg", "g");
830 |
831 | group.removeChild(this.__currentElement);
832 | clipPath.setAttribute("id", id);
833 | clipPath.appendChild(this.__currentElement);
834 |
835 | this.__defs.appendChild(clipPath);
836 |
837 | //set the clip path to this group
838 | group.setAttribute("clip-path", format("url(#{id})", {id:id}));
839 |
840 | //clip paths can be scaled and transformed, we need to add another wrapper group to avoid later transformations
841 | // to this path
842 | group.appendChild(newGroup);
843 |
844 | this.__currentElement = newGroup;
845 |
846 | };
847 |
848 | /**
849 | * Draws a canvas, image or mock context to this canvas.
850 | * Note that all svg dom manipulation uses node.childNodes rather than node.children for IE support.
851 | * http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-drawimage
852 | */
853 | ctx.prototype.drawImage = function(){
854 | //convert arguments to a real array
855 | var args = Array.prototype.slice.call(arguments),
856 | image=args[0],
857 | dx, dy, dw, dh, sx=0, sy=0, sw, sh, parent, svg, defs, group,
858 | currentElement, svgImage, canvas, context, id;
859 |
860 | if(args.length === 3) {
861 | dx = args[1];
862 | dy = args[2];
863 | sw = image.width;
864 | sh = image.height;
865 | dw = sw;
866 | dh = sh;
867 | } else if(args.length === 5) {
868 | dx = args[1];
869 | dy = args[2];
870 | dw = args[3];
871 | dh = args[4];
872 | sw = image.width;
873 | sh = image.height;
874 | } else if(args.length === 9) {
875 | sx = args[1];
876 | sy = args[2];
877 | sw = args[3];
878 | sh = args[4];
879 | dx = args[5];
880 | dy = args[6];
881 | dw = args[7];
882 | dh = args[8];
883 | } else {
884 | throw new Error("Inavlid number of arguments passed to drawImage: " + arguments.length);
885 | }
886 |
887 | parent = this.__closestGroupOrSvg();
888 | currentElement = this.__currentElement;
889 |
890 | if(image instanceof ctx) {
891 | //canvas2svg mock canvas context. In the future we may want to clone nodes instead.
892 | //also I'm currently ignoring dw, dh, sw, sh, sx, sy for a mock context.
893 | svg = image.getSvg();
894 | defs = svg.childNodes[0];
895 | while(defs.childNodes.length) {
896 | id = defs.childNodes[0].getAttribute("id");
897 | this.__ids[id] = id;
898 | this.__defs.appendChild(defs.childNodes[0]);
899 | }
900 | group = svg.childNodes[1];
901 | parent.appendChild(group);
902 | this.__currentElement = group;
903 | this.translate(dx, dy);
904 | this.__currentElement = currentElement;
905 | } else if(image.nodeName === "CANVAS" || image.nodeName === "IMG") {
906 | //canvas or image
907 | svgImage = document.createElementNS("http://www.w3.org/2000/svg", "image");
908 | svgImage.setAttribute("width", dw);
909 | svgImage.setAttribute("height", dh);
910 | svgImage.setAttribute("preserveAspectRatio", "none");
911 |
912 | if(sx || sy || sw !== image.width || sh !== image.height) {
913 | //crop the image using a temporary canvas
914 | canvas = document.createElement("canvas");
915 | canvas.width = dw;
916 | canvas.height = dh;
917 | context = canvas.getContext("2d");
918 | context.drawImage(image, sx, sy, sw, sh, 0, 0, dw, dh);
919 | image = canvas;
920 | }
921 |
922 | svgImage.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href",
923 | image.nodeName === "CANVAS" ? image.toDataURL() : image.getAttribute("src"));
924 | parent.appendChild(svgImage);
925 | this.__currentElement = svgImage;
926 | this.translate(dx, dy);
927 | this.__currentElement = currentElement;
928 | }
929 | };
930 |
931 | /**
932 | * Generates a pattern tag
933 | */
934 | ctx.prototype.createPattern = function(image, repetition){
935 | var pattern = document.createElementNS("http://www.w3.org/2000/svg", "pattern"), id = randomString(this.__ids),
936 | img;
937 | pattern.setAttribute("id", id);
938 | pattern.setAttribute("width", image.width);
939 | pattern.setAttribute("height", image.height);
940 | if(image.nodeName === "CANVAS" || image.nodeName === "IMG") {
941 | img = document.createElementNS("http://www.w3.org/2000/svg", "image");
942 | img.setAttribute("width", image.width);
943 | img.setAttribute("height", image.height);
944 | img.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href",
945 | image.nodeName === "CANVAS" ? image.toDataURL() : image.getAttribute("src"));
946 | pattern.appendChild(img);
947 | this.__defs.appendChild(pattern);
948 | } else if(image instanceof ctx) {
949 | pattern.appendChild(image.__root.childNodes[1]);
950 | this.__defs.appendChild(pattern);
951 | }
952 | return new CanvasPattern(pattern, this);
953 | };
954 |
955 | /**
956 | * Not yet implemented
957 | */
958 | ctx.prototype.drawFocusRing = function(){};
959 | ctx.prototype.createImageData = function(){};
960 | ctx.prototype.getImageData = function(){};
961 | ctx.prototype.putImageData = function(){};
962 | ctx.prototype.globalCompositeOperation = function(){};
963 | ctx.prototype.arcTo = function(){};
964 | ctx.prototype.setTransform = function(){};
965 |
966 | //add options for alternative namespace
967 | window.C2S = ctx;
968 |
969 | }());
970 |
971 | var p5SVG = (function(){
972 |
973 | p5.prototype.beginRecord = function () {
974 | this.orgDrawingContext = this.drawingContext;
975 | this.drawingContext = new C2S(this.drawingContext.canvas.clientWidth, this.drawingContext.canvas.clientHeight);
976 | };
977 |
978 | p5.prototype.endRecord = function () {
979 | document.body.innerHTML += 'Exported SVG
' + this.drawingContext.getSerializedSvg(true) + '';
980 | this.drawingContext = this.orgDrawingContext;
981 | };
982 |
983 | })();
--------------------------------------------------------------------------------
/empty-example/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/runemadsen/p5-svg-test/5d7935461d1dfc3439ca3298b71c3132a40bc542/empty-example/.DS_Store
--------------------------------------------------------------------------------
/empty-example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/empty-example/sketch.js:
--------------------------------------------------------------------------------
1 | var exportSVG = false;
2 |
3 | function setup() {
4 | createCanvas(500, 500);
5 | }
6 |
7 | function draw() {
8 |
9 | if(exportSVG) beginRecord();
10 |
11 | background(100);
12 | fill(255, 0, 0);
13 | ellipse(100, 100, 50, 50);
14 | fill(0, 255, 0);
15 | rect(200, 200, 200, 200);
16 |
17 | if(exportSVG)
18 | {
19 | exportSVG = false;
20 | endRecord();
21 | }
22 | }
23 |
24 | function keyPressed()
25 | {
26 | if(key == "S")
27 | {
28 | exportSVG = true;
29 | }
30 | }
--------------------------------------------------------------------------------
/p5.min.js:
--------------------------------------------------------------------------------
1 | /*! p5.min.js v0.3.2 August 08, 2014 */
2 |
3 | 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",ADDITIVE:"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},this._start=function(){this._userNode&&"string"==typeof this._userNode&&(this._userNode=document.getElementById(this._userNode)),this.createCanvas(this._defaultCanvasSize.width,this._defaultCanvasSize.height,!0);var t=this.preload||window.preload,e=this._isGlobal?window:this;t?(this._preloadFuncs.forEach(function(t){e[t]=function(r){return e._preload(t,r)}}),t(),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._preloadFuncs.forEach(function(e){t[e]=o.prototype[e]}),"function"==typeof t.setup&&t.setup();for(var e=new RegExp(/(^|\s)p5_hidden(?!\S)/g),r=document.getElementsByClassName("p5_hidden"),n=0;n=3?(n=arguments[0],i=arguments[1],s=arguments[2],a="number"==typeof arguments[3]?arguments[3]:e[3]):(t?n=i=s=arguments[0]:(n=s=arguments[0],i=0),a="number"==typeof arguments[1]?arguments[1]:e[3]),n*=255/e[0],i*=255/e[1],s*=255/e[2],a*=255/e[3],[n,i,s,a]},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,u,h=Math.floor(i),p=o*(1-r),l=o*(1-r*(i-h)),c=o*(1-r*(1-(i-h)));0===h?(s=o,a=c,u=p):1===h?(s=l,a=o,u=p):2===h?(s=p,a=o,u=c):3===h?(s=p,a=l,u=o):4===h?(s=c,a=p,u=o):(s=o,a=p,u=l),n=[Math.round(255*s),Math.round(255*a),Math.round(255*u),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),u=a-s,h=a;if(0===u)e=0,r=0;else{r=u/a;var p=((a-o)/6+u/2)/u,l=((a-n)/6+u/2)/u,c=((a-i)/6+u/2)/u;o===a?e=c-l:n===a?e=1/3+p-c:i===a&&(e=2/3+l-p),0>e&&(e+=1),e>1&&(e-=1)}return[Math.round(255*e),Math.round(255*r),Math.round(255*h),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.getColor=function(){if(arguments[0]instanceof o.Color)return arguments[0].colorString;if(arguments[0]instanceof Array)return o.Color.getColorString(arguments[0]);var t=o.Color.getNormalizedColor.apply(this,arguments);return this._colorMode===r.HSB&&(t=o.Color.getRGB(t)),o.Color.getColorString(t)},o.Color}({},core,constants),p5Element=function(t,e){function r(t,e,r){var o=r,n=function(t){e(t,o)};r.elt.addEventListener(t,n,!1),r._events[t]=n}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){"string"==typeof t&&(t=document.getElementById(t)),t.appendChild(this.elt)},o.Element.prototype.id=function(t){this.elt.id=t},o.Element.prototype.class=function(t){this.elt.className+=" "+t},o.Element.prototype.mousePressed=function(t){r("mousedown",t,this)},o.Element.prototype.mouseReleased=function(t){r("mouseup",t,this)},o.Element.prototype.mouseClicked=function(t){r("click",t,this)},o.Element.prototype.mouseMoved=function(t){r("mousemove",t,this)},o.Element.prototype.mouseOver=function(t){r("mouseover",t,this)},o.Element.prototype.mouseOut=function(t){r("mouseout",t,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){o.Element.call(this,t,e),this.canvas=t,this.drawingContext=this.canvas.getContext("2d"),this._pInst?(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.drawingContext.fillStyle="#FFFFFF",this.drawingContext.strokeStyle="#000000",this.drawingContext.lineCap=r.ROUND},o.Graphics.prototype=Object.create(o.Element.prototype),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,u,h,p,l=1,c=e-1;e>l;l++){i[e+l]=i[c]=u=c*c,h=s[e+l],p=s[c--];for(var d=0;256>d;d++)h[d]=p[d]=u*d}a=i[e]=e*e,h=s[e];for(var f=0;256>f;f++)h[f]=a*f}}function e(e,a){for(var u=r._toPixels(e),h=e.width,p=e.height,l=h*p,c=new Int32Array(l),d=0;l>d;d++)c[d]=r._getARGB(u,d);var f,g,y,m,w,v,_,x,b,C=new Int32Array(l),R=new Int32Array(l),E=new Int32Array(l),S=0;t(a);var T,M,I,A;for(M=0;p>M;M++){for(T=0;h>T;T++){if(m=y=g=f=0,w=T-o,0>w)b=-w,w=0;else{if(w>=h)break;b=0}for(I=b;n>I&&!(w>=h);I++){var P=c[w+S];A=s[I],g+=A[(16711680&P)>>16],y+=A[(65280&P)>>8],m+=A[255&P],f+=i[I],w++}v=S+T,C[v]=g/f,R[v]=y/f,E[v]=m/f}S+=h}for(S=0,_=-o,x=_*h,M=0;p>M;M++){for(T=0;h>T;T++){if(m=y=g=f=0,0>_)b=v=-_,w=T;else{if(_>=p)break;b=0,v=_,w=T+x}for(I=b;n>I&&!(v>=p);I++)A=s[I],g+=A[C[w]],y+=A[R[w]],m+=A[E[w]],f+=i[I],v++,w+=h;c[T+S]=4278190080|g/f<<16|y/f<<8|m/f}S+=h,x+=h,_++}r._setPixels(u,c)}var r={};r._toPixels=function(t){return t instanceof ImageData?t.data:t.getContext("2d").getImageData(0,0,t.width,t.height).data},r._getARGB=function(t,e){var r=4*e;return t[r+3]<<24&4278190080|t[r]<<16&16711680|t[r+1]<<8&65280|255&t[r+2]},r._setPixels=function(t,e){for(var r=0,o=0,n=t.length;n>o;o++)r=4*o,t[r+0]=(16711680&e[o])>>>16,t[r+1]=(65280&e[o])>>>8,t[r+2]=255&e[o],t[r+3]=(4278190080&e[o])>>>24},r._toImageData=function(t){return t instanceof ImageData?t:t.getContext("2d").getImageData(0,0,t.width,t.height)},r._createImageData=function(t,e){return r._tmpCanvas=document.createElement("canvas"),r._tmpCtx=r._tmpCanvas.getContext("2d"),this._tmpCtx.createImageData(t,e)},r.apply=function(t,e,r){var o=t.getContext("2d"),n=o.getImageData(0,0,t.width,t.height),i=e(n,r);i instanceof ImageData?o.putImageData(i,0,0,0,0,t.width,t.height):o.putImageData(n,0,0,0,0,t.width,t.height)},r.threshold=function(t,e){var o=r._toPixels(t);void 0===e&&(e=.5);for(var n=Math.floor(255*e),i=0;i=n?255:0,o[i]=o[i+1]=o[i+2]=s}},r.gray=function(t){for(var e=r._toPixels(t),o=0;oe||e>255)throw new Error("Level must be greater than 2 and less than 255 for posterize");for(var n=e-1,i=0;i>8)/n,o[i+1]=255*(a*e>>8)/n,o[i+2]=255*(u*e>>8)/n}},r.dilate=function(t){for(var e,o,n,i,s,a,u,h,p,l,c,d,f,g,y,m,w,v=r._toPixels(t),_=0,x=v.length?v.length/4:0,b=new Int32Array(x);x>_;)for(e=_,o=_+t.width;o>_;)n=i=r._getARGB(v,_),u=_-1,a=_+1,h=_-t.width,p=_+t.width,e>u&&(u=_),a>=o&&(a=_),0>h&&(h=0),p>=x&&(p=_),d=r._getARGB(v,h),c=r._getARGB(v,u),f=r._getARGB(v,p),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),b[_++]=i;r._setPixels(v,b)},r.erode=function(t){for(var e,o,n,i,s,a,u,h,p,l,c,d,f,g,y,m,w,v=r._toPixels(t),_=0,x=v.length?v.length/4:0,b=new Int32Array(x);x>_;)for(e=_,o=_+t.width;o>_;)n=i=r._getARGB(v,_),u=_-1,a=_+1,h=_-t.width,p=_+t.width,e>u&&(u=_),a>=o&&(a=_),0>h&&(h=0),p>=x&&(p=_),d=r._getARGB(v,h),c=r._getARGB(v,u),f=r._getARGB(v,p),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),b[_++]=i;r._setPixels(v,b)};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){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=[t,0,0,t.width,t.height,0,0,this.width,this.height];this.drawingContext.globalCompositeOperation="destination-out",this.copy.apply(this,r),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){var e;switch(t.toLowerCase()){case"png":e="image/png";break;case"jpeg":e="image/jpeg";break;case"jpg":e="image/jpeg";break;default:e="image/png"}if(void 0!==e){var r="image/octet-stream",o=this.canvas.toDataURL(e);o=o.replace(e,r),window.location.href=o}},o.Image}({},core,filters),polargeometry=function(){return{degreesToRadians:function(t){return 2*Math.PI*t/360},radiansToDegrees:function(t){return 360*t/(2*Math.PI)}}}({}),p5Vector=function(t,e,r,o){"use strict";var n=e,i=r,o=o;return n.Vector=function(){var t,e,r;arguments[0]instanceof n?(this.p5=arguments[0],t=arguments[1][0]||0,e=arguments[1][1]||0,r=arguments[1][2]||0):(t=arguments[0]||0,e=arguments[1]||0,r=arguments[2]||0),this.x=t,this.y=e,this.z=r},n.Vector.prototype.set=function(t,e,r){return t instanceof n.Vector?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this):t instanceof Array?(this.x=t[0]||0,this.y=t[1]||0,this.z=t[2]||0,this):(this.x=t||0,this.y=e||0,this.z=r||0,this)},n.Vector.prototype.get=function(){return this.p5?new n.Vector(this.p5,[this.x,this.y,this.z]):new n.Vector(this.x,this.y,this.z)},n.Vector.prototype.add=function(t,e,r){return t instanceof n.Vector?(this.x+=t.x||0,this.y+=t.y||0,this.z+=t.z||0,this):t instanceof Array?(this.x+=t[0]||0,this.y+=t[1]||0,this.z+=t[2]||0,this):(this.x+=t||0,this.y+=e||0,this.z+=r||0,this)},n.Vector.prototype.sub=function(t,e,r){return t instanceof n.Vector?(this.x-=t.x||0,this.y-=t.y||0,this.z-=t.z||0,this):t instanceof Array?(this.x-=t[0]||0,this.y-=t[1]||0,this.z-=t[2]||0,this):(this.x-=t||0,this.y-=e||0,this.z-=r||0,this)},n.Vector.prototype.mult=function(t){return this.x*=t||0,this.y*=t||0,this.z*=t||0,this},n.Vector.prototype.div=function(t){return this.x/=t,this.y/=t,this.z/=t,this},n.Vector.prototype.mag=function(){return Math.sqrt(this.magSq())},n.Vector.prototype.magSq=function(){var t=this.x,e=this.y,r=this.z;return t*t+e*e+r*r},n.Vector.prototype.dot=function(t,e,r){return t instanceof n.Vector?this.dot(t.x,t.y,t.z):this.x*(t||0)+this.y*(e||0)+this.z*(r||0)},n.Vector.prototype.cross=function(t){var e=this.y*t.z-this.z*t.y,r=this.z*t.x-this.x*t.z,o=this.x*t.y-this.y*t.x;return this.p5?new n.Vector(this.p5,[e,r,o]):new n.Vector(e,r,o)},n.Vector.prototype.dist=function(t){var e=t.get().sub(this);return e.mag()},n.Vector.prototype.normalize=function(){return this.div(this.mag())},n.Vector.prototype.limit=function(t){var e=this.magSq();return e>t*t&&(this.div(Math.sqrt(e)),this.mult(t)),this},n.Vector.prototype.setMag=function(t){return this.normalize().mult(t)},n.Vector.prototype.heading=function(){var t=Math.atan2(this.y,this.x);return this.p5?this.p5._angleMode===o.RADIANS?t:i.radiansToDegrees(t):t},n.Vector.prototype.rotate=function(t){this.p5&&this.p5._angleMode===o.DEGREES&&(t=i.degreesToRadians(t));var e=this.heading()+t,r=this.mag();return this.x=Math.cos(e)*r,this.y=Math.sin(e)*r,this},n.Vector.prototype.lerp=function(t,e,r,o){return t instanceof n.Vector?this.lerp(t.x,t.y,t.z,e):(this.x+=(t-this.x)*o||0,this.y+=(e-this.y)*o||0,this.z+=(r-this.z)*o||0,this)},n.Vector.prototype.array=function(){return[this.x||0,this.y||0,this.z||0]},n.Vector.fromAngle=function(t){return this.p5&&this.p5._angleMode===o.DEGREES&&(t=i.degreesToRadians(t)),this.p5?new n.Vector(this.p5,[Math.cos(t),Math.sin(t),0]):new n.Vector(Math.cos(t),Math.sin(t),0)},n.Vector.random2D=function(){var t;return t=this.p5?this.p5.random(this.p5._angleMode===o.DEGREES?360:o.TWO_PI):Math.random()*Math.PI*2,this.fromAngle(t)},n.Vector.random3D=function(){var t,e;this.p5?(t=this.p5.random(0,o.TWO_PI),e=this.p5.random(-1,1)):(t=Math.random()*Math.PI*2,e=2*Math.random()-1);var r=Math.sqrt(1-e*e)*Math.cos(t),i=Math.sqrt(1-e*e)*Math.sin(t);return this.p5?new n.Vector(this.p5,[r,i,e]):new n.Vector(r,i,e)},n.Vector.add=function(t,e){return t.get().add(e)},n.Vector.sub=function(t,e){return t.get().sub(e)},n.Vector.mult=function(t,e){return t.get().mult(e)},n.Vector.div=function(t,e){return t.get().div(e)},n.Vector.dot=function(t,e){return t.dot(e)},n.Vector.cross=function(t,e){return t.cross(e)},n.Vector.dist=function(t,e){return t.dist(e)},n.Vector.lerp=function(t,e,r){return t.get().lerp(e,r)},n.Vector.angleBetween=function(t,e){var r=Math.acos(t.dot(e)/(t.mag()*e.mag()));return this.p5&&this.p5._angleMode===o.DEGREES&&(r=i.radiansToDegrees(r)),r},n.Vector}({},core,polargeometry,constants),p5TableRow=function(t,e){"use strict";var r=e;return r.TableRow=function(t,e){var r=[],o={};t&&(e=e||",",r=t.split(e));for(var n=0;n=0))throw'This table has no column named "'+t+'"';this.obj[t]=e,this.arr[r]=e}else{if(!(ta;a++)s.push(r.prototype.lerp(t.rgba[a],e.rgba[a],o));return new r.Color(this,s)}return r.prototype.lerp(t,e,o)},r.prototype.red=function(t){if(t instanceof Array)return t[0];if(t instanceof r.Color)return t.rgba[0];throw new Error("Needs p5.Color or pixel array as argument.")},r.prototype.saturation=function(t){if(!t instanceof r.Color)throw new Error("Needs p5.Color as argument.");return t.hsba||(t.hsba=r.Color.getRGB(t.rgba),t.hsba=t.hsba.concat(t.rgba[3])),t.hsba[1]},r}({},core,p5Color),colorsetting=function(t,e,r){"use strict";var o=e,r=r;return o.prototype._doStroke=!0,o.prototype._doFill=!0,o.prototype._colorMode=r.RGB,o.prototype._maxRGB=[255,255,255,255],o.prototype._maxHSB=[255,255,255,255],o.prototype.background=function(){if(arguments[0]instanceof o.Image)this.image(arguments[0],0,0,this.width,this.height);else{var t=this.drawingContext.fillStyle,e=this.drawingContext;e.fillStyle=o.Color.getColor.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.getColor.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.getColor.apply(this,arguments)},o}({},core,constants,p5Color),dataarray_functions=function(t,e){"use strict";var r=e;return r.prototype.append=function(t,e){return t.push(e),t},r.prototype.arrayCopy=function(t,e,r,o,n){var i,s;"undefined"!=typeof n?(s=Math.min(n,t.length),i=o,t=t.slice(e,s+e)):("undefined"!=typeof r?(s=r,s=Math.min(s,t.length)):s=t.length,i=0,r=e,t=t.slice(0,s)),Array.prototype.splice.apply(r,[i,s].concat(t))},r.prototype.concat=function(t,e){return t.concat(e)},r.prototype.reverse=function(t){return t.reverse()},r.prototype.shorten=function(t){return t.pop(),t},r.prototype.sort=function(t,e){var r=e?t.slice(0,Math.min(e,t.length)):t,o=e?t.slice(Math.min(e,t.length)):[];return r="string"==typeof r[0]?r.sort():r.sort(function(t,e){return t-e}),r.concat(o)},r.prototype.splice=function(t,e,r){return Array.prototype.splice.apply(t,[r,0].concat(e)),t},r.prototype.subset=function(t,e,r){return"undefined"!=typeof r?t.slice(e,e+r):t.slice(e,t.length)},r}({},core),datastring_functions=function(t,e){"use strict";function r(){var t=arguments[0],e=0>t,r=e?t.toString().substring(1):t.toString(),o=r.indexOf("."),n=-1!==o?r.substring(0,o):r,i=-1!==o?r.substring(o+1):"",s=e?"-":"";if(3===arguments.length){for(var a=0;a1&&(r=r.substring(0,arguments[1]+1)),o+r}function n(){return parseFloat(arguments[0])>0?"+"+arguments[0].toString():arguments[0].toString()}function i(){return parseFloat(arguments[0])>0?" "+arguments[0].toString():arguments[0].toString()}var s=e;return s.prototype.join=function(t,e){return t.join(e)},s.prototype.match=function(t,e){return t.match(e)},s.prototype.matchAll=function(t,e){for(var r=new RegExp(e,"g"),o=r.exec(t),n=[];null!==o;)n.push(o),o=r.exec(t);return n},s.prototype.nf=function(){if(arguments[0]instanceof Array){var t=arguments[1],e=arguments[2];return arguments[0].map(function(o){return r(o,t,e)})}return r.apply(this,arguments)},s.prototype.nfc=function(){if(arguments[0]instanceof Array){var t=arguments[1];return arguments[0].map(function(e){return o(e,t)})}return o.apply(this,arguments)},s.prototype.nfp=function(){var t=this.nf(arguments);return t instanceof Array?t.map(n):n(t)},s.prototype.nfs=function(){var t=this.nf(arguments);return t instanceof Array?t.map(i):i(t)},s.prototype.split=function(t,e){return t.split(e)},s.prototype.splitTokens=function(){var t=arguments.length>0?arguments[1]:/\s/g;return arguments[0].split(t).filter(function(t){return t})},s.prototype.trim=function(t){return t instanceof Array?t.map(this.trim):t.trim()},s}({},core),environment=function(t,e,r){"use strict";function o(t){var e=document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled;if(!e)throw new Error("Fullscreen not enabled in this browser.");t.requestFullscreen?t.requestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.msRequestFullscreen&&t.msRequestFullscreen()}function n(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}var i=e,s=r,a=[s.ARROW,s.CROSS,s.HAND,s.MOVE,s.TEXT,s.WAIT];return i.prototype._frameRate=0,i.prototype._lastFrameTime=0,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,window.addEventListener("resize",function(){this.windowWidth=window.innerWidth}),i.prototype.windowHeight=window.innerHeight,window.addEventListener("resize",function(){this.windowHeight=window.windowHeight
4 | }),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)},r.crossOrigin="Anonymous",r.src=t,o},i.prototype.image=function(t,e,r,n,i){var s=t.canvas?t.canvas:t.elt;void 0===n&&(n=t.width),void 0===i&&(i=t.height);var a=o.modeAdjust(e,r,n,i,this._imageMode);this._tint?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.getNormalizedColor.apply(this,arguments);this._tint=t},i.prototype.noTint=function(){this._tint=null},i.prototype._getTintedImageCanvas=function(t){if(!t.canvas)return t;var e=s._toPixels(t.canvas),r=document.createElement("canvas");r.width=t.canvas.width,r.height=t.canvas.height;for(var o=r.getContext("2d"),n=o.createImageData(t.canvas.width,t.canvas.height),i=n.data,a=0;athis.width||e>this.height||0>t||0>e)return[0,0,0,255];var i=this.drawingContext.getImageData(t,e,r,n),s=i.data;if(1===r&&1===n){for(var a=[],u=0;u0;)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(),u=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())u(t.selectedIndex>=0?t.options[t.selectedIndex]:null);else for(i=0;t.length&&ie){var i=t;t=e,e=i}return r*(e-t)+t};var i,s=!1;return r.prototype.randomGaussian=function(t,e){var r,o,n,a;if(s)r=i,s=!1;else{do o=this.random(2)-1,n=this.random(2)-1,a=o*o+n*n;while(a>=1);a=Math.sqrt(-2*Math.log(a)/a),r=o*a,i=n*a,s=!0}var u=t||0,h=e||1;return r*h+u},r}({},core),mathnoise=function(t,e){"use strict";for(var r=e,o=4,n=1<g;g++)c[g]=Math.sin(g*f*p),d[g]=Math.cos(g*f*p);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 p=0;a+1>p;p++)m[p]=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),b=Math.floor(r),C=t-_,R=e-x,E=r-b,S=0,T=.5,M=function(t){return.5*(1-d[Math.floor(t*y)%l])},I=0;u>I;I++){var A=_+(x<=1&&(_++,C--),R>=1&&(x++,R--),E>=1&&(b++,E--)}return S},r.prototype.noiseDetail=function(t,e){t>0&&(u=t),e>0&&(h=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";var r=e;return r.prototype.pWriters=[],r.prototype.beginRaw=function(){throw"not yet implemented"},r.prototype.beginRecord=function(){throw"not yet implemented"},r.prototype.createOutput=function(){throw"not yet implemented"},r.prototype.createWriter=function(t){-1===this.pWriters.indexOf(t)&&(this.pWriters.name=new this.PrintWriter(t))},r.prototype.endRaw=function(){throw"not yet implemented"},r.prototype.endRecord=function(){throw"not yet implemented"},r.prototype.escape=function(t){return t},r.prototype.PrintWriter=function(t){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(){this.writeFile(this.content)}},r.prototype.saveBytes=function(){throw"not yet implemented"},r.prototype.saveJSONArray=function(){throw"not yet implemented"},r.prototype.saveJSONObject=function(){throw"not yet implemented"},r.prototype.saveStream=function(){throw"not yet implemented"},r.prototype.saveStrings=function(t){this.writeFile(t.join("\n"))},r.prototype.saveXML=function(){throw"not yet implemented"},r.prototype.selectOutput=function(){throw"not yet implemented"},r.prototype.writeFile=function(t){this.open("data:text/json;charset=utf-8,"+this.escape(t),"download")},r}({},core),outputimage=function(t,e){"use strict";var r=e;return r.prototype.save=function(){window.open(this._curElement.elt.toDataURL("image/png"))},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;if(r)n=document.createElement("canvas"),n.id="defaultCanvas";else if(n=document.getElementById("defaultCanvas"))n.id="";else{var i="Warning: createCanvas more than once NOT recommended.";i+=" Very unpredictable behavior may result.",console.log(i)}n.setAttribute("width",t*this._pixelDensity),n.setAttribute("height",e*this._pixelDensity),n.setAttribute("style","width:"+t+"px !important; height:"+e+"px !important;"),this._setupDone||(n.className+=" p5_hidden",n.style.visibility="hidden"),this._userNode?this._userNode.appendChild(n):document.body.appendChild(n);var s=new o.Graphics(n,this);return r&&this._elements.push(s),this.scale(this._pixelDensity,this._pixelDensity),s},o.prototype.createGraphics=function(t,e){var r=document.createElement("canvas");r.setAttribute("width",t*this._pixelDensity),r.setAttribute("height",e*this._pixelDensity),r.setAttribute("style","width:"+t+"px !important; height:"+e+"px !important;");var n=this._userNode||document.body;n.appendChild(r);var i=new o.Graphics(r);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.scale(this._pixelDensity,this._pixelDensity),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)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,u){if(this._doStroke||this._doFill){var h=this.drawingContext,p=r.arcModeAdjust(t,e,n,i,this._ellipseMode),l=p.h>p.w?p.h/2:p.w/2,c=p.h>p.w?p.w/p.h:1,d=p.h>p.w?1:p.h/p.w;return h.scale(c,d),h.beginPath(),h.arc(p.x,p.y,l,s,a),this._doStroke&&h.stroke(),u===o.CHORD||u===o.OPEN?h.closePath():(u===o.PIE||void 0===u)&&(h.lineTo(p.x,p.y),h.closePath()),this._doFill&&h.fill(),this._doStroke&&u!==o.OPEN&&void 0!==u&&h.stroke(),this}},n.prototype.ellipse=function(t,e,o,n){if(this._doStroke||this._doFill){var i=this.drawingContext,s=r.modeAdjust(t,e,o,n,this._ellipseMode),a=.5522848,u=s.w/2*a,h=s.h/2*a,p=s.x+s.w,l=s.y+s.h,c=s.x+s.w/2,d=s.y+s.h/2;return i.beginPath(),i.moveTo(s.x,d),i.bezierCurveTo(s.x,d-h,c-u,s.y,c,s.y),i.bezierCurveTo(c+u,s.y,p,d-h,p,d),i.bezierCurveTo(p,d+h,c+u,l,c,l),i.bezierCurveTo(c-u,l,s.x,d+h,s.x,d),i.closePath(),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 u=this.drawingContext;return u.beginPath(),u.moveTo(t,e),u.lineTo(r,o),u.lineTo(n,i),u.lineTo(s,a),u.closePath(),this._doFill&&u.fill(),this._doStroke&&u.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;return r.prototype._bezierDetail=20,r.prototype._curveDetail=20,r.prototype.bezier=function(t,e,o,n,i,s,a,u){if(this._doStroke){var h=this.drawingContext;h.beginPath(),h.moveTo(t,e);for(var p=0;p<=this._bezierDetail;p++){var l=p/parseFloat(this._bezierDetail),c=r.prototype.bezierPoint(t,o,i,a,l),d=r.prototype.bezierPoint(e,n,s,u,l);h.lineTo(c,d)}return h.stroke(),this}},r.prototype.bezierDetail=function(t){return this._setProperty("_bezierDetail",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
5 | },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,o,n,i,s,a,u){if(this._doStroke){var h=this.drawingContext;h.moveTo(t,e),h.beginPath();for(var p=0;p<=this._curveDetail;p++){var l=parseFloat(p/this._curveDetail),c=r.prototype.curvePoint(t,o,i,a,l),d=r.prototype.curvePoint(e,n,s,u,l);h.lineTo(c,d)}return h.stroke(),h.closePath(),this}},r.prototype.curveDetail=function(t){return this._setProperty("_curveDetail",t),this},r.prototype.curvePoint=function(t,e,r,o,n){var i=n*n*n,s=n*n,a=-.5*i+s-.5*n,u=1.5*i-2.5*s+1,h=-1.5*i+2*s+.5*n,p=.5*i-.5*s;return t*a+e*u+r*h+o*p},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,u=-9*i/2+4*n+.5,h=3*i/2-n;return t*s+e*a+r*u+o*h},r.prototype.curveTightness=function(){throw"not yet implemented"},r}({},core),shapevertex=function(t,e,r){"use strict";var o=e,r=r;return o.prototype._shapeKind=null,o.prototype._shapeInited=!1,o.prototype._contourInited=!1,o.prototype._contourVertices=[],o.prototype._curveVertices=[],o.prototype.beginContour=function(){return this._contourVertices=[],this._contourInited=!0,this},o.prototype.beginShape=function(t){return this._shapeKind=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,this._shapeInited=!0,this.drawingContext.beginPath(),this},o.prototype.bezierVertex=function(t,e,o,n,i,s){if(this._contourInited){var a={};return a.x=t,a.y=e,a.x3=o,a.y3=n,a.x4=i,a.y4=s,a.type=r.BEZIER,this._contourVertices.push(a),this}return this.drawingContext.bezierCurveTo(t,e,o,n,i,s),this},o.prototype.curveVertex=function(t,e){var r={};return r.x=t,r.y=e,this._curveVertices.push(r),this._curveVertices.length>=4&&(this.curve(this._curveVertices[0].x,this._curveVertices[0].y,this._curveVertices[1].x,this._curveVertices[1].y,this._curveVertices[2].x,this._curveVertices[2].y,this._curveVertices[3].x,this._curveVertices[3].y),this._curveVertices.shift()),this},o.prototype.endContour=function(){this._contourVertices.reverse(),this.drawingContext.moveTo(this._contourVertices[0].x,this._contourVertices[0].y);var t=this.drawingContext;return this._contourVertices.slice(1).forEach(function(e){switch(e.type){case r.LINEAR:t.lineTo(e.x,e.y);break;case r.QUADRATIC:t.quadraticCurveTo(e.x,e.y,e.x3,e.y3);break;case r.BEZIER:t.bezierCurveTo(e.x,e.y,e.x3,e.y3,e.x4,e.y4);break;case r.CURVE:}}),this.drawingContext.closePath(),this._contourInited=!1,this},o.prototype.endShape=function(t){return t===r.CLOSE&&(this.drawingContext.closePath(),this._doFill&&this.drawingContext.fill()),this._doStroke&&this._curveVertices.length<=0?this.drawingContext.stroke():this._curveVertices=[],this},o.prototype.quadraticVertex=function(t,e,o,n){if(this._contourInited){var i={};return i.x=t,i.y=e,i.x3=o,i.y3=n,i.type=r.QUADRATIC,this._contourVertices.push(i),this}return this.drawingContext.quadraticCurveTo(t,e,o,n),this},o.prototype.vertex=function(t,e){if(this._contourInited){var o={};return o.x=t,o.y=e,o.type=r.LINEAR,this._contourVertices.push(o),this}return this._shapeInited?this.drawingContext.moveTo(t,e):this.drawingContext.lineTo(t,e),this._shapeInited=!1,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";function o(t,e){for(var r=[],o=t.length,n=e.length,i=t[0].length,s=0;n>s;s++){r[s]=[];for(var a=0;i>a;a++){for(var u=0,h=0;o>h;h++)u+=t[h][a]*e[s][h];r[s].push(u)}}return r}var n=e,r=r;return n.prototype._matrices=[[1,0,0,1,0,0]],n.prototype.applyMatrix=function(t,e,r,n,i,s){this.drawingContext.transform(t,e,r,n,i,s);var a=this._matrices[this._matrices.length-1];return a=o(a,[t,e,r,n,i,s]),this},n.prototype.popMatrix=function(){throw new Error("popMatrix() not used, see pop()")},n.prototype.printMatrix=function(){throw new Error("printMatrix() not implemented")},n.prototype.pushMatrix=function(){throw new Error("pushMatrix() not used, see push()")},n.prototype.resetMatrix=function(){return this.drawingContext.setTransform(),this._matrices[this._matrices.length-1]=[1,0,0,1,0,0],this},n.prototype.rotate=function(t){this._angleMode===r.DEGREES&&(t=this.radians(t)),this.drawingContext.rotate(t);var e=this._matrices[this._matrices.length-1],o=Math.cos(t),n=Math.sin(t),i=e[0]*o+e[2]*n,s=e[1]*o+e[3]*n,a=e[0]*-n+e[2]*o,u=e[1]*-n+e[3]*o;return e[0]=i,e[1]=s,e[2]=a,e[3]=u,this},n.prototype.rotateX=function(){throw"not yet implemented"},n.prototype.rotateY=function(){throw"not yet implemented"},n.prototype.scale=function(){var t=1,e=1;1===arguments.length?t=e=arguments[0]:(t=arguments[0],e=arguments[1]),this.drawingContext.scale(t,e);var r=this._matrices[this._matrices.length-1];return r[0]*=t,r[1]*=t,r[2]*=e,r[3]*=e,this},n.prototype.shearX=function(t){this._angleMode===r.DEGREES&&(t=this.radians(t)),this.drawingContext.transform(1,0,this.tan(t),1,0,0);var e=this._matrices[this._matrices.length-1];return e=o(e,[1,0,this.tan(t),1,0,0]),this},n.prototype.shearY=function(t){this._angleMode===r.DEGREES&&(t=this.radians(t)),this.drawingContext.transform(1,this.tan(t),0,1,0,0);var e=this._matrices[this._matrices.length-1];return e=o(e,[1,this.tan(t),0,1,0,0]),this},n.prototype.translate=function(t,e){this.drawingContext.translate(t,e);var r=this._matrices[this._matrices.length-1];return r[4]+=r[0]*t+r[2]*e,r[5]+=r[1]*t+r[3]*e,this},n}({},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.textAlign=function(t){(t===r.LEFT||t===r.RIGHT||t===r.CENTER)&&(this.drawingContext.textAlign=t)},o.prototype.textHeight=function(t){return this.drawingContext.measureText(t).height},o.prototype.textLeading=function(t){this._setProperty("_textLeading",t)},o.prototype.textSize=function(t){this._setProperty("_textSize",t)},o.prototype.textStyle=function(t){(t===r.NORMAL||t===r.ITALIC||t===r.BOLD)&&this._setProperty("_textStyle",t)},o.prototype.textWidth=function(t){return this.drawingContext.measureText(t).width},o}({},core,constants),typographyloading_displaying=function(t,e,r){"use strict";var o=e,r=r;return o.prototype.text=function(){if(this.drawingContext.font=this._textStyle+" "+this._textSize+"px "+this._textFont,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){var t=arguments[0].split(" "),e="",o=r.modeAdjust(arguments[1],arguments[2],arguments[3],arguments[4],this._rectMode);o.y+=this._textLeading;for(var n=0;no.h)break;a>o.w&&n>0?(this._doFill&&this.drawingContext.fillText(e,o.x,o.y),this._doStroke&&this.drawingContext.strokeText(e,o.x,o.y),e=t[n]+" ",o.y+=this._textLeading):e=i}o.y<=o.h&&(this._doFill&&this.drawingContext.fillText(e,o.x,o.y),this._doStroke&&this.drawingContext.strokeText(e,o.x,o.y))}},o.prototype.textFont=function(t){this._setProperty("_textFont",t)},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,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);
--------------------------------------------------------------------------------