├── .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