Skip to content

Commit 3a5591c

Browse files
authored
Merge pull request #7179 from sproutleaf/dev-2.0
Standardize all parameter types
2 parents a85ce9f + fa7f53f commit 3a5591c

File tree

9 files changed

+204
-205
lines changed

9 files changed

+204
-205
lines changed

src/core/rendering.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const renderers = p5.renderers = {
5151
* @method createCanvas
5252
* @param {Number} [width] width of the canvas. Defaults to 100.
5353
* @param {Number} [height] height of the canvas. Defaults to 100.
54-
* @param {Constant} [renderer] either P2D or WEBGL. Defaults to `P2D`.
54+
* @param {(P2D|WEBGL)} [renderer] either P2D or WEBGL. Defaults to `P2D`.
5555
* @param {HTMLCanvasElement} [canvas] existing canvas element that should be used for the sketch.
5656
* @return {p5.Renderer} new `p5.Renderer` that holds the canvas.
5757
*
@@ -129,7 +129,7 @@ const renderers = p5.renderers = {
129129
* @param {HTMLCanvasElement} [canvas]
130130
* @return {p5.Renderer}
131131
*/
132-
p5.prototype.createCanvas = function(w, h, renderer, canvas) {
132+
p5.prototype.createCanvas = function (w, h, renderer, canvas) {
133133
p5._validateParameters('createCanvas', arguments);
134134
//optional: renderer, otherwise defaults to p2d
135135

@@ -314,7 +314,7 @@ p5.prototype.createCanvas = function(w, h, renderer, canvas) {
314314
* </code>
315315
* </div>
316316
*/
317-
p5.prototype.resizeCanvas = function(w, h, noRedraw) {
317+
p5.prototype.resizeCanvas = function (w, h, noRedraw) {
318318
p5._validateParameters('resizeCanvas', arguments);
319319
if (this._renderer) {
320320
// save canvas properties
@@ -372,7 +372,7 @@ p5.prototype.resizeCanvas = function(w, h, noRedraw) {
372372
* </code>
373373
* </div>
374374
*/
375-
p5.prototype.noCanvas = function() {
375+
p5.prototype.noCanvas = function () {
376376
if (this.canvas) {
377377
this.canvas.parentNode.removeChild(this.canvas);
378378
}
@@ -490,11 +490,11 @@ p5.prototype.noCanvas = function() {
490490
* @param {HTMLCanvasElement} [canvas]
491491
* @return {p5.Graphics}
492492
*/
493-
p5.prototype.createGraphics = function(w, h, ...args) {
494-
/**
495-
* args[0] is expected to be renderer
496-
* args[1] is expected to be canvas
497-
*/
493+
p5.prototype.createGraphics = function (w, h, ...args) {
494+
/**
495+
* args[0] is expected to be renderer
496+
* args[1] is expected to be canvas
497+
*/
498498
if (args[0] instanceof HTMLCanvasElement) {
499499
args[1] = args[0];
500500
args[0] = constants.P2D;
@@ -639,7 +639,7 @@ p5.prototype.createGraphics = function(w, h, ...args) {
639639
* </code>
640640
* </div>
641641
*/
642-
p5.prototype.createFramebuffer = function(options) {
642+
p5.prototype.createFramebuffer = function (options) {
643643
return new p5.Framebuffer(this, options);
644644
};
645645

@@ -723,7 +723,7 @@ p5.prototype.createFramebuffer = function(options) {
723723
* </code>
724724
* </div>
725725
*/
726-
p5.prototype.clearDepth = function(depth) {
726+
p5.prototype.clearDepth = function (depth) {
727727
this._assert3d('clearDepth');
728728
this._renderer.clearDepth(depth);
729729
};
@@ -1192,7 +1192,7 @@ p5.prototype.clearDepth = function(depth) {
11921192
* </code>
11931193
* </div>
11941194
*/
1195-
p5.prototype.blendMode = function(mode) {
1195+
p5.prototype.blendMode = function (mode) {
11961196
p5._validateParameters('blendMode', arguments);
11971197
if (mode === constants.NORMAL) {
11981198
// Warning added 3/26/19, can be deleted in future (1.0 release?)

src/dom/dom.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ p5.prototype._wrapElement = function (elt) {
225225
const children = Array.prototype.slice.call(elt.children);
226226
if (elt.tagName === 'INPUT' && elt.type === 'checkbox') {
227227
let converted = new p5.Element(elt, this);
228-
converted.checked = function(...args) {
228+
converted.checked = function (...args) {
229229
if (args.length === 0) {
230230
return this.elt.checked;
231231
} else if (args[0]) {
@@ -1020,7 +1020,7 @@ p5.prototype.createButton = function (label, value) {
10201020
*
10211021
* @method createCheckbox
10221022
* @param {String} [label] label displayed after the checkbox.
1023-
* @param {boolean} [value] value of the checkbox. Checked is `true` and unchecked is `false`.
1023+
* @param {Boolean} [value] value of the checkbox. Checked is `true` and unchecked is `false`.
10241024
* @return {p5.Element} new <a href="#/p5.Element">p5.Element</a> object.
10251025
*
10261026
* @example
@@ -1101,7 +1101,7 @@ p5.prototype.createButton = function (label, value) {
11011101
* </code>
11021102
* </div>
11031103
*/
1104-
p5.prototype.createCheckbox = function(...args) {
1104+
p5.prototype.createCheckbox = function (...args) {
11051105
p5._validateParameters('createCheckbox', args);
11061106

11071107
// Create a container element
@@ -1121,7 +1121,7 @@ p5.prototype.createCheckbox = function(...args) {
11211121
//checkbox must be wrapped in p5.Element before label so that label appears after
11221122
const self = addElement(elt, this);
11231123

1124-
self.checked = function(...args) {
1124+
self.checked = function (...args) {
11251125
const cb = self.elt.firstElementChild.getElementsByTagName('input')[0];
11261126
if (cb) {
11271127
if (args.length === 0) {
@@ -1178,7 +1178,7 @@ p5.prototype.createCheckbox = function(...args) {
11781178
* - `mySelect.enable(option)` marks a given option as enabled.
11791179
*
11801180
* @method createSelect
1181-
* @param {boolean} [multiple] support multiple selections.
1181+
* @param {Boolean} [multiple] support multiple selections.
11821182
* @return {p5.Element} new <a href="#/p5.Element">p5.Element</a> object.
11831183
*
11841184
* @example
@@ -1328,7 +1328,7 @@ p5.prototype.createCheckbox = function(...args) {
13281328
* @return {p5.Element}
13291329
*/
13301330

1331-
p5.prototype.createSelect = function(...args) {
1331+
p5.prototype.createSelect = function (...args) {
13321332
p5._validateParameters('createSelect', args);
13331333
let self;
13341334
let arg = args[0];
@@ -1580,7 +1580,7 @@ p5.prototype.createSelect = function(...args) {
15801580
* @method createRadio
15811581
* @return {p5.Element} new <a href="#/p5.Element">p5.Element</a> object.
15821582
*/
1583-
p5.prototype.createRadio = function(...args) {
1583+
p5.prototype.createRadio = function (...args) {
15841584
// Creates a div, adds each option as an individual input inside it.
15851585
// If already given with a containerEl, will search for all input[radio]
15861586
// it, create a p5.Element out of it, add options to it and return the p5.Element.
@@ -2394,7 +2394,7 @@ if (navigator.mediaDevices.getUserMedia === undefined) {
23942394
* </code>
23952395
* </div>
23962396
*/
2397-
p5.prototype.createCapture = function(...args) {
2397+
p5.prototype.createCapture = function (...args) {
23982398
p5._validateParameters('createCapture', args);
23992399

24002400
// return if getUserMedia is not supported by the browser
@@ -2436,7 +2436,7 @@ p5.prototype.createCapture = function(...args) {
24362436
domElement.src = window.URL.createObjectURL(stream);
24372437
}
24382438
}
2439-
catch(err) {
2439+
catch (err) {
24402440
domElement.src = stream;
24412441
}
24422442
}).catch(e => {
@@ -2467,7 +2467,7 @@ p5.prototype.createCapture = function(...args) {
24672467

24682468
if (callback) callback(domElement.srcObject);
24692469
});
2470-
videoEl.flipped=flipped;
2470+
videoEl.flipped = flipped;
24712471
return videoEl;
24722472
};
24732473

@@ -2944,10 +2944,10 @@ p5.Element.prototype.center = function (align) {
29442944
/**
29452945
* @method html
29462946
* @param {String} [html] the HTML to be placed inside the element
2947-
* @param {boolean} [append] whether to append HTML to existing
2947+
* @param {Boolean} [append] whether to append HTML to existing
29482948
* @chainable
29492949
*/
2950-
p5.Element.prototype.html = function(...args) {
2950+
p5.Element.prototype.html = function (...args) {
29512951
if (args.length === 0) {
29522952
return this.elt.innerHTML;
29532953
} else if (args[1]) {
@@ -3017,7 +3017,7 @@ p5.Element.prototype.html = function(...args) {
30173017
* @param {String} [positionType] it can be static, fixed, relative, sticky, initial or inherit (optional)
30183018
* @chainable
30193019
*/
3020-
p5.Element.prototype.position = function(...args) {
3020+
p5.Element.prototype.position = function (...args) {
30213021
if (args.length === 0) {
30223022
return { x: this.elt.offsetLeft, y: this.elt.offsetTop };
30233023
} else {
@@ -3042,7 +3042,7 @@ p5.Element.prototype.position = function(...args) {
30423042
};
30433043

30443044
/* Helper method called by p5.Element.style() */
3045-
p5.Element.prototype._translate = function(...args) {
3045+
p5.Element.prototype._translate = function (...args) {
30463046
this.elt.style.position = 'absolute';
30473047
// save out initial non-translate transform styling
30483048
let transform = '';
@@ -3074,7 +3074,7 @@ p5.Element.prototype._translate = function(...args) {
30743074
};
30753075

30763076
/* Helper method called by p5.Element.style() */
3077-
p5.Element.prototype._rotate = function(...args) {
3077+
p5.Element.prototype._rotate = function (...args) {
30783078
// save out initial non-rotate transform styling
30793079
let transform = '';
30803080
if (this.elt.style.transform) {
@@ -3461,7 +3461,7 @@ p5.Element.prototype.removeAttribute = function (attr) {
34613461
* @param {String|Number} value
34623462
* @chainable
34633463
*/
3464-
p5.Element.prototype.value = function(...args) {
3464+
p5.Element.prototype.value = function (...args) {
34653465
if (args.length > 0) {
34663466
this.elt.value = args[0];
34673467
return this;
@@ -4004,10 +4004,10 @@ p5.Element.prototype.draggable = function (elmMove) {
40044004
closeDragElementEvt = isTouch ? 'touchend' : 'mouseup',
40054005
elementDragEvt = isTouch ? 'touchmove' : 'mousemove';
40064006

4007-
if(elmMove === undefined){
4007+
if (elmMove === undefined) {
40084008
elmMove = this.elt;
40094009
elmDrag = elmMove;
4010-
}else if(elmMove !== this.elt && elmMove.elt !== this.elt){
4010+
} else if (elmMove !== this.elt && elmMove.elt !== this.elt) {
40114011
elmMove = elmMove.elt;
40124012
elmDrag = this.elt;
40134013
}
@@ -4018,11 +4018,11 @@ p5.Element.prototype.draggable = function (elmMove) {
40184018
function dragMouseDown(e) {
40194019
e = e || window.event;
40204020

4021-
if(isTouch){
4021+
if (isTouch) {
40224022
const touches = e.changedTouches;
40234023
px = parseInt(touches[0].clientX);
40244024
py = parseInt(touches[0].clientY);
4025-
}else{
4025+
} else {
40264026
px = parseInt(e.clientX);
40274027
py = parseInt(e.clientY);
40284028
}
@@ -4035,13 +4035,13 @@ p5.Element.prototype.draggable = function (elmMove) {
40354035
function elementDrag(e) {
40364036
e = e || window.event;
40374037

4038-
if(isTouch){
4038+
if (isTouch) {
40394039
const touches = e.changedTouches;
40404040
x = px - parseInt(touches[0].clientX);
40414041
y = py - parseInt(touches[0].clientY);
40424042
px = parseInt(touches[0].clientX);
40434043
py = parseInt(touches[0].clientY);
4044-
}else{
4044+
} else {
40454045
x = px - parseInt(e.clientX);
40464046
y = py - parseInt(e.clientY);
40474047
px = parseInt(e.clientX);
@@ -4950,7 +4950,7 @@ p5.MediaElement = class MediaElement extends p5.Element {
49504950
* set this value to false after uploading the texture; or might set
49514951
* it to true if metadata has become available but there is no actual
49524952
* texture data available yet..
4953-
* @param {boolean} val sets whether or not the element has been
4953+
* @param {Boolean} val sets whether or not the element has been
49544954
* modified.
49554955
* @private
49564956
*/

src/events/acceleration.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ p5.prototype.pAccelerationZ = 0;
122122
*
123123
* @private
124124
*/
125-
p5.prototype._updatePAccelerations = function() {
125+
p5.prototype._updatePAccelerations = function () {
126126
this._setProperty('pAccelerationX', this.accelerationX);
127127
this._setProperty('pAccelerationY', this.accelerationY);
128128
this._setProperty('pAccelerationZ', this.accelerationZ);
@@ -369,7 +369,7 @@ p5.prototype.pRotateDirectionX = undefined;
369369
p5.prototype.pRotateDirectionY = undefined;
370370
p5.prototype.pRotateDirectionZ = undefined;
371371

372-
p5.prototype._updatePRotations = function() {
372+
p5.prototype._updatePRotations = function () {
373373
this._setProperty('pRotationX', this.rotationX);
374374
this._setProperty('pRotationY', this.rotationY);
375375
this._setProperty('pRotationZ', this.rotationZ);
@@ -419,7 +419,7 @@ let shake_threshold = 30;
419419
* the <a href="#/p5/deviceMoved">deviceMoved()</a> function. The default threshold is set to 0.5.
420420
*
421421
* @method setMoveThreshold
422-
* @param {number} value The threshold value
422+
* @param {Number} value The threshold value
423423
* @example
424424
* <div class="norender">
425425
* <code>
@@ -451,7 +451,7 @@ let shake_threshold = 30;
451451
* </div>
452452
*/
453453

454-
p5.prototype.setMoveThreshold = function(val) {
454+
p5.prototype.setMoveThreshold = function (val) {
455455
p5._validateParameters('setMoveThreshold', arguments);
456456
move_threshold = val;
457457
};
@@ -493,7 +493,7 @@ p5.prototype.setMoveThreshold = function(val) {
493493
* </div>
494494
*/
495495

496-
p5.prototype.setShakeThreshold = function(val) {
496+
p5.prototype.setShakeThreshold = function (val) {
497497
p5._validateParameters('setShakeThreshold', arguments);
498498
shake_threshold = val;
499499
};
@@ -616,7 +616,7 @@ p5.prototype.setShakeThreshold = function(val) {
616616
* </div>
617617
*/
618618

619-
p5.prototype._ondeviceorientation = function(e) {
619+
p5.prototype._ondeviceorientation = function (e) {
620620
this._updatePRotations();
621621

622622
// Convert from degrees into current angle mode
@@ -625,14 +625,14 @@ p5.prototype._ondeviceorientation = function(e) {
625625
this._setProperty('rotationZ', this._fromDegrees(e.alpha));
626626
this._handleMotion();
627627
};
628-
p5.prototype._ondevicemotion = function(e) {
628+
p5.prototype._ondevicemotion = function (e) {
629629
this._updatePAccelerations();
630630
this._setProperty('accelerationX', e.acceleration.x * 2);
631631
this._setProperty('accelerationY', e.acceleration.y * 2);
632632
this._setProperty('accelerationZ', e.acceleration.z * 2);
633633
this._handleMotion();
634634
};
635-
p5.prototype._handleMotion = function() {
635+
p5.prototype._handleMotion = function () {
636636
if (window.orientation === 90 || window.orientation === -90) {
637637
this._setProperty('deviceOrientation', 'landscape');
638638
} else if (window.orientation === 0) {

0 commit comments

Comments
 (0)