Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/color/color_conversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ p5.ColorConversion = {};
/**
* Convert an HSBA array to HSLA.
*/
p5.ColorConversion._hsbaToHSLA = hsba => {
p5.ColorConversion._hsbaToHSLA = function(hsba) {
const hue = hsba[0];
let sat = hsba[1];
const val = hsba[2];
Expand All @@ -45,7 +45,7 @@ p5.ColorConversion._hsbaToHSLA = hsba => {
/**
* Convert an HSBA array to RGBA.
*/
p5.ColorConversion._hsbaToRGBA = hsba => {
p5.ColorConversion._hsbaToRGBA = function(hsba) {
const hue = hsba[0] * 6; // We will split hue into 6 sectors.
const sat = hsba[1];
const val = hsba[2];
Expand Down Expand Up @@ -100,7 +100,7 @@ p5.ColorConversion._hsbaToRGBA = hsba => {
/**
* Convert an HSLA array to HSBA.
*/
p5.ColorConversion._hslaToHSBA = hsla => {
p5.ColorConversion._hslaToHSBA = function(hsla) {
const hue = hsla[0];
let sat = hsla[1];
const li = hsla[2];
Expand Down Expand Up @@ -128,7 +128,7 @@ p5.ColorConversion._hslaToHSBA = hsla => {
* components, and pick a convenient third one ('zest') so that we don't need
* to calculate formal HSBA saturation.
*/
p5.ColorConversion._hslaToRGBA = hsla => {
p5.ColorConversion._hslaToRGBA = function(hsla) {
const hue = hsla[0] * 6; // We will split hue into 6 sectors.
const sat = hsla[1];
const li = hsla[2];
Expand Down Expand Up @@ -187,7 +187,7 @@ p5.ColorConversion._hslaToRGBA = hsla => {
/**
* Convert an RGBA array to HSBA.
*/
p5.ColorConversion._rgbaToHSBA = rgba => {
p5.ColorConversion._rgbaToHSBA = function(rgba) {
const red = rgba[0];
const green = rgba[1];
const blue = rgba[2];
Expand Down Expand Up @@ -226,7 +226,7 @@ p5.ColorConversion._rgbaToHSBA = rgba => {
/**
* Convert an RGBA array to HSLA.
*/
p5.ColorConversion._rgbaToHSLA = rgba => {
p5.ColorConversion._rgbaToHSLA = function(rgba) {
const red = rgba[0];
const green = rgba[1];
const blue = rgba[2];
Expand Down
4 changes: 2 additions & 2 deletions src/core/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const _windowPrint = window.print;
* @alt
* default grey canvas
*/
p5.prototype.print = (...args) => {
p5.prototype.print = function(...args) {
if (!args.length) {
_windowPrint();
} else {
Expand Down Expand Up @@ -733,7 +733,7 @@ p5.prototype.getURLPath = () =>
* no display.
*
*/
p5.prototype.getURLParams = () => {
p5.prototype.getURLParams = function() {
const re = /[?&]([^&=]+)(?:[&=])([^&=]+)/gim;
let m;
const v = {};
Expand Down
8 changes: 4 additions & 4 deletions src/core/error_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
* @param {Number} errorType
* @param {String} filePath
*/
p5._friendlyFileLoadError = (errorType, filePath) => {
p5._friendlyFileLoadError = function(errorType, filePath) {
const errorInfo = fileLoadErrorCases[errorType];
let message;
if (errorType === 7 || errorType === 8) {
Expand All @@ -214,7 +214,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
* @param {Number} message message to be printed
* @param {String} method name of method
*/
p5._friendlyError = (message, method) => {
p5._friendlyError = function(message, method) {
report(message, method);
};

Expand All @@ -224,7 +224,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
* @method _friendlyAutoplayError
* @private
*/
p5._friendlyAutoplayError = src => {
p5._friendlyAutoplayError = function(src) {
report(
`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 https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide for more information about why.`,
'autoplay'
Expand Down Expand Up @@ -552,7 +552,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
})('ValidationError');

// function for generating console.log() msg
p5._friendlyParamError = (errorObj, func) => {
p5._friendlyParamError = function(errorObj, func) {
let message;

function formatType() {
Expand Down
10 changes: 5 additions & 5 deletions src/core/legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@

import p5 from './main';

p5.prototype.pushStyle = () => {
p5.prototype.pushStyle = function() {
throw new Error('pushStyle() not used, see push()');
};

p5.prototype.popStyle = () => {
p5.prototype.popStyle = function() {
throw new Error('popStyle() not used, see pop()');
};

p5.prototype.popMatrix = () => {
p5.prototype.popMatrix = function() {
throw new Error('popMatrix() not used, see pop()');
};

p5.prototype.printMatrix = () => {
p5.prototype.printMatrix = function() {
throw new Error(
'printMatrix() is not implemented in p5.js, ' +
'refer to [https://simonsarris.com/a-transformation-class-for-canvas-to-keep-track-of-the-transformation-matrix/] ' +
'to add your own implementation.'
);
};

p5.prototype.pushMatrix = () => {
p5.prototype.pushMatrix = function() {
throw new Error('pushMatrix() not used, see push()');
};

Expand Down
4 changes: 2 additions & 2 deletions src/core/p5.Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ p5.Element._adjustListener = function(ev, fxn, ctx) {
return this;
};

p5.Element._attachListener = (ev, fxn, ctx) => {
p5.Element._attachListener = function(ev, fxn, ctx) {
// detach the old listener if there was one
if (ctx._events[ev]) {
p5.Element._detachListener(ev, ctx);
Expand All @@ -846,7 +846,7 @@ p5.Element._attachListener = (ev, fxn, ctx) => {
ctx._events[ev] = f;
};

p5.Element._detachListener = (ev, ctx) => {
p5.Element._detachListener = function(ev, ctx) {
const f = ctx._events[ev];
ctx.elt.removeEventListener(ev, f, false);
ctx._events[ev] = null;
Expand Down
6 changes: 3 additions & 3 deletions src/data/local_storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import p5 from '../core/main';
* If you reload the page, the last letter typed is still displaying.
*
*/
p5.prototype.storeItem = (key, value) => {
p5.prototype.storeItem = function(key, value) {
if (typeof value === 'undefined') {
console.log('You cannot store undefined variables using storeItem()');
}
Expand Down Expand Up @@ -189,7 +189,7 @@ p5.prototype.getItem = function(key) {
* }
* </code></div>
*/
p5.prototype.clearStorage = () => {
p5.prototype.clearStorage = function() {
localStorage.clear();
};

Expand All @@ -213,7 +213,7 @@ p5.prototype.clearStorage = () => {
* }
* </code></div>
*/
p5.prototype.removeItem = key => {
p5.prototype.removeItem = function(key) {
if (typeof key !== 'string') {
console.log(
`The argument that you passed to removeItem() - ${key} is not a string.`
Expand Down
2 changes: 1 addition & 1 deletion src/events/mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ p5.prototype.requestPointerLock = function() {
* cursor gets locked / unlocked on mouse-click
*
*/
p5.prototype.exitPointerLock = () => {
p5.prototype.exitPointerLock = function() {
document.exitPointerLock();
};

Expand Down
26 changes: 13 additions & 13 deletions src/image/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Filters = {};
* the data in thc RGBA order, with integer
* values between 0 and 255
*/
Filters._toPixels = canvas => {
Filters._toPixels = function(canvas) {
if (canvas instanceof ImageData) {
return canvas.data;
} else {
Expand All @@ -52,7 +52,7 @@ Filters._toPixels = canvas => {
* @return {Integer} 32 bit integer value representing
* ARGB value.
*/
Filters._getARGB = (data, i) => {
Filters._getARGB = function(data, i) {
const offset = i * 4;
return (
((data[offset + 3] << 24) & 0xff000000) |
Expand All @@ -71,7 +71,7 @@ Filters._getARGB = (data, i) => {
* @param {Int32Array} data source 1D array where each value
* represents ARGB values
*/
Filters._setPixels = (pixels, data) => {
Filters._setPixels = function(pixels, data) {
let offset = 0;
for (let i = 0, al = pixels.length; i < al; i++) {
offset = i * 4;
Expand All @@ -92,7 +92,7 @@ Filters._setPixels = (pixels, data) => {
* @return {ImageData} Holder of pixel data (and width and
* height) for a canvas
*/
Filters._toImageData = canvas => {
Filters._toImageData = function(canvas) {
if (canvas instanceof ImageData) {
return canvas;
} else {
Expand Down Expand Up @@ -136,7 +136,7 @@ Filters._createImageData = function(width, height) {
* @param {function(ImageData,Object)} func [description]
* @param {Object} filterParam [description]
*/
Filters.apply = (canvas, func, filterParam) => {
Filters.apply = function(canvas, func, filterParam) {
const pixelsState = canvas.getContext('2d');
const imageData = pixelsState.getImageData(0, 0, canvas.width, canvas.height);

Expand Down Expand Up @@ -181,7 +181,7 @@ Filters.apply = (canvas, func, filterParam) => {
* @param {Canvas} canvas
* @param {Float} level
*/
Filters.threshold = (canvas, level) => {
Filters.threshold = function(canvas, level) {
const pixels = Filters._toPixels(canvas);

if (level === undefined) {
Expand Down Expand Up @@ -213,7 +213,7 @@ Filters.threshold = (canvas, level) => {
* @private
* @param {Canvas} canvas
*/
Filters.gray = canvas => {
Filters.gray = function(canvas) {
const pixels = Filters._toPixels(canvas);

for (let i = 0; i < pixels.length; i += 4) {
Expand All @@ -233,7 +233,7 @@ Filters.gray = canvas => {
* @private
* @param {Canvas} canvas
*/
Filters.opaque = canvas => {
Filters.opaque = function(canvas) {
const pixels = Filters._toPixels(canvas);

for (let i = 0; i < pixels.length; i += 4) {
Expand All @@ -248,7 +248,7 @@ Filters.opaque = canvas => {
* @private
* @param {Canvas} canvas
*/
Filters.invert = canvas => {
Filters.invert = function(canvas) {
const pixels = Filters._toPixels(canvas);

for (let i = 0; i < pixels.length; i += 4) {
Expand All @@ -269,7 +269,7 @@ Filters.invert = canvas => {
* @param {Canvas} canvas
* @param {Integer} level
*/
Filters.posterize = (canvas, level) => {
Filters.posterize = function(canvas, level) {
const pixels = Filters._toPixels(canvas);

if (level < 2 || level > 255) {
Expand All @@ -296,7 +296,7 @@ Filters.posterize = (canvas, level) => {
* @param {Canvas} canvas
*
*/
Filters.dilate = canvas => {
Filters.dilate = function(canvas) {
const pixels = Filters._toPixels(canvas);
let currIdx = 0;
const maxIdx = pixels.length ? pixels.length / 4 : 0;
Expand Down Expand Up @@ -384,7 +384,7 @@ Filters.dilate = canvas => {
* @param {Canvas} canvas
*
*/
Filters.erode = canvas => {
Filters.erode = function(canvas) {
const pixels = Filters._toPixels(canvas);
let currIdx = 0;
const maxIdx = pixels.length ? pixels.length / 4 : 0;
Expand Down Expand Up @@ -615,7 +615,7 @@ function blurARGB(canvas, radius) {
Filters._setPixels(pixels, argb);
}

Filters.blur = (canvas, radius) => {
Filters.blur = function(canvas, radius) {
blurARGB(canvas, radius);
};

Expand Down
2 changes: 1 addition & 1 deletion src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ p5.prototype.saveCanvas = function() {
}, mimeType);
};

p5.prototype.saveGif = (pImg, filename) => {
p5.prototype.saveGif = function(pImg, filename) {
const props = pImg.gifProperties;

//convert loopLimit back into Netscape Block formatting
Expand Down
8 changes: 4 additions & 4 deletions src/io/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ p5.prototype.httpPost = function() {
* @param {function} [errorCallback]
* @return {Promise}
*/
p5.prototype.httpDo = (...args) => {
p5.prototype.httpDo = function(...args) {
let type;
let callback;
let errorCallback;
Expand Down Expand Up @@ -1783,7 +1783,7 @@ p5.prototype.saveTable = function(table, filename, options) {
* @param {String} [extension]
* @private
*/
p5.prototype.writeFile = (dataToDownload, filename, extension) => {
p5.prototype.writeFile = function(dataToDownload, filename, extension) {
let type = 'application/octet-stream';
if (p5.prototype._isSafari()) {
type = 'text/plain';
Expand All @@ -1807,7 +1807,7 @@ p5.prototype.writeFile = (dataToDownload, filename, extension) => {
* @param {String} [filename]
* @param {String} [extension]
*/
p5.prototype.downloadFile = (data, fName, extension) => {
p5.prototype.downloadFile = function(data, fName, extension) {
const fx = _checkFileExtension(fName, extension);
const filename = fx[0];

Expand Down Expand Up @@ -1880,7 +1880,7 @@ p5.prototype._checkFileExtension = _checkFileExtension;
* @return {Boolean} [description]
* @private
*/
p5.prototype._isSafari = () => {
p5.prototype._isSafari = function() {
const x = Object.prototype.toString.call(window.HTMLElement);
return x.indexOf('Constructor') > 0;
};
Expand Down
8 changes: 4 additions & 4 deletions src/math/calculation.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ p5.prototype.constrain = function(n, low, high) {
* @param {Number} z2 z-coordinate of the second point
* @return {Number} distance between the two points
*/
p5.prototype.dist = (...args) => {
p5.prototype.dist = function(...args) {
p5._validateParameters('dist', args);
if (args.length === 4) {
//2D
Expand Down Expand Up @@ -510,7 +510,7 @@ p5.prototype.map = function(n, start1, stop1, start2, stop2, withinBounds) {
* @param {Number[]} nums Numbers to compare
* @return {Number}
*/
p5.prototype.max = (...args) => {
p5.prototype.max = function(...args) {
p5._validateParameters('max', args);
if (args[0] instanceof Array) {
return Math.max.apply(null, args[0]);
Expand Down Expand Up @@ -560,7 +560,7 @@ p5.prototype.max = (...args) => {
* @param {Number[]} nums Numbers to compare
* @return {Number}
*/
p5.prototype.min = (...args) => {
p5.prototype.min = function(...args) {
p5._validateParameters('min', args);
if (args[0] instanceof Array) {
return Math.min.apply(null, args[0]);
Expand Down Expand Up @@ -705,7 +705,7 @@ p5.prototype.pow = Math.pow;
* horizontal center line squared values displayed on top and regular on bottom.
*
*/
p5.prototype.round = (n, decimals) => {
p5.prototype.round = function(n, decimals) {
if (!decimals) {
return Math.round(n);
}
Expand Down
Loading