From 1dd022f27f4ab978e6766572a49544fe51ef9042 Mon Sep 17 00:00:00 2001 From: Sam DeLong Date: Wed, 26 Aug 2020 19:04:19 -0400 Subject: [PATCH 01/97] Implementing p5.Vector setHeading() (Issue #4767) This commit adds the setHeading() function to the p5.Vector class. There are some remaining issues here. For example, there are no tests. --- src/math/p5.Vector.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/math/p5.Vector.js b/src/math/p5.Vector.js index e4e592b353..eb0bc62887 100644 --- a/src/math/p5.Vector.js +++ b/src/math/p5.Vector.js @@ -1440,6 +1440,30 @@ p5.Vector.prototype.heading = function heading() { return h; }; +/** + * Rotate the vector to a specific angle (only 2D vectors), magnitude remains the + * same + * + * @method setHeading + * @param {number} angle the angle of rotation + * @chainable + * @example + *
+ * + * let v = createVector(10.0, 20.0); + * // result of v.heading() is 1.1071487177940904 + * v.setHeading(Math.PI); + * // result of v.heading() is now 3.141592653589793 + * + *
+ */ + +p5.Vector.prototype.setHeading = function setHeading(a) { + this.rotate(-this.heading()); + this.rotate(a); + return this; +}; + /** * Rotate the vector by an angle (only 2D vectors), magnitude remains the * same From ea6fc5933b844ccda58932c53c93d1724a5f3395 Mon Sep 17 00:00:00 2001 From: Shantanu Kaushik Date: Wed, 23 Sep 2020 10:23:32 +0530 Subject: [PATCH 02/97] removed norender class, DOM examples now working --- src/dom/dom.js | 260 ++++++++++++++++++++++++++----------------------- 1 file changed, 136 insertions(+), 124 deletions(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index 680064d655..e155030cb1 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -54,7 +54,7 @@ import p5 from '../core/main'; * [a, b, c, d, e]; // unused * */ -p5.prototype.select = function(e, p) { +p5.prototype.select = function (e, p) { p5._validateParameters('select', arguments); const container = this._getContainer(p); const res = container.querySelector(e); @@ -79,7 +79,7 @@ p5.prototype.select = function(e, p) { * , or HTML element to search within * @return {p5.Element[]} Array of p5.Elements containing nodes found * @example - *
+ *
* function setup() { * createButton('btn'); * createButton('2nd btn'); @@ -109,7 +109,7 @@ p5.prototype.select = function(e, p) { * console.log(a); *
*/ -p5.prototype.selectAll = function(e, p) { +p5.prototype.selectAll = function (e, p) { p5._validateParameters('selectAll', arguments); const arr = []; const container = this._getContainer(p); @@ -126,7 +126,7 @@ p5.prototype.selectAll = function(e, p) { /** * Helper function for select and selectAll */ -p5.prototype._getContainer = function(p) { +p5.prototype._getContainer = function (p) { let container = document; if (typeof p === 'string') { container = document.querySelector(p) || document; @@ -141,11 +141,11 @@ p5.prototype._getContainer = function(p) { /** * Helper function for getElement and getElements. */ -p5.prototype._wrapElement = function(elt) { +p5.prototype._wrapElement = function (elt) { var children = Array.prototype.slice.call(elt.children); if (elt.tagName === 'INPUT' && elt.type === 'checkbox') { var converted = new p5.Element(elt, this); - converted.checked = function() { + converted.checked = function () { if (arguments.length === 0) { return this.elt.checked; } else if (arguments[0]) { @@ -162,7 +162,7 @@ p5.prototype._wrapElement = function(elt) { return this.createSelect(new p5.Element(elt, this)); } else if ( children.length > 0 && - children.every(function(c) { + children.every(function (c) { return c.tagName === 'INPUT' || c.tagName === 'LABEL'; }) ) { @@ -178,7 +178,7 @@ p5.prototype._wrapElement = function(elt) { * Event handlers are removed, and element is removed from the DOM. * @method removeElements * @example - *
+ *
* function setup() { * createCanvas(100, 100); * createDiv('this is some text'); @@ -189,7 +189,7 @@ p5.prototype._wrapElement = function(elt) { * } *
*/ -p5.prototype.removeElements = function(e) { +p5.prototype.removeElements = function (e) { p5._validateParameters('removeElements', arguments); // el.remove splices from this._elements, so don't mix iteration with it const isNotCanvasElement = el => !(el.elt instanceof HTMLCanvasElement); @@ -259,7 +259,7 @@ p5.prototype.removeElements = function(e) { * @alt * dropdown: pear, kiwi, grape. When selected text "its a" + selection shown. */ -p5.Element.prototype.changed = function(fxn) { +p5.Element.prototype.changed = function (fxn) { p5.Element._adjustListener('change', fxn, this); return this; }; @@ -278,7 +278,7 @@ p5.Element.prototype.changed = function(fxn) { * firing function will no longer fire. * @chainable * @example - *
+ *
* // Open your console to see the output * function setup() { * let inp = createInput(''); @@ -293,7 +293,7 @@ p5.Element.prototype.changed = function(fxn) { * @alt * no display. */ -p5.Element.prototype.input = function(fxn) { +p5.Element.prototype.input = function (fxn) { p5.Element._adjustListener('input', fxn, this); return this; }; @@ -316,11 +316,11 @@ function addElement(elt, pInst, media) { * @param {String} [html] inner HTML for element created * @return {p5.Element} pointer to p5.Element holding created node * @example - *
+ *
* createDiv('this is some text'); *
*/ -p5.prototype.createDiv = function(html = '') { +p5.prototype.createDiv = function (html = '') { let elt = document.createElement('div'); elt.innerHTML = html; return addElement(elt, this); @@ -334,11 +334,11 @@ p5.prototype.createDiv = function(html = '') { * @param {String} [html] inner HTML for element created * @return {p5.Element} pointer to p5.Element holding created node * @example - *
+ *
* createP('this is some text'); *
*/ -p5.prototype.createP = function(html = '') { +p5.prototype.createP = function (html = '') { let elt = document.createElement('p'); elt.innerHTML = html; return addElement(elt, this); @@ -351,11 +351,11 @@ p5.prototype.createP = function(html = '') { * @param {String} [html] inner HTML for element created * @return {p5.Element} pointer to p5.Element holding created node * @example - *
+ *
* createSpan('this is some text'); *
*/ -p5.prototype.createSpan = function(html = '') { +p5.prototype.createSpan = function (html = '') { let elt = document.createElement('span'); elt.innerHTML = html; return addElement(elt, this); @@ -370,7 +370,7 @@ p5.prototype.createSpan = function(html = '') { * @param {String} alt alternate text to be used if image does not load. You can use also an empty string (`""`) if that an image is not intended to be viewed. * @return {p5.Element} pointer to p5.Element holding created node * @example - *
+ *
* createImg( * 'https://p5js.org/assets/img/asterisk-01.png', * 'the p5 magenta asterisk' @@ -385,7 +385,7 @@ p5.prototype.createSpan = function(html = '') { * @param {Function} [successCallback] callback to be called once image data is loaded with the p5.Element as argument * @return {p5.Element} pointer to p5.Element holding created node */ -p5.prototype.createImg = function() { +p5.prototype.createImg = function () { p5._validateParameters('createImg', arguments); var elt = document.createElement('img'); var args = arguments; @@ -398,7 +398,7 @@ p5.prototype.createImg = function() { } elt.src = args[0]; self = addElement(elt, this); - elt.addEventListener('load', function() { + elt.addEventListener('load', function () { self.width = elt.offsetWidth || elt.width; self.height = elt.offsetHeight || elt.height; var last = args[args.length - 1]; @@ -417,11 +417,11 @@ p5.prototype.createImg = function() { * could be _blank, _self, _parent, _top. * @return {p5.Element} pointer to p5.Element holding created node * @example - *
+ *
* createA('http://p5js.org/', 'this is a link'); *
*/ -p5.prototype.createA = function(href, html, target) { +p5.prototype.createA = function (href, html, target) { p5._validateParameters('createA', arguments); var elt = document.createElement('a'); elt.href = href; @@ -472,7 +472,7 @@ p5.prototype.createA = function(href, html, target) { * } *
*/ -p5.prototype.createSlider = function(min, max, value, step) { +p5.prototype.createSlider = function (min, max, value, step) { p5._validateParameters('createSlider', arguments); var elt = document.createElement('input'); elt.type = 'range'; @@ -497,7 +497,7 @@ p5.prototype.createSlider = function(min, max, value, step) { * @param {String} [value] value of the button * @return {p5.Element} pointer to p5.Element holding created node * @example - *
+ *
* let button; * function setup() { * createCanvas(100, 100); @@ -513,7 +513,7 @@ p5.prototype.createSlider = function(min, max, value, step) { * } *
*/ -p5.prototype.createButton = function(label, value) { +p5.prototype.createButton = function (label, value) { p5._validateParameters('createButton', arguments); var elt = document.createElement('button'); elt.innerHTML = label; @@ -530,7 +530,7 @@ p5.prototype.createButton = function(label, value) { * @param {boolean} [value] value of the checkbox; checked is true, unchecked is false * @return {p5.Element} pointer to p5.Element holding created node * @example - *
+ *
* let checkbox; * * function setup() { @@ -547,7 +547,7 @@ p5.prototype.createButton = function(label, value) { * } *
*/ -p5.prototype.createCheckbox = function() { +p5.prototype.createCheckbox = function () { p5._validateParameters('createCheckbox', arguments); var elt = document.createElement('div'); var checkbox = document.createElement('input'); @@ -555,7 +555,7 @@ p5.prototype.createCheckbox = function() { elt.appendChild(checkbox); //checkbox must be wrapped in p5.Element before label so that label appears after var self = addElement(elt, this); - self.checked = function() { + self.checked = function () { var cb = self.elt.getElementsByTagName('input')[0]; if (cb) { if (arguments.length === 0) { @@ -568,7 +568,7 @@ p5.prototype.createCheckbox = function() { } return self; }; - this.value = function(val) { + this.value = function (val) { self.value = val; return this; }; @@ -646,7 +646,7 @@ p5.prototype.createCheckbox = function() { * @return {p5.Element} */ -p5.prototype.createSelect = function() { +p5.prototype.createSelect = function () { p5._validateParameters('createSelect', arguments); let self; let arg = arguments[0]; @@ -665,7 +665,7 @@ p5.prototype.createSelect = function() { self = addElement(elt, this); this.elt = elt; } - self.option = function(name, value) { + self.option = function (name, value) { let index; // if no name is passed, return @@ -698,7 +698,7 @@ p5.prototype.createSelect = function() { } }; - self.selected = function(value) { + self.selected = function (value) { // Update selected status of option if (value !== undefined) { for (let i = 0; i < this.elt.length; i += 1) { @@ -720,7 +720,7 @@ p5.prototype.createSelect = function() { } }; - self.disable = function(value) { + self.disable = function (value) { if (typeof value === 'string') { for (let i = 0; i < this.elt.length; i++) { if (this.elt[i].value.toString() === value) { @@ -804,7 +804,7 @@ p5.prototype.createSelect = function() { * @method createRadio * @return {p5.Element} pointer to p5.Element holding created node */ -p5.prototype.createRadio = function() { +p5.prototype.createRadio = function () { // Creates a div, adds each option as an individual input inside it. // If already given with a containerEl, will search for all input[radio] // it, create a p5.Element out of it, add options to it and return the p5.Element. @@ -829,11 +829,11 @@ p5.prototype.createRadio = function() { el instanceof HTMLInputElement && el.type === 'radio'; const isNextLabel = el => el.nextElementSibling instanceof HTMLLabelElement; - self._getOptionsArray = function() { + self._getOptionsArray = function () { return Array.from(this.elt.children).filter(isRadioInput); }; - self.option = function(value, label) { + self.option = function (value, label) { // return an option with this value, create if not exists. let optionEl; for (const option of self._getOptionsArray()) { @@ -865,7 +865,7 @@ p5.prototype.createRadio = function() { return optionEl; }; - self.remove = function(value) { + self.remove = function (value) { for (const optionEl of self._getOptionsArray()) { if (optionEl.value === value) { if (isNextLabel(optionEl)) optionEl.nextElementSibling.remove(); @@ -875,7 +875,7 @@ p5.prototype.createRadio = function() { } }; - self.value = function() { + self.value = function () { let result = ''; for (const option of self._getOptionsArray()) { if (option.checked) { @@ -886,7 +886,7 @@ p5.prototype.createRadio = function() { return result; }; - self.selected = function(value) { + self.selected = function (value) { let result = null; if (value === undefined) { for (const option of self._getOptionsArray()) { @@ -906,7 +906,7 @@ p5.prototype.createRadio = function() { return result; }; - self.disable = function(shouldDisable = true) { + self.disable = function (shouldDisable = true) { for (const radioInput of self._getOptionsArray()) { radioInput.setAttribute('disabled', shouldDisable); } @@ -967,7 +967,7 @@ p5.prototype.createRadio = function() { * } *
*/ -p5.prototype.createColorPicker = function(value) { +p5.prototype.createColorPicker = function (value) { p5._validateParameters('createColorPicker', arguments); var elt = document.createElement('input'); var self; @@ -989,7 +989,7 @@ p5.prototype.createColorPicker = function(value) { } self = addElement(elt, this); // Method to return a p5.Color object for the given color. - self.color = function() { + self.color = function () { if (value) { if (value.mode) { p5.prototype._colorMode = value.mode; @@ -1013,7 +1013,7 @@ p5.prototype.createColorPicker = function(value) { * Needs a value to be specified first. * @return {p5.Element} pointer to p5.Element holding created node * @example - *
+ *
* function setup() { * let inp = createInput(''); * inp.input(myInputEvent); @@ -1029,7 +1029,7 @@ p5.prototype.createColorPicker = function(value) { * @param {String} [value] * @return {p5.Element} */ -p5.prototype.createInput = function(value = '', type = 'text') { +p5.prototype.createInput = function (value = '', type = 'text') { p5._validateParameters('createInput', arguments); let elt = document.createElement('input'); elt.setAttribute('value', value); @@ -1073,10 +1073,10 @@ p5.prototype.createInput = function(value = '', type = 'text') { * } *
*/ -p5.prototype.createFileInput = function(callback, multiple = false) { +p5.prototype.createFileInput = function (callback, multiple = false) { p5._validateParameters('createFileInput', arguments); - const handleFileSelect = function(event) { + const handleFileSelect = function (event) { for (const file of event.target.files) { p5.File._load(file, callback); } @@ -1185,7 +1185,7 @@ function createMedia(pInst, type, src, callback) { * } *
*/ -p5.prototype.createVideo = function(src, callback) { +p5.prototype.createVideo = function (src, callback) { p5._validateParameters('createVideo', arguments); return createMedia(this, 'video', src, callback); }; @@ -1224,7 +1224,7 @@ p5.prototype.createVideo = function(src, callback) { * } *
*/ -p5.prototype.createAudio = function(src, callback) { +p5.prototype.createAudio = function (src, callback) { p5._validateParameters('createAudio', arguments); return createMedia(this, 'audio', src, callback); }; @@ -1254,7 +1254,7 @@ if (navigator.mediaDevices === undefined) { // with getUserMedia as it would overwrite existing properties. // Here, we will just add the getUserMedia property if it's missing. if (navigator.mediaDevices.getUserMedia === undefined) { - navigator.mediaDevices.getUserMedia = function(constraints) { + navigator.mediaDevices.getUserMedia = function (constraints) { // First get ahold of the legacy getUserMedia, if present var getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia; @@ -1268,7 +1268,7 @@ if (navigator.mediaDevices.getUserMedia === undefined) { } // Otherwise, wrap the call to the old navigator.getUserMedia with a Promise - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { getUserMedia.call(navigator, constraints, resolve, reject); }); }; @@ -1301,7 +1301,7 @@ if (navigator.mediaDevices.getUserMedia === undefined) { * stream has loaded * @return {p5.Element} capture video p5.Element * @example - *
+ *
* * let capture; * @@ -1356,7 +1356,7 @@ if (navigator.mediaDevices.getUserMedia === undefined) { * *
*/ -p5.prototype.createCapture = function() { +p5.prototype.createCapture = function () { p5._validateParameters('createCapture', arguments); // return if getUserMedia is not supported by browser @@ -1374,13 +1374,16 @@ p5.prototype.createCapture = function() { else if (typeof arg === 'object') constraints = arg; else if (typeof arg === 'function') callback = arg; } - if (!constraints) constraints = { video: useVideo, audio: useAudio }; + if (!constraints) constraints = { + video: useVideo, + audio: useAudio + }; const domElement = document.createElement('video'); // required to work in iOS 11 & up: domElement.setAttribute('playsinline', ''); - navigator.mediaDevices.getUserMedia(constraints).then(function(stream) { + navigator.mediaDevices.getUserMedia(constraints).then(function (stream) { try { if ('srcObject' in domElement) { domElement.srcObject = stream; @@ -1395,7 +1398,7 @@ p5.prototype.createCapture = function() { const videoEl = addElement(domElement, this, true); videoEl.loadedmetadata = false; // set width and height onload metadata - domElement.addEventListener('loadedmetadata', function() { + domElement.addEventListener('loadedmetadata', function () { domElement.play(); if (domElement.width) { videoEl.width = domElement.width; @@ -1419,11 +1422,11 @@ p5.prototype.createCapture = function() { * @param {String} [content] html content to be inserted into the element * @return {p5.Element} pointer to p5.Element holding created node * @example - *
+ *
* createElement('h2', 'im an h2 p5.element!'); *
*/ -p5.prototype.createElement = function(tag, content) { +p5.prototype.createElement = function (tag, content) { p5._validateParameters('createElement', arguments); var elt = document.createElement(tag); if (typeof content !== 'undefined') { @@ -1449,7 +1452,7 @@ p5.prototype.createElement = function(tag, content) { * div.addClass('myClass'); *
*/ -p5.Element.prototype.addClass = function(c) { +p5.Element.prototype.addClass = function (c) { if (this.elt.className) { if (!this.hasClass(c)) { this.elt.className = this.elt.className + ' ' + c; @@ -1485,7 +1488,7 @@ p5.Element.prototype.addClass = function(c) { * } *
*/ -p5.Element.prototype.removeClass = function(c) { +p5.Element.prototype.removeClass = function (c) { // Note: Removing a class that does not exist does NOT throw an error in classList.remove method this.elt.classList.remove(c); return this; @@ -1516,7 +1519,7 @@ p5.Element.prototype.removeClass = function(c) { * } *
*/ -p5.Element.prototype.hasClass = function(c) { +p5.Element.prototype.hasClass = function (c) { return this.elt.classList.contains(c); }; @@ -1541,7 +1544,7 @@ p5.Element.prototype.hasClass = function(c) { * } *
*/ -p5.Element.prototype.toggleClass = function(c) { +p5.Element.prototype.toggleClass = function (c) { // classList also has a toggle() method, but we cannot use that yet as support is unclear. // See https://github.com/processing/p5.js/issues/3631 // this.elt.classList.toggle(c); @@ -1587,7 +1590,7 @@ p5.Element.prototype.toggleClass = function(c) { * to add to the current element * @chainable */ -p5.Element.prototype.child = function(childNode) { +p5.Element.prototype.child = function (childNode) { if (typeof childNode === 'undefined') { return this.elt.childNodes; } @@ -1625,11 +1628,14 @@ p5.Element.prototype.child = function(childNode) { * } *
*/ -p5.Element.prototype.center = function(align) { +p5.Element.prototype.center = function (align) { var style = this.elt.style.display; var hidden = this.elt.style.display === 'none'; var parentHidden = this.parent().style.display === 'none'; - var pos = { x: this.elt.offsetLeft, y: this.elt.offsetTop }; + var pos = { + x: this.elt.offsetLeft, + y: this.elt.offsetTop + }; if (hidden) this.show(); if (parentHidden) this.parent().show(); @@ -1684,7 +1690,7 @@ p5.Element.prototype.center = function(align) { * @param {boolean} [append] whether to append HTML to existing * @chainable */ -p5.Element.prototype.html = function() { +p5.Element.prototype.html = function () { if (arguments.length === 0) { return this.elt.innerHTML; } else if (arguments[1]) { @@ -1736,9 +1742,12 @@ p5.Element.prototype.html = function() { * @param {String} positionType it can be static, fixed, relative, sticky, initial or inherit (optional) * @chainable */ -p5.Element.prototype.position = function() { +p5.Element.prototype.position = function () { if (arguments.length === 0) { - return { x: this.elt.offsetLeft, y: this.elt.offsetTop }; + return { + x: this.elt.offsetLeft, + y: this.elt.offsetTop + }; } else { let positionType = 'absolute'; if ( @@ -1761,7 +1770,7 @@ p5.Element.prototype.position = function() { }; /* Helper method called by p5.Element.style() */ -p5.Element.prototype._translate = function() { +p5.Element.prototype._translate = function () { this.elt.style.position = 'absolute'; // save out initial non-translate transform styling var transform = ''; @@ -1793,7 +1802,7 @@ p5.Element.prototype._translate = function() { }; /* Helper method called by p5.Element.style() */ -p5.Element.prototype._rotate = function() { +p5.Element.prototype._rotate = function () { // save out initial non-rotate transform styling var transform = ''; if (this.elt.style.transform) { @@ -1858,7 +1867,7 @@ p5.Element.prototype._rotate = function() { * @return {String} current value of property, if no value is given as second argument * @chainable */ -p5.Element.prototype.style = function(prop, val) { +p5.Element.prototype.style = function (prop, val) { var self = this; if (val instanceof p5.Color) { @@ -1929,7 +1938,7 @@ p5.Element.prototype.style = function(prop, val) { * @param {String} value value to assign to attribute * @chainable */ -p5.Element.prototype.attribute = function(attr, value) { +p5.Element.prototype.attribute = function (attr, value) { //handling for checkboxes and radios to ensure options get //attributes not divs if ( @@ -1983,7 +1992,7 @@ p5.Element.prototype.attribute = function(attr, value) { * } *
*/ -p5.Element.prototype.removeAttribute = function(attr) { +p5.Element.prototype.removeAttribute = function (attr) { if ( this.elt.firstChild != null && (this.elt.firstChild.type === 'checkbox' || @@ -2032,7 +2041,7 @@ p5.Element.prototype.removeAttribute = function(attr) { * @param {String|Number} value * @chainable */ -p5.Element.prototype.value = function() { +p5.Element.prototype.value = function () { if (arguments.length > 0) { this.elt.value = arguments[0]; return this; @@ -2056,7 +2065,7 @@ p5.Element.prototype.value = function() { * div.show(); // turns display to block *
*/ -p5.Element.prototype.show = function() { +p5.Element.prototype.show = function () { this.elt.style.display = 'block'; return this; }; @@ -2072,7 +2081,7 @@ p5.Element.prototype.show = function() { * div.hide(); *
*/ -p5.Element.prototype.hide = function() { +p5.Element.prototype.hide = function () { this.elt.style.display = 'none'; return this; }; @@ -2107,9 +2116,12 @@ p5.Element.prototype.hide = function() { * @param {Number|Constant} [h] height of the element, either AUTO, or a number * @chainable */ -p5.Element.prototype.size = function(w, h) { +p5.Element.prototype.size = function (w, h) { if (arguments.length === 0) { - return { width: this.elt.offsetWidth, height: this.elt.offsetHeight }; + return { + width: this.elt.offsetWidth, + height: this.elt.offsetHeight + }; } else { var aW = w; var aH = h; @@ -2167,12 +2179,12 @@ p5.Element.prototype.size = function(w, h) { * myDiv.remove(); *
*/ -p5.Element.prototype.remove = function() { +p5.Element.prototype.remove = function () { // stop all audios/videos and detach all devices like microphone/camera etc // used as input/output for audios/videos. if (this instanceof p5.MediaElement) { const tracks = this.elt.srcObject.getTracks(); - tracks.forEach(function(track) { + tracks.forEach(function (track) { track.stop(); }); } @@ -2251,13 +2263,13 @@ p5.Element.prototype.remove = function() { * @alt * Canvas turns into whatever image is dragged/dropped onto it. */ -p5.Element.prototype.drop = function(callback, fxn) { +p5.Element.prototype.drop = function (callback, fxn) { // Is the file stuff supported? if (window.File && window.FileReader && window.FileList && window.Blob) { if (!this._dragDisabled) { this._dragDisabled = true; - var preventDefault = function(evt) { + var preventDefault = function (evt) { evt.preventDefault(); }; @@ -2273,7 +2285,7 @@ p5.Element.prototype.drop = function(callback, fxn) { // Deal with the files p5.Element._attachListener( 'drop', - function(evt) { + function (evt) { evt.preventDefault(); // Call the second argument as a callback that receives the raw drop event if (typeof fxn === 'function') { @@ -2311,7 +2323,7 @@ p5.Element.prototype.drop = function(callback, fxn) { * @constructor * @param {String} elt DOM node that is wrapped */ -p5.MediaElement = function(elt, pInst) { +p5.MediaElement = function (elt, pInst) { p5.Element.call(this, elt, pInst); var self = this; @@ -2363,13 +2375,13 @@ p5.MediaElement = function(elt, pInst) { *
*/ Object.defineProperty(self, 'src', { - get: function() { + get: function () { var firstChildSrc = self.elt.children[0].src; var srcVal = self.elt.src === window.location.href ? '' : self.elt.src; var ret = firstChildSrc === window.location.href ? srcVal : firstChildSrc; return ret; }, - set: function(newValue) { + set: function (newValue) { for (var i = 0; i < self.elt.children.length; i++) { self.elt.removeChild(self.elt.children[i]); } @@ -2382,8 +2394,8 @@ p5.MediaElement = function(elt, pInst) { }); // private _onended callback, set by the method: onended(callback) - self._onended = function() {}; - self.elt.onended = function() { + self._onended = function () {}; + self.elt.onended = function () { self._onended(self); }; }; @@ -2427,7 +2439,7 @@ p5.MediaElement.prototype = Object.create(p5.Element.prototype); * } *
*/ -p5.MediaElement.prototype.play = function() { +p5.MediaElement.prototype.play = function () { if (this.elt.currentTime === this.elt.duration) { this.elt.currentTime = 0; } @@ -2440,7 +2452,7 @@ p5.MediaElement.prototype.play = function() { promise = this.elt.play(); } if (promise && promise.catch) { - promise.catch(function(e) { + promise.catch(function (e) { // if it's an autoplay failure error if (e.name === 'NotAllowedError') { p5._friendlyAutoplayError(this.src); @@ -2511,7 +2523,7 @@ p5.MediaElement.prototype.play = function() { * } * */ -p5.MediaElement.prototype.stop = function() { +p5.MediaElement.prototype.stop = function () { this.elt.pause(); this.elt.currentTime = 0; return this; @@ -2574,7 +2586,7 @@ p5.MediaElement.prototype.stop = function() { * } * */ -p5.MediaElement.prototype.pause = function() { +p5.MediaElement.prototype.pause = function () { this.elt.pause(); return this; }; @@ -2630,7 +2642,7 @@ p5.MediaElement.prototype.pause = function() { * } * */ -p5.MediaElement.prototype.loop = function() { +p5.MediaElement.prototype.loop = function () { this.elt.setAttribute('loop', true); this.play(); return this; @@ -2682,7 +2694,7 @@ p5.MediaElement.prototype.loop = function() { * } * */ -p5.MediaElement.prototype.noLoop = function() { +p5.MediaElement.prototype.noLoop = function () { this.elt.removeAttribute('loop'); return this; }; @@ -2693,7 +2705,7 @@ p5.MediaElement.prototype.noLoop = function() { * @method setupAutoplayFailDetection * @private */ -p5.MediaElement.prototype._setupAutoplayFailDetection = function() { +p5.MediaElement.prototype._setupAutoplayFailDetection = function () { const timeout = setTimeout(() => p5._friendlyAutoplayError(this.src), 500); this.elt.addEventListener('play', () => clearTimeout(timeout), { passive: true, @@ -2746,7 +2758,7 @@ p5.MediaElement.prototype._setupAutoplayFailDetection = function() { * An example of a video element which waits for a trigger for playing. */ -p5.MediaElement.prototype.autoplay = function(val) { +p5.MediaElement.prototype.autoplay = function (val) { const oldVal = this.elt.getAttribute('autoplay'); this.elt.setAttribute('autoplay', val); // if we turned on autoplay @@ -2846,7 +2858,7 @@ p5.MediaElement.prototype.autoplay = function(val) { * @param {Number} val volume between 0.0 and 1.0 * @chainable */ -p5.MediaElement.prototype.volume = function(val) { +p5.MediaElement.prototype.volume = function (val) { if (typeof val === 'undefined') { return this.elt.volume; } else { @@ -2931,7 +2943,7 @@ p5.MediaElement.prototype.volume = function(val) { * @param {Number} speed speed multiplier for element playback * @chainable */ -p5.MediaElement.prototype.speed = function(val) { +p5.MediaElement.prototype.speed = function (val) { if (typeof val === 'undefined') { return this.presetPlaybackRate || this.elt.playbackRate; } else { @@ -2993,7 +3005,7 @@ p5.MediaElement.prototype.speed = function(val) { * @param {Number} time time to jump to (in seconds) * @chainable */ -p5.MediaElement.prototype.time = function(val) { +p5.MediaElement.prototype.time = function (val) { if (typeof val === 'undefined') { return this.elt.currentTime; } else { @@ -3030,11 +3042,11 @@ p5.MediaElement.prototype.time = function(val) { * } * */ -p5.MediaElement.prototype.duration = function() { +p5.MediaElement.prototype.duration = function () { return this.elt.duration; }; p5.MediaElement.prototype.pixels = []; -p5.MediaElement.prototype._ensureCanvas = function() { +p5.MediaElement.prototype._ensureCanvas = function () { if (!this.canvas) { this.canvas = document.createElement('canvas'); this.drawingContext = this.canvas.getContext('2d'); @@ -3059,11 +3071,11 @@ p5.MediaElement.prototype._ensureCanvas = function() { this.setModified(true); } }; -p5.MediaElement.prototype.loadPixels = function() { +p5.MediaElement.prototype.loadPixels = function () { this._ensureCanvas(); return p5.Renderer2D.prototype.loadPixels.apply(this, arguments); }; -p5.MediaElement.prototype.updatePixels = function(x, y, w, h) { +p5.MediaElement.prototype.updatePixels = function (x, y, w, h) { if (this.loadedmetadata) { // wait for metadata this._ensureCanvas(); @@ -3072,16 +3084,16 @@ p5.MediaElement.prototype.updatePixels = function(x, y, w, h) { this.setModified(true); return this; }; -p5.MediaElement.prototype.get = function() { +p5.MediaElement.prototype.get = function () { this._ensureCanvas(); return p5.Renderer2D.prototype.get.apply(this, arguments); }; -p5.MediaElement.prototype._getPixel = function() { +p5.MediaElement.prototype._getPixel = function () { this.loadPixels(); return p5.Renderer2D.prototype._getPixel.apply(this, arguments); }; -p5.MediaElement.prototype.set = function(x, y, imgOrCol) { +p5.MediaElement.prototype.set = function (x, y, imgOrCol) { if (this.loadedmetadata) { // wait for metadata this._ensureCanvas(); @@ -3089,11 +3101,11 @@ p5.MediaElement.prototype.set = function(x, y, imgOrCol) { this.setModified(true); } }; -p5.MediaElement.prototype.copy = function() { +p5.MediaElement.prototype.copy = function () { this._ensureCanvas(); p5.prototype.copy.apply(this, arguments); }; -p5.MediaElement.prototype.mask = function() { +p5.MediaElement.prototype.mask = function () { this.loadPixels(); this.setModified(true); p5.Image.prototype.mask.apply(this, arguments); @@ -3107,7 +3119,7 @@ p5.MediaElement.prototype.mask = function() { * @return {boolean} a boolean indicating whether or not the * image has been updated or modified since last texture upload. */ -p5.MediaElement.prototype.isModified = function() { +p5.MediaElement.prototype.isModified = function () { return this._modified; }; /** @@ -3121,7 +3133,7 @@ p5.MediaElement.prototype.isModified = function() { * modified. * @private */ -p5.MediaElement.prototype.setModified = function(value) { +p5.MediaElement.prototype.setModified = function (value) { this._modified = value; }; /** @@ -3150,7 +3162,7 @@ p5.MediaElement.prototype.setModified = function(value) { * } * */ -p5.MediaElement.prototype.onended = function(callback) { +p5.MediaElement.prototype.onended = function (callback) { this._onended = callback; return this; }; @@ -3169,7 +3181,7 @@ p5.MediaElement.prototype.onended = function(callback) { * @param {AudioNode|Object} audioNode AudioNode from the Web Audio API, * or an object from the p5.sound library */ -p5.MediaElement.prototype.connect = function(obj) { +p5.MediaElement.prototype.connect = function (obj) { var audioContext, mainOutput; // if p5.sound exists, same audio context @@ -3213,7 +3225,7 @@ p5.MediaElement.prototype.connect = function(obj) { * * @method disconnect */ -p5.MediaElement.prototype.disconnect = function() { +p5.MediaElement.prototype.disconnect = function () { if (this.audioSourceNode) { this.audioSourceNode.disconnect(); } else { @@ -3248,7 +3260,7 @@ p5.MediaElement.prototype.disconnect = function() { * } * */ -p5.MediaElement.prototype.showControls = function() { +p5.MediaElement.prototype.showControls = function () { // must set style for the element to show on the page this.elt.style['text-align'] = 'inherit'; this.elt.controls = true; @@ -3279,7 +3291,7 @@ p5.MediaElement.prototype.showControls = function() { * } * */ -p5.MediaElement.prototype.hideControls = function() { +p5.MediaElement.prototype.hideControls = function () { this.elt.controls = false; }; @@ -3287,7 +3299,7 @@ p5.MediaElement.prototype.hideControls = function() { // Cue inspired by JavaScript setTimeout, and the // Tone.js Transport Timeline Event, MIT License Yotam Mann 2015 tonejs.org -var Cue = function(callback, time, id, val) { +var Cue = function (callback, time, id, val) { this.callback = callback; this.time = time; this.id = id; @@ -3344,7 +3356,7 @@ var Cue = function(callback, time, id, val) { * } * */ -p5.MediaElement.prototype.addCue = function(time, callback, val) { +p5.MediaElement.prototype.addCue = function (time, callback, val) { var id = this._cueIDCounter++; var cue = new Cue(callback, time, id, val); @@ -3386,7 +3398,7 @@ p5.MediaElement.prototype.addCue = function(time, callback, val) { * } * */ -p5.MediaElement.prototype.removeCue = function(id) { +p5.MediaElement.prototype.removeCue = function (id) { for (var i = 0; i < this._cues.length; i++) { if (this._cues[i].id === id) { console.log(id); @@ -3433,14 +3445,14 @@ p5.MediaElement.prototype.removeCue = function(id) { * } * */ -p5.MediaElement.prototype.clearCues = function() { +p5.MediaElement.prototype.clearCues = function () { this._cues = []; this.elt.ontimeupdate = null; }; // private method that checks for cues to be fired if events // have been scheduled using addCue(callback, time). -p5.MediaElement.prototype._onTimeUpdate = function() { +p5.MediaElement.prototype._onTimeUpdate = function () { var playbackTime = this.time(); for (var i = 0; i < this._cues.length; i++) { @@ -3464,7 +3476,7 @@ p5.MediaElement.prototype._onTimeUpdate = function() { * @constructor * @param {File} file File that is wrapped */ -p5.File = function(file, pInst) { +p5.File = function (file, pInst) { /** * Underlying File object. All normal File methods can be called on this. * @@ -3511,9 +3523,9 @@ p5.File = function(file, pInst) { this.data = undefined; }; -p5.File._createLoader = function(theFile, callback) { +p5.File._createLoader = function (theFile, callback) { var reader = new FileReader(); - reader.onload = function(e) { + reader.onload = function (e) { var p5file = new p5.File(theFile); if (p5file.file.type === 'application/json') { // Parse JSON and store the result in data @@ -3531,7 +3543,7 @@ p5.File._createLoader = function(theFile, callback) { return reader; }; -p5.File._load = function(f, callback) { +p5.File._load = function (f, callback) { // Text or data? // This should likely be improved if (/^text\//.test(f.type) || f.type === 'application/json') { From 2155745a5bd36395ac26ba05b8bfa32db51a8623 Mon Sep 17 00:00:00 2001 From: Shantanu Kaushik Date: Wed, 23 Sep 2020 11:25:58 +0530 Subject: [PATCH 03/97] examples now showing, removed spaces which caused error during build --- src/dom/dom.js | 240 +++++++++++++++++++++++-------------------------- 1 file changed, 114 insertions(+), 126 deletions(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index e155030cb1..ec39cdaac6 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -54,7 +54,7 @@ import p5 from '../core/main'; * [a, b, c, d, e]; // unused * */ -p5.prototype.select = function (e, p) { +p5.prototype.select = function(e, p) { p5._validateParameters('select', arguments); const container = this._getContainer(p); const res = container.querySelector(e); @@ -91,7 +91,7 @@ p5.prototype.select = function (e, p) { * } * } * - *
+ *
* // these are all valid calls to selectAll() * let a = selectAll('.beep'); * a = selectAll('div'); @@ -109,7 +109,7 @@ p5.prototype.select = function (e, p) { * console.log(a); *
*/ -p5.prototype.selectAll = function (e, p) { +p5.prototype.selectAll = function(e, p) { p5._validateParameters('selectAll', arguments); const arr = []; const container = this._getContainer(p); @@ -126,7 +126,7 @@ p5.prototype.selectAll = function (e, p) { /** * Helper function for select and selectAll */ -p5.prototype._getContainer = function (p) { +p5.prototype._getContainer = function(p) { let container = document; if (typeof p === 'string') { container = document.querySelector(p) || document; @@ -141,11 +141,11 @@ p5.prototype._getContainer = function (p) { /** * Helper function for getElement and getElements. */ -p5.prototype._wrapElement = function (elt) { +p5.prototype._wrapElement = function(elt) { var children = Array.prototype.slice.call(elt.children); if (elt.tagName === 'INPUT' && elt.type === 'checkbox') { var converted = new p5.Element(elt, this); - converted.checked = function () { + converted.checked = function() { if (arguments.length === 0) { return this.elt.checked; } else if (arguments[0]) { @@ -162,7 +162,7 @@ p5.prototype._wrapElement = function (elt) { return this.createSelect(new p5.Element(elt, this)); } else if ( children.length > 0 && - children.every(function (c) { + children.every(function(c) { return c.tagName === 'INPUT' || c.tagName === 'LABEL'; }) ) { @@ -189,7 +189,7 @@ p5.prototype._wrapElement = function (elt) { * } *
*/ -p5.prototype.removeElements = function (e) { +p5.prototype.removeElements = function(e) { p5._validateParameters('removeElements', arguments); // el.remove splices from this._elements, so don't mix iteration with it const isNotCanvasElement = el => !(el.elt instanceof HTMLCanvasElement); @@ -259,7 +259,7 @@ p5.prototype.removeElements = function (e) { * @alt * dropdown: pear, kiwi, grape. When selected text "its a" + selection shown. */ -p5.Element.prototype.changed = function (fxn) { +p5.Element.prototype.changed = function(fxn) { p5.Element._adjustListener('change', fxn, this); return this; }; @@ -293,7 +293,7 @@ p5.Element.prototype.changed = function (fxn) { * @alt * no display. */ -p5.Element.prototype.input = function (fxn) { +p5.Element.prototype.input = function(fxn) { p5.Element._adjustListener('input', fxn, this); return this; }; @@ -320,7 +320,7 @@ function addElement(elt, pInst, media) { * createDiv('this is some text'); * */ -p5.prototype.createDiv = function (html = '') { +p5.prototype.createDiv = function(html = '') { let elt = document.createElement('div'); elt.innerHTML = html; return addElement(elt, this); @@ -338,7 +338,7 @@ p5.prototype.createDiv = function (html = '') { * createP('this is some text'); * */ -p5.prototype.createP = function (html = '') { +p5.prototype.createP = function(html = '') { let elt = document.createElement('p'); elt.innerHTML = html; return addElement(elt, this); @@ -355,7 +355,7 @@ p5.prototype.createP = function (html = '') { * createSpan('this is some text'); * */ -p5.prototype.createSpan = function (html = '') { +p5.prototype.createSpan = function(html = '') { let elt = document.createElement('span'); elt.innerHTML = html; return addElement(elt, this); @@ -385,7 +385,7 @@ p5.prototype.createSpan = function (html = '') { * @param {Function} [successCallback] callback to be called once image data is loaded with the p5.Element as argument * @return {p5.Element} pointer to p5.Element holding created node */ -p5.prototype.createImg = function () { +p5.prototype.createImg = function() { p5._validateParameters('createImg', arguments); var elt = document.createElement('img'); var args = arguments; @@ -398,7 +398,7 @@ p5.prototype.createImg = function () { } elt.src = args[0]; self = addElement(elt, this); - elt.addEventListener('load', function () { + elt.addEventListener('load', function() { self.width = elt.offsetWidth || elt.width; self.height = elt.offsetHeight || elt.height; var last = args[args.length - 1]; @@ -421,7 +421,7 @@ p5.prototype.createImg = function () { * createA('http://p5js.org/', 'this is a link'); * */ -p5.prototype.createA = function (href, html, target) { +p5.prototype.createA = function(href, html, target) { p5._validateParameters('createA', arguments); var elt = document.createElement('a'); elt.href = href; @@ -472,7 +472,7 @@ p5.prototype.createA = function (href, html, target) { * } * */ -p5.prototype.createSlider = function (min, max, value, step) { +p5.prototype.createSlider = function(min, max, value, step) { p5._validateParameters('createSlider', arguments); var elt = document.createElement('input'); elt.type = 'range'; @@ -513,7 +513,7 @@ p5.prototype.createSlider = function (min, max, value, step) { * } * */ -p5.prototype.createButton = function (label, value) { +p5.prototype.createButton = function(label, value) { p5._validateParameters('createButton', arguments); var elt = document.createElement('button'); elt.innerHTML = label; @@ -547,7 +547,7 @@ p5.prototype.createButton = function (label, value) { * } * */ -p5.prototype.createCheckbox = function () { +p5.prototype.createCheckbox = function() { p5._validateParameters('createCheckbox', arguments); var elt = document.createElement('div'); var checkbox = document.createElement('input'); @@ -555,7 +555,7 @@ p5.prototype.createCheckbox = function () { elt.appendChild(checkbox); //checkbox must be wrapped in p5.Element before label so that label appears after var self = addElement(elt, this); - self.checked = function () { + self.checked = function() { var cb = self.elt.getElementsByTagName('input')[0]; if (cb) { if (arguments.length === 0) { @@ -568,7 +568,7 @@ p5.prototype.createCheckbox = function () { } return self; }; - this.value = function (val) { + this.value = function(val) { self.value = val; return this; }; @@ -646,7 +646,7 @@ p5.prototype.createCheckbox = function () { * @return {p5.Element} */ -p5.prototype.createSelect = function () { +p5.prototype.createSelect = function() { p5._validateParameters('createSelect', arguments); let self; let arg = arguments[0]; @@ -665,7 +665,7 @@ p5.prototype.createSelect = function () { self = addElement(elt, this); this.elt = elt; } - self.option = function (name, value) { + self.option = function(name, value) { let index; // if no name is passed, return @@ -698,7 +698,7 @@ p5.prototype.createSelect = function () { } }; - self.selected = function (value) { + self.selected = function(value) { // Update selected status of option if (value !== undefined) { for (let i = 0; i < this.elt.length; i += 1) { @@ -720,7 +720,7 @@ p5.prototype.createSelect = function () { } }; - self.disable = function (value) { + self.disable = function(value) { if (typeof value === 'string') { for (let i = 0; i < this.elt.length; i++) { if (this.elt[i].value.toString() === value) { @@ -804,7 +804,7 @@ p5.prototype.createSelect = function () { * @method createRadio * @return {p5.Element} pointer to p5.Element holding created node */ -p5.prototype.createRadio = function () { +p5.prototype.createRadio = function() { // Creates a div, adds each option as an individual input inside it. // If already given with a containerEl, will search for all input[radio] // it, create a p5.Element out of it, add options to it and return the p5.Element. @@ -829,11 +829,11 @@ p5.prototype.createRadio = function () { el instanceof HTMLInputElement && el.type === 'radio'; const isNextLabel = el => el.nextElementSibling instanceof HTMLLabelElement; - self._getOptionsArray = function () { + self._getOptionsArray = function() { return Array.from(this.elt.children).filter(isRadioInput); }; - self.option = function (value, label) { + self.option = function(value, label) { // return an option with this value, create if not exists. let optionEl; for (const option of self._getOptionsArray()) { @@ -865,7 +865,7 @@ p5.prototype.createRadio = function () { return optionEl; }; - self.remove = function (value) { + self.remove = function(value) { for (const optionEl of self._getOptionsArray()) { if (optionEl.value === value) { if (isNextLabel(optionEl)) optionEl.nextElementSibling.remove(); @@ -875,7 +875,7 @@ p5.prototype.createRadio = function () { } }; - self.value = function () { + self.value = function() { let result = ''; for (const option of self._getOptionsArray()) { if (option.checked) { @@ -886,7 +886,7 @@ p5.prototype.createRadio = function () { return result; }; - self.selected = function (value) { + self.selected = function(value) { let result = null; if (value === undefined) { for (const option of self._getOptionsArray()) { @@ -906,7 +906,7 @@ p5.prototype.createRadio = function () { return result; }; - self.disable = function (shouldDisable = true) { + self.disable = function(shouldDisable = true) { for (const radioInput of self._getOptionsArray()) { radioInput.setAttribute('disabled', shouldDisable); } @@ -967,7 +967,7 @@ p5.prototype.createRadio = function () { * } * */ -p5.prototype.createColorPicker = function (value) { +p5.prototype.createColorPicker = function(value) { p5._validateParameters('createColorPicker', arguments); var elt = document.createElement('input'); var self; @@ -989,7 +989,7 @@ p5.prototype.createColorPicker = function (value) { } self = addElement(elt, this); // Method to return a p5.Color object for the given color. - self.color = function () { + self.color = function() { if (value) { if (value.mode) { p5.prototype._colorMode = value.mode; @@ -1029,7 +1029,7 @@ p5.prototype.createColorPicker = function (value) { * @param {String} [value] * @return {p5.Element} */ -p5.prototype.createInput = function (value = '', type = 'text') { +p5.prototype.createInput = function(value = '', type = 'text') { p5._validateParameters('createInput', arguments); let elt = document.createElement('input'); elt.setAttribute('value', value); @@ -1073,10 +1073,10 @@ p5.prototype.createInput = function (value = '', type = 'text') { * } * */ -p5.prototype.createFileInput = function (callback, multiple = false) { +p5.prototype.createFileInput = function(callback, multiple = false) { p5._validateParameters('createFileInput', arguments); - const handleFileSelect = function (event) { + const handleFileSelect = function(event) { for (const file of event.target.files) { p5.File._load(file, callback); } @@ -1185,7 +1185,7 @@ function createMedia(pInst, type, src, callback) { * } * */ -p5.prototype.createVideo = function (src, callback) { +p5.prototype.createVideo = function(src, callback) { p5._validateParameters('createVideo', arguments); return createMedia(this, 'video', src, callback); }; @@ -1224,7 +1224,7 @@ p5.prototype.createVideo = function (src, callback) { * } * */ -p5.prototype.createAudio = function (src, callback) { +p5.prototype.createAudio = function(src, callback) { p5._validateParameters('createAudio', arguments); return createMedia(this, 'audio', src, callback); }; @@ -1254,7 +1254,7 @@ if (navigator.mediaDevices === undefined) { // with getUserMedia as it would overwrite existing properties. // Here, we will just add the getUserMedia property if it's missing. if (navigator.mediaDevices.getUserMedia === undefined) { - navigator.mediaDevices.getUserMedia = function (constraints) { + navigator.mediaDevices.getUserMedia = function(constraints) { // First get ahold of the legacy getUserMedia, if present var getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia; @@ -1268,7 +1268,7 @@ if (navigator.mediaDevices.getUserMedia === undefined) { } // Otherwise, wrap the call to the old navigator.getUserMedia with a Promise - return new Promise(function (resolve, reject) { + return new Promise(function(resolve, reject) { getUserMedia.call(navigator, constraints, resolve, reject); }); }; @@ -1318,7 +1318,7 @@ if (navigator.mediaDevices.getUserMedia === undefined) { * * * - *
+ *
* * function setup() { * createCanvas(480, 120); @@ -1338,7 +1338,7 @@ if (navigator.mediaDevices.getUserMedia === undefined) { * } * *
- *
+ *
* * let capture; * @@ -1356,7 +1356,7 @@ if (navigator.mediaDevices.getUserMedia === undefined) { * *
*/ -p5.prototype.createCapture = function () { +p5.prototype.createCapture = function() { p5._validateParameters('createCapture', arguments); // return if getUserMedia is not supported by browser @@ -1374,16 +1374,13 @@ p5.prototype.createCapture = function () { else if (typeof arg === 'object') constraints = arg; else if (typeof arg === 'function') callback = arg; } - if (!constraints) constraints = { - video: useVideo, - audio: useAudio - }; + if (!constraints) constraints = { video: useVideo, audio: useAudio }; const domElement = document.createElement('video'); // required to work in iOS 11 & up: domElement.setAttribute('playsinline', ''); - navigator.mediaDevices.getUserMedia(constraints).then(function (stream) { + navigator.mediaDevices.getUserMedia(constraints).then(function(stream) { try { if ('srcObject' in domElement) { domElement.srcObject = stream; @@ -1398,7 +1395,7 @@ p5.prototype.createCapture = function () { const videoEl = addElement(domElement, this, true); videoEl.loadedmetadata = false; // set width and height onload metadata - domElement.addEventListener('loadedmetadata', function () { + domElement.addEventListener('loadedmetadata', function() { domElement.play(); if (domElement.width) { videoEl.width = domElement.width; @@ -1426,7 +1423,7 @@ p5.prototype.createCapture = function () { * createElement('h2', 'im an h2 p5.element!'); *
*/ -p5.prototype.createElement = function (tag, content) { +p5.prototype.createElement = function(tag, content) { p5._validateParameters('createElement', arguments); var elt = document.createElement(tag); if (typeof content !== 'undefined') { @@ -1452,7 +1449,7 @@ p5.prototype.createElement = function (tag, content) { * div.addClass('myClass'); *
*/ -p5.Element.prototype.addClass = function (c) { +p5.Element.prototype.addClass = function(c) { if (this.elt.className) { if (!this.hasClass(c)) { this.elt.className = this.elt.className + ' ' + c; @@ -1488,7 +1485,7 @@ p5.Element.prototype.addClass = function (c) { * } * */ -p5.Element.prototype.removeClass = function (c) { +p5.Element.prototype.removeClass = function(c) { // Note: Removing a class that does not exist does NOT throw an error in classList.remove method this.elt.classList.remove(c); return this; @@ -1519,7 +1516,7 @@ p5.Element.prototype.removeClass = function (c) { * } * */ -p5.Element.prototype.hasClass = function (c) { +p5.Element.prototype.hasClass = function(c) { return this.elt.classList.contains(c); }; @@ -1544,7 +1541,7 @@ p5.Element.prototype.hasClass = function (c) { * } * */ -p5.Element.prototype.toggleClass = function (c) { +p5.Element.prototype.toggleClass = function(c) { // classList also has a toggle() method, but we cannot use that yet as support is unclear. // See https://github.com/processing/p5.js/issues/3631 // this.elt.classList.toggle(c); @@ -1590,7 +1587,7 @@ p5.Element.prototype.toggleClass = function (c) { * to add to the current element * @chainable */ -p5.Element.prototype.child = function (childNode) { +p5.Element.prototype.child = function(childNode) { if (typeof childNode === 'undefined') { return this.elt.childNodes; } @@ -1628,14 +1625,11 @@ p5.Element.prototype.child = function (childNode) { * } * */ -p5.Element.prototype.center = function (align) { +p5.Element.prototype.center = function(align) { var style = this.elt.style.display; var hidden = this.elt.style.display === 'none'; var parentHidden = this.parent().style.display === 'none'; - var pos = { - x: this.elt.offsetLeft, - y: this.elt.offsetTop - }; + var pos = { x: this.elt.offsetLeft, y: this.elt.offsetTop }; if (hidden) this.show(); if (parentHidden) this.parent().show(); @@ -1690,7 +1684,7 @@ p5.Element.prototype.center = function (align) { * @param {boolean} [append] whether to append HTML to existing * @chainable */ -p5.Element.prototype.html = function () { +p5.Element.prototype.html = function() { if (arguments.length === 0) { return this.elt.innerHTML; } else if (arguments[1]) { @@ -1742,12 +1736,9 @@ p5.Element.prototype.html = function () { * @param {String} positionType it can be static, fixed, relative, sticky, initial or inherit (optional) * @chainable */ -p5.Element.prototype.position = function () { +p5.Element.prototype.position = function() { if (arguments.length === 0) { - return { - x: this.elt.offsetLeft, - y: this.elt.offsetTop - }; + return { x: this.elt.offsetLeft, y: this.elt.offsetTop }; } else { let positionType = 'absolute'; if ( @@ -1770,7 +1761,7 @@ p5.Element.prototype.position = function () { }; /* Helper method called by p5.Element.style() */ -p5.Element.prototype._translate = function () { +p5.Element.prototype._translate = function() { this.elt.style.position = 'absolute'; // save out initial non-translate transform styling var transform = ''; @@ -1802,7 +1793,7 @@ p5.Element.prototype._translate = function () { }; /* Helper method called by p5.Element.style() */ -p5.Element.prototype._rotate = function () { +p5.Element.prototype._rotate = function() { // save out initial non-rotate transform styling var transform = ''; if (this.elt.style.transform) { @@ -1867,7 +1858,7 @@ p5.Element.prototype._rotate = function () { * @return {String} current value of property, if no value is given as second argument * @chainable */ -p5.Element.prototype.style = function (prop, val) { +p5.Element.prototype.style = function(prop, val) { var self = this; if (val instanceof p5.Color) { @@ -1938,7 +1929,7 @@ p5.Element.prototype.style = function (prop, val) { * @param {String} value value to assign to attribute * @chainable */ -p5.Element.prototype.attribute = function (attr, value) { +p5.Element.prototype.attribute = function(attr, value) { //handling for checkboxes and radios to ensure options get //attributes not divs if ( @@ -1992,7 +1983,7 @@ p5.Element.prototype.attribute = function (attr, value) { * } * */ -p5.Element.prototype.removeAttribute = function (attr) { +p5.Element.prototype.removeAttribute = function(attr) { if ( this.elt.firstChild != null && (this.elt.firstChild.type === 'checkbox' || @@ -2041,7 +2032,7 @@ p5.Element.prototype.removeAttribute = function (attr) { * @param {String|Number} value * @chainable */ -p5.Element.prototype.value = function () { +p5.Element.prototype.value = function() { if (arguments.length > 0) { this.elt.value = arguments[0]; return this; @@ -2065,7 +2056,7 @@ p5.Element.prototype.value = function () { * div.show(); // turns display to block * */ -p5.Element.prototype.show = function () { +p5.Element.prototype.show = function() { this.elt.style.display = 'block'; return this; }; @@ -2081,7 +2072,7 @@ p5.Element.prototype.show = function () { * div.hide(); * */ -p5.Element.prototype.hide = function () { +p5.Element.prototype.hide = function() { this.elt.style.display = 'none'; return this; }; @@ -2116,12 +2107,9 @@ p5.Element.prototype.hide = function () { * @param {Number|Constant} [h] height of the element, either AUTO, or a number * @chainable */ -p5.Element.prototype.size = function (w, h) { +p5.Element.prototype.size = function(w, h) { if (arguments.length === 0) { - return { - width: this.elt.offsetWidth, - height: this.elt.offsetHeight - }; + return { width: this.elt.offsetWidth, height: this.elt.offsetHeight }; } else { var aW = w; var aH = h; @@ -2179,12 +2167,12 @@ p5.Element.prototype.size = function (w, h) { * myDiv.remove(); * */ -p5.Element.prototype.remove = function () { +p5.Element.prototype.remove = function() { // stop all audios/videos and detach all devices like microphone/camera etc // used as input/output for audios/videos. if (this instanceof p5.MediaElement) { const tracks = this.elt.srcObject.getTracks(); - tracks.forEach(function (track) { + tracks.forEach(function(track) { track.stop(); }); } @@ -2263,13 +2251,13 @@ p5.Element.prototype.remove = function () { * @alt * Canvas turns into whatever image is dragged/dropped onto it. */ -p5.Element.prototype.drop = function (callback, fxn) { +p5.Element.prototype.drop = function(callback, fxn) { // Is the file stuff supported? if (window.File && window.FileReader && window.FileList && window.Blob) { if (!this._dragDisabled) { this._dragDisabled = true; - var preventDefault = function (evt) { + var preventDefault = function(evt) { evt.preventDefault(); }; @@ -2285,7 +2273,7 @@ p5.Element.prototype.drop = function (callback, fxn) { // Deal with the files p5.Element._attachListener( 'drop', - function (evt) { + function(evt) { evt.preventDefault(); // Call the second argument as a callback that receives the raw drop event if (typeof fxn === 'function') { @@ -2323,7 +2311,7 @@ p5.Element.prototype.drop = function (callback, fxn) { * @constructor * @param {String} elt DOM node that is wrapped */ -p5.MediaElement = function (elt, pInst) { +p5.MediaElement = function(elt, pInst) { p5.Element.call(this, elt, pInst); var self = this; @@ -2375,13 +2363,13 @@ p5.MediaElement = function (elt, pInst) { * */ Object.defineProperty(self, 'src', { - get: function () { + get: function() { var firstChildSrc = self.elt.children[0].src; var srcVal = self.elt.src === window.location.href ? '' : self.elt.src; var ret = firstChildSrc === window.location.href ? srcVal : firstChildSrc; return ret; }, - set: function (newValue) { + set: function(newValue) { for (var i = 0; i < self.elt.children.length; i++) { self.elt.removeChild(self.elt.children[i]); } @@ -2394,8 +2382,8 @@ p5.MediaElement = function (elt, pInst) { }); // private _onended callback, set by the method: onended(callback) - self._onended = function () {}; - self.elt.onended = function () { + self._onended = function() {}; + self.elt.onended = function() { self._onended(self); }; }; @@ -2439,7 +2427,7 @@ p5.MediaElement.prototype = Object.create(p5.Element.prototype); * } * */ -p5.MediaElement.prototype.play = function () { +p5.MediaElement.prototype.play = function() { if (this.elt.currentTime === this.elt.duration) { this.elt.currentTime = 0; } @@ -2452,7 +2440,7 @@ p5.MediaElement.prototype.play = function () { promise = this.elt.play(); } if (promise && promise.catch) { - promise.catch(function (e) { + promise.catch(function(e) { // if it's an autoplay failure error if (e.name === 'NotAllowedError') { p5._friendlyAutoplayError(this.src); @@ -2523,7 +2511,7 @@ p5.MediaElement.prototype.play = function () { * } * */ -p5.MediaElement.prototype.stop = function () { +p5.MediaElement.prototype.stop = function() { this.elt.pause(); this.elt.currentTime = 0; return this; @@ -2586,7 +2574,7 @@ p5.MediaElement.prototype.stop = function () { * } * */ -p5.MediaElement.prototype.pause = function () { +p5.MediaElement.prototype.pause = function() { this.elt.pause(); return this; }; @@ -2642,7 +2630,7 @@ p5.MediaElement.prototype.pause = function () { * } * */ -p5.MediaElement.prototype.loop = function () { +p5.MediaElement.prototype.loop = function() { this.elt.setAttribute('loop', true); this.play(); return this; @@ -2694,7 +2682,7 @@ p5.MediaElement.prototype.loop = function () { * } * */ -p5.MediaElement.prototype.noLoop = function () { +p5.MediaElement.prototype.noLoop = function() { this.elt.removeAttribute('loop'); return this; }; @@ -2705,7 +2693,7 @@ p5.MediaElement.prototype.noLoop = function () { * @method setupAutoplayFailDetection * @private */ -p5.MediaElement.prototype._setupAutoplayFailDetection = function () { +p5.MediaElement.prototype._setupAutoplayFailDetection = function() { const timeout = setTimeout(() => p5._friendlyAutoplayError(this.src), 500); this.elt.addEventListener('play', () => clearTimeout(timeout), { passive: true, @@ -2758,7 +2746,7 @@ p5.MediaElement.prototype._setupAutoplayFailDetection = function () { * An example of a video element which waits for a trigger for playing. */ -p5.MediaElement.prototype.autoplay = function (val) { +p5.MediaElement.prototype.autoplay = function(val) { const oldVal = this.elt.getAttribute('autoplay'); this.elt.setAttribute('autoplay', val); // if we turned on autoplay @@ -2858,7 +2846,7 @@ p5.MediaElement.prototype.autoplay = function (val) { * @param {Number} val volume between 0.0 and 1.0 * @chainable */ -p5.MediaElement.prototype.volume = function (val) { +p5.MediaElement.prototype.volume = function(val) { if (typeof val === 'undefined') { return this.elt.volume; } else { @@ -2943,7 +2931,7 @@ p5.MediaElement.prototype.volume = function (val) { * @param {Number} speed speed multiplier for element playback * @chainable */ -p5.MediaElement.prototype.speed = function (val) { +p5.MediaElement.prototype.speed = function(val) { if (typeof val === 'undefined') { return this.presetPlaybackRate || this.elt.playbackRate; } else { @@ -3005,7 +2993,7 @@ p5.MediaElement.prototype.speed = function (val) { * @param {Number} time time to jump to (in seconds) * @chainable */ -p5.MediaElement.prototype.time = function (val) { +p5.MediaElement.prototype.time = function(val) { if (typeof val === 'undefined') { return this.elt.currentTime; } else { @@ -3042,11 +3030,11 @@ p5.MediaElement.prototype.time = function (val) { * } * */ -p5.MediaElement.prototype.duration = function () { +p5.MediaElement.prototype.duration = function() { return this.elt.duration; }; p5.MediaElement.prototype.pixels = []; -p5.MediaElement.prototype._ensureCanvas = function () { +p5.MediaElement.prototype._ensureCanvas = function() { if (!this.canvas) { this.canvas = document.createElement('canvas'); this.drawingContext = this.canvas.getContext('2d'); @@ -3071,11 +3059,11 @@ p5.MediaElement.prototype._ensureCanvas = function () { this.setModified(true); } }; -p5.MediaElement.prototype.loadPixels = function () { +p5.MediaElement.prototype.loadPixels = function() { this._ensureCanvas(); return p5.Renderer2D.prototype.loadPixels.apply(this, arguments); }; -p5.MediaElement.prototype.updatePixels = function (x, y, w, h) { +p5.MediaElement.prototype.updatePixels = function(x, y, w, h) { if (this.loadedmetadata) { // wait for metadata this._ensureCanvas(); @@ -3084,16 +3072,16 @@ p5.MediaElement.prototype.updatePixels = function (x, y, w, h) { this.setModified(true); return this; }; -p5.MediaElement.prototype.get = function () { +p5.MediaElement.prototype.get = function() { this._ensureCanvas(); return p5.Renderer2D.prototype.get.apply(this, arguments); }; -p5.MediaElement.prototype._getPixel = function () { +p5.MediaElement.prototype._getPixel = function() { this.loadPixels(); return p5.Renderer2D.prototype._getPixel.apply(this, arguments); }; -p5.MediaElement.prototype.set = function (x, y, imgOrCol) { +p5.MediaElement.prototype.set = function(x, y, imgOrCol) { if (this.loadedmetadata) { // wait for metadata this._ensureCanvas(); @@ -3101,11 +3089,11 @@ p5.MediaElement.prototype.set = function (x, y, imgOrCol) { this.setModified(true); } }; -p5.MediaElement.prototype.copy = function () { +p5.MediaElement.prototype.copy = function() { this._ensureCanvas(); p5.prototype.copy.apply(this, arguments); }; -p5.MediaElement.prototype.mask = function () { +p5.MediaElement.prototype.mask = function() { this.loadPixels(); this.setModified(true); p5.Image.prototype.mask.apply(this, arguments); @@ -3119,7 +3107,7 @@ p5.MediaElement.prototype.mask = function () { * @return {boolean} a boolean indicating whether or not the * image has been updated or modified since last texture upload. */ -p5.MediaElement.prototype.isModified = function () { +p5.MediaElement.prototype.isModified = function() { return this._modified; }; /** @@ -3133,7 +3121,7 @@ p5.MediaElement.prototype.isModified = function () { * modified. * @private */ -p5.MediaElement.prototype.setModified = function (value) { +p5.MediaElement.prototype.setModified = function(value) { this._modified = value; }; /** @@ -3162,7 +3150,7 @@ p5.MediaElement.prototype.setModified = function (value) { * } * */ -p5.MediaElement.prototype.onended = function (callback) { +p5.MediaElement.prototype.onended = function(callback) { this._onended = callback; return this; }; @@ -3181,7 +3169,7 @@ p5.MediaElement.prototype.onended = function (callback) { * @param {AudioNode|Object} audioNode AudioNode from the Web Audio API, * or an object from the p5.sound library */ -p5.MediaElement.prototype.connect = function (obj) { +p5.MediaElement.prototype.connect = function(obj) { var audioContext, mainOutput; // if p5.sound exists, same audio context @@ -3225,7 +3213,7 @@ p5.MediaElement.prototype.connect = function (obj) { * * @method disconnect */ -p5.MediaElement.prototype.disconnect = function () { +p5.MediaElement.prototype.disconnect = function() { if (this.audioSourceNode) { this.audioSourceNode.disconnect(); } else { @@ -3260,7 +3248,7 @@ p5.MediaElement.prototype.disconnect = function () { * } * */ -p5.MediaElement.prototype.showControls = function () { +p5.MediaElement.prototype.showControls = function() { // must set style for the element to show on the page this.elt.style['text-align'] = 'inherit'; this.elt.controls = true; @@ -3291,7 +3279,7 @@ p5.MediaElement.prototype.showControls = function () { * } * */ -p5.MediaElement.prototype.hideControls = function () { +p5.MediaElement.prototype.hideControls = function() { this.elt.controls = false; }; @@ -3299,7 +3287,7 @@ p5.MediaElement.prototype.hideControls = function () { // Cue inspired by JavaScript setTimeout, and the // Tone.js Transport Timeline Event, MIT License Yotam Mann 2015 tonejs.org -var Cue = function (callback, time, id, val) { +var Cue = function(callback, time, id, val) { this.callback = callback; this.time = time; this.id = id; @@ -3356,7 +3344,7 @@ var Cue = function (callback, time, id, val) { * } * */ -p5.MediaElement.prototype.addCue = function (time, callback, val) { +p5.MediaElement.prototype.addCue = function(time, callback, val) { var id = this._cueIDCounter++; var cue = new Cue(callback, time, id, val); @@ -3398,7 +3386,7 @@ p5.MediaElement.prototype.addCue = function (time, callback, val) { * } * */ -p5.MediaElement.prototype.removeCue = function (id) { +p5.MediaElement.prototype.removeCue = function(id) { for (var i = 0; i < this._cues.length; i++) { if (this._cues[i].id === id) { console.log(id); @@ -3445,14 +3433,14 @@ p5.MediaElement.prototype.removeCue = function (id) { * } * */ -p5.MediaElement.prototype.clearCues = function () { +p5.MediaElement.prototype.clearCues = function() { this._cues = []; this.elt.ontimeupdate = null; }; // private method that checks for cues to be fired if events // have been scheduled using addCue(callback, time). -p5.MediaElement.prototype._onTimeUpdate = function () { +p5.MediaElement.prototype._onTimeUpdate = function() { var playbackTime = this.time(); for (var i = 0; i < this._cues.length; i++) { @@ -3476,7 +3464,7 @@ p5.MediaElement.prototype._onTimeUpdate = function () { * @constructor * @param {File} file File that is wrapped */ -p5.File = function (file, pInst) { +p5.File = function(file, pInst) { /** * Underlying File object. All normal File methods can be called on this. * @@ -3523,9 +3511,9 @@ p5.File = function (file, pInst) { this.data = undefined; }; -p5.File._createLoader = function (theFile, callback) { +p5.File._createLoader = function(theFile, callback) { var reader = new FileReader(); - reader.onload = function (e) { + reader.onload = function(e) { var p5file = new p5.File(theFile); if (p5file.file.type === 'application/json') { // Parse JSON and store the result in data @@ -3543,7 +3531,7 @@ p5.File._createLoader = function (theFile, callback) { return reader; }; -p5.File._load = function (f, callback) { +p5.File._load = function(f, callback) { // Text or data? // This should likely be improved if (/^text\//.test(f.type) || f.type === 'application/json') { From 6d734f59d8b33b447e8472faf9dd92914bf95731 Mon Sep 17 00:00:00 2001 From: gohai Date: Tue, 20 Oct 2020 12:24:24 -0700 Subject: [PATCH 04/97] Make camera() parameters optional The documentation for camera() suggests that all 9 parameters are optional, but passing some - but not all - does break currently. This proposed change lets you call camera() with three parameters for changing only the camera position, or six parameters for camera position & target (without having to specify the not-so-intuitive up vector also). Shouldn't affect current behavior inadvertently (e.g. when calling camera() w/o params). --- src/webgl/p5.Camera.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/webgl/p5.Camera.js b/src/webgl/p5.Camera.js index deb7b9880c..af344e1ca5 100644 --- a/src/webgl/p5.Camera.js +++ b/src/webgl/p5.Camera.js @@ -882,13 +882,17 @@ p5.Camera.prototype.camera = function( this.eyeY = eyeY; this.eyeZ = eyeZ; - this.centerX = centerX; - this.centerY = centerY; - this.centerZ = centerZ; + if (typeof centerX !== 'undefined') { + this.centerX = centerX; + this.centerY = centerY; + this.centerZ = centerZ; + } - this.upX = upX; - this.upY = upY; - this.upZ = upZ; + if (typeof upX !== 'undefined') { + this.upX = upX; + this.upY = upY; + this.upZ = upZ; + } const local = this._getLocalAxes(); From 0f0611199d9b6662e50f73fff1cf576ea7623871 Mon Sep 17 00:00:00 2001 From: Daniel Sarno <48413743+dansarno@users.noreply.github.com> Date: Mon, 9 Nov 2020 23:39:07 +0000 Subject: [PATCH 05/97] Add user dansarno to .all-contributorsrc --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 27896705eb..84622b477f 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2250,6 +2250,15 @@ "contributions": [ "code" ] + }, + { + "login": "dansarno", + "name": "Daniel Sarno", + "avatar_url": "https://avatars0.githubusercontent.com/u/48413743?v=4", + "profile": "https://github.com/dansarno", + "contributions": [ + "example" + ] } ], "repoType": "github", From a6ab733b3add9e038095d830d399adb61811637d Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2020 23:52:16 +0000 Subject: [PATCH 06/97] docs: update README.md [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8466b5c4b6..e50a74f59b 100644 --- a/README.md +++ b/README.md @@ -447,7 +447,7 @@ We recognize all types of contributions. This project follows the [all-contribut
Liam Piesley

💻 -
Rishabh Taparia

💻 +
Rishabh Taparia

💻 📖 From d4fcd77fc1b0d6491715cf650db87836b0b9d478 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2020 23:52:17 +0000 Subject: [PATCH 07/97] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 27896705eb..5798251ac2 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2248,7 +2248,8 @@ "avatar_url": "https://avatars0.githubusercontent.com/u/63252510?v=4", "profile": "https://github.com/rt1301", "contributions": [ - "code" + "code", + "doc" ] } ], From aad5781b27a0f2b858d54c1a18ad1e3b4814a9cf Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2020 23:53:16 +0000 Subject: [PATCH 08/97] docs: update README.md [skip ci] --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e50a74f59b..7e10625e1e 100644 --- a/README.md +++ b/README.md @@ -448,6 +448,8 @@ We recognize all types of contributions. This project follows the [all-contribut
Rishabh Taparia

💻 📖 +
Daniel Sarno

💡 +
Kunal Kumar Verma

📖 From 0cdbc8842a5dfd477d8eaa6ced13121f2d68ba7b Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2020 23:53:17 +0000 Subject: [PATCH 09/97] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index ff71475ac1..9a962e1282 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2260,6 +2260,15 @@ "contributions": [ "example" ] + }, + { + "login": "KKVANONYMOUS", + "name": "Kunal Kumar Verma", + "avatar_url": "https://avatars3.githubusercontent.com/u/58628586?v=4", + "profile": "https://kkvanonymous.github.io/", + "contributions": [ + "doc" + ] } ], "repoType": "github", From 75b8afdfe7f03f7bec395904b137c7f1b8d940f3 Mon Sep 17 00:00:00 2001 From: Vamoss Date: Mon, 16 Nov 2020 16:43:05 -0300 Subject: [PATCH 10/97] Smooth Quad Distortion (relates to #4288) --- src/core/p5.Renderer2D.js | 50 ++++++++++++++++++++++++--- src/core/shape/2d_primitives.js | 9 +++-- src/webgl/3d_primitives.js | 60 ++++++++++++++++++++++++++------- 3 files changed, 100 insertions(+), 19 deletions(-) diff --git a/src/core/p5.Renderer2D.js b/src/core/p5.Renderer2D.js index 31f144a2fd..0bdaf5a0b1 100644 --- a/src/core/p5.Renderer2D.js +++ b/src/core/p5.Renderer2D.js @@ -582,7 +582,18 @@ p5.Renderer2D.prototype.point = function(x, y) { this._setFill(f); }; -p5.Renderer2D.prototype.quad = function(x1, y1, x2, y2, x3, y3, x4, y4) { +p5.Renderer2D.prototype.quad = function( + x1, + y1, + x2, + y2, + x3, + y3, + x4, + y4, + detailX, + detailY +) { const ctx = this.drawingContext; const doFill = this._doFill, doStroke = this._doStroke; @@ -595,12 +606,41 @@ p5.Renderer2D.prototype.quad = function(x1, y1, x2, y2, x3, y3, x4, y4) { return this; } } + + if (typeof detailX === 'undefined') { + detailX = 2; + } + if (typeof detailY === 'undefined') { + detailY = 2; + } + ctx.beginPath(); - ctx.moveTo(x1, y1); - ctx.lineTo(x2, y2); - ctx.lineTo(x3, y3); - ctx.lineTo(x4, y4); + + let xRes = 1.0 / (detailX - 1); + let yRes = 1.0 / (detailY - 1); + for (let y = 0; y < detailY; y++) { + for (let x = 0; x < detailX; x++) { + let pctx = x * xRes; + let pcty = y * yRes; + + let linePt0x = (1 - pcty) * x1 + pcty * x4; + let linePt0y = (1 - pcty) * y1 + pcty * y4; + let linePt1x = (1 - pcty) * x2 + pcty * x3; + let linePt1y = (1 - pcty) * y2 + pcty * y3; + + let ptx = (1 - pctx) * linePt0x + pctx * linePt1x; + let pty = (1 - pctx) * linePt0y + pctx * linePt1y; + + if (x === 0 && y === 0) { + ctx.moveTo(ptx, pty); + } else { + ctx.lineTo(ptx, pty); + } + } + } + ctx.closePath(); + if (doFill) { ctx.fill(); } diff --git a/src/core/shape/2d_primitives.js b/src/core/shape/2d_primitives.js index 081ac1ad01..9819ce252a 100644 --- a/src/core/shape/2d_primitives.js +++ b/src/core/shape/2d_primitives.js @@ -488,6 +488,8 @@ p5.prototype.point = function(...args) { * @param {Number} y3 the y-coordinate of the third point * @param {Number} x4 the x-coordinate of the fourth point * @param {Number} y4 the y-coordinate of the fourth point + * @param {Integer} [detailX] number of segments in the x-direction + * @param {Integer} [detailY] number of segments in the y-direction * @chainable * @example *
@@ -513,13 +515,15 @@ p5.prototype.point = function(...args) { * @param {Number} x4 * @param {Number} y4 * @param {Number} z4 the z-coordinate of the fourth point + * @param {Integer} [detailX] + * @param {Integer} [detailY] * @chainable */ p5.prototype.quad = function(...args) { p5._validateParameters('quad', args); if (this._renderer._doStroke || this._renderer._doFill) { - if (this._renderer.isP3D && args.length !== 12) { + if (this._renderer.isP3D && args.length <= 12) { // if 3D and we weren't passed 12 args, assume Z is 0 // prettier-ignore this._renderer.quad.call( @@ -527,7 +531,8 @@ p5.prototype.quad = function(...args) { args[0], args[1], 0, args[2], args[3], 0, args[4], args[5], 0, - args[6], args[7], 0); + args[6], args[7], 0, + args[8], args[9]); } else { this._renderer.quad(...args); //accessibile outputs diff --git a/src/webgl/3d_primitives.js b/src/webgl/3d_primitives.js index 3c17821f4c..5f91b564f0 100644 --- a/src/webgl/3d_primitives.js +++ b/src/webgl/3d_primitives.js @@ -1233,24 +1233,60 @@ p5.RendererGL.prototype.rect = function(args) { }; // prettier-ignore -p5.RendererGL.prototype.quad = function(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4) { +p5.RendererGL.prototype.quad = function(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, detailX, detailY) { + if (typeof detailX === 'undefined') { + detailX = 2; + } + if (typeof detailY === 'undefined') { + detailY = 2; + } + const gId = - `quad|${x1}|${y1}|${z1}|${x2}|${y2}|${z2}|${x3}|${y3}|${z3}|${x4}|${y4}|${z4}`; + `quad|${x1}|${y1}|${z1}|${x2}|${y2}|${z2}|${x3}|${y3}|${z3}|${x4}|${y4}|${z4}|${detailX}|${detailY}`; + if (!this.geometryInHash(gId)) { - const _quad = function() { - this.vertices.push(new p5.Vector(x1, y1, z1)); - this.vertices.push(new p5.Vector(x2, y2, z2)); - this.vertices.push(new p5.Vector(x3, y3, z3)); - this.vertices.push(new p5.Vector(x4, y4, z4)); - this.uvs.push(0, 0, 1, 0, 1, 1, 0, 1); - this.strokeIndices = [[0, 1], [1, 2], [2, 3], [3, 0]]; - }; - const quadGeom = new p5.Geometry(2, 2, _quad); + const quadGeom = new p5.Geometry(detailX, detailY, function() { + //algorithm adapted from c++ to js + //https://stackoverflow.com/questions/16989181/whats-the-correct-way-to-draw-a-distorted-plane-in-opengl/16993202#16993202 + let xRes = 1.0 / (this.detailX - 1); + let yRes = 1.0 / (this.detailY - 1); + for (let y = 0; y < this.detailY; y++) { + for (let x = 0; x < this.detailX; x++) { + let pctx = x * xRes; + let pcty = y * yRes; + + let linePt0x = (1 - pcty) * x1 + pcty * x4; + let linePt0y = (1 - pcty) * y1 + pcty * y4; + let linePt0z = (1 - pcty) * z1 + pcty * z4; + let linePt1x = (1 - pcty) * x2 + pcty * x3; + let linePt1y = (1 - pcty) * y2 + pcty * y3; + let linePt1z = (1 - pcty) * z2 + pcty * z3; + + let ptx = (1 - pctx) * linePt0x + pctx * linePt1x; + let pty = (1 - pctx) * linePt0y + pctx * linePt1y; + let ptz = (1 - pctx) * linePt0z + pctx * linePt1z; + + this.vertices.push(new p5.Vector(ptx, pty, ptz)); + this.uvs.push([pctx, pcty]); + } + } + }); + + quadGeom.faces = []; + for(let y = 0; y < detailY-1; y++){ + for(let x = 0; x < detailX-1; x++){ + let pt0 = x + y * detailX; + let pt1 = (x + 1) + y * detailX; + let pt2 = (x + 1) + (y + 1) * detailX; + let pt3 = x + (y + 1) * detailX; + quadGeom.faces.push([pt0, pt1, pt2]); + quadGeom.faces.push([pt0, pt2, pt3]); + } + } quadGeom .computeNormals() ._makeTriangleEdges() ._edgesToVertices(); - quadGeom.faces = [[0, 1, 2], [2, 3, 0]]; this.createBuffers(gId, quadGeom); } this.drawBuffers(gId); From 33ccd72a595118912c18436f3860275a89cb8d9c Mon Sep 17 00:00:00 2001 From: Akshay Padte Date: Wed, 18 Nov 2020 06:38:44 +0530 Subject: [PATCH 11/97] Prevent i18next from using browser storage --- src/core/internationalization.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/internationalization.js b/src/core/internationalization.js index 55f79576e5..7c98055182 100644 --- a/src/core/internationalization.js +++ b/src/core/internationalization.js @@ -140,7 +140,12 @@ export const initialize = () => { escapeValue: false }, detection: { - checkWhitelist: false + checkWhitelist: false, + + // prevent storing or locating language from cookie or localStorage + // more info on https://github.com/processing/p5.js/issues/4862 + order: ['querystring', 'navigator', 'htmlTag', 'path', 'subdomain'], + caches: [] }, backend: { fallback: 'en', From ce97280cc727e685a9ef47566a94ec5b967eea96 Mon Sep 17 00:00:00 2001 From: Lisa Jamhoury Date: Wed, 18 Nov 2020 12:56:31 -0500 Subject: [PATCH 12/97] Add canvas to addCue example addCue() example needs a canvas for changeBackground function to show changes. --- src/dom/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index e2d04beb57..15c116aabd 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -3325,7 +3325,7 @@ var Cue = function(callback, time, id, val) { * // * // * function setup() { - * noCanvas(); + * createCanvas(200,200); * * let audioEl = createAudio('assets/beat.mp3'); * audioEl.showControls(); From 4345eccdb98daea8caaaaeab681126183926a963 Mon Sep 17 00:00:00 2001 From: BharathKumarRavichandran Date: Sun, 22 Nov 2020 15:14:51 +0530 Subject: [PATCH 13/97] Update dom to ES6 --- src/dom/dom.js | 133 +++++++++++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 65 deletions(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index e2d04beb57..db87ef5025 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -142,9 +142,9 @@ p5.prototype._getContainer = function(p) { * Helper function for getElement and getElements. */ p5.prototype._wrapElement = function(elt) { - var children = Array.prototype.slice.call(elt.children); + const children = Array.prototype.slice.call(elt.children); if (elt.tagName === 'INPUT' && elt.type === 'checkbox') { - var converted = new p5.Element(elt, this); + let converted = new p5.Element(elt, this); converted.checked = function() { if (arguments.length === 0) { return this.elt.checked; @@ -302,9 +302,11 @@ p5.Element.prototype.input = function(fxn) { * Helpers for create methods. */ function addElement(elt, pInst, media) { - var node = pInst._userNode ? pInst._userNode : document.body; + const node = pInst._userNode ? pInst._userNode : document.body; node.appendChild(elt); - var c = media ? new p5.MediaElement(elt, pInst) : new p5.Element(elt, pInst); + const c = media + ? new p5.MediaElement(elt, pInst) + : new p5.Element(elt, pInst); pInst._elements.push(c); return c; } @@ -387,9 +389,9 @@ p5.prototype.createSpan = function(html = '') { */ p5.prototype.createImg = function() { p5._validateParameters('createImg', arguments); - var elt = document.createElement('img'); - var args = arguments; - var self; + const elt = document.createElement('img'); + const args = arguments; + let self; if (args.length > 1 && typeof args[1] === 'string') { elt.alt = args[1]; } @@ -401,7 +403,7 @@ p5.prototype.createImg = function() { elt.addEventListener('load', function() { self.width = elt.offsetWidth || elt.width; self.height = elt.offsetHeight || elt.height; - var last = args[args.length - 1]; + const last = args[args.length - 1]; if (typeof last === 'function') last(self); }); return self; @@ -423,7 +425,7 @@ p5.prototype.createImg = function() { */ p5.prototype.createA = function(href, html, target) { p5._validateParameters('createA', arguments); - var elt = document.createElement('a'); + const elt = document.createElement('a'); elt.href = href; elt.innerHTML = html; if (target) elt.target = target; @@ -474,7 +476,7 @@ p5.prototype.createA = function(href, html, target) { */ p5.prototype.createSlider = function(min, max, value, step) { p5._validateParameters('createSlider', arguments); - var elt = document.createElement('input'); + const elt = document.createElement('input'); elt.type = 'range'; elt.min = min; elt.max = max; @@ -515,7 +517,7 @@ p5.prototype.createSlider = function(min, max, value, step) { */ p5.prototype.createButton = function(label, value) { p5._validateParameters('createButton', arguments); - var elt = document.createElement('button'); + const elt = document.createElement('button'); elt.innerHTML = label; if (value) elt.value = value; return addElement(elt, this); @@ -549,14 +551,14 @@ p5.prototype.createButton = function(label, value) { */ p5.prototype.createCheckbox = function() { p5._validateParameters('createCheckbox', arguments); - var elt = document.createElement('div'); - var checkbox = document.createElement('input'); + const elt = document.createElement('div'); + const checkbox = document.createElement('input'); checkbox.type = 'checkbox'; elt.appendChild(checkbox); //checkbox must be wrapped in p5.Element before label so that label appears after - var self = addElement(elt, this); + const self = addElement(elt, this); self.checked = function() { - var cb = self.elt.getElementsByTagName('input')[0]; + const cb = self.elt.getElementsByTagName('input')[0]; if (cb) { if (arguments.length === 0) { return cb.checked; @@ -573,10 +575,10 @@ p5.prototype.createCheckbox = function() { return this; }; if (arguments[0]) { - var ran = Math.random() + const ran = Math.random() .toString(36) .slice(2); - var label = document.createElement('label'); + const label = document.createElement('label'); checkbox.setAttribute('id', ran); label.htmlFor = ran; self.value(arguments[0]); @@ -969,8 +971,8 @@ p5.prototype.createRadio = function() { */ p5.prototype.createColorPicker = function(value) { p5._validateParameters('createColorPicker', arguments); - var elt = document.createElement('input'); - var self; + const elt = document.createElement('input'); + let self; elt.type = 'color'; if (value) { if (value instanceof p5.Color) { @@ -1256,7 +1258,7 @@ if (navigator.mediaDevices === undefined) { if (navigator.mediaDevices.getUserMedia === undefined) { navigator.mediaDevices.getUserMedia = function(constraints) { // First get ahold of the legacy getUserMedia, if present - var getUserMedia = + const getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia; // Some browsers just don't implement it - return a rejected promise with an error @@ -1425,7 +1427,7 @@ p5.prototype.createCapture = function() { */ p5.prototype.createElement = function(tag, content) { p5._validateParameters('createElement', arguments); - var elt = document.createElement(tag); + const elt = document.createElement(tag); if (typeof content !== 'undefined') { elt.innerHTML = content; } @@ -1626,18 +1628,18 @@ p5.Element.prototype.child = function(childNode) { *
*/ p5.Element.prototype.center = function(align) { - var style = this.elt.style.display; - var hidden = this.elt.style.display === 'none'; - var parentHidden = this.parent().style.display === 'none'; - var pos = { x: this.elt.offsetLeft, y: this.elt.offsetTop }; + const style = this.elt.style.display; + const hidden = this.elt.style.display === 'none'; + const parentHidden = this.parent().style.display === 'none'; + const pos = { x: this.elt.offsetLeft, y: this.elt.offsetTop }; if (hidden) this.show(); if (parentHidden) this.parent().show(); this.elt.style.display = 'block'; this.position(0, 0); - var wOffset = Math.abs(this.parent().offsetWidth - this.elt.offsetWidth); - var hOffset = Math.abs(this.parent().offsetHeight - this.elt.offsetHeight); + const wOffset = Math.abs(this.parent().offsetWidth - this.elt.offsetWidth); + const hOffset = Math.abs(this.parent().offsetHeight - this.elt.offsetHeight); if (align === 'both' || align === undefined) { this.position( @@ -1764,7 +1766,7 @@ p5.Element.prototype.position = function() { p5.Element.prototype._translate = function() { this.elt.style.position = 'absolute'; // save out initial non-translate transform styling - var transform = ''; + let transform = ''; if (this.elt.style.transform) { transform = this.elt.style.transform.replace(/translate3d\(.*\)/g, ''); transform = transform.replace(/translate[X-Z]?\(.*\)/g, ''); @@ -1795,7 +1797,7 @@ p5.Element.prototype._translate = function() { /* Helper method called by p5.Element.style() */ p5.Element.prototype._rotate = function() { // save out initial non-rotate transform styling - var transform = ''; + let transform = ''; if (this.elt.style.transform) { transform = this.elt.style.transform.replace(/rotate3d\(.*\)/g, ''); transform = transform.replace(/rotate[X-Z]?\(.*\)/g, ''); @@ -1859,7 +1861,7 @@ p5.Element.prototype._rotate = function() { * @chainable */ p5.Element.prototype.style = function(prop, val) { - var self = this; + const self = this; if (val instanceof p5.Color) { val = @@ -1882,9 +1884,9 @@ p5.Element.prototype.style = function(prop, val) { return style; } else { // value set using `:` in a single line string - var attrs = prop.split(';'); - for (var i = 0; i < attrs.length; i++) { - var parts = attrs[i].split(':'); + const attrs = prop.split(';'); + for (let i = 0; i < attrs.length; i++) { + const parts = attrs[i].split(':'); if (parts[0] && parts[1]) { this.elt.style[parts[0].trim()] = parts[1].trim(); } @@ -1940,7 +1942,7 @@ p5.Element.prototype.attribute = function(attr, value) { if (typeof value === 'undefined') { return this.elt.firstChild.getAttribute(attr); } else { - for (var i = 0; i < this.elt.childNodes.length; i++) { + for (let i = 0; i < this.elt.childNodes.length; i++) { this.elt.childNodes[i].setAttribute(attr, value); } } @@ -1989,7 +1991,7 @@ p5.Element.prototype.removeAttribute = function(attr) { (this.elt.firstChild.type === 'checkbox' || this.elt.firstChild.type === 'radio') ) { - for (var i = 0; i < this.elt.childNodes.length; i++) { + for (let i = 0; i < this.elt.childNodes.length; i++) { this.elt.childNodes[i].removeAttribute(attr); } } @@ -2111,9 +2113,9 @@ p5.Element.prototype.size = function(w, h) { if (arguments.length === 0) { return { width: this.elt.offsetWidth, height: this.elt.offsetHeight }; } else { - var aW = w; - var aH = h; - var AUTO = p5.prototype.AUTO; + let aW = w; + let aH = h; + const AUTO = p5.prototype.AUTO; if (aW !== AUTO || aH !== AUTO) { if (aW === AUTO) { aW = h * this.width / this.height; @@ -2122,9 +2124,9 @@ p5.Element.prototype.size = function(w, h) { } // set diff for cnv vs normal div if (this.elt instanceof HTMLCanvasElement) { - var j = {}; - var k = this.elt.getContext('2d'); - var prop; + const j = {}; + const k = this.elt.getContext('2d'); + let prop; for (prop in k) { j[prop] = k[prop]; } @@ -2257,7 +2259,7 @@ p5.Element.prototype.drop = function(callback, fxn) { if (!this._dragDisabled) { this._dragDisabled = true; - var preventDefault = function(evt) { + const preventDefault = function(evt) { evt.preventDefault(); }; @@ -2280,11 +2282,11 @@ p5.Element.prototype.drop = function(callback, fxn) { fxn.call(this, evt); } // A FileList - var files = evt.dataTransfer.files; + const files = evt.dataTransfer.files; // Load each one and trigger the callback - for (var i = 0; i < files.length; i++) { - var f = files[i]; + for (let i = 0; i < files.length; i++) { + const f = files[i]; p5.File._load(f, callback); } }, @@ -2314,7 +2316,7 @@ p5.Element.prototype.drop = function(callback, fxn) { p5.MediaElement = function(elt, pInst) { p5.Element.call(this, elt, pInst); - var self = this; + const self = this; this.elt.crossOrigin = 'anonymous'; this._prevTime = 0; @@ -2364,16 +2366,17 @@ p5.MediaElement = function(elt, pInst) { */ Object.defineProperty(self, 'src', { get: function() { - var firstChildSrc = self.elt.children[0].src; - var srcVal = self.elt.src === window.location.href ? '' : self.elt.src; - var ret = firstChildSrc === window.location.href ? srcVal : firstChildSrc; + const firstChildSrc = self.elt.children[0].src; + const srcVal = self.elt.src === window.location.href ? '' : self.elt.src; + const ret = + firstChildSrc === window.location.href ? srcVal : firstChildSrc; return ret; }, set: function(newValue) { - for (var i = 0; i < self.elt.children.length; i++) { + for (let i = 0; i < self.elt.children.length; i++) { self.elt.removeChild(self.elt.children[i]); } - var source = document.createElement('source'); + const source = document.createElement('source'); source.src = newValue; elt.appendChild(source); self.elt.src = newValue; @@ -2431,7 +2434,7 @@ p5.MediaElement.prototype.play = function() { if (this.elt.currentTime === this.elt.duration) { this.elt.currentTime = 0; } - var promise; + let promise; if (this.elt.readyState > 1) { promise = this.elt.play(); } else { @@ -3170,7 +3173,7 @@ p5.MediaElement.prototype.onended = function(callback) { * or an object from the p5.sound library */ p5.MediaElement.prototype.connect = function(obj) { - var audioContext, mainOutput; + let audioContext, mainOutput; // if p5.sound exists, same audio context if (typeof p5.prototype.getAudioContext === 'function') { @@ -3287,7 +3290,7 @@ p5.MediaElement.prototype.hideControls = function() { // Cue inspired by JavaScript setTimeout, and the // Tone.js Transport Timeline Event, MIT License Yotam Mann 2015 tonejs.org -var Cue = function(callback, time, id, val) { +const Cue = function(callback, time, id, val) { this.callback = callback; this.time = time; this.id = id; @@ -3345,9 +3348,9 @@ var Cue = function(callback, time, id, val) { * */ p5.MediaElement.prototype.addCue = function(time, callback, val) { - var id = this._cueIDCounter++; + const id = this._cueIDCounter++; - var cue = new Cue(callback, time, id, val); + const cue = new Cue(callback, time, id, val); this._cues.push(cue); if (!this.elt.ontimeupdate) { @@ -3387,7 +3390,7 @@ p5.MediaElement.prototype.addCue = function(time, callback, val) { * */ p5.MediaElement.prototype.removeCue = function(id) { - for (var i = 0; i < this._cues.length; i++) { + for (let i = 0; i < this._cues.length; i++) { if (this._cues[i].id === id) { console.log(id); this._cues.splice(i, 1); @@ -3441,11 +3444,11 @@ p5.MediaElement.prototype.clearCues = function() { // private method that checks for cues to be fired if events // have been scheduled using addCue(callback, time). p5.MediaElement.prototype._onTimeUpdate = function() { - var playbackTime = this.time(); + const playbackTime = this.time(); - for (var i = 0; i < this._cues.length; i++) { - var callbackTime = this._cues[i].time; - var val = this._cues[i].val; + for (let i = 0; i < this._cues.length; i++) { + const callbackTime = this._cues[i].time; + const val = this._cues[i].val; if (this._prevTime < callbackTime && callbackTime <= playbackTime) { // pass the scheduled callbackTime as parameter to the callback @@ -3476,7 +3479,7 @@ p5.File = function(file, pInst) { // Splitting out the file type into two components // This makes determining if image or text etc simpler - var typeList = file.type.split('/'); + const typeList = file.type.split('/'); /** * File type (image, text, etc.) * @@ -3512,9 +3515,9 @@ p5.File = function(file, pInst) { }; p5.File._createLoader = function(theFile, callback) { - var reader = new FileReader(); + const reader = new FileReader(); reader.onload = function(e) { - var p5file = new p5.File(theFile); + const p5file = new p5.File(theFile); if (p5file.file.type === 'application/json') { // Parse JSON and store the result in data p5file.data = JSON.parse(e.target.result); @@ -3539,7 +3542,7 @@ p5.File._load = function(f, callback) { } else if (!/^(video|audio)\//.test(f.type)) { p5.File._createLoader(f, callback).readAsDataURL(f); } else { - var file = new p5.File(f); + const file = new p5.File(f); file.data = URL.createObjectURL(f); callback(file); } From 8e3914e1267f08b1e59831f7a8565e60f5559c5b Mon Sep 17 00:00:00 2001 From: BharathKumarRavichandran Date: Sun, 22 Nov 2020 17:23:37 +0530 Subject: [PATCH 14/97] Update p5.Font.js in typography to ES6 --- src/typography/p5.Font.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/typography/p5.Font.js b/src/typography/p5.Font.js index c6b4bc9ffa..d57036dbdf 100644 --- a/src/typography/p5.Font.js +++ b/src/typography/p5.Font.js @@ -130,17 +130,17 @@ p5.Font.prototype.textBounds = function(str, x = 0, y = 0, fontSize, opts) { maxX[lineCount] = Math.max.apply(null, xCoords[lineCount]); } - var finalMaxX = 0; - for (var i = 0; i <= lineCount; i++) { + let finalMaxX = 0; + for (let i = 0; i <= lineCount; i++) { minX[i] = Math.min.apply(null, xCoords[i]); maxX[i] = Math.max.apply(null, xCoords[i]); - var lineLength = maxX[i] - minX[i]; + const lineLength = maxX[i] - minX[i]; if (lineLength > finalMaxX) { finalMaxX = lineLength; } } - var finalMinX = Math.min.apply(null, minX); + const finalMinX = Math.min.apply(null, minX); minY = Math.min.apply(null, yCoords); maxY = Math.max.apply(null, yCoords); From 8ee7bae1f90e1e3aa2062f599231d7cc759f7071 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2020 12:04:16 +0000 Subject: [PATCH 15/97] docs: update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7e10625e1e..7b00376d80 100644 --- a/README.md +++ b/README.md @@ -450,6 +450,7 @@ We recognize all types of contributions. This project follows the [all-contribut
Rishabh Taparia

💻 📖
Daniel Sarno

💡
Kunal Kumar Verma

📖 +
Bharath Kumar R

💻 From 75042cccf72f415ea0b9c62ed7695b3ecc0c94d0 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2020 12:04:17 +0000 Subject: [PATCH 16/97] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 9a962e1282..04dab5869f 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2269,6 +2269,15 @@ "contributions": [ "doc" ] + }, + { + "login": "BharathKumarRavichandran", + "name": "Bharath Kumar R", + "avatar_url": "https://avatars2.githubusercontent.com/u/16106573?v=4", + "profile": "http://bharathkumarravichandran.github.io", + "contributions": [ + "code" + ] } ], "repoType": "github", From 26f1af47f004849525afd61ade885a193bb8fda2 Mon Sep 17 00:00:00 2001 From: Lauren Lee McCarthy Date: Sun, 22 Nov 2020 15:29:22 -0800 Subject: [PATCH 17/97] Update src/dom/dom.js Co-authored-by: Kenneth Lim --- src/dom/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index 15c116aabd..483709325a 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -3325,7 +3325,7 @@ var Cue = function(callback, time, id, val) { * // * // * function setup() { - * createCanvas(200,200); + * createCanvas(200, 200); * * let audioEl = createAudio('assets/beat.mp3'); * audioEl.showControls(); From 7f32fbf4651e59450c92596af114e5324796f8a9 Mon Sep 17 00:00:00 2001 From: kkvanonymous Date: Mon, 23 Nov 2020 10:17:54 +0530 Subject: [PATCH 18/97] Remove console.log() at Line 414 of /src/io/files.js --- src/io/files.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/io/files.js b/src/io/files.js index 9971b7c9ad..59649e370d 100644 --- a/src/io/files.js +++ b/src/io/files.js @@ -411,8 +411,6 @@ p5.prototype.loadTable = function(path) { } } - console.log('SEP IS ' + sep); - const t = new p5.Table(); const self = this; From 141e62eba3689a859ae1e8507c07c4768c8e64f0 Mon Sep 17 00:00:00 2001 From: kkvanonymous Date: Mon, 23 Nov 2020 17:43:41 +0530 Subject: [PATCH 19/97] Fix alignment of radio buttons in the second example of createRadio() reference --- src/dom/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index 3cde8e6c36..ae8d2bbba2 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -784,7 +784,7 @@ p5.prototype.createSelect = function() { * radio.option('apple', 1); * radio.option('bread', 2); * radio.option('juice', 3); - * radio.style('width', '60px'); + * radio.style('width', '30px'); * textAlign(CENTER); * } * From a86547109ce24bdcad681edae9059b0e13e9ca84 Mon Sep 17 00:00:00 2001 From: Arijit Kundu Date: Thu, 26 Nov 2020 22:53:38 +0530 Subject: [PATCH 20/97] Added Hindi Translation of Preparing a pull request --- .../hi/preparing_a_pull_request.md | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 contributor_docs/hi/preparing_a_pull_request.md diff --git a/contributor_docs/hi/preparing_a_pull_request.md b/contributor_docs/hi/preparing_a_pull_request.md new file mode 100644 index 0000000000..cadc3b9356 --- /dev/null +++ b/contributor_docs/hi/preparing_a_pull_request.md @@ -0,0 +1,50 @@ +# एक पुल अनुरोध तैयार करना + +जब आपका कोड अप टू डेट हो तो पुल-रिक्वेस्ट आसान हो जाती है! आप अपने कोड को अन्य योगदानकर्ताओं से परिवर्तनों को शामिल करने के लिए अद्यतन करने के लिए git rebase का उपयोग कर सकते हैं। ऐसे। + +## सहेजें और अपडेट करें + +### आपके पास जो कुछ है उसे बचाओ! + git status + git add -u + git commit + +### परिवर्तनों के बारे में जानें +सुनिश्चित करें कि आप अपस्ट्रीम p5.js रिपॉजिटरी को ट्रैक कर रहे हैं। + + git remote show upstream + +यदि आपको कोई त्रुटि दिखाई देती है, तो आपको "upstream" रिमोट रिपॉजिटरी के रूप में मुख्य p5.js रेपो को ट्रैक करना शुरू करना होगा। आपको केवल एक बार ऐसा करने की आवश्यकता होगी! लेकिन, अगर आप इसे दूसरी बार चलाते हैं तो कोई नुकसान नहीं होता है। + + git remote add upstream https://github.com/processing/p5.js + +फिर नवीनतम परिवर्तनों के बारे में पूछें। + + git fetch upstream + +### शायद ज़रुरत पड़े: एक नई शाखा में अपने परिवर्तनों की एक प्रति बनाएँ + git branch your-branch-name-backup + +### मुख्य शाखा से परिवर्तन लागू करें, अपने परिवर्तन जोड़ता है * के बाद * + git rebase upstream/main + +### संघर्षों का समाधान +आप कुछ संघर्ष हो सकता है! +यदि यह केवल lib / p5.js और lib / p5.min.js है, तो इसे ठीक करना आसान है। बस परियोजना को फिर से ग्रंट के साथ बनाएं। + + grunt + git add -u + git rebase --continue + +यदि आपके पास अन्य फ़ाइलों में विरोध है और आप सुनिश्चित नहीं हैं कि उन्हें कैसे हल किया जाए ... मदद के लिए पूछें! + +### और अंत में, महान गौरव के लिए + git push origin + +यदि आप तकनीकी विवरणों के बारे में गहन जानकारी प्राप्त कर रहे हैं, तो रिबासिंग पर एक अच्छा संदर्भ है। https://www.atlassian.com/git/tutorials/merging-vs-rebasing + +## पुल अनुरोध बनाना + +यहाँ [गिटहब पर पुल अनुरोध बनाने के निर्देश](https://help.github.com/articles/creating-a-pull-request/) दिए गए हैं। आप जिस भी शाखा में काम कर रहे हैं, उसका नाम बता सकते हैं। आप p5.js. की "मुख्य" शाखा के खिलाफ अपना पुल अनुरोध प्रस्तुत करेंगे + +एक बार जब आप अपना पुल अनुरोध सबमिट कर देते हैं, तो इसकी समीक्षा की जाएगी और जैसे ही अन्य ऐसा करने के लिए उपलब्ध होगा, विलय कर दिया जाएगा। परिवर्तन p5.js लाइब्रेरी की अगली रिलीज़ के साथ दिखाई देंगे। \ No newline at end of file From a39457e64d84a4c4dd556588a387207838e58eed Mon Sep 17 00:00:00 2001 From: Arijit Kundu Date: Thu, 26 Nov 2020 22:54:24 +0530 Subject: [PATCH 21/97] Added Hindi Translation of Benchmarking p5 --- contributor_docs/hi/benchmarking_p5.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 contributor_docs/hi/benchmarking_p5.md diff --git a/contributor_docs/hi/benchmarking_p5.md b/contributor_docs/hi/benchmarking_p5.md new file mode 100644 index 0000000000..62ae02760b --- /dev/null +++ b/contributor_docs/hi/benchmarking_p5.md @@ -0,0 +1,3 @@ +# बेंचमार्किंग p5.js + +बेंचमार्किंग को https://github.com/limzykenneth/p5-benchmark पर उपलब्ध अपने रेपो में स्थानांतरित कर दिया गया है। P5.js के नवीनतम संस्करण के बेंचमार्क परिणाम का एक समग्र दृश्य https://limzykenneth.github.io/p5-benchmark/ पर देखा जा सकता है। अभी भी कार्य प्रगति पर है। \ No newline at end of file From 907d459e8af42d4e4d17476ed1c5d93851f70c0e Mon Sep 17 00:00:00 2001 From: Arijit Kundu Date: Thu, 26 Nov 2020 22:54:46 +0530 Subject: [PATCH 22/97] Added Hindi Translation of Discussions --- contributor_docs/hi/discussions.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 contributor_docs/hi/discussions.md diff --git a/contributor_docs/hi/discussions.md b/contributor_docs/hi/discussions.md new file mode 100644 index 0000000000..8648c18440 --- /dev/null +++ b/contributor_docs/hi/discussions.md @@ -0,0 +1,3 @@ +p5 कैसे विकसित होता है, इस बारे में चर्चा में शामिल होना और योगदान देने का एक शानदार तरीका है। यह कई तरीकों से किया जा सकता है, लेकिन शुरू करने के लिए एक बढ़िया जगह मौजूदा गिटहब [जिन मुद्दों को 'चर्चा' करार दिया गया है](https://github.com/processing/p5.js/labels/discubion) की जाँच करके और अपनी आवाज जोड़ रहा है। + +इस चर्चा के आधार पर इस उपधारा में दस्तावेज विकसित किए जाते हैं। यह वह जगह है जहां हम पुस्तकालय के लिए वर्तमान और भविष्य के डिजाइन के बारे में विचारों को संकलित करते हैं। \ No newline at end of file From 428e162e7556bad09eed70cceb9fc0181ba3b298 Mon Sep 17 00:00:00 2001 From: Arijit Kundu Date: Thu, 26 Nov 2020 23:23:41 +0530 Subject: [PATCH 23/97] Added Hindi Translation of Design Principles --- contributor_docs/hi/design_principles.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 contributor_docs/hi/design_principles.md diff --git a/contributor_docs/hi/design_principles.md b/contributor_docs/hi/design_principles.md new file mode 100644 index 0000000000..6b00ea4900 --- /dev/null +++ b/contributor_docs/hi/design_principles.md @@ -0,0 +1,9 @@ +# P5.js के लिए डिजाइन सिद्धांत + +- **शुरुआती मित्रवत** p5.js एपीआई का उद्देश्य शुरुआती कोडरों के अनुकूल होना है, जो अत्याधुनिक HTML5 / कैनवस / DOM एपीआई के साथ इंटरैक्टिव और विज़ुअल वेब कंटेंट बनाने के लिए एक कम अवरोध प्रदान करता है। + +- **शैक्षिक** p5.js एक एपीआई और पाठ्यक्रम पर केंद्रित है जो शैक्षिक उपयोग का समर्थन करता है, जिसमें समर्थन उदाहरणों के साथ एपीआई का पूरा संदर्भ शामिल है, साथ ही साथ ट्यूटोरियल और नमूना वर्ग पाठ्यक्रम जो एक स्पष्ट और स्पष्ट रचनात्मक रचनात्मक कोडिंग सिद्धांतों का परिचय देता है आकर्षक क्रम। + +- **जावास्क्रिप्ट और इसके समुदाय** p5.js का उद्देश्य वेब विकास प्रथाओं को उचित जावास्क्रिप्ट डिजाइन पैटर्न और उपयोग के माध्यम से शुरुआती लोगों के लिए अधिक सुलभ बनाना है, जबकि उन्हें आवश्यक रूप से अमूर्त करना है। एक ओपन सोर्स लाइब्रेरी के रूप में, p5.js में इसके निर्माण, प्रलेखन और प्रसार में व्यापक जावास्क्रिप्ट समुदाय भी शामिल है। + +- **प्रसंस्करण और इसका समुदाय** p5.js प्रसंस्करण भाषा और इसके समुदाय के लिए एक सीधी प्रतिक्रिया है, और इसका लक्ष्य प्रसंस्करण से जावास्क्रिप्ट में परिवर्तन को आसान और स्पष्ट बनाना है। प्रसंस्करण एपीआई और समुदाय का समर्थन करना p5.js के लिए प्राथमिकता है, जबकि वेब पर रचनात्मक कोडिंग की नई संभावनाओं को शामिल करने के लिए विस्तार करना, और उस एपीआई को शुरुआती लोगों को उजागर करने के लिए प्रसंस्करण-शैली दृष्टिकोण लेना। From 8c5719dd412ab84a7947cc0a2b21a5943c77316a Mon Sep 17 00:00:00 2001 From: Arijit Kundu Date: Thu, 26 Nov 2020 23:24:11 +0530 Subject: [PATCH 24/97] Added Hindi Translation of Contributing documentation --- .../hi/contributing_documentation.md | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 contributor_docs/hi/contributing_documentation.md diff --git a/contributor_docs/hi/contributing_documentation.md b/contributor_docs/hi/contributing_documentation.md new file mode 100644 index 0000000000..f02b599487 --- /dev/null +++ b/contributor_docs/hi/contributing_documentation.md @@ -0,0 +1,36 @@ +नए शिक्षार्थियों और अनुभवी प्रोग्रामर के लिए समान रूप से प्रलेखन आवश्यक है। यह हमारे समुदाय को उन लोगों के लिए एक अनुकूल हाथ बढ़ाकर समावेशी बनाने में मदद करता है जो p5.js. से कम परिचित हैं। यह हमें कोड के साथ बग्स और मुद्दों को खोजने में भी मदद करता है, क्योंकि हम दस्तावेज के रूप में चीजों का परीक्षण और परीक्षण करते हैं। + +प्रलेखन में योगदान देने के कई तरीके हैं: + +## ☝️ मुद्दों को खोलें +यदि आप अभी शुरुआत कर रहे हैं, तो एक बहुत ही उपयोगी तरीका जो आप योगदान कर सकते हैं, वह है प्रलेखन आवश्यकताओं के लिए मुद्दे खोलना। यदि आप एक टाइपो, एक लापता या टूटा हुआ उदाहरण, या एक फ़ंक्शन विवरण जो भ्रामक है, नोटिस करते हैं, [इसके लिए एक मुद्दा खोलें](https://github.com/processing/p5.js/issues)! कृपया उस पृष्ठ का लिंक शामिल करें जिसे ठीक करने की आवश्यकता है ताकि हम इसे आसानी से पा सकें। + +## 🗯 संदर्भ के लिए योगदान करें +[संदर्भ](http://p5js.org/reference/) के माध्यम से पढ़ें, और टाइपो, टूटे उदाहरणों या भ्रमित करने वाले दस्तावेज़ देखें। यदि यह एक सीधा तय है, तो आगे बढ़ें और उस पर काम करें! यदि यह अधिक सम्मिलित प्रश्न है, जिस पर चर्चा की आवश्यकता है, तो एक [मुद्दा](https://github.com/processing/p5.js/issues/new) बनाएं। +* [यहाँ](./README.md) पहली बार p5.js रेपो के साथ सेटअप होने के लिए निर्देश दिए गए हैं। +* संदर्भ स्रोत कोड में (इन `src /` फ़ोल्डर में पाया गया) इनलाइन प्रलेखन से बनाया गया है। +* यहाँ [कैसे अद्यतन या इनलाइन प्रलेखन और उदाहरणों को जोड़ने के लिए](./inline_documentation.md) पर जानकारी है। +यदि आप [स्पेनिश प्रलेखन](http://p5js.org/es) के साथ त्रुटियां पाते हैं, तो इसे [यहाँ](https://github.com/processing/p5.js-website#internationalization-i18n) और संरचना अद्यतन करने के निर्देश हैं । +* सामुदायिक-अनुरक्षित टाइपस्क्रिप्ट परिभाषाएँ [यहाँ](https://github.com/p5-types/p5.ts) हैं । + +## ✨ उदाहरण बनाओ +जबकि संदर्भ में उदाहरण कोड के बहुत ही सरल स्निपेट होने के लिए होते हैं, लेकिन लंबे, अधिक जटिल उदाहरणों के लिए भी उपयोगी है। +* वर्तमान में हम [प्रसंस्करण उदाहरण पृष्ठ](https://processing.org/examples/) से [p5.js उदाहरण पृष्ठ](http://p5js.org/examples) के उदाहरणों को पोर्ट करने पर काम कर रहे हैं। यदि आप इसके साथ मदद करना चाहते हैं, तो कृपया [यहाँ](https://github.com/processing/p5.js-website/blob/main/contributor_docs/Adding_examples.md) के निर्देश देखें। +* वैकल्पिक रूप से, आप अपने स्वयं के उदाहरण सेट कर सकते हैं और उन्हें स्वतंत्र रूप से प्रकाशित कर सकते हैं जैसे आप कहीं भी हैं। यदि आप उन्हें ऑनलाइन टैग [@ p5xjs](https://twitter.com/p5xjs) या ईमेल [hello@p5js.org](mailto:hello@p5js.org) पर साझा करते हैं, तो हमें बताएं, और हम दूर तक साझा करेंगे और विस्तृत! यह [एम्बेडिंग p5.js के लिए गाइड](https://github.com/processing/p5.js/wiki/Embedding-p5.js) आपके उदाहरणों को ऑनलाइन पोस्ट करने के लिए उपयोगी हो सकता है। +यदि आप रास्ते में p5.js में बग ढूंढते हैं, तो कृपया उन्हें [मुद्दों](https://github.com/processing/p5.js/issues) में लॉग इन करें। + +## 👯 ट्यूटोरियल बनाएं +* यदि आप p5.js में नए हैं, तो यह शुरू करने के लिए एक शानदार जगह है। खुद कुछ बनाने की कोशिश करें, फिर दूसरों को भी करने के लिए एक ट्यूटोरियल बनाना। +* वर्तमान में हम [प्रसंस्करण ट्यूटोरियल पेज](https://processing.org/tutorials) से [p5.js learn page](http://p5js.org/learn) पर ट्यूटोरियल को पोर्ट करने पर काम कर रहे हैं। यदि आप इसकी सहायता करना चाहते हैं, तो कृपया ट्यूटोरियल बनाने के लिए ट्यूटोरियल देखें [यहाँ](https://p5js.org/learn/tutorial-guide.html)। +* हम विभिन्न विषयों पर ट्यूटोरियल का भी स्वागत करते हैं। आप इन्हें कहीं भी, किसी भी प्रारूप में प्रकाशित कर सकते हैं। यदि आप उन्हें ऑनलाइन टैग [@ p5xjs](https://twitter.com/p5xjs) या ईमेल [hello@p5js.org](mailto:hello@p5js.org) पर साझा करते हैं, तो हमें बताएं, और हम दूर तक साझा करेंगे और विस्तृत! हम विशेष रूप से एक विशिष्ट दर्शकों के साथ बनाए गए ट्यूटोरियल को ध्यान में रखते हैं या मामले में उपयोग करते हैं (उदाहरण: पत्रकारों, कार्यकर्ताओं, कवियों, बच्चों, वरिष्ठ नागरिकों, सपने देखने वालों के लिए एक अलग भाषा में, आदि)। हम विचार करना पसंद करते हैं, जो पहले से ही स्वागत नहीं करता है या पी 5 समुदाय में शामिल है, और क्या हम सीखने को निमंत्रण के रूप में उपयोग कर सकते हैं? वह कौन सी भाषा है जिसका उपयोग आप अपने दर्शकों के साथ संवाद करने और उन्हें महसूस करने के लिए करते हैं? अपने प्रारूप के साथ प्रयोग करने के लिए स्वतंत्र महसूस करें। प्रेरणा के लिए कोड शेरंग पर [शेरोन डी ला क्रूज़ की चर्चा](https://www.youtube.com/watch?v=CFT6w9NKfCs) देखें। +यदि आप रास्ते में p5.js में बग ढूंढते हैं, तो कृपया उन्हें [मुद्दों](https://github.com/processing/p5.js/issues) में लॉग इन करें। + +## 👉 आरंभ करना +* [P5.js समुदाय कथन](http://p5js.org/community/) पढ़ें +* वैकल्पिक: रिपॉजिटरी का अवलोकन प्राप्त करने और कोड का निर्माण करने का तरीका जानने के लिए [योगदानकर्ता डॉक्स](./README.md) देखें (यदि आपके लिए प्रासंगिक हो)। +* सभी चर्चा गितुब मुद्दों पर होती है, इसलिए आपको इसमें शामिल होने की जरूरत नहीं है। +* Readme.md फ़ाइल में अपना नाम [योगदान सूची](https://github.com/processing/p5.js#contributors) में जोड़ें! निर्देश [यहां](https://github.com/processing/p5.js/issues/2309) करें। +* और निश्चित रूप से, यदि आप एक बग फिक्सर व्यक्ति के अधिक हैं, तो किसी भी [मुद्दों](https://github.com/processing/p5.js/issues) को लेने के लिए स्वतंत्र महसूस करें! + +स्वागत हे! हमें बहुत खुशी है कि आप यहाँ हैं! +❤️ p5.js समुदाय \ No newline at end of file From 9cab8fa499934ad3940bff46e03006fdc9305983 Mon Sep 17 00:00:00 2001 From: Kunal Kumar Verma <58628586+KKVANONYMOUS@users.noreply.github.com> Date: Fri, 27 Nov 2020 11:44:59 +0530 Subject: [PATCH 25/97] Update .all-contributorsrc --- .all-contributorsrc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 04dab5869f..cbcec144c5 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2267,7 +2267,9 @@ "avatar_url": "https://avatars3.githubusercontent.com/u/58628586?v=4", "profile": "https://kkvanonymous.github.io/", "contributions": [ - "doc" + "doc", + "bug", + "code" ] }, { From cdd0f0904aa09de729c49397ca01b5616a07b08a Mon Sep 17 00:00:00 2001 From: kkvanonymous Date: Sat, 28 Nov 2020 12:59:59 +0530 Subject: [PATCH 26/97] Add Hindi Translation of access.md --- contributor_docs/hi/access.md | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 contributor_docs/hi/access.md diff --git a/contributor_docs/hi/access.md b/contributor_docs/hi/access.md new file mode 100644 index 0000000000..9199157020 --- /dev/null +++ b/contributor_docs/hi/access.md @@ -0,0 +1,40 @@ +# एक्सेस पर हमारा ध्यान + +[२०१ ९ के योगदानकर्ताओं के सम्मेलन](https://p5js.org/community/contributors-conference-2019.html) में, हमने पहुंच को बढ़ाने के लिए केवल p5.js में सुविधाओं को जोड़ने के लिए एक प्रतिबद्धता बनाई (जिसका अर्थ है समावेश / और / पहुंच क्षमता) । इसका अर्थ है विविधता के वैक्टर (जैसे लिंग, सामाजिक, आर्थिक, नस्ल, जातीयता, भाषा, विकलांगता, आदि) पर विचार करना जो पहुंच / भागीदारी को प्रभावित कर सकता है; और बाधाओं को स्वीकार, विघटित करने और रोकने के लिए कार्रवाई कर रहा है। हम p5.js. के साथ अधिक विशेषाधिकार प्राप्त समूहों के निरंतर आराम से अधिक ऐतिहासिक रूप से हाशिए वाले समूहों की आवश्यकताओं को प्राथमिकता देते हैं। + +हम उन सुविधा अनुरोधों को स्वीकार नहीं करेंगे जो पहुंच बढ़ाने के हमारे प्रयास का समर्थन नहीं करते हैं। आप इस मानदंड को हमारे मुद्दे में परिलक्षित देखेंगे और अनुरोध टेम्पलेट खींचेंगे। + +यह p5.js. के भीतर पहुंच और समावेश के बारे में चल रही बातचीत का हिस्सा है इन मूल मूल्यों को धारण करने की हमारी मंशा जिससे p5.js बनाया गया है, हमारे [कम्युनिटी स्टेटमेट](.../CODE_OF_CONDUCT.md) में बनाया गया है, जिसे [2015 कॉन्ट्रिब्यूटर्स](https://p5js.org/community/contributors-conference-2015.htmltml)। + +**कृपया इसे एक प्रारंभिक बिंदु माने** हम इस बारे में अधिक बातचीत को आमंत्रित करना चाहते हैं कि पहुँच का क्या अर्थ है और हम इसे कैसे प्राथमिकता दे सकते हैं। + +## तरह की पहुँच + +बढ़ती पहुंच p5.js समुदाय के लोगों की कच्ची संख्या के विस्तार पर केंद्रित नहीं है। यह p5.js को उपलब्ध कराने और उन लोगों के लिए स्वीकार्य करने पर ध्यान केंद्रित करता है, जिन्हें p5.js समुदाय (जानबूझकर या नहीं) और समान उपकरण और समुदायों से बाहर रखा गया है। + +यहां पहुंच का मतलब है कि p5.js को इसके लिए बेहतर बनाना: + +- जो लोग अंग्रेजी के अलावा अन्य भाषाएं बोलते हैं +- काले लोग, स्वदेशी लोग और रंग के लोग +- जो लोग समलैंगिक, समलैंगिक, उभयलिंगी, ट्रांस या क्वीर हैं +- सीमांत लिंग वाले लोग +- विकलांग या बीमारी वाले लोग +- वे लोग जिनके पास कक्षा या आय के कारण रचनात्मक कोडिंग के साथ जुड़ने के अवसरों और / या संसाधनों का अभाव है +- ओपन सोर्स और क्रिएटिव कोडिंग में बहुत कम या पहले के अनुभव वाले लोग +- और अन्य लोग जिन्हें व्यवस्थित रूप से बाहर रखा गया है और ऐतिहासिक रूप से कम आंकलन किया गया है + +### उदाहरण + +हमारे द्वारा पहुँच बढ़ाने के लिए किए गए प्रयासों के उदाहरण हैं: + +- अधिक दस्तावेजों और अन्य सामग्रियों का अधिक भाषाओं में अनुवाद करना +- सहायक तकनीकों के लिए हमारे समर्थन में सुधार (जैसे कि स्क्रीन्रेडर्स) +- हमारे टूल में वेब कंटेंट एक्सेसिबिलिटी दिशानिर्देशों का पालन करना और उपयोगकर्ताओं को उनकी परियोजनाओं में उनका पालन करना आसान बनाने की दिशा में काम करना +- टूल का उपयोग करने वाले लोगों के लिए p5.js त्रुटि संदेशों को अधिक सहायक और सहायक बनाना +- ऐतिहासिक रूप से रचनात्मक कोडिंग और डिजिटल आर्ट्स में हाशिए पर छोड़ दिए गए समुदायों के भीतर p5.js के शिक्षार्थियों का परामर्श और समर्थन करना + +ऐसी अन्य चीजें हैं जिनके बारे में हमने अभी तक सोचा नहीं है और हम यह पता लगाने के लिए उत्साहित हैं कि वे एक साथ क्या कर रहे हैं। यदि आपके पास एक विचार है, तो कृपया [इसे एक मुद्दे के रूप में साझा करें](https://github.com/processing/p5.js/issues/new/choose)। + +## रखरखाव + +हम p5.js. के मौजूदा फीचर सेट को बनाए रखने के अपने इरादे की भी पुष्टि करते हैं हम बग्स को ठीक करना चाहते हैं चाहे कोडबेस के किस क्षेत्र में हो क्योंकि हम मानते हैं कि उपकरण की निरंतरता इसे शुरुआती लोगों के लिए अधिक सुलभ बनाती है। \ No newline at end of file From fd2c5e9cde8fc73f666b5b1f8d6a3709ffce0a75 Mon Sep 17 00:00:00 2001 From: kkvanonymous Date: Sat, 28 Nov 2020 13:01:45 +0530 Subject: [PATCH 27/97] Add Hindi Translation of issue_labels.md --- contributor_docs/hi/issue_labels.md | 72 +++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 contributor_docs/hi/issue_labels.md diff --git a/contributor_docs/hi/issue_labels.md b/contributor_docs/hi/issue_labels.md new file mode 100644 index 0000000000..b1805ea4b0 --- /dev/null +++ b/contributor_docs/hi/issue_labels.md @@ -0,0 +1,72 @@ +# p5.js लेबल जारी करें + +p5.js मुद्दों को सुलझाने और व्यवस्थित करने में मदद करने के लिए लेबल के एक सेट का उपयोग करता है। + +सभी मुद्दों पर गंभीरता, कठिनाई का स्तर और कौन से घटक / क्षेत्र प्रभावित होते हैं, यह इंगित करने के लिए लेबल लगाए जाने चाहिए। अतिरिक्त स्थिति टैग किसी रिज़ॉल्यूशन या बग के प्रकार (उदाहरण के लिए, डुप्लिकेट समस्याएँ) को इंगित करने के लिए लागू किया जा सकता है। + +## स्थिति + +लेबल | प्रयोग +------------------- | ------------- +help_wanted | निश्चित नहीं है कि कैसे तय किया जाए, योगदान की तलाश में, लोगों के लिए आसान पहुंच बिंदु (इंगित करता है कि नए डेवलपर द्वारा दावा किया जा सकता है +inconsistent_style | अस्पष्ट कोड, भ्रामक वाक्यविन्यास, शायद अपर्याप्त प्रलेखन +duplicate | मुद्दा पहले ही कहीं और नोट किया गया है +missing_test | स्वचालित परीक्षण की आवश्यकता है +wont_fix | वैध मुद्दा, लेकिन समुदाय द्वारा गुंजाइश पर सहमत होने के कारण संबोधित नहीं किया जाएगा +gsoc | समस्या को पहले से ही Google समर ऑफ़ कोड द्वारा संबोधित किया जा रहा है +invalid| अब प्रासंगिक नहीं है (उदाहरण के लिए, पुराने एपीआई में सुविधा अनुरोध), वास्तव में समस्या नहीं है +discussion | जानें कि समस्या क्या है, समाधान का निर्धारण करने के लिए सामुदायिक इनपुट की आवश्यकता है +question | निश्चित नहीं है कि क्या समस्या है / यदि कोई समस्या है, तो स्पष्टीकरण की आवश्यकता है +feature | एक अतिरिक्त या कोडबेस में सुधार +regression | कार्य / सुविधा एक बार काम करती है, लेकिन तब से टूट गई है। अस्थिर सुविधाओं या घटकों की पहचान करने के लिए उपयोगी है + + +## तीव्रता +P5.js उपयोगकर्ताओं और डेवलपर्स पर बग के प्रभाव को वर्गीकृत करें। + +लेबल | प्रयोग +------------------- | ------------- +severity:critical | अन्य डेवलपर्स के ब्लॉक काम करते हैं (उदाहरण के लिए एक टूटी हुई निर्माण); या लाइब्रेरी या IDE उपयोगकर्ता के लिए डेटा हानि का कारण बनता है +severity:major | एक महत्वपूर्ण घटक में कार्यक्षमता का नुकसान +severity:minor | कई उपयोगकर्ताओं द्वारा देखा जाने की संभावना नहीं है एक छोटी सी वस्तु; या ऐसा कुछ जो केवल उपयोगकर्ता द्वारा सामना किए जाने पर मामूली झुंझलाहट होगी; या किसी ज्ञात कार्य के साथ + +## कठिनाई स्तर +टैग स्तर और सुविधा अनुरोध कठिनाई स्तर के अनुसार। उन बगों की पहचान करने में सहायता करें, जो शुरुआती या नए योगदानकर्ताओं, या आइटम से निपट सकते हैं जो अनुभवी योगदानकर्ताओं से भी पर्याप्त प्रयास करेंगे। + +लेबल | प्रयोग +------------------- | ------------- +level:bite size| आसानी से स्क्वैश किया जा सकता है, एक नए / जूनियर डेवलपर द्वारा सामना किया जा सकता है +level:moderate | कोड बेस के साथ काम या परिचित की एक बड़ी राशि की आवश्यकता है +level:advanced | बड़ी मात्रा में काम करने की आवश्यकता होती है और संभवतः एक आक्रामक फिक्स या पुनः वास्तुकला +level:unknown | समस्या दाखिल करने वाले व्यक्ति द्वारा ज्ञात नहीं होने से कठिनाई + +## क्षेत्र +समस्या से प्रभावित कोड आधार के भाग को इंगित करें। + +* area:3d +* area:color +* area:core +* area:documentation +* area:dom +* area:events +* area:examples +* area:image +* area:io +* area:math +* area:tutorial +* area:typography + +## ओएस / ब्राउज़र +जब कोई समस्या केवल एक विशिष्ट ऑपरेटिंग सिस्टम और / या ब्राउज़र को प्रभावित करती है, तो समस्या को उचित रूप से टैग करें। + +* chrome +* ie +* safari +* opera +* firefox +* android +* ios +* windows_mobile +* windows +* osx +* linux \ No newline at end of file From f6ef734c9238f65826aa0dcc79113100f592682f Mon Sep 17 00:00:00 2001 From: kkvanonymous Date: Sat, 28 Nov 2020 13:02:33 +0530 Subject: [PATCH 28/97] Add Hindi Translation of organization.md --- contributor_docs/hi/organization.md | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 contributor_docs/hi/organization.md diff --git a/contributor_docs/hi/organization.md b/contributor_docs/hi/organization.md new file mode 100644 index 0000000000..04eea807a5 --- /dev/null +++ b/contributor_docs/hi/organization.md @@ -0,0 +1,46 @@ +# योगदान का आयोजन + +रिपॉजिटरी को व्यवस्थित रखना यह सुनिश्चित करता है कि यह हमेशा स्पष्ट हो कि कौन से विचार-विमर्श और कार्य सबसे महत्वपूर्ण हैं। यह अनुरक्षक से नए योगदानकर्ताओं तक सभी को अभिभूत किए बिना भंडार को नेविगेट करने में मदद करता है। इसके साथ मदद करने के लिए, हमारे पास मुद्दों को व्यवस्थित करने, काम करने और अनुरोधों को खींचने के लिए दिशानिर्देशों का एक सेट है। + +संगठन के साथ योगदान करने के लिए एक शानदार तरीका हो सकता है। यदि बग रिपोर्ट मिस कोड जैसी जानकारी गुम है, तो बेझिझक झंकार करें और लापता जानकारी मांगें। यदि किसी कार्यपालक के पास कोई समस्या 60 दिनों के लिए नहीं देखी गई है, तो यह देखने के लिए कि क्या वे अभी भी मुद्दे पर काम करना चाहते हैं, इस मुद्दे पर टिप्पणी करने के लिए कार्यभार के साथ जाँच करने में मददगार हो सकते हैं। जब भी आप संगठनात्मक कार्यों में मदद कर रहे हों, सुनिश्चित करें कि आप दयालु हों और हमेशा समुदाय के दिशानिर्देशों को ध्यान में रखें। + +# संगठन के लिए दिशा निर्देश + +## मुद्दे +- **सभी बग रिपोर्ट में नमूना कोड शामिल होना चाहिए** + - यह मुद्दे के शरीर में पोस्ट किए गए कोड के रूप में हो सकता है, या यह [ऑनलाइन संपादक](https://editor.p5js.org) में अधिमानतः कोड के ऑनलाइन उदाहरण का लिंक हो सकता है +- **सभी मुद्दों में कम से कम 2 लेबल होने चाहिए** + - इससे मुद्दों को नेविगेट करने में काफी आसानी होती है। + - क्षेत्र (वेबल, कोर, छवि, आदि) के लिए एक लेबल जोड़ने का प्रयास करें +- **यह कार्य पहले आओ, पहले पाओ है** + - यदि बग को पुन: पेश किया गया है, या समुदाय द्वारा एक सुविधा अनुरोध / वृद्धि पर सहमति हुई है, तो यह असाइनमेंट के लिए उपलब्ध है। जब ऐसा होता है कि "मैं इस मुद्दे पर काम करना चाहूंगा" जैसे कुछ कहकर असाइनमेंट का अनुरोध करने वाला पहला योगदानकर्ता है! सौंपा जाएगा। + - अगर यह अस्पष्ट है कि बग प्रतिलिपि प्रस्तुत करने योग्य है या सुविधा अनुरोध / वृद्धि पर सहमति व्यक्त की गई है, तो किसी मुद्दे को सौंपा जाने का अनुरोध न करें। + +## पुल अनुरोध +- **सभी पुल अनुरोधों को एक मुद्दे के साथ जोड़ा जाना चाहिए** + - यदि आप बग को ठीक करना चाहते हैं या एक सुविधा जोड़ना चाहते हैं, तो एक समस्या को खोलकर शुरू करें ताकि समुदाय उस पर चर्चा कर सके। + - यदि किसी संबंधित मुद्दे के बिना एक पुल अनुरोध खोला जाता है, तो टिप्पणी करें और योगदानकर्ता को पुल अनुरोध खोलने के लिए कहें। + + + +# निर्णय लेने के लिए दिशानिर्देश + +p5 अपनी निर्णय लेने की प्रक्रिया को यथासंभव पारदर्शी और क्षैतिज बनाने की इच्छा रखता है। ऐसा करने के लिए, पी 5 निर्णय लेने के लिए एक अनौपचारिक सहमति-मांग मॉडल का उपयोग करता है। इसका मतलब यह है कि हम किसी भी और सभी निर्णयों पर सामुदायिक सहमति तक पहुंचना पसंद करते हैं। अगर यह विफल होता है, तो इसके बजाय एक वोट होगा। + +**स्टूवर्स** में प्रस्तावों को वीटो करने की क्षमता है। यह तब हो सकता है जब कोई प्रस्ताव मिशन / सामुदायिक दिशानिर्देशों के साथ संरेखित नहीं होता है, या जब कोई प्रस्ताव एक महत्वपूर्ण रखरखाव या कार्यान्वयन चुनौती प्रस्तुत करता है कि परियोजना उस समय से निपटने में सक्षम नहीं है। + +एक बदलाव का प्रस्ताव करने के लिए, एक मुद्दा खोलें। यदि यह एक बड़ा परिवर्तन या परिवर्तन है जो महत्वपूर्ण डिजाइन विचार की आवश्यकता है, तो मुद्दे पर 'चर्चा' लेबल जोड़ें। इच्छुक समुदाय के सदस्य अपने विचारों के साथ झंकार करेंगे। एक महत्वपूर्ण अवधि बीत जाने के बाद (30 दिन जब तक जरूरी नहीं), रखवाले यह समझने की कोशिश करेंगे कि क्या कोई महत्वपूर्ण हित है और क्या सर्वोत्तम दृष्टिकोण के बारे में आम सहमति बन गई है। इस बिंदु पर, अनुरक्षक या तो वोट का अनुरोध करेगा, समस्या को बंद करेगा, या पुल अनुरोधों के लिए समस्या को खोल देगा। चर्चा संपन्न होने से पहले प्रस्तुत अनुरोधों को नजरअंदाज कर दिया जाएगा। + +> भविष्य में यह उपरोक्त संगठन और निर्णय लेने की प्रक्रियाओं को स्वचालित करने के लिए बहुत अच्छा होगा। + +> अगर आपको बॉट या गीथब एक्शन के साथ उपरोक्त में से किसी को भी स्वचालित करने का विचार है तो अपने प्रस्ताव के साथ समस्या को खोलने के लिए स्वतंत्र महसूस करें! + + + +# स्टूवर्स + +स्टीवर्ड ऐसे योगदानकर्ता होते हैं जो विशेष रूप से परियोजना के कुछ क्षेत्रों से परिचित, परिचित या उत्तरदायी होते हैं। उनकी भूमिका p5.js. पर काम करने वाले अन्य लोगों को संदर्भ और मार्गदर्शन प्रदान करने में मदद करना है। यदि आपके पास किसी विशेष क्षेत्र में योगदान करने के बारे में कोई सवाल है, तो आप सूचीबद्ध स्टीवर्ड को किसी समस्या या टैग अनुरोध में टैग कर सकते हैं। वे समुदाय अनुरोधों पर भी वजन कर सकते हैं और समुदाय के इनपुट के साथ अपने क्षेत्र की समग्र दिशा का मार्गदर्शन कर सकते हैं। + +कोई भी इच्छुक स्वयंसेवक एक स्टूवर्ड हो सकता है! विशेषज्ञता के लिए कोई विशिष्ट आवश्यकताएं नहीं हैं, बस सक्रिय रूप से सीखने और भाग लेने में रुचि है। यदि आप इस परियोजना के एक या अधिक हिस्सों से परिचित हैं, तो एक समस्या को स्वयंसेवक के रूप में खोलें! + +एक बार जोड़े जाने के बाद, एक स्टीवर्ड का उपयोगकर्ता नाम [रीडमी के स्टीवर्ड सेक्शन](https://github.com/processing/p5.js#stewards) में रहेगा, जब तक कि उन्हें हटाने का अनुरोध नहीं किया जाता। यदि एक स्टवर्ड एक विस्तारित अवधि के लिए अनुत्तरदायी है, तो हम उनसे उनकी स्थिति के बारे में पूछने के लिए पिंग कर सकते हैं। और आप हमेशा एक स्टीवर्ड के रूप में ब्रेक ले सकते हैं और वापस आ सकते हैं! \ No newline at end of file From 0b3bf609fa47ac40af2b94ed33929328a2485884 Mon Sep 17 00:00:00 2001 From: kkvanonymous Date: Sat, 28 Nov 2020 13:03:07 +0530 Subject: [PATCH 29/97] Add Hindi Translation of roadmap.md --- contributor_docs/hi/roadmap.md | 66 ++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 contributor_docs/hi/roadmap.md diff --git a/contributor_docs/hi/roadmap.md b/contributor_docs/hi/roadmap.md new file mode 100644 index 0000000000..9a55c6ebb4 --- /dev/null +++ b/contributor_docs/hi/roadmap.md @@ -0,0 +1,66 @@ +# p5.js 1.0 रोडमैप [WIP] + +यह दस्तावेज़ भविष्य के 1.0 संस्करण p5.js. के लिए संभावित सुविधाओं, सुधारों और रखरखाव मदों की एक सूची है। पहला मसौदा कार्य समूह द्वारा यूसीएलए डिजाइन मीडिया आर्ट्स में बनाया गया था और आपकी प्रतिक्रिया के लिए बाहर रखा गया है। यह एक कामकाजी मसौदा है जिसे अद्यतन किया जा सकता है और इसे अगस्त 2019 के लिए p5.js योगदानकर्ता सम्मेलन में संशोधित किया जाएगा। हमारा लक्ष्य 2019 के अंत तक p5.js 1.0 जारी करना है। + +ईएस 6 प्रवास के अपवाद के साथ, यहां कार्यों को प्राथमिकता से आदेश नहीं दिया गया है। गथुब पर [मील के पत्थर](https://github.com/processing/p5.js/milestones) है, जहां हम रिलीज और ट्रैक प्रगति के लिए कार्यों को प्राथमिकता देते हैं। + +## ES6 प्रवास +* चरण 1: उपयोगकर्ता का सामना करना पड़ रहा है + * p5js.org ट्यूटोरियल (प्रति ट्यूटोरियल इश्यू) + * p5js.org उदाहरण (प्रति अनुभाग समस्या) + * p5js.org संदर्भ उदाहरण (प्रति अनुभाग जारी) +* चरण 2: डेवलपर का सामना करना पड़ रहा है + * प्रक्रियाओं का निर्माण + * डेवलपर +* चरण 3: कोडबेस + * टीबीडी: यह एक समर्पित व्यक्ति द्वारा किया जा सकता है, हम इस पर शुरू नहीं करेंगे जब तक कि यह निर्धारित न हो। +* बाद का चरण: + * अन्य सामग्री - किस हद तक बाहरी सामग्री (p5.js पुस्तक के साथ शुरू करना, कोडिंग ट्रेन) को शैक्षिक संसाधनों के एक चिकनी रोलआउट को सुनिश्चित करने के लिए अद्यतन करने की आवश्यकता है? + * योगदान पुस्तकालयों + +## रखरखाव +* लंबित क्रोम परिवर्तनों के लिए ऑडियो अपडेट (उपयोगकर्ता को पहले बातचीत करनी चाहिए) + * अद्यतन संदर्भ प्रलेखन और उदाहरण, और उदाहरण पृष्ठ + * इस बारे में चेतावनी देने के लिए FES अपडेट करें? +* अधिक पूर्ण इकाई परीक्षण + * ऐसा करने के लिए स्पष्ट ट्यूटोरियल +* मित्रतापूर्ण त्रुटि प्रणाली प्रलेखन में सुधार + * इस प्रक्रिया में क्या हो रहा है, इसे बेहतर दस्तावेज़ के लिए टिप्पणियों को https://github.com/processing/p5.js/blob/main/src/core/friendly_errors/fes_core.js पर जोड़ें। + +## बग फिक्सिंग +* मोबाइल डिवाइस का समर्थन / उन्नयन +* WebGL मजबूती + * प्रकाश + * रोशनी () कार्यान्वयन + * डिफ़ॉल्ट रूप से प्रति पिक्सेल प्रकाश व्यवस्था + * शेडर पाइपलाइन को सरल बनाएं? + * अद्यतन उदाहरण + * आकार पाइपलाइन को सरल बनाएं + * आकृतियों के लिए एक रेंडरिंग विधि, रिटेन मोड से जियोम ऑब्जेक्ट का निर्माण करें + +## नए विशेषताएँ +* आकृतियाँ + * createShape () p5.Geometry ऑब्जेक्ट वापस करने के लिए सार्वजनिक API ?? 2D में समतुल्य क्या है? + * 2 डी के लिए एसवीजी कुछ भी? +* छवि के साथ GIF समर्थन () + * createImg एक अच्छा काम है लेकिन छात्रों को gifs पसंद है :) +* I18n (स्थानीयकरण) त्रुटि संदेशों के लिए + FES + * स्थानीय त्रुटि के लिए बुनियादी ढांचे का विकास करना और कोडबेस के भीतर संदेशों को सांत्वना देना + * विभिन्न त्रुटि संदेशों का अनुवाद करें +* K-12 समर्थन के रूप में चर्चा की [धागे में](https://github.com/processing/p5.js/issues/2305) + * सर्कल () और वर्ग जोड़ें () + * पुस्तकालयों पृष्ठ पर makeyourownalgorithmicart / simple.js प्राप्त करें +* पुस्तकालय भर में वादों को लागू करें + * कोडबेस में प्रोमिस के उपयोग की पुष्टि / कार्यान्वयन + * लोड एक्सएक्सएक्स (लोड प्राथमिकता) के लिए एपीआई में प्रोमिस का खुला उपयोग? + +## योगदानकर्ता प्रक्रिया और समर्थन +* विभिन्न क्षेत्रों में अपूर्णता के लिए खुले टिकट: + * परिक्षण + * फ़ीचर कार्यान्वयन + * अनुवाद +* [शब्दार्थ संस्करण](https://semver.org/) का कठोर उपयोग +* भविष्य के संस्करणों के लिए रोडमैप इनपुट को सुलझाने के लिए स्पष्ट प्रक्रिया। + +## आदि +* 1.0 रिलीज के लिए, कलाकारों और कोडर से क्यूरेटेड उदाहरणों का एक नया सेट ड्रॉप करें। \ No newline at end of file From 360333375036a1ce6a1545e06bd93ff7b43f47f0 Mon Sep 17 00:00:00 2001 From: TraXIcoN Date: Thu, 3 Dec 2020 04:41:34 -0500 Subject: [PATCH 30/97] Made changes for min() and max() parameter validation --- src/math/calculation.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/math/calculation.js b/src/math/calculation.js index 59c109136b..bd7bd7c15e 100644 --- a/src/math/calculation.js +++ b/src/math/calculation.js @@ -501,7 +501,6 @@ p5.prototype.map = function(n, start1, stop1, start2, stop2, withinBounds) { * @return {Number} */ p5.prototype.max = function(...args) { - p5._validateParameters('max', args); if (args[0] instanceof Array) { return Math.max.apply(null, args[0]); } else { @@ -550,7 +549,6 @@ p5.prototype.max = function(...args) { * @return {Number} */ p5.prototype.min = function(...args) { - p5._validateParameters('min', args); if (args[0] instanceof Array) { return Math.min.apply(null, args[0]); } else { From 5aec43464056f4e76849d5df108b800d25af80c0 Mon Sep 17 00:00:00 2001 From: Arijit Kundu Date: Thu, 3 Dec 2020 16:32:48 +0530 Subject: [PATCH 31/97] Fixed typos/spellings --- contributor_docs/friendly_error_system.md | 4 ++-- contributor_docs/hi/unit_testing.md | 2 +- contributor_docs/inline_documentation.md | 4 ++-- contributor_docs/release_process.md | 2 +- contributor_docs/unit_testing.md | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contributor_docs/friendly_error_system.md b/contributor_docs/friendly_error_system.md index cd85ff8a51..a94020172d 100644 --- a/contributor_docs/friendly_error_system.md +++ b/contributor_docs/friendly_error_system.md @@ -131,7 +131,7 @@ function setup() { } /* FES will show: -p5.js says: It seems that you may have accidently written "colour" instead of "color" (on line 2 in sketch.js [http://localhost:8000/lib/empty-example/sketch.js:2:3]). +p5.js says: It seems that you may have accidentally written "colour" instead of "color" (on line 2 in sketch.js [http://localhost:8000/lib/empty-example/sketch.js:2:3]). Please correct it to color if you wish to use the function from p5.js (http://p5js.org/reference/#/p5/color) */ @@ -146,7 +146,7 @@ function preLoad() { } /* FES will show: -p5.js says: It seems that you may have accidently written preLoad instead of preload. +p5.js says: It seems that you may have accidentally written preLoad instead of preload. Please correct it if it's not intentional. (http://p5js.org/reference/#/p5/preload) */ diff --git a/contributor_docs/hi/unit_testing.md b/contributor_docs/hi/unit_testing.md index d9991a366c..15c76cac86 100644 --- a/contributor_docs/hi/unit_testing.md +++ b/contributor_docs/hi/unit_testing.md @@ -49,7 +49,7 @@ suite.only('color/p5.ColorConversion', function() { चिह्नित किया जाएगा, और इस तरह की रिपोर्ट की जाएगी। -##Infrastucture +##Infrastructure ###Framework हम अपने यूनिट परीक्षणों को संरचित करने और चलाने के लिए [Mocha](https://mochajs.org/) का उपयोग करते हैं diff --git a/contributor_docs/inline_documentation.md b/contributor_docs/inline_documentation.md index 61118f444a..1c8837094b 100644 --- a/contributor_docs/inline_documentation.md +++ b/contributor_docs/inline_documentation.md @@ -194,7 +194,7 @@ arc(50, 55, 80, 80, PI+QUARTER_PI, TWO_PI); ``` You can have multiple examples for one function, just make sure you have only -one @example followed by each example having it's own `
` wrapping seperated +one @example followed by each example having it's own `
` wrapping separated by a line break. ``` @@ -266,7 +266,7 @@ horizontal wave pattern effected by mouse x-position & updating noise values. ``` ## Template for methods -Here is an example for a well-documentated method. To create a new method, you can use [this template](https://github.com/processing/p5.js/tree/main/contributor_docs/method.example.js). Replace the text with your method's variables and remove the remaining ones. +Here is an example for a well-documented method. To create a new method, you can use [this template](https://github.com/processing/p5.js/tree/main/contributor_docs/method.example.js). Replace the text with your method's variables and remove the remaining ones. ![Image showing inline documentation example for methods](https://raw.githubusercontent.com/processing/p5.js/main/contributor_docs/images/method-template-example.png) diff --git a/contributor_docs/release_process.md b/contributor_docs/release_process.md index 5bfc23eba1..fe2952f707 100644 --- a/contributor_docs/release_process.md +++ b/contributor_docs/release_process.md @@ -39,6 +39,6 @@ In the case where you have push access to the repositories: In the case where you don't have push access to the repositories: * You will need to edit the `name` field of `package.json` to a namespaced version, eg. `@username/p5` and commit this change into git before running `npm run release -- --preview` as usual. When prompted just choose not to publish the package to the namespaced packaged on NPM, nothing will be published online. -* You can do a full test run of the release with `npm run release` provided you have edited the `name` field of `package.json`. To choose where to clone and push the Bower release and website repositories from, you can set them by specifiying additional arguments like so: `npm run release -- --bowerReleaser=username --docsReleaser=username`. +* You can do a full test run of the release with `npm run release` provided you have edited the `name` field of `package.json`. To choose where to clone and push the Bower release and website repositories from, you can set them by specifying additional arguments like so: `npm run release -- --bowerReleaser=username --docsReleaser=username`. __NOTE:__ `np` (`6.2.0`) currently has a [bug](https://github.com/sindresorhus/np/issues/508) that prevents release to namespaced package name, you can revert to `5.2.1` if you must test this otherwise it will fail at the publish step. \ No newline at end of file diff --git a/contributor_docs/unit_testing.md b/contributor_docs/unit_testing.md index 88f29e94ba..442a4c4506 100644 --- a/contributor_docs/unit_testing.md +++ b/contributor_docs/unit_testing.md @@ -40,7 +40,7 @@ Now when you use `npm test`, only tests within that `function()` body will be ru This feature is the inverse of `.only()`. By appending `.skip()`, you may tell Mocha to simply ignore these suite(s) and test case(s). Anything skipped will be marked as pending, and reported as such. -## Infrastucture +## Infrastructure ### Frameworks From 9469cd0325d9eda2944fbd514fb01701d741c9b0 Mon Sep 17 00:00:00 2001 From: Arijit Kundu Date: Fri, 4 Dec 2020 01:14:49 +0530 Subject: [PATCH 32/97] Proposed changes :heavy_check_mark: --- test/unit/core/error_helpers.js | 12 ++++++------ translations/en/translation.json | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/unit/core/error_helpers.js b/test/unit/core/error_helpers.js index b29a8d80b1..47e6a29d0e 100644 --- a/test/unit/core/error_helpers.js +++ b/test/unit/core/error_helpers.js @@ -391,7 +391,7 @@ suite('Error Helpers', function() { const logMsg = help(new ReferenceError('MouseX is not defined')); assert.match( logMsg, - /It seems that you may have accidently written "MouseX"/ + /It seems that you may have accidentally written "MouseX"/ ); assert.match(logMsg, /mouseX/); }); @@ -400,7 +400,7 @@ suite('Error Helpers', function() { const logMsg = help(new ReferenceError('colour is not defined')); assert.match( logMsg, - /It seems that you may have accidently written "colour"/ + /It seems that you may have accidentally written "colour"/ ); assert.match(logMsg, /color/); }); @@ -411,7 +411,7 @@ suite('Error Helpers', function() { const logMsg = help(new ReferenceError('strok is not defined')); assert.match( logMsg, - /It seems that you may have accidently written "strok"/ + /It seems that you may have accidentally written "strok"/ ); assert.match(logMsg, /stroke/); assert.match(logMsg, /STROKE/); @@ -422,7 +422,7 @@ suite('Error Helpers', function() { const logMsg = help(new ReferenceError('RandomGossian is not defined')); assert.match( logMsg, - /It seems that you may have accidently written "RandomGossian"/ + /It seems that you may have accidentally written "RandomGossian"/ ); assert.match(logMsg, /randomGaussian/); }); @@ -459,7 +459,7 @@ suite('Error Helpers', function() { assert.strictEqual(log.length, 1, 'One message is displayed'); assert.match( log[0], - /It seems that you may have accidently written preLoad instead of preload/ + /It seems that you may have accidentally written preLoad instead of preload/ ); } ); @@ -492,7 +492,7 @@ suite('Error Helpers', function() { assert.strictEqual(log.length, 1); assert.match( log[0], - /It seems that you may have accidently written DRAW instead of draw/ + /It seems that you may have accidentally written DRAW instead of draw/ ); }); } diff --git a/translations/en/translation.json b/translations/en/translation.json index dfae559192..ff45b2c26d 100644 --- a/translations/en/translation.json +++ b/translations/en/translation.json @@ -1,7 +1,7 @@ { "fes": { "autoplay": "The media that tried to play (with '{{src}}') wasn't allowed to by this browser, most likely due to the browser's autoplay policy. Check out {{link}} for more information about why.", - "checkUserDefinedFns": "It seems that you may have accidently written {{name}} instead of {{actualName}}.\n\nPlease correct it if it's not intentional.", + "checkUserDefinedFns": "It seems that you may have accidentally written {{name}} instead of {{actualName}}.\n\nPlease correct it if it's not intentional.", "fileLoadError": { "bytes": "It looks like there was a problem loading your file. {{suggestion}}", "font": "It looks like there was a problem loading your font. {{suggestion}}", @@ -37,8 +37,8 @@ }, "libraryError": "An error with message \"{{error}}\" occured inside the p5js library when {{func}} was called {{location}}\n\nIf not stated otherwise, it might be an issue with the arguments passed to {{func}}.", "location": "(on line {{line}} in {{file}} [{{location}}])", - "misspelling": "It seems that you may have accidently written \"{{name}}\" instead of \"{{actualName}}\" {{location}}.\n\nPlease correct it to {{actualName}} if you wish to use the {{type}} from p5.js", - "misspelling_plural": "It seems that you may have accidently written \"{{name}}\" {{location}}.\n\nYou may have meant one of the following:\n{{suggestions}}", + "misspelling": "It seems that you may have accidentally written \"{{name}}\" instead of \"{{actualName}}\" {{location}}.\n\nPlease correct it to {{actualName}} if you wish to use the {{type}} from p5.js", + "misspelling_plural": "It seems that you may have accidentally written \"{{name}}\" {{location}}.\n\nYou may have meant one of the following:\n{{suggestions}}", "misusedTopLevel": "Did you just try to use p5.js's {{symbolName}} {{symbolType}}? If so, you may want to move it into your sketch's setup() function.\n\nFor more details, see: {{link}}", "positions": { "p_1": "first", @@ -58,4 +58,4 @@ "welcome": "Welcome! This is your friendly debugger. To turn me off, switch to using p5.min.js.", "wrongPreload": "An error with message \"{{error}}\" occured inside the p5js library when \"{{func}}\" was called {{location}}.\n\nIf not stated otherwise, it might be due to \"{{func}}\" being called from preload. Nothing besides load calls (loadImage, loadJSON, loadFont, loadStrings, etc.) should be inside the preload function." } -} +} \ No newline at end of file From bba097f0210fbeedf6783963cdcac2e1db6f57e1 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 4 Dec 2020 06:03:07 +0000 Subject: [PATCH 33/97] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7b00376d80..473da3ada9 100644 --- a/README.md +++ b/README.md @@ -449,8 +449,9 @@ We recognize all types of contributions. This project follows the [all-contribut
Rishabh Taparia

💻 📖
Daniel Sarno

💡 -
Kunal Kumar Verma

📖 +
Kunal Kumar Verma

📖 🐛 💻
Bharath Kumar R

💻 +
Aditya Mohan

💻 From 5e4bed551bbea0cd8d5d6f301be52e4818e273fb Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 4 Dec 2020 06:03:08 +0000 Subject: [PATCH 34/97] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index cbcec144c5..63196383be 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2280,6 +2280,15 @@ "contributions": [ "code" ] + }, + { + "login": "TraXIcoN", + "name": "Aditya Mohan", + "avatar_url": "https://avatars2.githubusercontent.com/u/54040096?v=4", + "profile": "https://www.linkedin.com/in/aditya-mohan-b1ba7a182/", + "contributions": [ + "code" + ] } ], "repoType": "github", From 3eb44b9ad715712da7a75c3b811f2d16a9d06c3a Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 7 Dec 2020 04:29:28 +0000 Subject: [PATCH 35/97] docs: update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 473da3ada9..858666de97 100644 --- a/README.md +++ b/README.md @@ -452,6 +452,7 @@ We recognize all types of contributions. This project follows the [all-contribut
Kunal Kumar Verma

📖 🐛 💻
Bharath Kumar R

💻
Aditya Mohan

💻 +
Arijit Kundu

🐛 💻 📖 From 8fdbad10d4ac9593b1ec7a91774d62dbc939114f Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 7 Dec 2020 04:29:29 +0000 Subject: [PATCH 36/97] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 63196383be..624a876823 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2289,6 +2289,17 @@ "contributions": [ "code" ] + }, + { + "login": "covalentbond", + "name": "Arijit Kundu", + "avatar_url": "https://avatars1.githubusercontent.com/u/53327173?v=4", + "profile": "https://www.linkedin.com/in/arijit-kundu/", + "contributions": [ + "bug", + "code", + "doc" + ] } ], "repoType": "github", From 4379e6b62e9e78b26ef4f9c1a5823042dc3a842f Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 10 Dec 2020 14:39:55 +0000 Subject: [PATCH 37/97] docs: update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 858666de97..94ff9e0ed0 100644 --- a/README.md +++ b/README.md @@ -453,6 +453,7 @@ We recognize all types of contributions. This project follows the [all-contribut
Bharath Kumar R

💻
Aditya Mohan

💻
Arijit Kundu

🐛 💻 📖 +
Tanner Dolby

💻 From 0f0a9ee6a92066fe0ce59170033b77d38a2ca3f1 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 10 Dec 2020 14:39:56 +0000 Subject: [PATCH 38/97] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 624a876823..a6021c3981 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2300,6 +2300,15 @@ "code", "doc" ] + }, + { + "login": "tannerdolby", + "name": "Tanner Dolby", + "avatar_url": "https://avatars3.githubusercontent.com/u/48612525?v=4", + "profile": "https://tannerdolby.com", + "contributions": [ + "code" + ] } ], "repoType": "github", From 9783974a8ccdd193d1d8e43b411022e258bffb44 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Dec 2020 18:22:23 +0000 Subject: [PATCH 39/97] Bump ini from 1.3.5 to 1.3.7 Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.7. - [Release notes](https://github.com/isaacs/ini/releases) - [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.7) Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 09a6dbdec7..abc2f16058 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7630,9 +7630,9 @@ "dev": true }, "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.7.tgz", + "integrity": "sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==", "dev": true }, "inline-source-map": { From 21bff77ca3388f2326d27c2b5425372c04ad3ea4 Mon Sep 17 00:00:00 2001 From: Sam DeLong Date: Fri, 11 Dec 2020 11:55:09 -0500 Subject: [PATCH 40/97] Changed implementation of setHeading() function for increased performance. (Issue #4767) --- src/math/p5.Vector.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/math/p5.Vector.js b/src/math/p5.Vector.js index eb0bc62887..fc5e69653d 100644 --- a/src/math/p5.Vector.js +++ b/src/math/p5.Vector.js @@ -1459,8 +1459,9 @@ p5.Vector.prototype.heading = function heading() { */ p5.Vector.prototype.setHeading = function setHeading(a) { - this.rotate(-this.heading()); - this.rotate(a); + let m = this.mag(); + this.x = m * Math.cos(a); + this.y = m * Math.sin(a); return this; }; From 579467ddf9735d29c74b267f045b966f2a4dd55a Mon Sep 17 00:00:00 2001 From: Sam DeLong Date: Sat, 12 Dec 2020 18:26:16 -0500 Subject: [PATCH 41/97] Added unit tests --- test/unit/math/p5.Vector.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/unit/math/p5.Vector.js b/test/unit/math/p5.Vector.js index 6431b0f778..0fd38efef2 100644 --- a/test/unit/math/p5.Vector.js +++ b/test/unit/math/p5.Vector.js @@ -18,6 +18,15 @@ suite('p5.Vector', function() { }); var v; + suite('setHeading', function() { + setup(function() { + v = createVector(1,1); + v.setHeading(1); + }); + test('should have heading() value of 0', function(){ + assert.closeTo(v.heading(), 1, 0.001); + }); + }); suite('p5.prototype.createVector()', function() { setup(function() { v = myp5.createVector(); From 73a370f305a5c05927e9a4fe95a2f182d0f73824 Mon Sep 17 00:00:00 2001 From: Sam DeLong Date: Sat, 12 Dec 2020 18:30:53 -0500 Subject: [PATCH 42/97] Fixed lint --- test/unit/math/p5.Vector.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/math/p5.Vector.js b/test/unit/math/p5.Vector.js index 0fd38efef2..2f2d3339f7 100644 --- a/test/unit/math/p5.Vector.js +++ b/test/unit/math/p5.Vector.js @@ -20,10 +20,10 @@ suite('p5.Vector', function() { suite('setHeading', function() { setup(function() { - v = createVector(1,1); + v = myp5.createVector(1, 1); v.setHeading(1); }); - test('should have heading() value of 0', function(){ + test('should have heading() value of 1', function() { assert.closeTo(v.heading(), 1, 0.001); }); }); From a06e537ae90598b11a971cb1baa1a3bfb608ac49 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sun, 13 Dec 2020 15:44:51 +0000 Subject: [PATCH 43/97] docs: update README.md [skip ci] --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 94ff9e0ed0..7ddc3fee52 100644 --- a/README.md +++ b/README.md @@ -455,6 +455,9 @@ We recognize all types of contributions. This project follows the [all-contribut
Arijit Kundu

🐛 💻 📖
Tanner Dolby

💻 + +
sam delong

💻 + From 373439f15b61e0b2141e8e430d1c4554be92a4f7 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sun, 13 Dec 2020 15:44:52 +0000 Subject: [PATCH 44/97] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index a6021c3981..050598348e 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2309,6 +2309,15 @@ "contributions": [ "code" ] + }, + { + "login": "samdelong", + "name": "sam delong", + "avatar_url": "https://avatars0.githubusercontent.com/u/20839292?v=4", + "profile": "https://samdelong.com", + "contributions": [ + "code" + ] } ], "repoType": "github", From 7de450245ba34c68e48e858a583f830186781418 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 06:34:56 +0000 Subject: [PATCH 45/97] docs: update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7ddc3fee52..c5537cdffe 100644 --- a/README.md +++ b/README.md @@ -457,6 +457,7 @@ We recognize all types of contributions. This project follows the [all-contribut
sam delong

💻 +
Zhao Xin

💻 From 03e021d7691e05bae1b7cd6edcc3d4da62177203 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 06:34:57 +0000 Subject: [PATCH 46/97] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 050598348e..09ea9573b8 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2318,6 +2318,15 @@ "contributions": [ "code" ] + }, + { + "login": "archtaurus", + "name": "Zhao Xin", + "avatar_url": "https://avatars0.githubusercontent.com/u/1265068?v=4", + "profile": "https://www.haoohaoo.com", + "contributions": [ + "code" + ] } ], "repoType": "github", From c76770824e679235f2b28bcb4faafe0b3b643238 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 06:35:31 +0000 Subject: [PATCH 47/97] docs: update README.md [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c5537cdffe..5059e5f274 100644 --- a/README.md +++ b/README.md @@ -457,7 +457,7 @@ We recognize all types of contributions. This project follows the [all-contribut
sam delong

💻 -
Zhao Xin

💻 +
Zhao Xin

💻 👀 From 65b4b0eb118278653769ae90abbf5ba3b1be88dc Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 06:35:32 +0000 Subject: [PATCH 48/97] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 09ea9573b8..cbea05c797 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2325,7 +2325,8 @@ "avatar_url": "https://avatars0.githubusercontent.com/u/1265068?v=4", "profile": "https://www.haoohaoo.com", "contributions": [ - "code" + "code", + "review" ] } ], From fa493b0276bafd177c2ec3467b719afb0e7b85cf Mon Sep 17 00:00:00 2001 From: LordLoss Date: Tue, 15 Dec 2020 14:48:29 +0330 Subject: [PATCH 49/97] adjusted value of pointSize when passing to shader to fix issue num #4867 --- src/webgl/p5.RendererGL.js | 131 +++++++++++++++++++------------------ 1 file changed, 67 insertions(+), 64 deletions(-) diff --git a/src/webgl/p5.RendererGL.js b/src/webgl/p5.RendererGL.js index bbe89a842d..b2c533ee33 100755 --- a/src/webgl/p5.RendererGL.js +++ b/src/webgl/p5.RendererGL.js @@ -45,7 +45,7 @@ const defaultShaders = { lineVert: readFileSync(join(__dirname, '/shaders/line.vert'), 'utf-8'), lineFrag: readFileSync(join(__dirname, '/shaders/line.frag'), 'utf-8'), pointVert: readFileSync(join(__dirname, '/shaders/point.vert'), 'utf-8'), - pointFrag: readFileSync(join(__dirname, '/shaders/point.frag'), 'utf-8') + pointFrag: readFileSync(join(__dirname, '/shaders/point.frag'), 'utf-8'), }; /** @@ -57,7 +57,7 @@ const defaultShaders = { * @todo extend class to include public method for offscreen * rendering (FBO). */ -p5.RendererGL = function(elt, pInst, isMainCanvas, attr) { +p5.RendererGL = function (elt, pInst, isMainCanvas, attr) { p5.Renderer.call(this, elt, pInst, isMainCanvas); this._setAttributeDefaults(pInst); this._initContext(); @@ -160,8 +160,8 @@ p5.RendererGL = function(elt, pInst, isMainCanvas, attr) { text: [ new p5.RenderBuffer(3, 'vertices', 'vertexBuffer', 'aPosition',this, this._vToNArray), new p5.RenderBuffer(2, 'uvs', 'uvBuffer', 'aTexCoord', this, this._flatten) - ] - } + ], + }, }; // Immediate Mode @@ -186,8 +186,8 @@ p5.RendererGL = function(elt, pInst, isMainCanvas, attr) { new p5.RenderBuffer(3, 'lineVertices', 'lineVertexBuffer', 'aPosition', this, this._flatten), new p5.RenderBuffer(4, 'lineNormals', 'lineNormalBuffer', 'aDirection', this, this._flatten) ], - point: this.GL.createBuffer() - } + point: this.GL.createBuffer(), + }, }; this.pointSize = 5.0; //default point size @@ -228,7 +228,7 @@ p5.RendererGL.prototype = Object.create(p5.Renderer.prototype); // Setting ////////////////////////////////////////////// -p5.RendererGL.prototype._setAttributeDefaults = function(pInst) { +p5.RendererGL.prototype._setAttributeDefaults = function (pInst) { // See issue #3850, safer to enable AA in Safari const applyAA = navigator.userAgent.toLowerCase().includes('safari'); const defaults = { @@ -238,7 +238,7 @@ p5.RendererGL.prototype._setAttributeDefaults = function(pInst) { antialias: applyAA, premultipliedAlpha: false, preserveDrawingBuffer: true, - perPixelLighting: true + perPixelLighting: true, }; if (pInst._glAttributes === null) { pInst._glAttributes = defaults; @@ -248,7 +248,7 @@ p5.RendererGL.prototype._setAttributeDefaults = function(pInst) { return; }; -p5.RendererGL.prototype._initContext = function() { +p5.RendererGL.prototype._initContext = function () { try { this.drawingContext = this.canvas.getContext('webgl', this._pInst._glAttributes) || @@ -272,7 +272,7 @@ p5.RendererGL.prototype._initContext = function() { //This is helper function to reset the context anytime the attributes //are changed with setAttributes() -p5.RendererGL.prototype._resetContext = function(options, callback) { +p5.RendererGL.prototype._resetContext = function (options, callback) { const w = this.width; const h = this.height; const defaultId = this.canvas.id; @@ -473,7 +473,7 @@ p5.RendererGL.prototype._resetContext = function(options, callback) { * @param {Object} obj object with key-value pairs */ -p5.prototype.setAttributes = function(key, value) { +p5.prototype.setAttributes = function (key, value) { if (typeof this._glAttributes === 'undefined') { console.log( 'You are trying to use setAttributes on a p5.Graphics object ' + @@ -529,7 +529,7 @@ p5.prototype.setAttributes = function(key, value) { * @class p5.RendererGL */ -p5.RendererGL.prototype._update = function() { +p5.RendererGL.prototype._update = function () { // reset model view and apply initial camera transform // (containing only look at info; no projection). this.uMVMatrix.set( @@ -583,7 +583,7 @@ p5.RendererGL.prototype._update = function() { /** * [background description] */ -p5.RendererGL.prototype.background = function(...args) { +p5.RendererGL.prototype.background = function (...args) { const _col = this._pInst.color(...args); const _r = _col.levels[0] / 255; const _g = _col.levels[1] / 255; @@ -629,7 +629,7 @@ p5.RendererGL.prototype.background = function(...args) { * @alt * black canvas with purple cube spinning */ -p5.RendererGL.prototype.fill = function(v1, v2, v3, a) { +p5.RendererGL.prototype.fill = function (v1, v2, v3, a) { //see material.js for more info on color blending in webgl const color = p5.prototype.color.apply(this._pInst, arguments); this.curFillColor = color._array; @@ -668,7 +668,7 @@ p5.RendererGL.prototype.fill = function(v1, v2, v3, a) { * @alt * black canvas with purple cube with pink outline spinning */ -p5.RendererGL.prototype.stroke = function(r, g, b, a) { +p5.RendererGL.prototype.stroke = function (r, g, b, a) { //@todo allow transparency in stroking currently doesn't have //any impact and causes problems with specularMaterial arguments[3] = 255; @@ -676,25 +676,25 @@ p5.RendererGL.prototype.stroke = function(r, g, b, a) { this.curStrokeColor = color._array; }; -p5.RendererGL.prototype.strokeCap = function(cap) { +p5.RendererGL.prototype.strokeCap = function (cap) { // @TODO : to be implemented console.error('Sorry, strokeCap() is not yet implemented in WEBGL mode'); }; -p5.RendererGL.prototype.strokeJoin = function(join) { +p5.RendererGL.prototype.strokeJoin = function (join) { // @TODO : to be implemented // https://processing.org/reference/strokeJoin_.html console.error('Sorry, strokeJoin() is not yet implemented in WEBGL mode'); }; -p5.RendererGL.prototype.filter = function(filterType) { +p5.RendererGL.prototype.filter = function (filterType) { // filter can be achieved using custom shaders. // https://github.com/aferriss/p5jsShaderExamples // https://itp-xstory.github.io/p5js-shaders/#/ console.error('filter() does not work in WEBGL mode'); }; -p5.RendererGL.prototype.blendMode = function(mode) { +p5.RendererGL.prototype.blendMode = function (mode) { if ( mode === constants.DARKEST || mode === constants.LIGHTEST || @@ -721,7 +721,7 @@ p5.RendererGL.prototype.blendMode = function(mode) { } }; -p5.RendererGL.prototype.erase = function(opacityFill, opacityStroke) { +p5.RendererGL.prototype.erase = function (opacityFill, opacityStroke) { if (!this._isErasing) { this._applyBlendMode(constants.REMOVE); this._isErasing = true; @@ -734,7 +734,7 @@ p5.RendererGL.prototype.erase = function(opacityFill, opacityStroke) { } }; -p5.RendererGL.prototype.noErase = function() { +p5.RendererGL.prototype.noErase = function () { if (this._isErasing) { this._isErasing = false; this.curFillColor = this._cachedFillStyle.slice(); @@ -782,7 +782,7 @@ p5.RendererGL.prototype.noErase = function() { * black canvas with two purple rotating spheres with pink * outlines the sphere on top has much heavier outlines, */ -p5.RendererGL.prototype.strokeWeight = function(w) { +p5.RendererGL.prototype.strokeWeight = function (w) { if (this.curStrokeWeight !== w) { this.pointSize = w; this.curStrokeWeight = w; @@ -790,7 +790,7 @@ p5.RendererGL.prototype.strokeWeight = function(w) { }; // x,y are canvas-relative (pre-scaled by _pixelDensity) -p5.RendererGL.prototype._getPixel = function(x, y) { +p5.RendererGL.prototype._getPixel = function (x, y) { let imageData, index; imageData = new Uint8Array(4); // prettier-ignore @@ -804,7 +804,7 @@ p5.RendererGL.prototype._getPixel = function(x, y) { imageData[index + 0], imageData[index + 1], imageData[index + 2], - imageData[index + 3] + imageData[index + 3], ]; }; @@ -817,7 +817,7 @@ p5.RendererGL.prototype._getPixel = function(x, y) { * @method loadPixels */ -p5.RendererGL.prototype.loadPixels = function() { +p5.RendererGL.prototype.loadPixels = function () { const pixelsState = this._pixelsState; //@todo_FES @@ -850,7 +850,7 @@ p5.RendererGL.prototype.loadPixels = function() { // HASH | for geometry ////////////////////////////////////////////// -p5.RendererGL.prototype.geometryInHash = function(gId) { +p5.RendererGL.prototype.geometryInHash = function (gId) { return this.retainedMode.geometry[gId] !== undefined; }; @@ -860,7 +860,7 @@ p5.RendererGL.prototype.geometryInHash = function(gId) { * @param {Number} w [description] * @param {Number} h [description] */ -p5.RendererGL.prototype.resize = function(w, h) { +p5.RendererGL.prototype.resize = function (w, h) { p5.Renderer.prototype.resize.call(this, w, h); this.GL.viewport( 0, @@ -893,7 +893,7 @@ p5.RendererGL.prototype.resize = function(w, h) { * @param {Number} b normalized blue val. * @param {Number} a normalized alpha val. */ -p5.RendererGL.prototype.clear = function(...args) { +p5.RendererGL.prototype.clear = function (...args) { const _r = args[0] || 0; const _g = args[1] || 0; const _b = args[2] || 0; @@ -902,7 +902,7 @@ p5.RendererGL.prototype.clear = function(...args) { this.GL.clear(this.GL.COLOR_BUFFER_BIT | this.GL.DEPTH_BUFFER_BIT); }; -p5.RendererGL.prototype.applyMatrix = function(a, b, c, d, e, f) { +p5.RendererGL.prototype.applyMatrix = function (a, b, c, d, e, f) { if (arguments.length === 16) { p5.Matrix.prototype.apply.apply(this.uMVMatrix, arguments); } else { @@ -925,7 +925,7 @@ p5.RendererGL.prototype.applyMatrix = function(a, b, c, d, e, f) { * @chainable * @todo implement handle for components or vector as args */ -p5.RendererGL.prototype.translate = function(x, y, z) { +p5.RendererGL.prototype.translate = function (x, y, z) { if (x instanceof p5.Vector) { z = x.z; y = x.y; @@ -943,12 +943,12 @@ p5.RendererGL.prototype.translate = function(x, y, z) { * @param {Number} [z] z-axis scalar * @chainable */ -p5.RendererGL.prototype.scale = function(x, y, z) { +p5.RendererGL.prototype.scale = function (x, y, z) { this.uMVMatrix.scale(x, y, z); return this; }; -p5.RendererGL.prototype.rotate = function(rad, axis) { +p5.RendererGL.prototype.rotate = function (rad, axis) { if (typeof axis === 'undefined') { return this.rotateZ(rad); } @@ -956,22 +956,22 @@ p5.RendererGL.prototype.rotate = function(rad, axis) { return this; }; -p5.RendererGL.prototype.rotateX = function(rad) { +p5.RendererGL.prototype.rotateX = function (rad) { this.rotate(rad, 1, 0, 0); return this; }; -p5.RendererGL.prototype.rotateY = function(rad) { +p5.RendererGL.prototype.rotateY = function (rad) { this.rotate(rad, 0, 1, 0); return this; }; -p5.RendererGL.prototype.rotateZ = function(rad) { +p5.RendererGL.prototype.rotateZ = function (rad) { this.rotate(rad, 0, 0, 1); return this; }; -p5.RendererGL.prototype.push = function() { +p5.RendererGL.prototype.push = function () { // get the base renderer style const style = p5.Renderer.prototype.push.apply(this); @@ -1029,7 +1029,7 @@ p5.RendererGL.prototype.push = function() { return style; }; -p5.RendererGL.prototype.resetMatrix = function() { +p5.RendererGL.prototype.resetMatrix = function () { this.uMVMatrix = p5.Matrix.identity(this._pInst); return this; }; @@ -1044,7 +1044,7 @@ p5.RendererGL.prototype.resetMatrix = function() { * and the shader must be valid in that context. */ -p5.RendererGL.prototype._getImmediateStrokeShader = function() { +p5.RendererGL.prototype._getImmediateStrokeShader = function () { // select the stroke shader to use const stroke = this.userStrokeShader; if (!stroke || !stroke.isStrokeShader()) { @@ -1060,7 +1060,7 @@ p5.RendererGL.prototype._getRetainedStrokeShader = * selects which fill shader should be used based on renderer state, * for use with begin/endShape and immediate vertex mode. */ -p5.RendererGL.prototype._getImmediateFillShader = function() { +p5.RendererGL.prototype._getImmediateFillShader = function () { const fill = this.userFillShader; if (this._useNormalMaterial) { if (!fill || !fill.isNormalShader()) { @@ -1085,7 +1085,7 @@ p5.RendererGL.prototype._getImmediateFillShader = function() { * selects which fill shader should be used based on renderer state * for retained mode. */ -p5.RendererGL.prototype._getRetainedFillShader = function() { +p5.RendererGL.prototype._getRetainedFillShader = function () { if (this._useNormalMaterial) { return this._getNormalShader(); } @@ -1105,7 +1105,7 @@ p5.RendererGL.prototype._getRetainedFillShader = function() { return fill; }; -p5.RendererGL.prototype._getImmediatePointShader = function() { +p5.RendererGL.prototype._getImmediatePointShader = function () { // select the point shader to use const point = this.userPointShader; if (!point || !point.isPointShader()) { @@ -1117,7 +1117,7 @@ p5.RendererGL.prototype._getImmediatePointShader = function() { p5.RendererGL.prototype._getRetainedLineShader = p5.RendererGL.prototype._getImmediateLineShader; -p5.RendererGL.prototype._getLightShader = function() { +p5.RendererGL.prototype._getLightShader = function () { if (!this._defaultLightShader) { if (this._pInst._glAttributes.perPixelLighting) { this._defaultLightShader = new p5.Shader( @@ -1137,7 +1137,7 @@ p5.RendererGL.prototype._getLightShader = function() { return this._defaultLightShader; }; -p5.RendererGL.prototype._getImmediateModeShader = function() { +p5.RendererGL.prototype._getImmediateModeShader = function () { if (!this._defaultImmediateModeShader) { this._defaultImmediateModeShader = new p5.Shader( this, @@ -1149,7 +1149,7 @@ p5.RendererGL.prototype._getImmediateModeShader = function() { return this._defaultImmediateModeShader; }; -p5.RendererGL.prototype._getNormalShader = function() { +p5.RendererGL.prototype._getNormalShader = function () { if (!this._defaultNormalShader) { this._defaultNormalShader = new p5.Shader( this, @@ -1161,7 +1161,7 @@ p5.RendererGL.prototype._getNormalShader = function() { return this._defaultNormalShader; }; -p5.RendererGL.prototype._getColorShader = function() { +p5.RendererGL.prototype._getColorShader = function () { if (!this._defaultColorShader) { this._defaultColorShader = new p5.Shader( this, @@ -1173,7 +1173,7 @@ p5.RendererGL.prototype._getColorShader = function() { return this._defaultColorShader; }; -p5.RendererGL.prototype._getPointShader = function() { +p5.RendererGL.prototype._getPointShader = function () { if (!this._defaultPointShader) { this._defaultPointShader = new p5.Shader( this, @@ -1184,7 +1184,7 @@ p5.RendererGL.prototype._getPointShader = function() { return this._defaultPointShader; }; -p5.RendererGL.prototype._getLineShader = function() { +p5.RendererGL.prototype._getLineShader = function () { if (!this._defaultLineShader) { this._defaultLineShader = new p5.Shader( this, @@ -1196,7 +1196,7 @@ p5.RendererGL.prototype._getLineShader = function() { return this._defaultLineShader; }; -p5.RendererGL.prototype._getFontShader = function() { +p5.RendererGL.prototype._getFontShader = function () { if (!this._defaultFontShader) { this.GL.getExtension('OES_standard_derivatives'); this._defaultFontShader = new p5.Shader( @@ -1208,7 +1208,7 @@ p5.RendererGL.prototype._getFontShader = function() { return this._defaultFontShader; }; -p5.RendererGL.prototype._getEmptyTexture = function() { +p5.RendererGL.prototype._getEmptyTexture = function () { if (!this._emptyTexture) { // a plain white texture RGBA, full alpha, single pixel. const im = new p5.Image(1, 1); @@ -1218,7 +1218,7 @@ p5.RendererGL.prototype._getEmptyTexture = function() { return this._emptyTexture; }; -p5.RendererGL.prototype.getTexture = function(img) { +p5.RendererGL.prototype.getTexture = function (img) { const textures = this.textures; for (const texture of textures) { @@ -1230,7 +1230,7 @@ p5.RendererGL.prototype.getTexture = function(img) { return tex; }; -p5.RendererGL.prototype._setStrokeUniforms = function(strokeShader) { +p5.RendererGL.prototype._setStrokeUniforms = function (strokeShader) { strokeShader.bindShader(); // set the uniform values @@ -1238,7 +1238,7 @@ p5.RendererGL.prototype._setStrokeUniforms = function(strokeShader) { strokeShader.setUniform('uStrokeWeight', this.curStrokeWeight); }; -p5.RendererGL.prototype._setFillUniforms = function(fillShader) { +p5.RendererGL.prototype._setFillUniforms = function (fillShader) { fillShader.bindShader(); // TODO: optimize @@ -1303,21 +1303,24 @@ p5.RendererGL.prototype._setFillUniforms = function(fillShader) { fillShader.bindTextures(); }; -p5.RendererGL.prototype._setPointUniforms = function(pointShader) { +p5.RendererGL.prototype._setPointUniforms = function (pointShader) { pointShader.bindShader(); // set the uniform values pointShader.setUniform('uMaterialColor', this.curStrokeColor); // @todo is there an instance where this isn't stroke weight? // should be they be same var? - pointShader.setUniform('uPointSize', this.pointSize); + pointShader.setUniform( + 'uPointSize', + this.pointSize * this._pInst._pixelDensity + ); }; /* Binds a buffer to the drawing context * when passed more than two arguments it also updates or initializes * the data associated with the buffer */ -p5.RendererGL.prototype._bindBuffer = function( +p5.RendererGL.prototype._bindBuffer = function ( buffer, target, values, @@ -1335,7 +1338,7 @@ p5.RendererGL.prototype._bindBuffer = function( /////////////////////////////// //// UTILITY FUNCTIONS ////////////////////////////// -p5.RendererGL.prototype._arraysEqual = function(a, b) { +p5.RendererGL.prototype._arraysEqual = function (a, b) { const aLength = a.length; if (aLength !== b.length) return false; for (let i = 0; i < aLength; i++) { @@ -1344,7 +1347,7 @@ p5.RendererGL.prototype._arraysEqual = function(a, b) { return true; }; -p5.RendererGL.prototype._isTypedArray = function(arr) { +p5.RendererGL.prototype._isTypedArray = function (arr) { let res = false; res = arr instanceof Float32Array; res = arr instanceof Float64Array; @@ -1360,7 +1363,7 @@ p5.RendererGL.prototype._isTypedArray = function(arr) { * @return {Array} 1-dimensional array * [[1, 2, 3],[4, 5, 6]] -> [1, 2, 3, 4, 5, 6] */ -p5.RendererGL.prototype._flatten = function(arr) { +p5.RendererGL.prototype._flatten = function (arr) { //when empty, return empty if (arr.length === 0) { return []; @@ -1398,7 +1401,7 @@ p5.RendererGL.prototype._flatten = function(arr) { * [p5.Vector(1, 2, 3), p5.Vector(4, 5, 6)] -> * [1, 2, 3, 4, 5, 6] */ -p5.RendererGL.prototype._vToNArray = function(arr) { +p5.RendererGL.prototype._vToNArray = function (arr) { const ret = []; for (const item of arr) { @@ -1411,7 +1414,7 @@ p5.RendererGL.prototype._vToNArray = function(arr) { /** * ensures that p5 is using a 3d renderer. throws an error if not. */ -p5.prototype._assert3d = function(name) { +p5.prototype._assert3d = function (name) { if (!this._renderer.isP3D) throw new Error( `${name}() is only supported in WEBGL mode. If you'd like to use 3D graphics and WebGL, see https://p5js.org/examples/form-3d-primitives.html for more information.` @@ -1457,7 +1460,7 @@ p5.RendererGL.prototype._initTessy = function initTesselator() { return tessy; }; -p5.RendererGL.prototype._triangulate = function(contours) { +p5.RendererGL.prototype._triangulate = function (contours) { // libtess will take 3d verts and flatten to a plane for tesselation // since only doing 2d tesselation here, provide z=1 normal to skip // iterating over verts only to get the same answer. @@ -1484,7 +1487,7 @@ p5.RendererGL.prototype._triangulate = function(contours) { }; // function to calculate BezierVertex Coefficients -p5.RendererGL.prototype._bezierCoefficients = function(t) { +p5.RendererGL.prototype._bezierCoefficients = function (t) { const t2 = t * t; const t3 = t2 * t; const mt = 1 - t; @@ -1494,7 +1497,7 @@ p5.RendererGL.prototype._bezierCoefficients = function(t) { }; // function to calculate QuadraticVertex Coefficients -p5.RendererGL.prototype._quadraticCoefficients = function(t) { +p5.RendererGL.prototype._quadraticCoefficients = function (t) { const t2 = t * t; const mt = 1 - t; const mt2 = mt * mt; @@ -1502,7 +1505,7 @@ p5.RendererGL.prototype._quadraticCoefficients = function(t) { }; // function to convert Bezier coordinates to Catmull Rom Splines -p5.RendererGL.prototype._bezierToCatmull = function(w) { +p5.RendererGL.prototype._bezierToCatmull = function (w) { const p1 = w[1]; const p2 = w[1] + (w[2] - w[0]) / this._curveTightness; const p3 = w[2] - (w[3] - w[1]) / this._curveTightness; From 7da1cc22f38d6a10afc9b895156f7f719a9c9854 Mon Sep 17 00:00:00 2001 From: kkvanonymous Date: Sat, 19 Dec 2020 12:35:39 +0530 Subject: [PATCH 50/97] Fix 'this.elt.srcObject is null' error --- src/dom/dom.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index ae8d2bbba2..61c2a6cc01 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -2173,10 +2173,14 @@ p5.Element.prototype.remove = function() { // stop all audios/videos and detach all devices like microphone/camera etc // used as input/output for audios/videos. if (this instanceof p5.MediaElement) { - const tracks = this.elt.srcObject.getTracks(); - tracks.forEach(function(track) { - track.stop(); - }); + this.stop(); + let sources = this.elt.srcObject; + if (sources !== null) { + let tracks = sources.getTracks(); + tracks.forEach(track => { + track.stop(); + }); + } } // delete the reference in this._pInst._elements From 7eb8ef32220f45f050f036ec81e25b8aab34db16 Mon Sep 17 00:00:00 2001 From: LordLoss Date: Sat, 19 Dec 2020 19:49:21 +0330 Subject: [PATCH 51/97] fixed linting --- src/webgl/p5.RendererGL.js | 131 ++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 67 deletions(-) diff --git a/src/webgl/p5.RendererGL.js b/src/webgl/p5.RendererGL.js index b2c533ee33..1652e5fce2 100755 --- a/src/webgl/p5.RendererGL.js +++ b/src/webgl/p5.RendererGL.js @@ -45,7 +45,7 @@ const defaultShaders = { lineVert: readFileSync(join(__dirname, '/shaders/line.vert'), 'utf-8'), lineFrag: readFileSync(join(__dirname, '/shaders/line.frag'), 'utf-8'), pointVert: readFileSync(join(__dirname, '/shaders/point.vert'), 'utf-8'), - pointFrag: readFileSync(join(__dirname, '/shaders/point.frag'), 'utf-8'), + pointFrag: readFileSync(join(__dirname, '/shaders/point.frag'), 'utf-8') }; /** @@ -57,7 +57,7 @@ const defaultShaders = { * @todo extend class to include public method for offscreen * rendering (FBO). */ -p5.RendererGL = function (elt, pInst, isMainCanvas, attr) { +p5.RendererGL = function(elt, pInst, isMainCanvas, attr) { p5.Renderer.call(this, elt, pInst, isMainCanvas); this._setAttributeDefaults(pInst); this._initContext(); @@ -160,8 +160,8 @@ p5.RendererGL = function (elt, pInst, isMainCanvas, attr) { text: [ new p5.RenderBuffer(3, 'vertices', 'vertexBuffer', 'aPosition',this, this._vToNArray), new p5.RenderBuffer(2, 'uvs', 'uvBuffer', 'aTexCoord', this, this._flatten) - ], - }, + ] + } }; // Immediate Mode @@ -186,8 +186,8 @@ p5.RendererGL = function (elt, pInst, isMainCanvas, attr) { new p5.RenderBuffer(3, 'lineVertices', 'lineVertexBuffer', 'aPosition', this, this._flatten), new p5.RenderBuffer(4, 'lineNormals', 'lineNormalBuffer', 'aDirection', this, this._flatten) ], - point: this.GL.createBuffer(), - }, + point: this.GL.createBuffer() + } }; this.pointSize = 5.0; //default point size @@ -228,7 +228,7 @@ p5.RendererGL.prototype = Object.create(p5.Renderer.prototype); // Setting ////////////////////////////////////////////// -p5.RendererGL.prototype._setAttributeDefaults = function (pInst) { +p5.RendererGL.prototype._setAttributeDefaults = function(pInst) { // See issue #3850, safer to enable AA in Safari const applyAA = navigator.userAgent.toLowerCase().includes('safari'); const defaults = { @@ -238,7 +238,7 @@ p5.RendererGL.prototype._setAttributeDefaults = function (pInst) { antialias: applyAA, premultipliedAlpha: false, preserveDrawingBuffer: true, - perPixelLighting: true, + perPixelLighting: true }; if (pInst._glAttributes === null) { pInst._glAttributes = defaults; @@ -248,7 +248,7 @@ p5.RendererGL.prototype._setAttributeDefaults = function (pInst) { return; }; -p5.RendererGL.prototype._initContext = function () { +p5.RendererGL.prototype._initContext = function() { try { this.drawingContext = this.canvas.getContext('webgl', this._pInst._glAttributes) || @@ -272,7 +272,7 @@ p5.RendererGL.prototype._initContext = function () { //This is helper function to reset the context anytime the attributes //are changed with setAttributes() -p5.RendererGL.prototype._resetContext = function (options, callback) { +p5.RendererGL.prototype._resetContext = function(options, callback) { const w = this.width; const h = this.height; const defaultId = this.canvas.id; @@ -473,7 +473,7 @@ p5.RendererGL.prototype._resetContext = function (options, callback) { * @param {Object} obj object with key-value pairs */ -p5.prototype.setAttributes = function (key, value) { +p5.prototype.setAttributes = function(key, value) { if (typeof this._glAttributes === 'undefined') { console.log( 'You are trying to use setAttributes on a p5.Graphics object ' + @@ -529,7 +529,7 @@ p5.prototype.setAttributes = function (key, value) { * @class p5.RendererGL */ -p5.RendererGL.prototype._update = function () { +p5.RendererGL.prototype._update = function() { // reset model view and apply initial camera transform // (containing only look at info; no projection). this.uMVMatrix.set( @@ -583,7 +583,7 @@ p5.RendererGL.prototype._update = function () { /** * [background description] */ -p5.RendererGL.prototype.background = function (...args) { +p5.RendererGL.prototype.background = function(...args) { const _col = this._pInst.color(...args); const _r = _col.levels[0] / 255; const _g = _col.levels[1] / 255; @@ -629,7 +629,7 @@ p5.RendererGL.prototype.background = function (...args) { * @alt * black canvas with purple cube spinning */ -p5.RendererGL.prototype.fill = function (v1, v2, v3, a) { +p5.RendererGL.prototype.fill = function(v1, v2, v3, a) { //see material.js for more info on color blending in webgl const color = p5.prototype.color.apply(this._pInst, arguments); this.curFillColor = color._array; @@ -668,7 +668,7 @@ p5.RendererGL.prototype.fill = function (v1, v2, v3, a) { * @alt * black canvas with purple cube with pink outline spinning */ -p5.RendererGL.prototype.stroke = function (r, g, b, a) { +p5.RendererGL.prototype.stroke = function(r, g, b, a) { //@todo allow transparency in stroking currently doesn't have //any impact and causes problems with specularMaterial arguments[3] = 255; @@ -676,25 +676,25 @@ p5.RendererGL.prototype.stroke = function (r, g, b, a) { this.curStrokeColor = color._array; }; -p5.RendererGL.prototype.strokeCap = function (cap) { +p5.RendererGL.prototype.strokeCap = function(cap) { // @TODO : to be implemented console.error('Sorry, strokeCap() is not yet implemented in WEBGL mode'); }; -p5.RendererGL.prototype.strokeJoin = function (join) { +p5.RendererGL.prototype.strokeJoin = function(join) { // @TODO : to be implemented // https://processing.org/reference/strokeJoin_.html console.error('Sorry, strokeJoin() is not yet implemented in WEBGL mode'); }; -p5.RendererGL.prototype.filter = function (filterType) { +p5.RendererGL.prototype.filter = function(filterType) { // filter can be achieved using custom shaders. // https://github.com/aferriss/p5jsShaderExamples // https://itp-xstory.github.io/p5js-shaders/#/ console.error('filter() does not work in WEBGL mode'); }; -p5.RendererGL.prototype.blendMode = function (mode) { +p5.RendererGL.prototype.blendMode = function(mode) { if ( mode === constants.DARKEST || mode === constants.LIGHTEST || @@ -721,7 +721,7 @@ p5.RendererGL.prototype.blendMode = function (mode) { } }; -p5.RendererGL.prototype.erase = function (opacityFill, opacityStroke) { +p5.RendererGL.prototype.erase = function(opacityFill, opacityStroke) { if (!this._isErasing) { this._applyBlendMode(constants.REMOVE); this._isErasing = true; @@ -734,7 +734,7 @@ p5.RendererGL.prototype.erase = function (opacityFill, opacityStroke) { } }; -p5.RendererGL.prototype.noErase = function () { +p5.RendererGL.prototype.noErase = function() { if (this._isErasing) { this._isErasing = false; this.curFillColor = this._cachedFillStyle.slice(); @@ -782,7 +782,7 @@ p5.RendererGL.prototype.noErase = function () { * black canvas with two purple rotating spheres with pink * outlines the sphere on top has much heavier outlines, */ -p5.RendererGL.prototype.strokeWeight = function (w) { +p5.RendererGL.prototype.strokeWeight = function(w) { if (this.curStrokeWeight !== w) { this.pointSize = w; this.curStrokeWeight = w; @@ -790,7 +790,7 @@ p5.RendererGL.prototype.strokeWeight = function (w) { }; // x,y are canvas-relative (pre-scaled by _pixelDensity) -p5.RendererGL.prototype._getPixel = function (x, y) { +p5.RendererGL.prototype._getPixel = function(x, y) { let imageData, index; imageData = new Uint8Array(4); // prettier-ignore @@ -804,7 +804,7 @@ p5.RendererGL.prototype._getPixel = function (x, y) { imageData[index + 0], imageData[index + 1], imageData[index + 2], - imageData[index + 3], + imageData[index + 3] ]; }; @@ -817,7 +817,7 @@ p5.RendererGL.prototype._getPixel = function (x, y) { * @method loadPixels */ -p5.RendererGL.prototype.loadPixels = function () { +p5.RendererGL.prototype.loadPixels = function() { const pixelsState = this._pixelsState; //@todo_FES @@ -850,7 +850,7 @@ p5.RendererGL.prototype.loadPixels = function () { // HASH | for geometry ////////////////////////////////////////////// -p5.RendererGL.prototype.geometryInHash = function (gId) { +p5.RendererGL.prototype.geometryInHash = function(gId) { return this.retainedMode.geometry[gId] !== undefined; }; @@ -860,7 +860,7 @@ p5.RendererGL.prototype.geometryInHash = function (gId) { * @param {Number} w [description] * @param {Number} h [description] */ -p5.RendererGL.prototype.resize = function (w, h) { +p5.RendererGL.prototype.resize = function(w, h) { p5.Renderer.prototype.resize.call(this, w, h); this.GL.viewport( 0, @@ -893,7 +893,7 @@ p5.RendererGL.prototype.resize = function (w, h) { * @param {Number} b normalized blue val. * @param {Number} a normalized alpha val. */ -p5.RendererGL.prototype.clear = function (...args) { +p5.RendererGL.prototype.clear = function(...args) { const _r = args[0] || 0; const _g = args[1] || 0; const _b = args[2] || 0; @@ -902,7 +902,7 @@ p5.RendererGL.prototype.clear = function (...args) { this.GL.clear(this.GL.COLOR_BUFFER_BIT | this.GL.DEPTH_BUFFER_BIT); }; -p5.RendererGL.prototype.applyMatrix = function (a, b, c, d, e, f) { +p5.RendererGL.prototype.applyMatrix = function(a, b, c, d, e, f) { if (arguments.length === 16) { p5.Matrix.prototype.apply.apply(this.uMVMatrix, arguments); } else { @@ -925,7 +925,7 @@ p5.RendererGL.prototype.applyMatrix = function (a, b, c, d, e, f) { * @chainable * @todo implement handle for components or vector as args */ -p5.RendererGL.prototype.translate = function (x, y, z) { +p5.RendererGL.prototype.translate = function(x, y, z) { if (x instanceof p5.Vector) { z = x.z; y = x.y; @@ -943,12 +943,12 @@ p5.RendererGL.prototype.translate = function (x, y, z) { * @param {Number} [z] z-axis scalar * @chainable */ -p5.RendererGL.prototype.scale = function (x, y, z) { +p5.RendererGL.prototype.scale = function(x, y, z) { this.uMVMatrix.scale(x, y, z); return this; }; -p5.RendererGL.prototype.rotate = function (rad, axis) { +p5.RendererGL.prototype.rotate = function(rad, axis) { if (typeof axis === 'undefined') { return this.rotateZ(rad); } @@ -956,22 +956,22 @@ p5.RendererGL.prototype.rotate = function (rad, axis) { return this; }; -p5.RendererGL.prototype.rotateX = function (rad) { +p5.RendererGL.prototype.rotateX = function(rad) { this.rotate(rad, 1, 0, 0); return this; }; -p5.RendererGL.prototype.rotateY = function (rad) { +p5.RendererGL.prototype.rotateY = function(rad) { this.rotate(rad, 0, 1, 0); return this; }; -p5.RendererGL.prototype.rotateZ = function (rad) { +p5.RendererGL.prototype.rotateZ = function(rad) { this.rotate(rad, 0, 0, 1); return this; }; -p5.RendererGL.prototype.push = function () { +p5.RendererGL.prototype.push = function() { // get the base renderer style const style = p5.Renderer.prototype.push.apply(this); @@ -1029,7 +1029,7 @@ p5.RendererGL.prototype.push = function () { return style; }; -p5.RendererGL.prototype.resetMatrix = function () { +p5.RendererGL.prototype.resetMatrix = function() { this.uMVMatrix = p5.Matrix.identity(this._pInst); return this; }; @@ -1044,7 +1044,7 @@ p5.RendererGL.prototype.resetMatrix = function () { * and the shader must be valid in that context. */ -p5.RendererGL.prototype._getImmediateStrokeShader = function () { +p5.RendererGL.prototype._getImmediateStrokeShader = function() { // select the stroke shader to use const stroke = this.userStrokeShader; if (!stroke || !stroke.isStrokeShader()) { @@ -1060,7 +1060,7 @@ p5.RendererGL.prototype._getRetainedStrokeShader = * selects which fill shader should be used based on renderer state, * for use with begin/endShape and immediate vertex mode. */ -p5.RendererGL.prototype._getImmediateFillShader = function () { +p5.RendererGL.prototype._getImmediateFillShader = function() { const fill = this.userFillShader; if (this._useNormalMaterial) { if (!fill || !fill.isNormalShader()) { @@ -1085,7 +1085,7 @@ p5.RendererGL.prototype._getImmediateFillShader = function () { * selects which fill shader should be used based on renderer state * for retained mode. */ -p5.RendererGL.prototype._getRetainedFillShader = function () { +p5.RendererGL.prototype._getRetainedFillShader = function() { if (this._useNormalMaterial) { return this._getNormalShader(); } @@ -1105,7 +1105,7 @@ p5.RendererGL.prototype._getRetainedFillShader = function () { return fill; }; -p5.RendererGL.prototype._getImmediatePointShader = function () { +p5.RendererGL.prototype._getImmediatePointShader = function() { // select the point shader to use const point = this.userPointShader; if (!point || !point.isPointShader()) { @@ -1117,7 +1117,7 @@ p5.RendererGL.prototype._getImmediatePointShader = function () { p5.RendererGL.prototype._getRetainedLineShader = p5.RendererGL.prototype._getImmediateLineShader; -p5.RendererGL.prototype._getLightShader = function () { +p5.RendererGL.prototype._getLightShader = function() { if (!this._defaultLightShader) { if (this._pInst._glAttributes.perPixelLighting) { this._defaultLightShader = new p5.Shader( @@ -1137,7 +1137,7 @@ p5.RendererGL.prototype._getLightShader = function () { return this._defaultLightShader; }; -p5.RendererGL.prototype._getImmediateModeShader = function () { +p5.RendererGL.prototype._getImmediateModeShader = function() { if (!this._defaultImmediateModeShader) { this._defaultImmediateModeShader = new p5.Shader( this, @@ -1149,7 +1149,7 @@ p5.RendererGL.prototype._getImmediateModeShader = function () { return this._defaultImmediateModeShader; }; -p5.RendererGL.prototype._getNormalShader = function () { +p5.RendererGL.prototype._getNormalShader = function() { if (!this._defaultNormalShader) { this._defaultNormalShader = new p5.Shader( this, @@ -1161,7 +1161,7 @@ p5.RendererGL.prototype._getNormalShader = function () { return this._defaultNormalShader; }; -p5.RendererGL.prototype._getColorShader = function () { +p5.RendererGL.prototype._getColorShader = function() { if (!this._defaultColorShader) { this._defaultColorShader = new p5.Shader( this, @@ -1173,7 +1173,7 @@ p5.RendererGL.prototype._getColorShader = function () { return this._defaultColorShader; }; -p5.RendererGL.prototype._getPointShader = function () { +p5.RendererGL.prototype._getPointShader = function() { if (!this._defaultPointShader) { this._defaultPointShader = new p5.Shader( this, @@ -1184,7 +1184,7 @@ p5.RendererGL.prototype._getPointShader = function () { return this._defaultPointShader; }; -p5.RendererGL.prototype._getLineShader = function () { +p5.RendererGL.prototype._getLineShader = function() { if (!this._defaultLineShader) { this._defaultLineShader = new p5.Shader( this, @@ -1196,7 +1196,7 @@ p5.RendererGL.prototype._getLineShader = function () { return this._defaultLineShader; }; -p5.RendererGL.prototype._getFontShader = function () { +p5.RendererGL.prototype._getFontShader = function() { if (!this._defaultFontShader) { this.GL.getExtension('OES_standard_derivatives'); this._defaultFontShader = new p5.Shader( @@ -1208,7 +1208,7 @@ p5.RendererGL.prototype._getFontShader = function () { return this._defaultFontShader; }; -p5.RendererGL.prototype._getEmptyTexture = function () { +p5.RendererGL.prototype._getEmptyTexture = function() { if (!this._emptyTexture) { // a plain white texture RGBA, full alpha, single pixel. const im = new p5.Image(1, 1); @@ -1218,7 +1218,7 @@ p5.RendererGL.prototype._getEmptyTexture = function () { return this._emptyTexture; }; -p5.RendererGL.prototype.getTexture = function (img) { +p5.RendererGL.prototype.getTexture = function(img) { const textures = this.textures; for (const texture of textures) { @@ -1230,7 +1230,7 @@ p5.RendererGL.prototype.getTexture = function (img) { return tex; }; -p5.RendererGL.prototype._setStrokeUniforms = function (strokeShader) { +p5.RendererGL.prototype._setStrokeUniforms = function(strokeShader) { strokeShader.bindShader(); // set the uniform values @@ -1238,7 +1238,7 @@ p5.RendererGL.prototype._setStrokeUniforms = function (strokeShader) { strokeShader.setUniform('uStrokeWeight', this.curStrokeWeight); }; -p5.RendererGL.prototype._setFillUniforms = function (fillShader) { +p5.RendererGL.prototype._setFillUniforms = function(fillShader) { fillShader.bindShader(); // TODO: optimize @@ -1303,24 +1303,21 @@ p5.RendererGL.prototype._setFillUniforms = function (fillShader) { fillShader.bindTextures(); }; -p5.RendererGL.prototype._setPointUniforms = function (pointShader) { +p5.RendererGL.prototype._setPointUniforms = function(pointShader) { pointShader.bindShader(); // set the uniform values pointShader.setUniform('uMaterialColor', this.curStrokeColor); // @todo is there an instance where this isn't stroke weight? // should be they be same var? - pointShader.setUniform( - 'uPointSize', - this.pointSize * this._pInst._pixelDensity - ); + pointShader.setUniform('uPointSize', this.pointSize * this._pInst._pixelDensity); }; /* Binds a buffer to the drawing context * when passed more than two arguments it also updates or initializes * the data associated with the buffer */ -p5.RendererGL.prototype._bindBuffer = function ( +p5.RendererGL.prototype._bindBuffer = function( buffer, target, values, @@ -1338,7 +1335,7 @@ p5.RendererGL.prototype._bindBuffer = function ( /////////////////////////////// //// UTILITY FUNCTIONS ////////////////////////////// -p5.RendererGL.prototype._arraysEqual = function (a, b) { +p5.RendererGL.prototype._arraysEqual = function(a, b) { const aLength = a.length; if (aLength !== b.length) return false; for (let i = 0; i < aLength; i++) { @@ -1347,7 +1344,7 @@ p5.RendererGL.prototype._arraysEqual = function (a, b) { return true; }; -p5.RendererGL.prototype._isTypedArray = function (arr) { +p5.RendererGL.prototype._isTypedArray = function(arr) { let res = false; res = arr instanceof Float32Array; res = arr instanceof Float64Array; @@ -1363,7 +1360,7 @@ p5.RendererGL.prototype._isTypedArray = function (arr) { * @return {Array} 1-dimensional array * [[1, 2, 3],[4, 5, 6]] -> [1, 2, 3, 4, 5, 6] */ -p5.RendererGL.prototype._flatten = function (arr) { +p5.RendererGL.prototype._flatten = function(arr) { //when empty, return empty if (arr.length === 0) { return []; @@ -1401,7 +1398,7 @@ p5.RendererGL.prototype._flatten = function (arr) { * [p5.Vector(1, 2, 3), p5.Vector(4, 5, 6)] -> * [1, 2, 3, 4, 5, 6] */ -p5.RendererGL.prototype._vToNArray = function (arr) { +p5.RendererGL.prototype._vToNArray = function(arr) { const ret = []; for (const item of arr) { @@ -1414,7 +1411,7 @@ p5.RendererGL.prototype._vToNArray = function (arr) { /** * ensures that p5 is using a 3d renderer. throws an error if not. */ -p5.prototype._assert3d = function (name) { +p5.prototype._assert3d = function(name) { if (!this._renderer.isP3D) throw new Error( `${name}() is only supported in WEBGL mode. If you'd like to use 3D graphics and WebGL, see https://p5js.org/examples/form-3d-primitives.html for more information.` @@ -1460,7 +1457,7 @@ p5.RendererGL.prototype._initTessy = function initTesselator() { return tessy; }; -p5.RendererGL.prototype._triangulate = function (contours) { +p5.RendererGL.prototype._triangulate = function(contours) { // libtess will take 3d verts and flatten to a plane for tesselation // since only doing 2d tesselation here, provide z=1 normal to skip // iterating over verts only to get the same answer. @@ -1487,7 +1484,7 @@ p5.RendererGL.prototype._triangulate = function (contours) { }; // function to calculate BezierVertex Coefficients -p5.RendererGL.prototype._bezierCoefficients = function (t) { +p5.RendererGL.prototype._bezierCoefficients = function(t) { const t2 = t * t; const t3 = t2 * t; const mt = 1 - t; @@ -1497,7 +1494,7 @@ p5.RendererGL.prototype._bezierCoefficients = function (t) { }; // function to calculate QuadraticVertex Coefficients -p5.RendererGL.prototype._quadraticCoefficients = function (t) { +p5.RendererGL.prototype._quadraticCoefficients = function(t) { const t2 = t * t; const mt = 1 - t; const mt2 = mt * mt; @@ -1505,7 +1502,7 @@ p5.RendererGL.prototype._quadraticCoefficients = function (t) { }; // function to convert Bezier coordinates to Catmull Rom Splines -p5.RendererGL.prototype._bezierToCatmull = function (w) { +p5.RendererGL.prototype._bezierToCatmull = function(w) { const p1 = w[1]; const p2 = w[1] + (w[2] - w[0]) / this._curveTightness; const p3 = w[2] - (w[3] - w[1]) / this._curveTightness; From 59f8426500630d546c3f21a71d24c26b5109e5b4 Mon Sep 17 00:00:00 2001 From: LordLoss Date: Sat, 19 Dec 2020 20:02:12 +0330 Subject: [PATCH 52/97] fixed linting again --- src/webgl/p5.RendererGL.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/webgl/p5.RendererGL.js b/src/webgl/p5.RendererGL.js index 1652e5fce2..c0fdc2b9ba 100755 --- a/src/webgl/p5.RendererGL.js +++ b/src/webgl/p5.RendererGL.js @@ -1310,7 +1310,10 @@ p5.RendererGL.prototype._setPointUniforms = function(pointShader) { pointShader.setUniform('uMaterialColor', this.curStrokeColor); // @todo is there an instance where this isn't stroke weight? // should be they be same var? - pointShader.setUniform('uPointSize', this.pointSize * this._pInst._pixelDensity); + pointShader.setUniform( + 'uPointSize', + this.pointSize * this._pInst._pixelDensity + ); }; /* Binds a buffer to the drawing context From b20d0f8e29e17a6ab440bbc4d225e645eccd8584 Mon Sep 17 00:00:00 2001 From: kkvanonymous Date: Sun, 20 Dec 2020 09:55:29 +0530 Subject: [PATCH 53/97] Implement requested changes --- src/dom/dom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index 61c2a6cc01..c8e73b6b3f 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -2174,9 +2174,9 @@ p5.Element.prototype.remove = function() { // used as input/output for audios/videos. if (this instanceof p5.MediaElement) { this.stop(); - let sources = this.elt.srcObject; + const sources = this.elt.srcObject; if (sources !== null) { - let tracks = sources.getTracks(); + const tracks = sources.getTracks(); tracks.forEach(track => { track.stop(); }); From b191434378d4df530e039f2149acff6179ee452c Mon Sep 17 00:00:00 2001 From: Lauren McCarthy Date: Sat, 19 Dec 2020 23:15:47 -0800 Subject: [PATCH 54/97] fixing createRadio example to clarify labels and values closes #4948 --- src/dom/dom.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index c8e73b6b3f..90a4a03720 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -781,9 +781,9 @@ p5.prototype.createSelect = function() { * * function setup() { * radio = createRadio(); - * radio.option('apple', 1); - * radio.option('bread', 2); - * radio.option('juice', 3); + * radio.option(1, 'apple'); + * radio.option(2, 'bread'); + * radio.option(3, 'juice'); * radio.style('width', '30px'); * textAlign(CENTER); * } From 94e99fde3041a7e0a920795e271f31294b4ca432 Mon Sep 17 00:00:00 2001 From: limzykenneth Date: Sun, 20 Dec 2020 12:46:11 +0000 Subject: [PATCH 55/97] Update puppeteer to latest version --- package-lock.json | 254 ++++++++++++++++++++++++++++++---------------- package.json | 2 +- 2 files changed, 169 insertions(+), 87 deletions(-) diff --git a/package-lock.json b/package-lock.json index abc2f16058..40991b753d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1771,6 +1771,16 @@ "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", "dev": true }, + "@types/yauzl": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.1.tgz", + "integrity": "sha512-A1b8SU4D10uoPjwb0lnHmmu8wZhR9d+9o2PKBQT2jU5YPTKsxac6M2qGAdY7VcL+dHHhARVUDmeg0rOrcd9EjA==", + "dev": true, + "optional": true, + "requires": { + "@types/node": "*" + } + }, "JSONStream": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", @@ -1858,13 +1868,10 @@ "dev": true }, "agent-base": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", - "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", - "dev": true, - "requires": { - "es6-promisify": "^5.0.0" - } + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-5.1.1.tgz", + "integrity": "sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g==", + "dev": true }, "ajv": { "version": "5.5.2", @@ -3652,8 +3659,7 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.3.tgz", "integrity": "sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==", - "dev": true, - "optional": true + "dev": true }, "ci-info": { "version": "2.0.0", @@ -4619,6 +4625,12 @@ "minimist": "^1.1.1" } }, + "devtools-protocol": { + "version": "0.0.818844", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.818844.tgz", + "integrity": "sha512-AD1hi7iVJ8OD0aMLQU5VK0XH9LDlA1+BcPIgrAxPfaibx2DbWucuyOhc4oyQCbnvDDO68nN6/LcKfqTP343Jjg==", + "dev": true + }, "didyoumean": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.1.tgz", @@ -4891,15 +4903,6 @@ "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", "dev": true }, - "es6-promisify": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", - "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", - "dev": true, - "requires": { - "es6-promise": "^4.0.3" - } - }, "es6-set": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", @@ -5659,28 +5662,40 @@ } }, "extract-zip": { - "version": "1.6.7", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz", - "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", + "integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==", "dev": true, "requires": { - "concat-stream": "1.6.2", - "debug": "2.6.9", - "mkdirp": "0.5.1", - "yauzl": "2.4.1" + "@types/yauzl": "^2.9.1", + "debug": "^4.1.1", + "get-stream": "^5.1.0", + "yauzl": "^2.10.0" }, "dependencies": { - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", "dev": true, "requires": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" + "ms": "2.1.2" } + }, + "get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true } } }, @@ -5798,9 +5813,9 @@ } }, "fd-slicer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", - "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", "dev": true, "requires": { "pend": "~1.2.0" @@ -7299,22 +7314,22 @@ "dev": true }, "https-proxy-agent": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz", - "integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz", + "integrity": "sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg==", "dev": true, "requires": { - "agent-base": "^4.3.0", - "debug": "^3.1.0" + "agent-base": "5", + "debug": "4" }, "dependencies": { "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "ms": { @@ -12153,7 +12168,7 @@ }, "find-up": { "version": "3.0.0", - "resolved": false, + "resolved": "", "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", "dev": true, "requires": { @@ -12168,7 +12183,7 @@ }, "is-fullwidth-code-point": { "version": "2.0.0", - "resolved": false, + "resolved": "", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, @@ -12196,7 +12211,7 @@ }, "resolve-from": { "version": "4.0.0", - "resolved": false, + "resolved": "", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true }, @@ -12234,7 +12249,7 @@ }, "which-module": { "version": "2.0.0", - "resolved": false, + "resolved": "", "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "dev": true }, @@ -12251,7 +12266,7 @@ }, "y18n": { "version": "4.0.0", - "resolved": false, + "resolved": "", "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "dev": true }, @@ -13219,9 +13234,9 @@ } }, "proxy-from-env": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", - "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", "dev": true }, "pseudomap": { @@ -13284,35 +13299,52 @@ } }, "puppeteer": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.20.0.tgz", - "integrity": "sha512-bt48RDBy2eIwZPrkgbcwHtb51mj2nKvHOPMaSH2IsWiv7lOG9k9zhaRzpDZafrk05ajMc3cu+lSQYYOfH2DkVQ==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-5.5.0.tgz", + "integrity": "sha512-OM8ZvTXAhfgFA7wBIIGlPQzvyEETzDjeRa4mZRCRHxYL+GNH5WAuYUQdja3rpWZvkX/JKqmuVgbsxDNsDFjMEg==", "dev": true, "requires": { "debug": "^4.1.0", - "extract-zip": "^1.6.6", - "https-proxy-agent": "^2.2.1", - "mime": "^2.0.3", + "devtools-protocol": "0.0.818844", + "extract-zip": "^2.0.0", + "https-proxy-agent": "^4.0.0", + "node-fetch": "^2.6.1", + "pkg-dir": "^4.2.0", "progress": "^2.0.1", "proxy-from-env": "^1.0.0", - "rimraf": "^2.6.1", - "ws": "^6.1.0" + "rimraf": "^3.0.2", + "tar-fs": "^2.0.0", + "unbzip2-stream": "^1.3.3", + "ws": "^7.2.3" }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, - "mime": { - "version": "2.4.4", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz", - "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==", - "dev": true + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } }, "ms": { "version": "2.1.2", @@ -13320,20 +13352,65 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, + "node-fetch": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", + "dev": true + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + } + }, "progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", "dev": true }, - "ws": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", - "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "dev": true, "requires": { - "async-limiter": "~1.0.0" + "glob": "^7.1.3" } + }, + "ws": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.1.tgz", + "integrity": "sha512-pTsP8UAfhy3sk1lSk/O/s4tjD0CRwvMnzvwr4OKGX7ZvqZtUyx4KIJB5JWbkykPoc55tixMGgTNoh3k4FkNGFQ==", + "dev": true } } }, @@ -15569,7 +15646,6 @@ "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.0.0.tgz", "integrity": "sha512-vaY0obB6Om/fso8a8vakQBzwholQ7v5+uy+tF3Ozvxv1KNezmVQAiWtcNmMHFSFPqL3dJA8ha6gdtFbfX9mcxA==", "dev": true, - "optional": true, "requires": { "chownr": "^1.1.1", "mkdirp": "^0.5.1", @@ -15582,7 +15658,6 @@ "resolved": "https://registry.npmjs.org/bl/-/bl-3.0.0.tgz", "integrity": "sha512-EUAyP5UHU5hxF8BPT0LKW8gjYLhq1DQIcneOX/pL/m2Alo+OYDQAJlHq+yseMP50Os2nHXOSic6Ss3vSQeyf4A==", "dev": true, - "optional": true, "requires": { "readable-stream": "^3.0.1" } @@ -15592,7 +15667,6 @@ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", "dev": true, - "optional": true, "requires": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -15603,15 +15677,13 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", - "dev": true, - "optional": true + "dev": true }, "string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", "dev": true, - "optional": true, "requires": { "safe-buffer": "~5.2.0" } @@ -15621,7 +15693,6 @@ "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.0.tgz", "integrity": "sha512-+DAn4Nb4+gz6WZigRzKEZl1QuJVOLtAwwF+WUxy1fJ6X63CaGaUAxJRD2KEn1OMfcbCjySTYpNC6WmfQoIEOdw==", "dev": true, - "optional": true, "requires": { "bl": "^3.0.0", "end-of-stream": "^1.4.1", @@ -16048,6 +16119,16 @@ "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", "dev": true }, + "unbzip2-stream": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz", + "integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==", + "dev": true, + "requires": { + "buffer": "^5.2.1", + "through": "^2.3.8" + } + }, "unc-path-regex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", @@ -16892,12 +16973,13 @@ } }, "yauzl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", - "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", "dev": true, "requires": { - "fd-slicer": "~1.0.1" + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" } }, "yui": { diff --git a/package.json b/package.json index af48339e86..7ae46700d8 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "opentype.js": "^0.9.0", "prettier": "^1.7.4", "promise-map-series": "^0.2.3", - "puppeteer": "^1.20.0", + "puppeteer": "^5.5.0", "regenerator-runtime": "^0.13.3", "release-it": "^12.6.2", "request": "^2.88.0", From e9f04db7880a797afae3d6e13862f0ddd2fef592 Mon Sep 17 00:00:00 2001 From: limzykenneth Date: Sun, 20 Dec 2020 17:09:45 +0000 Subject: [PATCH 56/97] Add linux sandbox flag to puppeteer command --- tasks/test/mocha-chrome.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/test/mocha-chrome.js b/tasks/test/mocha-chrome.js index fe02a99873..b6903b3b90 100644 --- a/tasks/test/mocha-chrome.js +++ b/tasks/test/mocha-chrome.js @@ -16,7 +16,7 @@ module.exports = function(grunt) { // Launch Chrome in headless mode const browser = await puppeteer.launch({ headless: true, - args: ['--no-sandbox'] + args: ['--no-sandbox', '--disable-setuid-sandbox'] }); try { From e8b9dc7de6d1747def928408d8323fa1dbc0cd50 Mon Sep 17 00:00:00 2001 From: siv2r Date: Mon, 21 Dec 2020 21:49:44 +0530 Subject: [PATCH 57/97] added line break before the template image --- contributor_docs/inline_documentation.md | 1 + 1 file changed, 1 insertion(+) diff --git a/contributor_docs/inline_documentation.md b/contributor_docs/inline_documentation.md index 1c8837094b..bb6ccb13fd 100644 --- a/contributor_docs/inline_documentation.md +++ b/contributor_docs/inline_documentation.md @@ -267,6 +267,7 @@ horizontal wave pattern effected by mouse x-position & updating noise values. ## Template for methods Here is an example for a well-documented method. To create a new method, you can use [this template](https://github.com/processing/p5.js/tree/main/contributor_docs/method.example.js). Replace the text with your method's variables and remove the remaining ones. + ![Image showing inline documentation example for methods](https://raw.githubusercontent.com/processing/p5.js/main/contributor_docs/images/method-template-example.png) From f4a5e1f74f9059f9a38133acd016fe01ab64defe Mon Sep 17 00:00:00 2001 From: siv2r Date: Mon, 21 Dec 2020 22:01:00 +0530 Subject: [PATCH 58/97] changed definition to description --- contributor_docs/inline_documentation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributor_docs/inline_documentation.md b/contributor_docs/inline_documentation.md index bb6ccb13fd..c5e8bbf943 100644 --- a/contributor_docs/inline_documentation.md +++ b/contributor_docs/inline_documentation.md @@ -115,7 +115,7 @@ If a method has multiple possible parameter options, you can specify each indivi ``` Notes: -* If a parameter has been defined previously, like `a` in this case, you do not need to fill in the definition again. +* If a parameter was given description previously, like `a` in this case, you do not need to rewrite its description again. * It is not necessary to create a separate signature if the only difference between two signatures is the addition of an optional parameter. * You can see two examples of this inline in the source code for [background](https://github.com/processing/p5.js/blob/f38f91308fdacc2f1982e0430b620778fff30a5a/src/color/setting.js#L106) and [color](https://github.com/processing/p5.js/blob/f38f91308fdacc2f1982e0430b620778fff30a5a/src/color/creating_reading.js#L241). From daf460517cdcfefb5fa91986385ab5247a0ed535 Mon Sep 17 00:00:00 2001 From: siv2r Date: Mon, 21 Dec 2020 22:10:16 +0530 Subject: [PATCH 59/97] fixed broken link --- contributor_docs/inline_documentation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributor_docs/inline_documentation.md b/contributor_docs/inline_documentation.md index c5e8bbf943..73952bea19 100644 --- a/contributor_docs/inline_documentation.md +++ b/contributor_docs/inline_documentation.md @@ -147,7 +147,7 @@ Use `@private` if a property or variable is a private variable (default is `@pub ## Specify module for files -The top of each *file* should contain a `@module` tag. Modules should correspond to JavaScript files (or require.js modules). They can work as groups in the lists of items. See http://p5js.org/api/#methods (the modules are COLOR, IMAGE, PVECTOR, etc.). +The top of each *file* should contain a `@module` tag. Modules should correspond to JavaScript files (or require.js modules). They can work as groups in the lists of items. See [here](https://p5js.org/reference/#collection-list-nav) (the modules are COLOR, IMAGE, IO, PVECTOR, etc.). ``` /** From 321cfe384c77e3fb61049111406842f37323ca8f Mon Sep 17 00:00:00 2001 From: siv2r Date: Mon, 21 Dec 2020 22:15:40 +0530 Subject: [PATCH 60/97] renamed yuidoc-p5-theme-src to yuidoc-p5-theme --- contributor_docs/inline_documentation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributor_docs/inline_documentation.md b/contributor_docs/inline_documentation.md index 73952bea19..6793bf77f7 100644 --- a/contributor_docs/inline_documentation.md +++ b/contributor_docs/inline_documentation.md @@ -273,7 +273,7 @@ Here is an example for a well-documented method. To create a new method, you can ## Generating documentation -* Run `grunt yui:build` once first to generate all local files needed, as well as a copy of the reference from the source code. Run it again anytime you make changes to the core JS files behind the yuidoc reference page. These are changes in files located in the yuidoc-p5-theme-src folder, NOT inline documentation changes to src. +* Run `grunt yui:build` once first to generate all local files needed, as well as a copy of the reference from the source code. Run it again anytime you make changes to the core JS files behind the yuidoc reference page. These are changes in files located in the yuidoc-p5-theme folder, NOT inline documentation changes to src. * If you only made changes to the source code, you can just run `grunt yui`, though `grunt yui:build` will also do the trick. * You can run `npm run docs:dev` to launch a live preview of the site that will update each time you make changes. (You will need to refresh the page after making changes to see them appear.) From c709728fde5a3e598b738b2510f38e5277892c7b Mon Sep 17 00:00:00 2001 From: siv2r Date: Mon, 21 Dec 2020 22:25:02 +0530 Subject: [PATCH 61/97] added npm run before grunt --- contributor_docs/inline_documentation.md | 6 +++--- contributor_docs/ko/inline_documentation.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contributor_docs/inline_documentation.md b/contributor_docs/inline_documentation.md index 6793bf77f7..4f0892648f 100644 --- a/contributor_docs/inline_documentation.md +++ b/contributor_docs/inline_documentation.md @@ -273,11 +273,11 @@ Here is an example for a well-documented method. To create a new method, you can ## Generating documentation -* Run `grunt yui:build` once first to generate all local files needed, as well as a copy of the reference from the source code. Run it again anytime you make changes to the core JS files behind the yuidoc reference page. These are changes in files located in the yuidoc-p5-theme folder, NOT inline documentation changes to src. -* If you only made changes to the source code, you can just run `grunt yui`, though `grunt yui:build` will also do the trick. +* Run `npm run grunt yui:build` once first to generate all local files needed, as well as a copy of the reference from the source code. Run it again anytime you make changes to the core JS files behind the yuidoc reference page. These are changes in files located in the yuidoc-p5-theme folder, NOT inline documentation changes to src. +* If you only made changes to the source code, you can just run `npm run grunt yui`, though `npm run grunt yui:build` will also do the trick. * You can run `npm run docs:dev` to launch a live preview of the site that will update each time you make changes. (You will need to refresh the page after making changes to see them appear.) -The build reference can be found in docs/reference. To preview it locally, run `grunt yui:dev` and view it as http://localhost:9001/docs/reference/. +The build reference can be found in docs/reference. To preview it locally, run `npm run grunt yui:dev` and view it as http://localhost:9001/docs/reference/. ## Spanish language version diff --git a/contributor_docs/ko/inline_documentation.md b/contributor_docs/ko/inline_documentation.md index a33c920d03..8cba28438c 100644 --- a/contributor_docs/ko/inline_documentation.md +++ b/contributor_docs/ko/inline_documentation.md @@ -271,11 +271,11 @@ horizontal wave pattern effected by mouse x-position & updating noise values. ## 문서 생성 -* 먼저 `grunt yui:build`를 한 번 실행하여 필요한 모든 로컬 파일과 소스 코드의 참조 사본을 생성합니다. yuidoc 레퍼런스 페이지 뒤에서 코어 JS 파일을 변경할 때마다 다시 실행해주세요. 이는 src의 인라인 문서 변경이 아니라 yuidoc-p5-theme-src 폴더에있는 파일에 대한 변경 사항입니다. -* 소스 코드만 변경했다면 `grunt yui`만 실행할 수 있지만 `grunt yui:build`도 사용할 수 있습니다. +* 먼저 `npm run grunt yui:build`를 한 번 실행하여 필요한 모든 로컬 파일과 소스 코드의 참조 사본을 생성합니다. yuidoc 레퍼런스 페이지 뒤에서 코어 JS 파일을 변경할 때마다 다시 실행해주세요. 이는 src의 인라인 문서 변경이 아니라 yuidoc-p5-theme-src 폴더에있는 파일에 대한 변경 사항입니다. +* 소스 코드만 변경했다면 `npm run grunt yui`만 실행할 수 있지만 `npm run grunt yui:build`도 사용할 수 있습니다. * `npm run docs:dev`를 실행하여 변경할 때마다 업데이트되는 사이트의 실시간 미리보기를 할 수 있습니다.(변경 한 후 페이지를 새로고침해야 표시됩니다.) -빌드 레퍼런스는 docs/reference에서 찾을 수 있으며. 로컬에서 미리 보려면 `grunt yui:dev`를 실행해 http://localhost:9001/docs/reference/ 에서 살펴보세요. +빌드 레퍼런스는 docs/reference에서 찾을 수 있으며. 로컬에서 미리 보려면 `npm run grunt yui:dev`를 실행해 http://localhost:9001/docs/reference/ 에서 살펴보세요. ## 스페인어 버전 From df81685f7e6fbbaa50c1e4655f32e65ace252580 Mon Sep 17 00:00:00 2001 From: Vamoss Date: Mon, 21 Dec 2020 15:21:55 -0300 Subject: [PATCH 62/97] remove smooth option from quad function (original restored) --- src/core/p5.Renderer2D.js | 50 ++++----------------------------------- 1 file changed, 5 insertions(+), 45 deletions(-) diff --git a/src/core/p5.Renderer2D.js b/src/core/p5.Renderer2D.js index 0bdaf5a0b1..31f144a2fd 100644 --- a/src/core/p5.Renderer2D.js +++ b/src/core/p5.Renderer2D.js @@ -582,18 +582,7 @@ p5.Renderer2D.prototype.point = function(x, y) { this._setFill(f); }; -p5.Renderer2D.prototype.quad = function( - x1, - y1, - x2, - y2, - x3, - y3, - x4, - y4, - detailX, - detailY -) { +p5.Renderer2D.prototype.quad = function(x1, y1, x2, y2, x3, y3, x4, y4) { const ctx = this.drawingContext; const doFill = this._doFill, doStroke = this._doStroke; @@ -606,41 +595,12 @@ p5.Renderer2D.prototype.quad = function( return this; } } - - if (typeof detailX === 'undefined') { - detailX = 2; - } - if (typeof detailY === 'undefined') { - detailY = 2; - } - ctx.beginPath(); - - let xRes = 1.0 / (detailX - 1); - let yRes = 1.0 / (detailY - 1); - for (let y = 0; y < detailY; y++) { - for (let x = 0; x < detailX; x++) { - let pctx = x * xRes; - let pcty = y * yRes; - - let linePt0x = (1 - pcty) * x1 + pcty * x4; - let linePt0y = (1 - pcty) * y1 + pcty * y4; - let linePt1x = (1 - pcty) * x2 + pcty * x3; - let linePt1y = (1 - pcty) * y2 + pcty * y3; - - let ptx = (1 - pctx) * linePt0x + pctx * linePt1x; - let pty = (1 - pctx) * linePt0y + pctx * linePt1y; - - if (x === 0 && y === 0) { - ctx.moveTo(ptx, pty); - } else { - ctx.lineTo(ptx, pty); - } - } - } - + ctx.moveTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.lineTo(x3, y3); + ctx.lineTo(x4, y4); ctx.closePath(); - if (doFill) { ctx.fill(); } From bd382c12dd2bc6c0c69f9086f442ba7dc46e1dec Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 21 Dec 2020 19:49:45 +0000 Subject: [PATCH 63/97] docs: update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5059e5f274..074860acc0 100644 --- a/README.md +++ b/README.md @@ -458,6 +458,7 @@ We recognize all types of contributions. This project follows the [all-contribut
sam delong

💻
Zhao Xin

💻 👀 +
Sivaram D

📖 From 95240abfecc67830fbe1ea5956d9ca9c8112cc0b Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 21 Dec 2020 19:49:46 +0000 Subject: [PATCH 64/97] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index cbea05c797..5d79ec4320 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2328,6 +2328,15 @@ "code", "review" ] + }, + { + "login": "siv2r", + "name": "Sivaram D", + "avatar_url": "https://avatars3.githubusercontent.com/u/56887198?v=4", + "profile": "https://github.com/siv2r", + "contributions": [ + "doc" + ] } ], "repoType": "github", From 998d10caec443d6c611a8a65d96983d3ccea78cb Mon Sep 17 00:00:00 2001 From: siv2r Date: Thu, 31 Dec 2020 00:07:29 +0530 Subject: [PATCH 65/97] added rotate (static function) for p5.Vector --- src/math/p5.Vector.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/math/p5.Vector.js b/src/math/p5.Vector.js index fc5e69653d..175ae5a9ec 100644 --- a/src/math/p5.Vector.js +++ b/src/math/p5.Vector.js @@ -2138,6 +2138,34 @@ p5.Vector.mult = function mult(v, n, target) { return target; }; +/** + * Rotates the vector (only 2D vectors) by the given angle, magnitude remains the same and returns a new vector. + */ + +/** + * @method rotate + * @static + * @param {p5.Vector} v + * @param {Number} angle angle of rotation + * @param {p5.Vector} [target] the vector to receive the result (Optional) + */ + +p5.Vector.rotate = function rotate(v, a, target) { + if (!target) { + target = v.copy(); + if (arguments.length === 3) { + p5._friendlyError( + 'The target parameter is undefined, it should be of type p5.Vector', + 'p5.Vector.rotate' + ); + } + } else { + target.set(v); + } + target.rotate(a); + return target; +}; + /** * Divides a vector by a scalar and returns a new vector. */ From 2ab9ab100486dcf9c84be04eb17afed72f37fee8 Mon Sep 17 00:00:00 2001 From: siv2r Date: Thu, 31 Dec 2020 00:11:31 +0530 Subject: [PATCH 66/97] removed addtional param description for angle --- src/math/p5.Vector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/math/p5.Vector.js b/src/math/p5.Vector.js index 175ae5a9ec..05443dbef0 100644 --- a/src/math/p5.Vector.js +++ b/src/math/p5.Vector.js @@ -2146,7 +2146,7 @@ p5.Vector.mult = function mult(v, n, target) { * @method rotate * @static * @param {p5.Vector} v - * @param {Number} angle angle of rotation + * @param {Number} angle * @param {p5.Vector} [target] the vector to receive the result (Optional) */ From f25907b190e14cf5ae54ac71d76158be9f1b5132 Mon Sep 17 00:00:00 2001 From: siv2r Date: Thu, 31 Dec 2020 00:41:57 +0530 Subject: [PATCH 67/97] added example for rotate func (static implementation) --- src/math/p5.Vector.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/math/p5.Vector.js b/src/math/p5.Vector.js index 05443dbef0..a6c2833227 100644 --- a/src/math/p5.Vector.js +++ b/src/math/p5.Vector.js @@ -1482,6 +1482,19 @@ p5.Vector.prototype.setHeading = function setHeading(a) { * *
* + *
+ * + * // static function implementation + * let v = createVector(10.0, 20.0); + * // v has components [10.0, 20.0, 0.0] + * let rotated_v = p5.Vector.rotate(v, HALF_PI); + * console.log(rotated_v); + * // rotated_v's components are set to [-20.0, 9.999999, 0.0] + * console.log(v); + * // v's components remains the same (i.e, [10.0, 20.0, 0.0]) + * + *
+ * *
* * let angle = 0; From 48d309ce1cbb3ade14e76fc26b219d339ad4d93e Mon Sep 17 00:00:00 2001 From: Shantanu Kaushik Date: Mon, 4 Jan 2021 13:02:38 +0530 Subject: [PATCH 68/97] removed no render class, and corrected the styling of DOM examples for better display --- src/dom/dom.js | 73 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index 680064d655..3ef840fba3 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -79,19 +79,20 @@ p5.prototype.select = function(e, p) { * , or HTML element to search within * @return {p5.Element[]} Array of p5.Elements containing nodes found * @example - *
+ *
* function setup() { * createButton('btn'); * createButton('2nd btn'); * createButton('3rd btn'); * let buttons = selectAll('button'); * - * for (let i = 0; i < buttons.length; i++) { - * buttons[i].size(100, 100); + * for (let i = 0; i < 3; i++) { + * buttons[i].size(100); + * buttons[i].position(0, i * 30); * } * } *
- *
+ *
* // these are all valid calls to selectAll() * let a = selectAll('.beep'); * a = selectAll('div'); @@ -178,11 +179,14 @@ p5.prototype._wrapElement = function(elt) { * Event handlers are removed, and element is removed from the DOM. * @method removeElements * @example - *
+ *
* function setup() { * createCanvas(100, 100); - * createDiv('this is some text'); - * createP('this is a paragraph'); + * background('grey'); + * let div = createDiv('this is some text'); + * let p = createP('this is a paragraph'); + * div.style('font-size', '16px'); + * p.style('font-size', '16px'); * } * function mousePressed() { * removeElements(); // this will remove the div and p, not canvas @@ -278,10 +282,14 @@ p5.Element.prototype.changed = function(fxn) { * firing function will no longer fire. * @chainable * @example - *
+ *
* // Open your console to see the output * function setup() { + * createCanvas(100, 100); + * background('grey'); * let inp = createInput(''); + * inp.position(0, 0); + * inp.size(100); * inp.input(myInputEvent); * } * @@ -316,8 +324,10 @@ function addElement(elt, pInst, media) { * @param {String} [html] inner HTML for element created * @return {p5.Element} pointer to p5.Element holding created node * @example - *
- * createDiv('this is some text'); + *
+ * let div = createDiv('this is some text'); + * div.style('font-size', '16px'); + * div.position(10, 0); *
*/ p5.prototype.createDiv = function(html = '') { @@ -334,8 +344,10 @@ p5.prototype.createDiv = function(html = '') { * @param {String} [html] inner HTML for element created * @return {p5.Element} pointer to p5.Element holding created node * @example - *
- * createP('this is some text'); + *
+ * let p = createP('this is some text'); + * p.style('font-size', '16px'); + * p.position(10, 0); *
*/ p5.prototype.createP = function(html = '') { @@ -351,8 +363,9 @@ p5.prototype.createP = function(html = '') { * @param {String} [html] inner HTML for element created * @return {p5.Element} pointer to p5.Element holding created node * @example - *
- * createSpan('this is some text'); + *
+ * let span = createSpan('this is some text'); + * span.position(0, 0); *
*/ p5.prototype.createSpan = function(html = '') { @@ -370,11 +383,12 @@ p5.prototype.createSpan = function(html = '') { * @param {String} alt alternate text to be used if image does not load. You can use also an empty string (`""`) if that an image is not intended to be viewed. * @return {p5.Element} pointer to p5.Element holding created node * @example - *
- * createImg( + *
+ * let img = createImg( * 'https://p5js.org/assets/img/asterisk-01.png', * 'the p5 magenta asterisk' * ); + * img.position(0, -10); *
*/ /** @@ -417,8 +431,9 @@ p5.prototype.createImg = function() { * could be _blank, _self, _parent, _top. * @return {p5.Element} pointer to p5.Element holding created node * @example - *
- * createA('http://p5js.org/', 'this is a link'); + *
+ * let a = createA('http://p5js.org/', 'this is a link'); + * a.position(0, 0); *
*/ p5.prototype.createA = function(href, html, target) { @@ -497,13 +512,13 @@ p5.prototype.createSlider = function(min, max, value, step) { * @param {String} [value] value of the button * @return {p5.Element} pointer to p5.Element holding created node * @example - *
+ *
* let button; * function setup() { * createCanvas(100, 100); * background(0); * button = createButton('click me'); - * button.position(19, 19); + * button.position(0, 0); * button.mousePressed(changeBG); * } * @@ -530,7 +545,7 @@ p5.prototype.createButton = function(label, value) { * @param {boolean} [value] value of the checkbox; checked is true, unchecked is false * @return {p5.Element} pointer to p5.Element holding created node * @example - *
+ *
* let checkbox; * * function setup() { @@ -1013,9 +1028,13 @@ p5.prototype.createColorPicker = function(value) { * Needs a value to be specified first. * @return {p5.Element} pointer to p5.Element holding created node * @example - *
+ *
* function setup() { + * createCanvas(100, 100); + * background('grey'); * let inp = createInput(''); + * inp.position(0, 0); + * inp.size(100); * inp.input(myInputEvent); * } * @@ -1301,12 +1320,12 @@ if (navigator.mediaDevices.getUserMedia === undefined) { * stream has loaded * @return {p5.Element} capture video p5.Element * @example - *
+ *
* * let capture; * * function setup() { - * createCanvas(480, 480); + * createCanvas(100, 100); * capture = createCapture(VIDEO); * capture.hide(); * } @@ -1419,8 +1438,10 @@ p5.prototype.createCapture = function() { * @param {String} [content] html content to be inserted into the element * @return {p5.Element} pointer to p5.Element holding created node * @example - *
- * createElement('h2', 'im an h2 p5.element!'); + *
+ * let h5 = createElement('h5', 'im an h5 p5.element!'); + * h5.style('color', '#00a1d3'); + * h5.position(0, 0); *
*/ p5.prototype.createElement = function(tag, content) { From b5abdddbb402137de94d7b550a92db0c334f3c39 Mon Sep 17 00:00:00 2001 From: siv2r Date: Tue, 5 Jan 2021 00:12:08 +0530 Subject: [PATCH 69/97] better checks for rotate (static function) --- src/math/p5.Vector.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/math/p5.Vector.js b/src/math/p5.Vector.js index a6c2833227..8ae9e57912 100644 --- a/src/math/p5.Vector.js +++ b/src/math/p5.Vector.js @@ -2162,18 +2162,17 @@ p5.Vector.mult = function mult(v, n, target) { * @param {Number} angle * @param {p5.Vector} [target] the vector to receive the result (Optional) */ - p5.Vector.rotate = function rotate(v, a, target) { - if (!target) { + if (arguments.length === 2) { target = v.copy(); - if (arguments.length === 3) { - p5._friendlyError( - 'The target parameter is undefined, it should be of type p5.Vector', - 'p5.Vector.rotate' - ); - } - } else { + } else if (target instanceof p5.Vector) { target.set(v); + } else { + target = v.copy(); + p5._friendlyError( + 'The target parameter should be of type p5.Vector', + 'p5.Vector.rotate' + ); } target.rotate(a); return target; From 0b89c6fb4ff606160c91d3400dcca1461b2f53b5 Mon Sep 17 00:00:00 2001 From: siv2r Date: Tue, 5 Jan 2021 20:45:45 +0530 Subject: [PATCH 70/97] improved checks for static p5.Vector rotate() --- src/math/p5.Vector.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/math/p5.Vector.js b/src/math/p5.Vector.js index 8ae9e57912..7a0c6fbb89 100644 --- a/src/math/p5.Vector.js +++ b/src/math/p5.Vector.js @@ -2165,14 +2165,14 @@ p5.Vector.mult = function mult(v, n, target) { p5.Vector.rotate = function rotate(v, a, target) { if (arguments.length === 2) { target = v.copy(); - } else if (target instanceof p5.Vector) { - target.set(v); } else { - target = v.copy(); - p5._friendlyError( - 'The target parameter should be of type p5.Vector', - 'p5.Vector.rotate' - ); + if (!(target instanceof p5.Vector)) { + p5._friendlyError( + 'The target parameter should be of type p5.Vector', + 'p5.Vector.rotate' + ); + } + target.set(v); } target.rotate(a); return target; From fa1264fb5cbca788ad450234c6311b029198e76d Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 6 Jan 2021 10:55:23 +0000 Subject: [PATCH 71/97] docs: update README.md [skip ci] --- README.md | 748 +++++++++++++++++++++++++++--------------------------- 1 file changed, 375 insertions(+), 373 deletions(-) diff --git a/README.md b/README.md index 074860acc0..cc5e90b196 100644 --- a/README.md +++ b/README.md @@ -87,382 +87,384 @@ We recognize all types of contributions. This project follows the [all-contribut - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Lauren McCarthy


Jason Sigal


Karen


Evelyn Eastmond


Daniel Shiffman


Casey Reas


Ben Fry


Kenneth Lim

🐛 💻 📖

kate hollenbach


Stalgia Grigg


Jerel Johnson


Saksham Saxena


saber khan


Daniel Howe


Kevin Siwoff


Atul Varma


Jess Klein


uno seis tres


susan evans


Saskia Freeke


Phoenix Perry


jesse cahn-thompson


Lee T


Chelly Jin


L05


DIYgirls


lam802


Maya Man


Tega Brain


luisaph


AlM Chng


aarón montoya-moraga


Cassie Tarakajian


Niklas Peters

📖

Mathura MG


Yining Shi


Jen Kagan


Jiashan Wu


Marc Abbey


K.Adam White


Joe Cridge


Michael Hadley


Todd H. Page


Jared Sprague

💻 📖 💡 💵 ⚠️ 🐛

evelyn masso


Blaize Kaye


Sanchit Kapoor


Oliver Wright


Matthew Kaney


Spongman


Claire K-V


R. Luke DuBois


Kevin Barabash


codeanticode


Bob Holt


Sarah Groff Hennigh-Palermo


Jordan Shaw


brightredchilli


Derek J. Kinsman


harkirat singh


GoToLoop


Max Goldstein


XY Feng


Sparsh Paliwal


Austin Cawley-Edwards

📖 💡

taseenb


Yannick Assogba


John Pasquarello

💻

Kevin Workman


gauini


David Wicks


Guillermo Montecinos


Shawn Van Every


Sinan Ascioglu


Abe Pazos


Char


Gene Kogan


Jason Mandel


Mark Russo


Jonathan Dahan


Darius Morawiec


Darby Rathbone


hrishit


Chiun Hau You


Francesco Bigiarini


Fabian Morón Zirfas


Mike Anderson


Mikael Lindqvist


Chris


Max Segal


Tyler Stefanich


Dave


Xavier Snelgrove


Gareth Battensby


Taeyoon Choi


AKASH RAJ


Kevin Ho


Harsh Agrawal


Luca Damasco


Sam Lavigne


Epic Jefferson


Caroline Record


Christine de Carteret


Chris Hallberg


David Newbury


piinthecloud


Paolo Pedercini


Jason Alderman


Jennifer Jacobs


Sepand Ansari


Val Head


Emily Chen


Ben Moren


Rune Skjoldborg Madsen


Scott Murray


Scott Garner


b2renger


Craig Pickard


mxchelle


Zach Rispoli


Liu Chang


Cristóbal Valenzuela


Miles Peyton


Golan Levin


feedzh


Shahriar Rahman Rubayet


Chiciuc Nicușor


Ken Miller


Chandler McWilliams


Jaymz Rhime


Niels Joubert


Utkarsh Tiwari


Arihant Parsoya


Brad Buchanan


Johan Karlsson


Andy Timmons


zacharystenger


Brian Boucheron


sortasleepy


Kyle McDonald


Antonio Jesús Sánchez Padial

💻

Brad Smith


Vítor Galvão


Devon Rifkin


Emily Xie


Boris Bucha


Petr Brzek


Ramin


Arsenije Savic


Luke Burgess-Yeo


Sun Lifei


naoyashiga


Jimish Fotariya


Jorge Moreno

🐛 💻 📖

Steven Green


Marcus Parsons


Nick Yahnke


Anthony Su


kroko / Reinis Adovičs


Robyn Overstreet


Ben Hinchley


Max Kolyanov


Zeno Zeng


Seth


plural


Lionel Ringenbach


Harshil Goel


Joshua Storm Becker


maxdevjs


trych


Alejandra Trejo


Prashant Gupta


Kai-han Chang


kjav


maddy


Christopher Coleman


Boaz


Yasai

📝

Jay Gupta


Nitish Bansal


Caroline Hermans

💡 📖

Faith Wuyue Yu


Aatish Bhatia

📖 🐛

Mislav Milicevic

💻 🐛

Yuting Lu

📖

Adil Rabbani

💻 🐛 💡

Pierre Krafft

🐛 💻 📖 💡 👀 ⚠️ 🔧

Zoë Ingram

📖

Aidan Nelson

🐛 💻 📖

Cameron Yick

📖

Tanvi Kumar

🐛 💻 📖 💡

Katsuya Endoh


Kevin Bradley

📖

Justin Kim

📖

Federico Grandi

💻 📖

Freddie Rawlins

💻 📖

Luc de wit

💻 🐛

Mark Nikora

💻

Louis Demange

🐛

Sanket Singh

💻 🐛 📖 💡

Oren Shoham

💻

Abhinav Sagar

💻

Jonathan Heindl

💻 💡 🤔 📖

Hirad Sab

💻 🐛 📖 💡

Vishal Singh

📖 💻

Corey Gouker

💻 📖 🐛

Lisa Mabley

📖 💡

Adam Ferriss

💻 📖 🐛 💡

Joshua Marris

📖 💻 📢

Erica Pramer

📖

Vasu Goel

💻 ⚠️

Tokini Irene Fubara

📖

Dhruv Sahnan

💻 📖

Jon Kaufman

📖

Nico Finkernagel

🚇 👀

ashu8912

💻

ffd8

💻

Sona Lee

💻

Ryan Slade

💻

Mann Shah


Juraj Onuska


ANURAG GUPTA

📖

Sagar Arora


Rajiv Ranjan Singh


Fenil Gandhi

📖 💡

Akshay Padte

💻 🐛 ⚠️

Satyam Kulkarni

📖

Shirou

💻 🐛

Sarthak Saxena

💻

Nick McIntyre

🔌 🐛

Amey Bhavsar

🐛 💡

Minjun Kim

🐛 🌍

Fisher Diede

💻

karinaxlpz

🌍

Samuel Alarco Cantos

🌍

DIVYANSHU RAJ

💻 🐛 📖

sm7515

📖

Aditya Rachman Putra

📖

shaharyarshamshi

🌍

Ayush Jain

🌍

Summer Rizzo

📖

Aierie

💻 🐛

Mateusz Swiatkowski

💻 🐛

XingZiLong

🌍

ov

🌍

Kyle James

💻

Abhi Gulati

📖

Jeremy Tuloup

📖

Luis Morales-Navarro

️️️️♿️

Yuki

🌍

cedarfall

📖

Isaac Durazo

🌍

İsmail Namdar

💻 ⚠️

skyperx

💻

Joseph Aronson

💻 🐛

Haider Ali Punjabi

💻

Swapnil-2001

📖

Takuma Kira

🐛 💻 ⚠️

Mohammad Hussain Nagaria

🐛

Tushar Choudhari

📖 💻

Nakul Shahdadpuri

💻

Jacques P. du Toit

💻

surajsurajsuraj

🐛

Connie Liu

💻 🎨

Zeke Sikelianos

📖

Ramon Jr. Yniguez

💻

Benoît Bouré

📖

Hitesh Kumar

💻

Sampo Rapeli

💡

Nick Müller

🔌

Keith Tan

📖

Berke Özgen

🐛

Musab Kılıç

💻 ⚠️

Nicholas Marino

📖

Greg Sadetsky

💻

Priya-Pathak

💡

Daniel Michel

💻

Nisar Hassan Naqvi

💻

Joshua Noble

📖

Liam Piesley

💻

Rishabh Taparia

💻 📖

Daniel Sarno

💡

Kunal Kumar Verma

📖 🐛 💻

Bharath Kumar R

💻

Aditya Mohan

💻

Arijit Kundu

🐛 💻 📖

Tanner Dolby

💻

sam delong

💻

Zhao Xin

💻 👀

Sivaram D

📖

Lauren McCarthy


Jason Sigal


Karen


Evelyn Eastmond


Daniel Shiffman


Casey Reas


Ben Fry


Kenneth Lim

🐛 💻 📖

kate hollenbach


Stalgia Grigg


Jerel Johnson


Saksham Saxena


saber khan


Daniel Howe


Kevin Siwoff


Atul Varma


Jess Klein


uno seis tres


susan evans


Saskia Freeke


Phoenix Perry


jesse cahn-thompson


Lee T


Chelly Jin


L05


DIYgirls


lam802


Maya Man


Tega Brain


luisaph


AlM Chng


aarón montoya-moraga


Cassie Tarakajian


Niklas Peters

📖

Mathura MG


Yining Shi


Jen Kagan


Jiashan Wu


Marc Abbey


K.Adam White


Joe Cridge


Michael Hadley


Todd H. Page


Jared Sprague

💻 📖 💡 💵 ⚠️ 🐛

evelyn masso


Blaize Kaye


Sanchit Kapoor


Oliver Wright


Matthew Kaney


Spongman


Claire K-V


R. Luke DuBois


Kevin Barabash


codeanticode


Bob Holt


Sarah Groff Hennigh-Palermo


Jordan Shaw


brightredchilli


Derek J. Kinsman


harkirat singh


GoToLoop


Max Goldstein


XY Feng


Sparsh Paliwal


Austin Cawley-Edwards

📖 💡

taseenb


Yannick Assogba


John Pasquarello

💻

Kevin Workman


gauini


David Wicks


Guillermo Montecinos


Shawn Van Every


Sinan Ascioglu


Abe Pazos


Char


Gene Kogan


Jason Mandel


Mark Russo


Jonathan Dahan


Darius Morawiec


Darby Rathbone


hrishit


Chiun Hau You


Francesco Bigiarini


Fabian Morón Zirfas


Mike Anderson


Mikael Lindqvist


Chris


Max Segal


Tyler Stefanich


Dave


Xavier Snelgrove


Gareth Battensby


Taeyoon Choi


AKASH RAJ


Kevin Ho


Harsh Agrawal


Luca Damasco


Sam Lavigne


Epic Jefferson


Caroline Record


Christine de Carteret


Chris Hallberg


David Newbury


piinthecloud


Paolo Pedercini


Jason Alderman


Jennifer Jacobs


Sepand Ansari


Val Head


Emily Chen


Ben Moren


Rune Skjoldborg Madsen


Scott Murray


Scott Garner


b2renger


Craig Pickard


mxchelle


Zach Rispoli


Liu Chang


Cristóbal Valenzuela


Miles Peyton


Golan Levin


feedzh


Shahriar Rahman Rubayet


Chiciuc Nicușor


Ken Miller


Chandler McWilliams


Jaymz Rhime


Niels Joubert


Utkarsh Tiwari


Arihant Parsoya


Brad Buchanan


Johan Karlsson


Andy Timmons


zacharystenger


Brian Boucheron


sortasleepy


Kyle McDonald


Antonio Jesús Sánchez Padial

💻

Brad Smith


Vítor Galvão


Devon Rifkin


Emily Xie


Boris Bucha


Petr Brzek


Ramin


Arsenije Savic


Luke Burgess-Yeo


Sun Lifei


naoyashiga


Jimish Fotariya


Jorge Moreno

🐛 💻 📖

Steven Green


Marcus Parsons


Nick Yahnke


Anthony Su


kroko / Reinis Adovičs


Robyn Overstreet


Ben Hinchley


Max Kolyanov


Zeno Zeng


Seth


plural


Lionel Ringenbach


Harshil Goel


Joshua Storm Becker


maxdevjs


trych


Alejandra Trejo


Prashant Gupta


Kai-han Chang


kjav


maddy


Christopher Coleman


Boaz


Yasai

📝

Jay Gupta


Nitish Bansal


Caroline Hermans

💡 📖

Faith Wuyue Yu


Aatish Bhatia

📖 🐛

Mislav Milicevic

💻 🐛

Yuting Lu

📖

Adil Rabbani

💻 🐛 💡

Pierre Krafft

🐛 💻 📖 💡 👀 ⚠️ 🔧

Zoë Ingram

📖

Aidan Nelson

🐛 💻 📖

Cameron Yick

📖

Tanvi Kumar

🐛 💻 📖 💡

Katsuya Endoh


Kevin Bradley

📖

Justin Kim

📖

Federico Grandi

💻 📖

Freddie Rawlins

💻 📖

Luc de wit

💻 🐛

Mark Nikora

💻

Louis Demange

🐛

Sanket Singh

💻 🐛 📖 💡

Oren Shoham

💻

Abhinav Sagar

💻

Jonathan Heindl

💻 💡 🤔 📖

Hirad Sab

💻 🐛 📖 💡

Vishal Singh

📖 💻

Corey Gouker

💻 📖 🐛

Lisa Mabley

📖 💡

Adam Ferriss

💻 📖 🐛 💡

Joshua Marris

📖 💻 📢

Erica Pramer

📖

Vasu Goel

💻 ⚠️

Tokini Irene Fubara

📖

Dhruv Sahnan

💻 📖

Jon Kaufman

📖

Nico Finkernagel

🚇 👀

ashu8912

💻

ffd8

💻

Sona Lee

💻

Ryan Slade

💻

Mann Shah


Juraj Onuska


ANURAG GUPTA

📖

Sagar Arora


Rajiv Ranjan Singh


Fenil Gandhi

📖 💡

Akshay Padte

💻 🐛 ⚠️

Satyam Kulkarni

📖

Shirou

💻 🐛

Sarthak Saxena

💻

Nick McIntyre

🔌 🐛

Amey Bhavsar

🐛 💡

Minjun Kim

🐛 🌍

Fisher Diede

💻

karinaxlpz

🌍

Samuel Alarco Cantos

🌍

DIVYANSHU RAJ

💻 🐛 📖

sm7515

📖

Aditya Rachman Putra

📖

shaharyarshamshi

🌍

Ayush Jain

🌍

Summer Rizzo

📖

Aierie

💻 🐛

Mateusz Swiatkowski

💻 🐛

XingZiLong

🌍

ov

🌍

Kyle James

💻

Abhi Gulati

📖

Jeremy Tuloup

📖

Luis Morales-Navarro

️️️️♿️

Yuki

🌍

cedarfall

📖

Isaac Durazo

🌍

İsmail Namdar

💻 ⚠️

skyperx

💻

Joseph Aronson

💻 🐛

Haider Ali Punjabi

💻

Swapnil-2001

📖

Takuma Kira

🐛 💻 ⚠️

Mohammad Hussain Nagaria

🐛

Tushar Choudhari

📖 💻

Nakul Shahdadpuri

💻

Jacques P. du Toit

💻

surajsurajsuraj

🐛

Connie Liu

💻 🎨

Zeke Sikelianos

📖

Ramon Jr. Yniguez

💻

Benoît Bouré

📖

Hitesh Kumar

💻

Sampo Rapeli

💡

Nick Müller

🔌

Keith Tan

📖

Berke Özgen

🐛

Musab Kılıç

💻 ⚠️

Nicholas Marino

📖

Greg Sadetsky

💻

Priya-Pathak

💡

Daniel Michel

💻

Nisar Hassan Naqvi

💻

Joshua Noble

📖

Liam Piesley

💻

Rishabh Taparia

💻 📖

Daniel Sarno

💡

Kunal Kumar Verma

📖 🐛 💻

Bharath Kumar R

💻

Aditya Mohan

💻

Arijit Kundu

🐛 💻 📖

Tanner Dolby

💻

sam delong

💻

Zhao Xin

💻 👀

Sivaram D

📖

Pragya

💻
- + + Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key))! From a6ac09cd8895f457eb74dd4ca48ef4d60942fbd7 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 6 Jan 2021 10:55:29 +0000 Subject: [PATCH 72/97] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 5d79ec4320..15d3528263 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2337,6 +2337,15 @@ "contributions": [ "doc" ] + }, + { + "login": "frappelatte28", + "name": "Pragya", + "avatar_url": "https://avatars0.githubusercontent.com/u/64382399?v=4", + "profile": "https://github.com/frappelatte28", + "contributions": [ + "code" + ] } ], "repoType": "github", From 8d7a063adaf01a8ba87b5447550fec4e25d646b0 Mon Sep 17 00:00:00 2001 From: limzykenneth Date: Thu, 7 Jan 2021 12:45:47 +0000 Subject: [PATCH 73/97] Fix typo in color toString method --- src/color/p5.Color.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/color/p5.Color.js b/src/color/p5.Color.js index 8832386db8..6eda86a0c1 100644 --- a/src/color/p5.Color.js +++ b/src/color/p5.Color.js @@ -104,7 +104,7 @@ p5.Color.prototype.toString = function(format) { a[0] < 16 ? '0'.concat(a[0].toString(16)) : a[0].toString(16), a[1] < 16 ? '0'.concat(a[1].toString(16)) : a[1].toString(16), a[2] < 16 ? '0'.concat(a[2].toString(16)) : a[2].toString(16), - a[3] < 16 ? '0'.concat(a[2].toString(16)) : a[3].toString(16) + a[3] < 16 ? '0'.concat(a[3].toString(16)) : a[3].toString(16) ); case '#rgb': From 426b6935a789f94cfaf709f55b5b4dbf73459be7 Mon Sep 17 00:00:00 2001 From: Sivaram D Date: Sat, 9 Jan 2021 08:45:55 +0530 Subject: [PATCH 74/97] Update .all-contributorsrc updating my info for code contribution. (for #4972 ) --- .all-contributorsrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 15d3528263..653b8b2202 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2335,7 +2335,8 @@ "avatar_url": "https://avatars3.githubusercontent.com/u/56887198?v=4", "profile": "https://github.com/siv2r", "contributions": [ - "doc" + "doc", + "code" ] }, { From 18dbd51ae8b35f271521b208b7bc40f6b20795e3 Mon Sep 17 00:00:00 2001 From: Wes Lord Date: Sun, 17 Jan 2021 06:05:58 -0800 Subject: [PATCH 75/97] Make p5.Vector.mag() comments consistent with others --- src/math/p5.Vector.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/math/p5.Vector.js b/src/math/p5.Vector.js index 7a0c6fbb89..574bc5c74e 100644 --- a/src/math/p5.Vector.js +++ b/src/math/p5.Vector.js @@ -2303,11 +2303,15 @@ p5.Vector.lerp = function lerp(v1, v2, amt, target) { return target; }; +/** + * Calculates the magnitude (length) of the vector and returns the result as + * a float (this is simply the equation sqrt(x\*x + y\*y + z\*z).) + */ /** * @method mag + * @static * @param {p5.Vector} vecT the vector to return the magnitude of * @return {Number} the magnitude of vecT - * @static */ p5.Vector.mag = function mag(vecT) { const x = vecT.x, From 3d34b2e92c6a46ca5bf27c626e8c507cb2612acc Mon Sep 17 00:00:00 2001 From: weslord Date: Tue, 13 Oct 2020 04:13:52 -0700 Subject: [PATCH 76/97] Add static version of Vector.normalize() --- src/math/p5.Vector.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/math/p5.Vector.js b/src/math/p5.Vector.js index 574bc5c74e..f7ac8bc1b4 100644 --- a/src/math/p5.Vector.js +++ b/src/math/p5.Vector.js @@ -1213,6 +1213,20 @@ p5.Vector.prototype.dist = function dist(v) { * // [0.4454354, 0.8908708, 0.089087084] *
*
+ * + *
+ * + * // Static method + * let v_initial = createVector(10, 20, 2); + * // v_initial has components [10.0, 20.0, 2.0] + * let v_normalized = p5.Vector.normalize(v_initial); + * print(v_normalized); + * // returns a new vector with components set to + * // [0.4454354, 0.8908708, 0.089087084] + * // v_initial remains unchanged + * + *
+ * *
* * function draw() { @@ -2321,4 +2335,29 @@ p5.Vector.mag = function mag(vecT) { return Math.sqrt(magSq); }; +/** + * Normalize the vector to length 1 (make it a unit vector). + */ +/** + * @method normalize + * @static + * @param {p5.Vector} v the vector to normalize + * @param {p5.Vector} [target] the vector to receive the result (Optional) + * @return {p5.Vector} v normalized to a length of 1 + */ +p5.Vector.normalize = function normalize(v, target) { + if (arguments.length < 2) { + target = v.copy(); + } else { + if (!(target instanceof p5.Vector)) { + p5._friendlyError( + 'The target parameter should be of type p5.Vector', + 'p5.Vector.normalize' + ); + } + target.set(v); + } + return target.normalize(); +}; + export default p5.Vector; From 4143134937cd8d177f54850cc97e01625506049e Mon Sep 17 00:00:00 2001 From: Wes Lord Date: Sat, 2 Jan 2021 21:34:40 -0800 Subject: [PATCH 77/97] Add tests for p5.Vector.normalize() --- test/unit/math/p5.Vector.js | 54 ++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/test/unit/math/p5.Vector.js b/test/unit/math/p5.Vector.js index 2f2d3339f7..7c317c4822 100644 --- a/test/unit/math/p5.Vector.js +++ b/test/unit/math/p5.Vector.js @@ -868,18 +868,16 @@ suite('p5.Vector', function() { }); suite('normalize', function() { - setup(function() { - v.x = 1; - v.y = 1; - v.z = 1; - }); + suite('v.normalize()', function() { + setup(function() { + v = myp5.createVector(1, 1, 1); + }); - test('should return the same object', function() { - expect(v.normalize()).to.eql(v); - }); + test('should return the same object', function() { + expect(v.normalize()).to.eql(v); + }); - suite('with unit vector', function() { - test('should not change the vector', function() { + test('unit vector should not change values', function() { v.x = 1; v.y = 0; v.z = 0; @@ -888,10 +886,8 @@ suite('p5.Vector', function() { expect(v.y).to.eql(0); expect(v.z).to.eql(0); }); - }); - suite('with 2,2,1', function() { - test('should normalize to 0.66,0.66,0.33', function() { + test('2,2,1 should normalize to ~0.66,0.66,0.33', function() { v.x = 2; v.y = 2; v.z = 1; @@ -901,6 +897,38 @@ suite('p5.Vector', function() { expect(v.z).to.be.closeTo(0.3333, 0.01); }); }); + + suite('p5.Vector.normalize(v)', function() { + var res; + setup(function() { + v = myp5.createVector(1, 0, 0); + res = p5.Vector.normalize(v); + }); + + test('should not be undefined', function() { + expect(res).to.not.eql(undefined); + }); + + test('should not return same object v', function() { + expect(res).to.not.equal(v); + }); + + test('unit vector 1,0,0 should normalize to 1,0,0', function() { + expect(res.x).to.eql(1); + expect(res.y).to.eql(0); + expect(res.z).to.eql(0); + }); + + test('2,2,1 should normalize to ~0.66,0.66,0.33', function() { + v.x = 2; + v.y = 2; + v.z = 1; + res = p5.Vector.normalize(v); + expect(res.x).to.be.closeTo(0.6666, 0.01); + expect(res.y).to.be.closeTo(0.6666, 0.01); + expect(res.z).to.be.closeTo(0.3333, 0.01); + }); + }); }); suite('limit', function() { From 4b146e40ac53749660885714eabd3af0ed091ba0 Mon Sep 17 00:00:00 2001 From: Roshan Choxi Date: Mon, 18 Jan 2021 14:42:39 -0600 Subject: [PATCH 78/97] Fixes offscreen rendering bug - p5.Graphics wraps the renderer but doesn't initialize `accessibleOutputs` property - This moves the `accessibleOutputs` initialize into `initializeInstanceVariables` since that's applied on the default renderer and p5.Graphics --- src/core/main.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/main.js b/src/core/main.js index cebb712d59..fd5b1ad0a4 100644 --- a/src/core/main.js +++ b/src/core/main.js @@ -166,12 +166,6 @@ class p5 { // PRIVATE p5 PROPERTIES AND METHODS ////////////////////////////////////////////// - this._accessibleOutputs = { - text: false, - grid: false, - textLabel: false, - gridLabel: false - }; this._setupDone = false; // for handling hidpi this._pixelDensity = Math.ceil(window.devicePixelRatio) || 1; @@ -583,6 +577,13 @@ class p5 { } _initializeInstanceVariables() { + this._accessibleOutputs = { + text: false, + grid: false, + textLabel: false, + gridLabel: false + }; + this._styles = []; this._bezierDetail = 20; From 5b16ce013ffa3b1be9b77a3be0cf38ac2f8c5ce2 Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Fri, 22 Jan 2021 13:42:47 -0500 Subject: [PATCH 79/97] Add self as steward --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cc5e90b196..bd80c7d97d 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ Anyone interested can volunteer to be a steward! There are no specific requireme * [@lmccart](https://github.com/lmccart) * [@outofambit](https://github.com/outofambit) * [@limzykenneth](https://github.com/limzykenneth) +* [stalgiag](https://github.com/stalgiag) | Area | Steward(s) | | :-------------------------------- | :------------------------------------------- | @@ -67,12 +68,12 @@ Anyone interested can volunteer to be a steward! There are no specific requireme | Data | | | DOM | outofambit | | Events | outofambit
limzykenneth | -| Image | | +| Image | stalgiag | | IO | limzykenneth | | Math | limzykenneth | | Typography | | | Utilities | | -| WebGL | | +| WebGL | stalgiag | | Build Process/Unit Testing | outofambit | | Localization Tools | outofambit | | Friendly Errors | outofambit | From 4218dd102908cde23be03883e840dbb008b97386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?aar=C3=B3n=20montoya-moraga?= Date: Sat, 23 Jan 2021 13:29:48 -0500 Subject: [PATCH 80/97] added myself as steward also added the @ to stalgiag :) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bd80c7d97d..cd017ac491 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,8 @@ Anyone interested can volunteer to be a steward! There are no specific requireme * [@lmccart](https://github.com/lmccart) * [@outofambit](https://github.com/outofambit) * [@limzykenneth](https://github.com/limzykenneth) -* [stalgiag](https://github.com/stalgiag) +* [@stalgiag](https://github.com/stalgiag) +* [@montoyamoraga](https://github.com/montoyamoraga) | Area | Steward(s) | | :-------------------------------- | :------------------------------------------- | From ae90c376b73e7c94f9c29c5c8381d4c4feac407b Mon Sep 17 00:00:00 2001 From: hdcola Date: Mon, 25 Jan 2021 18:31:49 -0500 Subject: [PATCH 81/97] translation into Chinese --- .../zh/contributing_documentation.md | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 contributor_docs/zh/contributing_documentation.md diff --git a/contributor_docs/zh/contributing_documentation.md b/contributor_docs/zh/contributing_documentation.md new file mode 100644 index 0000000000..2b816a66b1 --- /dev/null +++ b/contributor_docs/zh/contributing_documentation.md @@ -0,0 +1,36 @@ +文档对于新的学习者和有经验的程序员来说都是必不可少的。它通过向那些不太熟悉p5.js的人伸出友好之手,帮助我们的社区变得更包容。它还能帮助我们找到代码本身的bug和问题,因为我们在文档中测试和尝试一些东西。 + +有几种方法可以为文档做出贡献: + +## ☝️ Open issues +如果你刚刚开始,一个非常有帮助的方式是通过打开文档需求的问题。如果你注意到一个错别字、一个缺失或损坏的例子、或者一个令人困惑的函数描述,[为它打开一个 issue](https://github.com/processing/p5.js/issues)!请附上需要修复的页面的链接,以便我们可以很容易地找到。 + +## 🗯 为参考资料作出贡献 +仔细阅读[参考文献](http://p5js.org/reference/),看看是否有错别字、损坏的例子或混乱的文档。如果是哪就直接修复,请继续努力。如果是需要讨论的问题,请创建一个 [issue](https://github.com/processing/p5.js/issues/new)。 +* 这里是[为初次使用p5.js代码库进行设置](./README.md)的说明。 +* 参考文献是根据源代码中的内联文档(在`src/`文件夹中找到)建立的。 +* 这里是关于[如何更新或添加内联文档和例子](./inline_documentation.md)的信息。 +* 如果你发现[西班牙语文档](http://p5js.org/es)有错误,有更新说明[这里](https://github.com/processing/p5.js-website#internationalization-i18n-and-structure)。 +* 社区维护的Typescript定义在[此处](https://github.com/p5-types/p5.ts)。 + +## ✨ 制作示例 +虽然参考文的例子是为了非常简单的代码片段,但有更长、更复杂的示例也是有用的。 +* 目前我们正在努力将[processing示例页](https://processing.org/examples/)中的示例移植到[p5.js示例页](http://p5js.org/examples)。如果你愿意帮忙,请看说明[这里](https://github.com/processing/p5.js-website/blob/main/contributor_docs/Adding_examples.md)。 +* 或者,你可以创建你自己的示例,并在你喜欢的地方独立发布。如果你在网上分享它们,请标记[@p5xjs](https://twitter.com/p5xjs)或发送电子邮件到[hello@p5js.org](mailto:hello@p5js.org)让我们知道,我们将广泛分享! 这个[嵌入p5.js指南](https://github.com/processing/p5.js/wiki/Embedding-p5.js)可能对你在网上发布你的示例很有用。 +* 如果你发现p5.js中的bug,请在[issues](https://github.com/processing/p5.js/issues)中记录下来。 + +## 👯 制作教程 +* 如果你是p5.js的新手,这是一个很好的开始。试着自己做一些东西,然后做一个教程来教别人做。 +* 目前,我们正在努力将教程从[processing教程页](https://processing.org/tutorials)移植到[p5.js学习页](http://p5js.org/learn)。如果你愿意帮忙,请看教程的制作教程[这里](https://p5js.org/learn/tutorial-guide.html)。 +* 我们也欢迎不同主题的教程。你可以在任何地方,以任何格式发布这些教程。如果您在网上分享这些教程,请给[@p5xjs](https://twitter.com/p5xjs)打上标签,或者给[hello@p5js.org](mailto:hello@p5js.org)发邮件,让我们知道,我们会广泛地分享这些教程。我们特别鼓励针对特定受众或使用案例创建的教程(例如:记者、活动家、诗人、孩子、老人、梦想家、不同语言的p5等等)。我们喜欢考虑,谁还没有感觉到自己在p5社区中受到欢迎或融入,我们能否把学习作为一种邀请?你用什么语言和你的听众沟通,让他们感到被了解?请自由尝试你的形式。可以参考[Sharon De La Cruz关于代码俚语的演讲](https://www.youtube.com/watch?v=CFT6w9NKfCs)获得灵感。 +* 如果你发现p5.js中的bug,请在[issues](https://github.com/processing/p5.js/issues)中记录下来。 + +## 👉 开始 +* 阅读[p5.js社区声明](http://p5js.org/community/) +* 可选:查看[贡献者文档](./README.md)以了解版本库的概况,并学习如何构建代码(如果与你相关的话)。 +* 所有的讨论都发生在github issue上,所以你不需要加入slack/gitter/等等频道。 +* 在readme.md文件中把你的名字加入[贡献者名单](https://github.com/processing/p5.js#contributors)! 说明[在此](https://github.com/processing/p5.js/issues/2309)。 +* 当然,如果你更喜欢修复bug,可以随时跳进任何一个[issue](https://github.com/processing/p5.js/issues)! + +欢迎!我们很高兴你在这里! +❤️ p5.js社区 From 46b7e950394db2807dafd42c1a94e62df9600161 Mon Sep 17 00:00:00 2001 From: PandaBalls <13515613@qq.com> Date: Tue, 26 Jan 2021 16:32:56 +0800 Subject: [PATCH 82/97] fix saveTable() issue fixed #5006 --- src/io/files.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/io/files.js b/src/io/files.js index 59649e370d..6f56238092 100644 --- a/src/io/files.js +++ b/src/io/files.js @@ -1727,14 +1727,14 @@ p5.prototype.saveTable = function(table, filename, options) { for (j = 0; j < table.rows[i].arr.length; j++) { if (j < table.rows[i].arr.length - 1) { //double quotes should be inserted in csv only if contains comma separated single value - if (ext === 'csv' && table.rows[i].arr[j].includes(',')) { + if (ext === 'csv' && String(table.rows[i].arr[j]).includes(',')) { pWriter.write('"' + table.rows[i].arr[j] + '"' + sep); } else { pWriter.write(table.rows[i].arr[j] + sep); } } else { //double quotes should be inserted in csv only if contains comma separated single value - if (ext === 'csv' && table.rows[i].arr[j].includes(',')) { + if (ext === 'csv' && String(table.rows[i].arr[j]).includes(',')) { pWriter.write('"' + table.rows[i].arr[j] + '"'); } else { pWriter.write(table.rows[i].arr[j]); From 2b6302d2fd193d16da29ebf85eaab602f99f6341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan-David=20Schr=C3=B6der?= Date: Thu, 28 Jan 2021 21:13:21 +0100 Subject: [PATCH 83/97] #4866 V texture coordinate inversion on OBJ loadModel Testing this as WebGL requires a flipped/inverted V texture coordinate --- src/webgl/loading.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/webgl/loading.js b/src/webgl/loading.js index 413ebf972d..78e19145c2 100755 --- a/src/webgl/loading.js +++ b/src/webgl/loading.js @@ -222,8 +222,10 @@ function parseObj(model, lines) { loadedVerts[tokens[0]].push(vertex); } else if (tokens[0] === 'vt') { // Check if this line describes a texture coordinate. - // It will have two numeric parameters. - const texVertex = [parseFloat(tokens[1]), parseFloat(tokens[2])]; + // It will have two numeric parameters U and V (W is omitted). + // Because of WebGL texture coordinates rendering behaviour, the V + // coordinate is inversed. + const texVertex = [parseFloat(tokens[1]), 1 - parseFloat(tokens[2])]; loadedVerts[tokens[0]].push(texVertex); } else if (tokens[0] === 'f') { // Check if this line describes a face. From 01b5f7b0adc6b7e09c454e59e5446f6177e1307a Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 29 Jan 2021 13:41:06 +0000 Subject: [PATCH 84/97] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cd017ac491..cdde864b50 100644 --- a/README.md +++ b/README.md @@ -460,8 +460,9 @@ We recognize all types of contributions. This project follows the [all-contribut
sam delong

💻
Zhao Xin

💻 👀 -
Sivaram D

📖 +
Sivaram D

📖 💻
Pragya

💻 +
Jonathan-David Schröder

🤔 💻 From a4e7cf52a254a2c885cbaf55c18131c48e7cfe91 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 29 Jan 2021 13:41:07 +0000 Subject: [PATCH 85/97] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 653b8b2202..dcc044dc89 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2347,6 +2347,16 @@ "contributions": [ "code" ] + }, + { + "login": "myselfhimself", + "name": "Jonathan-David Schröder", + "avatar_url": "https://avatars.githubusercontent.com/u/1265346?v=4", + "profile": "https://github.com/myselfhimself", + "contributions": [ + "ideas", + "code" + ] } ], "repoType": "github", From 0002ceb1b235b465082ed4e0080c15a5fed97f1f Mon Sep 17 00:00:00 2001 From: Shubham Kumar Date: Mon, 1 Feb 2021 20:30:29 +0530 Subject: [PATCH 86/97] Changed frameInfo.delay value whent it is equal to 0 --- src/image/loading_displaying.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/image/loading_displaying.js b/src/image/loading_displaying.js index 9f80ff8721..86a63550cc 100644 --- a/src/image/loading_displaying.js +++ b/src/image/loading_displaying.js @@ -193,9 +193,13 @@ function _createGif( loadGIFFrameIntoImage(j, gifReader); const imageData = new ImageData(framePixels, pImg.width, pImg.height); pImg.drawingContext.putImageData(imageData, 0, 0); + let frameDelay = frameInfo.delay; + if (frameDelay === 0) { + frameDelay = 10; + } frames.push({ image: pImg.drawingContext.getImageData(0, 0, pImg.width, pImg.height), - delay: frameInfo.delay * 10 //GIF stores delay in one-hundredth of a second, shift to ms + delay: frameDelay * 10 //GIF stores delay in one-hundredth of a second, shift to ms }); } From b933baf2609043bb655af1c76b7deb4c546c39c5 Mon Sep 17 00:00:00 2001 From: Shubham Kumar <47415702+ShenpaiSharma@users.noreply.github.com> Date: Tue, 2 Feb 2021 09:39:23 +0530 Subject: [PATCH 87/97] Added comment to explain default 10FPS --- src/image/loading_displaying.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/image/loading_displaying.js b/src/image/loading_displaying.js index 86a63550cc..86f705857e 100644 --- a/src/image/loading_displaying.js +++ b/src/image/loading_displaying.js @@ -194,6 +194,7 @@ function _createGif( const imageData = new ImageData(framePixels, pImg.width, pImg.height); pImg.drawingContext.putImageData(imageData, 0, 0); let frameDelay = frameInfo.delay; + // To maintain the default of 10FPS when frameInfo.delay equals to 0 if (frameDelay === 0) { frameDelay = 10; } From 5c50ff7cc26fc749f4c04396455a8d0d88a330ca Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 2 Feb 2021 15:27:41 +0000 Subject: [PATCH 88/97] docs: update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cdde864b50..4d7b45551f 100644 --- a/README.md +++ b/README.md @@ -463,6 +463,7 @@ We recognize all types of contributions. This project follows the [all-contribut
Sivaram D

📖 💻
Pragya

💻
Jonathan-David Schröder

🤔 💻 +
Shubham Kumar

💻 From cefcfab3fb901a63521e7c4a9caa9d8b0e5f0b5e Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 2 Feb 2021 15:27:42 +0000 Subject: [PATCH 89/97] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index dcc044dc89..058219ddeb 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2357,6 +2357,15 @@ "ideas", "code" ] + }, + { + "login": "ShenpaiSharma", + "name": "Shubham Kumar", + "avatar_url": "https://avatars.githubusercontent.com/u/47415702?v=4", + "profile": "https://github.com/ShenpaiSharma", + "contributions": [ + "code" + ] } ], "repoType": "github", From e248e413d1c49f7b8a30a82e7126a6cd178d83b5 Mon Sep 17 00:00:00 2001 From: Jean Pierre Charalambos Date: Tue, 2 Feb 2021 20:00:58 -0500 Subject: [PATCH 90/97] Update .all-contributorsrc --- .all-contributorsrc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 058219ddeb..e1af226926 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2366,7 +2366,18 @@ "contributions": [ "code" ] - } + }, + { + "login": "nakednous", + "name": "Jean Pierre Charalambos", + "avatar_url": "https://avatars.githubusercontent.com/nakednous", + "profile": "https://github.com/nakednous", + "contributions": [ + "code", + "tool", + "tool" + ] + }, ], "repoType": "github", "repoHost": "https://github.com", From a8abe642686fb7924f35bf66d83620884f71f0ac Mon Sep 17 00:00:00 2001 From: Prateek Jain Date: Wed, 3 Feb 2021 19:12:43 +0530 Subject: [PATCH 91/97] Update unit_testing.md Changed `isKeyPressed` to `keyIsPressed` --- contributor_docs/unit_testing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contributor_docs/unit_testing.md b/contributor_docs/unit_testing.md index 442a4c4506..e060752fa6 100644 --- a/contributor_docs/unit_testing.md +++ b/contributor_docs/unit_testing.md @@ -78,7 +78,7 @@ If you have to add a test file for a module to `test/unit`, then you'll also nee ### Writing Unit Tests -Pick a unit, it can be a method or a variable to test. Lets use `p5.prototype.isKeyPressed` as an example. Before beginning to write tests, we need to understand the expected behaviour of this method. +Pick a unit, it can be a method or a variable to test. Lets use `p5.prototype.keyIsPressed` as an example. Before beginning to write tests, we need to understand the expected behaviour of this method. **Expected behaviour:** The boolean system variable should be true if any key is pressed and false if no keys are pressed. Now you can think of various tests against this expected behaviour. Possible test cases could be: @@ -89,7 +89,7 @@ Now you can think of various tests against this expected behaviour. Possible tes - it should be false if no keys are pressed - if you can think of more, go ahead and add tests for them! -We can create a test suite for `p5.prototype.isKeyPressed` and start creating tests for it. We will use mocha for structuring our unit tests. +We can create a test suite for `p5.prototype.keyIsPressed` and start creating tests for it. We will use mocha for structuring our unit tests. ``` suite('p5.prototype.keyIsPressed', function() { From 4f878bcfe62ff44dd2c8171460a767c0d9e67387 Mon Sep 17 00:00:00 2001 From: limzykenneth Date: Wed, 3 Feb 2021 14:32:59 +0000 Subject: [PATCH 92/97] Edit Chinese translation of contributor documentation --- contributor_docs/zh/contributing_documentation.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contributor_docs/zh/contributing_documentation.md b/contributor_docs/zh/contributing_documentation.md index 2b816a66b1..0eb9bfcc4a 100644 --- a/contributor_docs/zh/contributing_documentation.md +++ b/contributor_docs/zh/contributing_documentation.md @@ -6,23 +6,23 @@ 如果你刚刚开始,一个非常有帮助的方式是通过打开文档需求的问题。如果你注意到一个错别字、一个缺失或损坏的例子、或者一个令人困惑的函数描述,[为它打开一个 issue](https://github.com/processing/p5.js/issues)!请附上需要修复的页面的链接,以便我们可以很容易地找到。 ## 🗯 为参考资料作出贡献 -仔细阅读[参考文献](http://p5js.org/reference/),看看是否有错别字、损坏的例子或混乱的文档。如果是哪就直接修复,请继续努力。如果是需要讨论的问题,请创建一个 [issue](https://github.com/processing/p5.js/issues/new)。 +仔细阅读[参考文献](http://p5js.org/reference/),看看是否有错别字、损坏的例子或混乱的文档。如果是简单的修复,您可以直接修改。如果是需要讨论的问题,请创建一个 [issue](https://github.com/processing/p5.js/issues/new)。 * 这里是[为初次使用p5.js代码库进行设置](./README.md)的说明。 * 参考文献是根据源代码中的内联文档(在`src/`文件夹中找到)建立的。 * 这里是关于[如何更新或添加内联文档和例子](./inline_documentation.md)的信息。 -* 如果你发现[西班牙语文档](http://p5js.org/es)有错误,有更新说明[这里](https://github.com/processing/p5.js-website#internationalization-i18n-and-structure)。 +* 如果你发现[西班牙语文档](http://p5js.org/es)有错误,在[这里](https://github.com/processing/p5.js-website#internationalization-i18n-and-structure)能找到更新指示。 * 社区维护的Typescript定义在[此处](https://github.com/p5-types/p5.ts)。 -## ✨ 制作示例 -虽然参考文的例子是为了非常简单的代码片段,但有更长、更复杂的示例也是有用的。 +## ✨ 制作示例 +虽然参考文的例子通常是非常简单的代码片段,但更长、更复杂的示例也是有用的。 * 目前我们正在努力将[processing示例页](https://processing.org/examples/)中的示例移植到[p5.js示例页](http://p5js.org/examples)。如果你愿意帮忙,请看说明[这里](https://github.com/processing/p5.js-website/blob/main/contributor_docs/Adding_examples.md)。 * 或者,你可以创建你自己的示例,并在你喜欢的地方独立发布。如果你在网上分享它们,请标记[@p5xjs](https://twitter.com/p5xjs)或发送电子邮件到[hello@p5js.org](mailto:hello@p5js.org)让我们知道,我们将广泛分享! 这个[嵌入p5.js指南](https://github.com/processing/p5.js/wiki/Embedding-p5.js)可能对你在网上发布你的示例很有用。 * 如果你发现p5.js中的bug,请在[issues](https://github.com/processing/p5.js/issues)中记录下来。 ## 👯 制作教程 -* 如果你是p5.js的新手,这是一个很好的开始。试着自己做一些东西,然后做一个教程来教别人做。 -* 目前,我们正在努力将教程从[processing教程页](https://processing.org/tutorials)移植到[p5.js学习页](http://p5js.org/learn)。如果你愿意帮忙,请看教程的制作教程[这里](https://p5js.org/learn/tutorial-guide.html)。 -* 我们也欢迎不同主题的教程。你可以在任何地方,以任何格式发布这些教程。如果您在网上分享这些教程,请给[@p5xjs](https://twitter.com/p5xjs)打上标签,或者给[hello@p5js.org](mailto:hello@p5js.org)发邮件,让我们知道,我们会广泛地分享这些教程。我们特别鼓励针对特定受众或使用案例创建的教程(例如:记者、活动家、诗人、孩子、老人、梦想家、不同语言的p5等等)。我们喜欢考虑,谁还没有感觉到自己在p5社区中受到欢迎或融入,我们能否把学习作为一种邀请?你用什么语言和你的听众沟通,让他们感到被了解?请自由尝试你的形式。可以参考[Sharon De La Cruz关于代码俚语的演讲](https://www.youtube.com/watch?v=CFT6w9NKfCs)获得灵感。 +* 如果你是p5.js的新手,这是一个很好开始的地方。试着自己做一些东西,然后做一个教程来教别人做。 +* 目前,我们正在努力将教程从[processing教程页](https://processing.org/tutorials)移植到[p5.js学习页](http://p5js.org/learn)。如果你愿意帮忙,请看[这个](https://p5js.org/learn/tutorial-guide.html)教程制作教程。 +* 我们也欢迎不同主题的教程。你可以在任何地方,以任何格式发布这些教程。如果您在网上分享这些教程,请给[@p5xjs](https://twitter.com/p5xjs)打上标签,或者给[hello@p5js.org](mailto:hello@p5js.org)发邮件,让我们知道,我们会广泛地分享这些教程。我们特别鼓励针对特定受众或使用案例创建的教程(例如:记者、维权人士、诗人、孩子、老人、梦想家、不同语言的p5等等)。我们喜欢考虑,谁还没有感觉到自己在p5社区中受到欢迎或融入,我们能否把学习作为一种邀请?你用什么语言和你的听众沟通,让他们感到被了解?请自由尝试你的形式。可以参考[Sharon De La Cruz关于代码俚语的演讲](https://www.youtube.com/watch?v=CFT6w9NKfCs)获得灵感。 * 如果你发现p5.js中的bug,请在[issues](https://github.com/processing/p5.js/issues)中记录下来。 ## 👉 开始 From eb9b15a46dd2bd3c0e1396ec58c0cfdab6c52d93 Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Sat, 6 Feb 2021 10:54:23 -0500 Subject: [PATCH 93/97] Fixed link to Mozilla JS practices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Link that was originally there led to a landing page with a new link – updated! :) --- contributor_docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributor_docs/README.md b/contributor_docs/README.md index 89161205b5..954c5c4188 100644 --- a/contributor_docs/README.md +++ b/contributor_docs/README.md @@ -149,7 +149,7 @@ Here is a quick summary of code style rules. Please note that this list may be i * Comment your code whenever there is ambiguity or complexity in the function you are writing -* See the [Mozilla JS practices](https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#JavaScript_practices) as a useful guide for more styling tips +* See the [Mozilla JS practices](https://firefox-source-docs.mozilla.org/code-quality/coding-style/index.html) as a useful guide for more styling tips From a82557a644baa10e76a56f1f20826dd8f8f3ba61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?aar=C3=B3n=20montoya-moraga?= Date: Fri, 12 Feb 2021 14:23:47 -0500 Subject: [PATCH 94/97] delete comma to fix it --- .all-contributorsrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index e1af226926..c3ac9ea475 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2377,7 +2377,7 @@ "tool", "tool" ] - }, + } ], "repoType": "github", "repoHost": "https://github.com", From 39fcd6e835d5f5fcdba48d6f93adaa9ace784a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?aar=C3=B3n=20montoya-moraga?= Date: Fri, 12 Feb 2021 14:25:01 -0500 Subject: [PATCH 95/97] delete duplicate "tool" and fix link to avatar --- .all-contributorsrc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index c3ac9ea475..435c65c585 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2370,11 +2370,10 @@ { "login": "nakednous", "name": "Jean Pierre Charalambos", - "avatar_url": "https://avatars.githubusercontent.com/nakednous", + "avatar_url": "https://avatars.githubusercontent.com/u/645599?&v=4", "profile": "https://github.com/nakednous", "contributions": [ "code", - "tool", "tool" ] } From b30e5c9adf210c2a0a439275b4fdff63d88e7293 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 12 Feb 2021 19:25:19 +0000 Subject: [PATCH 96/97] docs: update README.md [skip ci] --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 4d7b45551f..47ec6855c7 100644 --- a/README.md +++ b/README.md @@ -464,6 +464,10 @@ We recognize all types of contributions. This project follows the [all-contribut
Pragya

💻
Jonathan-David Schröder

🤔 💻
Shubham Kumar

💻 +
Jean Pierre Charalambos

💻 🔧 + + +
Sai Bhushan

💻 📖 From 60eeae836dc1b05c9be3ff393bcda082a9dff204 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 12 Feb 2021 19:25:20 +0000 Subject: [PATCH 97/97] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 435c65c585..be96df1aca 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2376,6 +2376,16 @@ "code", "tool" ] + }, + { + "login": "satyasaibhushan", + "name": "Sai Bhushan", + "avatar_url": "https://avatars.githubusercontent.com/u/40578313?v=4", + "profile": "https://github.com/satyasaibhushan", + "contributions": [ + "code", + "doc" + ] } ], "repoType": "github",