Skip to content

Commit 789327f

Browse files
less arguments
1 parent 9f0e406 commit 789327f

File tree

8 files changed

+20
-22
lines changed

8 files changed

+20
-22
lines changed

src/color/setting.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,9 @@ p5.prototype.clear = function(...args) {
555555
* @param {Number} [maxA] range for the alpha.
556556
* @chainable
557557
*/
558-
p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) {
559-
p5._validateParameters('colorMode', arguments);
558+
p5.prototype.colorMode = function(...args) {
559+
const [mode, max1, max2, max3, maxA] = args;
560+
p5._validateParameters('colorMode', args);
560561
if (
561562
mode === constants.RGB ||
562563
mode === constants.HSB ||
@@ -567,16 +568,16 @@ p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) {
567568

568569
// Set color maxes.
569570
const maxes = this._colorMaxes[mode];
570-
if (arguments.length === 2) {
571+
if (args.length === 2) {
571572
maxes[0] = max1; // Red
572573
maxes[1] = max1; // Green
573574
maxes[2] = max1; // Blue
574575
maxes[3] = max1; // Alpha
575-
} else if (arguments.length === 4) {
576+
} else if (args.length === 4) {
576577
maxes[0] = max1; // Red
577578
maxes[1] = max2; // Green
578579
maxes[2] = max3; // Blue
579-
} else if (arguments.length === 5) {
580+
} else if (args.length === 5) {
580581
maxes[0] = max1; // Red
581582
maxes[1] = max2; // Green
582583
maxes[2] = max3; // Blue

src/core/p5.Graphics.js

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ p5.Graphics = class extends p5.Element {
7373

7474
this._renderer.resize(w, h);
7575
this._renderer._applyDefaults();
76-
return this;
7776
}
7877

7978
/**

src/core/shape/2d_primitives.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,7 @@ p5.prototype.quad = function(...args) {
580580
if (this._renderer._doStroke || this._renderer._doFill) {
581581
if (this._renderer.isP3D && args.length < 12) {
582582
// if 3D and we weren't passed 12 args, assume Z is 0
583-
this._renderer.quad.call(
584-
this._renderer,
585-
args[0], args[1], 0,
583+
this._renderer.quad(args[0], args[1], 0,
586584
args[2], args[3], 0,
587585
args[4], args[5], 0,
588586
args[6], args[7], 0,

src/data/p5.TypedDict.js

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ p5.TypedDict = class TypedDict {
9696
this.data = {};
9797
this.data[key] = value;
9898
}
99-
return this;
10099
}
101100

102101
/**

src/math/p5.Vector.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,8 @@ p5.Vector = class {
956956
* @param {p5.Vector} v vector to divide the components of the original vector by.
957957
* @chainable
958958
*/
959-
div(x, y, z) {
959+
div(...args) {
960+
const [x, y, z] = args;
960961
if (x instanceof p5.Vector) {
961962
// new p5.Vector will check that values are valid upon construction but it's possible
962963
// that someone could change the value of a component after creation, which is why we still
@@ -1019,7 +1020,7 @@ p5.Vector = class {
10191020
return this;
10201021
}
10211022

1022-
const vectorComponents = [...arguments];
1023+
const vectorComponents = [...args];
10231024
if (
10241025
vectorComponents.every(element => Number.isFinite(element)) &&
10251026
vectorComponents.every(element => typeof element === 'number')
@@ -1029,16 +1030,16 @@ p5.Vector = class {
10291030
return this;
10301031
}
10311032

1032-
if (arguments.length === 1) {
1033+
if (args.length === 1) {
10331034
this.x /= x;
10341035
this.y /= x;
10351036
this.z /= x;
10361037
}
1037-
if (arguments.length === 2) {
1038+
if (args.length === 2) {
10381039
this.x /= x;
10391040
this.y /= y;
10401041
}
1041-
if (arguments.length === 3) {
1042+
if (args.length === 3) {
10421043
this.x /= x;
10431044
this.y /= y;
10441045
this.z /= z;

src/webgl/light.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ p5.prototype.ambientLight = function(v1, v2, v3, a) {
229229
* @param {p5.Color} color color as a <a href="#/p5.Color">p5.Color</a>
230230
* @chainable
231231
*/
232-
p5.prototype.specularColor = function(v1, v2, v3) {
232+
p5.prototype.specularColor = function(...args) {
233233
this._assert3d('specularColor');
234-
p5._validateParameters('specularColor', arguments);
235-
const color = this.color(...arguments);
234+
p5._validateParameters('specularColor', args);
235+
const color = this.color(...args);
236236

237237
this._renderer.specularColors = [
238238
color._array[0],

src/webgl/material.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1123,11 +1123,11 @@ p5.prototype.emissiveMaterial = function (v1, v2, v3, a) {
11231123
* as an array, or as a CSS string
11241124
* @chainable
11251125
*/
1126-
p5.prototype.specularMaterial = function (v1, v2, v3, alpha) {
1126+
p5.prototype.specularMaterial = function (...args) {
11271127
this._assert3d('specularMaterial');
1128-
p5._validateParameters('specularMaterial', arguments);
1128+
p5._validateParameters('specularMaterial', args);
11291129

1130-
const color = p5.prototype.color.apply(this, arguments);
1130+
const color = p5.prototype.color.apply(this, args);
11311131
this._renderer.curSpecularColor = color._array;
11321132
this._renderer._useSpecularMaterial = true;
11331133
this._renderer._useNormalMaterial = false;

src/webgl/p5.Texture.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ p5.Texture = class Texture {
109109
this.height = textureData.height;
110110

111111
this.init(textureData);
112-
return this;
113112
}
114113

115114
_getTextureDataFromSource () {
@@ -295,6 +294,7 @@ p5.Texture = class Texture {
295294
/**
296295
* Binds the texture to the appropriate GL target.
297296
* @method bindTexture
297+
* @chainable
298298
*/
299299
bindTexture () {
300300
// bind texture using gl context + glTarget and

0 commit comments

Comments
 (0)