Skip to content

Commit 9ba2d64

Browse files
committed
revert merge with parameter validation issues
1 parent e98a609 commit 9ba2d64

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1199
-1250
lines changed

docs/parameterData.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@
374374
[
375375
"Number?",
376376
"Number?",
377-
"String?",
377+
"P2D|WEBGL?",
378378
"HTMLCanvasElement?"
379379
],
380380
[

src/accessibility/describe.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function describe(p5, fn){
118118
*/
119119

120120
fn.describe = function(text, display) {
121-
// p5._validateParameters('describe', arguments);
121+
p5._validateParameters('describe', arguments);
122122
if (typeof text !== 'string') {
123123
return;
124124
}
@@ -244,7 +244,7 @@ function describe(p5, fn){
244244
*/
245245

246246
fn.describeElement = function(name, text, display) {
247-
// p5._validateParameters('describeElement', arguments);
247+
p5._validateParameters('describeElement', arguments);
248248
if (typeof text !== 'string' || typeof name !== 'string') {
249249
return;
250250
}

src/accessibility/outputs.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function outputs(p5, fn){
122122
*/
123123

124124
fn.textOutput = function(display) {
125-
// p5._validateParameters('textOutput', arguments);
125+
p5._validateParameters('textOutput', arguments);
126126
//if textOutput is already true
127127
if (this._accessibleOutputs.text) {
128128
return;
@@ -257,7 +257,7 @@ function outputs(p5, fn){
257257
*/
258258

259259
fn.gridOutput = function(display) {
260-
// p5._validateParameters('gridOutput', arguments);
260+
p5._validateParameters('gridOutput', arguments);
261261
//if gridOutput is already true
262262
if (this._accessibleOutputs.grid) {
263263
return;

src/app.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// core
22
import p5 from './core/main';
3-
// import './core/friendly_errors/stacktrace';
4-
// import './core/friendly_errors/validate_params';
5-
// import './core/friendly_errors/file_errors';
6-
// import './core/friendly_errors/fes_core';
7-
// import './core/friendly_errors/sketch_reader';
3+
import './core/friendly_errors/stacktrace';
4+
import './core/friendly_errors/validate_params';
5+
import './core/friendly_errors/file_errors';
6+
import './core/friendly_errors/fes_core';
7+
import './core/friendly_errors/sketch_reader';
88
import shape from './shape';
99
shape(p5);
1010

@@ -61,8 +61,6 @@ webgl(p5);
6161
import type from './type'
6262
type(p5);
6363

64-
import { waitForDocumentReady, waitingForTranslator, _globalInit } from './core/init';
65-
Promise.all([waitForDocumentReady(), waitingForTranslator]).then(_globalInit);
64+
import './core/init';
6665

6766
export default p5;
68-

src/color/creating_reading.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ function creatingReading(p5, fn){
349349
* @return {p5.Color}
350350
*/
351351
fn.color = function(...args) {
352-
// p5._validateParameters('color', args);
352+
p5._validateParameters('color', args);
353353
if (args[0] instanceof Color) {
354354
// TODO: perhaps change color mode to match instance mode?
355355
return args[0]; // Do nothing if argument is already a color object.
@@ -495,7 +495,7 @@ function creatingReading(p5, fn){
495495
* </div>
496496
*/
497497
fn.red = function(c) {
498-
// p5._validateParameters('red', arguments);
498+
p5._validateParameters('red', arguments);
499499
// Get current red max
500500
return this.color(c)._getRed();
501501
};
@@ -632,7 +632,7 @@ function creatingReading(p5, fn){
632632
* </div>
633633
*/
634634
fn.green = function(c) {
635-
// p5._validateParameters('green', arguments);
635+
p5._validateParameters('green', arguments);
636636
// Get current green max
637637
return this.color(c)._getGreen();
638638
};
@@ -769,7 +769,7 @@ function creatingReading(p5, fn){
769769
* </div>
770770
*/
771771
fn.blue = function(c) {
772-
// p5._validateParameters('blue', arguments);
772+
p5._validateParameters('blue', arguments);
773773
// Get current blue max
774774
return this.color(c)._getBlue();
775775
};
@@ -871,7 +871,7 @@ function creatingReading(p5, fn){
871871
* </div>
872872
*/
873873
fn.alpha = function(c) {
874-
// p5._validateParameters('alpha', arguments);
874+
p5._validateParameters('alpha', arguments);
875875
// Get current alpha max
876876
return this.color(c)._getAlpha();
877877
};
@@ -993,7 +993,7 @@ function creatingReading(p5, fn){
993993
* </div>
994994
*/
995995
fn.hue = function(c) {
996-
// p5._validateParameters('hue', arguments);
996+
p5._validateParameters('hue', arguments);
997997
return this.color(c)._getHue();
998998
};
999999

@@ -1170,7 +1170,7 @@ function creatingReading(p5, fn){
11701170
* </div>
11711171
*/
11721172
fn.saturation = function(c) {
1173-
// p5._validateParameters('saturation', arguments);
1173+
p5._validateParameters('saturation', arguments);
11741174
return this.color(c)._getSaturation();
11751175
};
11761176

@@ -1315,7 +1315,7 @@ function creatingReading(p5, fn){
13151315
* </div>
13161316
*/
13171317
fn.brightness = function(c) {
1318-
// p5._validateParameters('brightness', arguments);
1318+
p5._validateParameters('brightness', arguments);
13191319
return this.color(c)._getBrightness();
13201320
};
13211321

@@ -1460,7 +1460,7 @@ function creatingReading(p5, fn){
14601460
* </div>
14611461
*/
14621462
fn.lightness = function(c) {
1463-
// p5._validateParameters('lightness', arguments);
1463+
p5._validateParameters('lightness', arguments);
14641464
return this.color(c)._getLightness();
14651465
};
14661466

@@ -1524,7 +1524,7 @@ function creatingReading(p5, fn){
15241524
* </div>
15251525
*/
15261526
fn.lerpColor = function(c1, c2, amt) {
1527-
// p5._validateParameters('lerpColor', arguments);
1527+
p5._validateParameters('lerpColor', arguments);
15281528
return c1.lerp(c2, amt, this._renderer.states.colorMode);
15291529
};
15301530
}

src/color/p5.Color.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Color {
8989
this._color = to(this._color, this._color.spaceId);
9090
}catch(err){
9191
// TODO: Invalid color string
92-
throw new Error('Invalid color string');
92+
console.error('Invalid color string');
9393
}
9494

9595
}else{
@@ -107,8 +107,6 @@ class Color {
107107
}else if(vals.length === 1){
108108
mappedVals = Color.mapColorRange([vals[0], vals[0], vals[0]], this.mode, colorMaxes);
109109
mappedVals.push(1);
110-
}else{
111-
throw new Error('Invalid color');
112110
}
113111
}else{
114112
mappedVals = vals;

src/color/setting.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ function setting(p5, fn){
949949
* @return {String} The current color mode.
950950
*/
951951
fn.colorMode = function(mode, max1, max2, max3, maxA) {
952-
// p5._validateParameters('colorMode', arguments);
952+
p5._validateParameters('colorMode', arguments);
953953
if (
954954
[
955955
RGB,
@@ -2184,7 +2184,7 @@ function setting(p5, fn){
21842184
* </div>
21852185
*/
21862186
fn.blendMode = function (mode) {
2187-
// p5._validateParameters('blendMode', arguments);
2187+
p5._validateParameters('blendMode', arguments);
21882188
if (mode === constants.NORMAL) {
21892189
// Warning added 3/26/19, can be deleted in future (1.0 release?)
21902190
console.warn(

src/core/constants.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const VERSION = 'VERSION_WILL_BE_REPLACED_BY_BUILD';
2020
* @property {P2D} P2D
2121
* @final
2222
*/
23-
export const P2D = 'p2d';
23+
export const P2D = Symbol('p2d');
2424

2525
export const P2DHDR = 'p2d-hdr';
2626

@@ -45,7 +45,7 @@ export const P2DHDR = 'p2d-hdr';
4545
* @property {WEBGL} WEBGL
4646
* @final
4747
*/
48-
export const WEBGL = 'webgl';
48+
export const WEBGL = Symbol('webgl');
4949
/**
5050
* One of the two possible values of a WebGL canvas (either WEBGL or WEBGL2),
5151
* which can be used to determine what capabilities the rendering environment
@@ -54,7 +54,7 @@ export const WEBGL = 'webgl';
5454
* @property {WEBGL2} WEBGL2
5555
* @final
5656
*/
57-
export const WEBGL2 = 'webgl2';
57+
export const WEBGL2 = Symbol('webgl2');
5858

5959
// ENVIRONMENT
6060
/**

src/core/environment.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ function environment(p5, fn){
407407
* @return {Number} current frame rate.
408408
*/
409409
fn.frameRate = function(fps) {
410-
// p5._validateParameters('frameRate', arguments);
410+
p5._validateParameters('frameRate', arguments);
411411
if (typeof fps !== 'number' || fps < 0) {
412412
return this._frameRate;
413413
} else {
@@ -992,7 +992,7 @@ function environment(p5, fn){
992992
* </div>
993993
*/
994994
fn.fullscreen = function(val) {
995-
// p5._validateParameters('fullscreen', arguments);
995+
p5._validateParameters('fullscreen', arguments);
996996
// no arguments, return fullscreen or not
997997
if (typeof val === 'undefined') {
998998
return (
@@ -1070,7 +1070,7 @@ function environment(p5, fn){
10701070
* @returns {Number} current pixel density of the sketch.
10711071
*/
10721072
fn.pixelDensity = function(val) {
1073-
// p5._validateParameters('pixelDensity', arguments);
1073+
p5._validateParameters('pixelDensity', arguments);
10741074
let returnValue;
10751075
if (typeof val === 'number') {
10761076
if (val !== this._renderer._pixelDensity) {

0 commit comments

Comments
 (0)