exercises/libs/js/p5.dom.min.js

3 lines
21 KiB
JavaScript
Raw Permalink Normal View History

2025-02-19 02:13:21 +00:00
/*! p5.js v0.9.0 July 01, 2019 */
!function(t,e){"function"==typeof define&&define.amd?define("p5.dom",["p5"],function(t){e(t)}):"object"==typeof exports?e(require("../p5")):e(t.p5)}(this,function(d){function l(t){var e=document;return"string"==typeof t&&"#"===t[0]?(t=t.slice(1),e=document.getElementById(t)||document):t instanceof d.Element?e=t.elt:t instanceof HTMLElement&&(e=t),e}function c(t,e,i){(e._userNode?e._userNode:document.body).appendChild(t);var n=i?new d.MediaElement(t,e):new d.Element(t,e);return e._elements.push(n),n}d.prototype.select=function(t,e){d._validateParameters("select",arguments);var i=null,n=l(e);return(i="."===t[0]?(t=t.slice(1),(i=n.getElementsByClassName(t)).length?i[0]:null):"#"===t[0]?(t=t.slice(1),n.getElementById(t)):(i=n.getElementsByTagName(t)).length?i[0]:null)?this._wrapElement(i):null},d.prototype.selectAll=function(t,e){d._validateParameters("selectAll",arguments);var i,n=[],r=l(e);if(i="."===t[0]?(t=t.slice(1),r.getElementsByClassName(t)):r.getElementsByTagName(t))for(var o=0;o<i.length;o++){var s=this._wrapElement(i[o]);n.push(s)}return n},d.prototype._wrapElement=function(t){var e=Array.prototype.slice.call(t.children);if("INPUT"!==t.tagName||"checkbox"!==t.type)return"VIDEO"===t.tagName||"AUDIO"===t.tagName?new d.MediaElement(t,this):"SELECT"===t.tagName?this.createSelect(new d.Element(t,this)):0<e.length&&e.every(function(t){return"INPUT"===t.tagName||"LABEL"===t.tagName})?this.createRadio(new d.Element(t,this)):new d.Element(t,this);var i=new d.Element(t,this);return i.checked=function(){return 0===arguments.length?this.elt.checked:(arguments[0]?this.elt.checked=!0:this.elt.checked=!1,this)},i},d.prototype.removeElements=function(t){d._validateParameters("removeElements",arguments);for(var e=0;e<this._elements.length;e++)this._elements[e].elt instanceof HTMLCanvasElement||this._elements[e].remove()},d.Element.prototype.changed=function(t){return d.Element._adjustListener("change",t,this),this},d.Element.prototype.input=function(t){return d.Element._adjustListener("input",t,this),this};function i(t,e,i,n){var r=document.createElement(e);"string"==typeof(i=i||"")&&(i=[i]);for(var o=0;o<i.length;o++){var s=document.createElement("source");s.src=i[o],r.appendChild(s)}if(void 0!==n){var l=function(){n(),r.removeEventListener("canplaythrough",l)};r.addEventListener("canplaythrough",l)}var a=c(r,t,!0);return a.loadedmetadata=!1,r.addEventListener("loadedmetadata",function(){a.width=r.videoWidth,a.height=r.videoHeight,0===a.elt.width&&(a.elt.width=r.videoWidth),0===a.elt.height&&(a.elt.height=r.videoHeight),a.presetPlaybackRate&&(a.elt.playbackRate=a.presetPlaybackRate,delete a.presetPlaybackRate),a.loadedmetadata=!0}),a}["div","p","span"].forEach(function(i){var t="create"+i.charAt(0).toUpperCase()+i.slice(1);d.prototype[t]=function(t){var e=document.createElement(i);return e.innerHTML=void 0===t?"":t,c(e,this)}}),d.prototype.createImg=function(){d._validateParameters("createImg",arguments);var t=document.createElement("img");t.crossOrigin="Anonymous";var e,i=arguments;return t.src=i[0],1<i.length&&"string"==typeof i[1]&&(t.alt=i[1]),t.onload=function(){e.width=t.offsetWidth||t.width,e.height=t.offsetHeight||t.height,1<i.length&&"function"==typeof i[1]?(e.fn=i[1],e.fn()):1<i.length&&"function"==typeof i[2]&&(e.fn=i[2],e.fn())},e=c(t,this)},d.prototype.createA=function(t,e,i){d._validateParameters("createA",arguments);var n=document.createElement("a");return n.href=t,n.innerHTML=e,i&&(n.target=i),c(n,this)},d.prototype.createSlider=function(t,e,i,n){d._validateParameters("createSlider",arguments);var r=document.createElement("input");return r.type="range",r.min=t,r.max=e,0===n?r.step=1e-18:n&&(r.step=n),"number"==typeof i&&(r.value=i),c(r,this)},d.prototype.createButton=function(t,e){d._validateParameters("createButton",arguments);var i=document.createElement("button");return i.innerHTML=t,e&&(i.value=e),c(i,this)},d.prototype.createCheckbox=function(){d._validateParameters("createCheckbox",arguments);var t=document.createElement("div"),e=document.createElement("input");e.type="checkbox",t.appendChild(e);var i=c(t,t