Skip to content

Commit bb0d92f

Browse files
authored
Merge pull request #8075 from Nitin2332/reference-fix
Reference-fixes
2 parents cd2c827 + 5917779 commit bb0d92f

File tree

4 files changed

+83
-15
lines changed

4 files changed

+83
-15
lines changed

src/color/setting.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,11 @@ p5.prototype.clip = function(callback, options) {
439439
* in RGB values. Calling `background(255, 204, 0)` sets the background a bright
440440
* yellow color.
441441
*
442+
* The version of `background()` with four parameters interprets them as RGBA,
443+
* HSBA, or HSLA colors, depending on the current
444+
* <a href="#/p5/colorMode">colorMode()</a>. The last parameter sets the alpha
445+
* (transparency) value.
446+
*
442447
* @method background
443448
* @param {p5.Color} color any value created by the <a href="#/p5/color">color()</a> function
444449
* @chainable
@@ -487,6 +492,19 @@ p5.prototype.clip = function(callback, options) {
487492
* function setup() {
488493
* createCanvas(100, 100);
489494
*
495+
* // R, G, B, and Alpha values.
496+
* background(255, 0, 0, 128);
497+
*
498+
* describe('A canvas with a semi-transparent red background.');
499+
* }
500+
* </code>
501+
* </div>
502+
*
503+
* <div>
504+
* <code>
505+
* function setup() {
506+
* createCanvas(100, 100);
507+
*
490508
* // Use HSB color.
491509
* colorMode(HSB);
492510
*
@@ -996,6 +1014,10 @@ p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) {
9961014
* <a href="#/p5/colorMode">colorMode()</a>. The default color space is RGB,
9971015
* with each value in the range from 0 to 255.
9981016
*
1017+
* The version of `fill()` with four parameters interprets them as `RGBA`, `HSBA`,
1018+
* or `HSLA` colors, depending on the current <a href="#/p5/colorMode">colorMode()</a>. The last parameter
1019+
* sets the alpha (transparency) value.
1020+
*
9991021
* @method fill
10001022
* @param {Number} v1 red value if color mode is RGB or hue value if color mode is HSB.
10011023
* @param {Number} v2 green value if color mode is RGB or saturation value if color mode is HSB.
@@ -1040,6 +1062,22 @@ p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) {
10401062
* function setup() {
10411063
* createCanvas(100, 100);
10421064
*
1065+
* background(200);
1066+
*
1067+
* // R, G, B, and Alpha values.
1068+
* fill(255, 0, 0, 128);
1069+
* square(20, 20, 60);
1070+
*
1071+
* describe('A semi-transparent red square with a black outline.');
1072+
* }
1073+
* </code>
1074+
* </div>
1075+
*
1076+
* <div>
1077+
* <code>
1078+
* function setup() {
1079+
* createCanvas(100, 100);
1080+
*
10431081
* background(100);
10441082
*
10451083
* // Use HSB color.
@@ -1336,7 +1374,7 @@ p5.prototype.noStroke = function() {
13361374
* Sets the color used to draw points, lines, and the outlines of shapes.
13371375
*
13381376
* Calling `stroke(255, 165, 0)` or `stroke('orange')` means all shapes drawn
1339-
* after calling `stroke()` will be filled with the color orange. The way
1377+
* after calling `stroke()` will be outlined with the color orange. The way
13401378
* these parameters are interpreted may be changed with the
13411379
* <a href="#/p5/colorMode">colorMode()</a> function.
13421380
*

src/core/shape/2d_primitives.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ p5.prototype._normalizeArcAngles = (
111111
* The fifth and sixth parameters, `start` and `stop`, set the angles
112112
* between which to draw the arc. Arcs are always drawn clockwise from
113113
* `start` to `stop`. The fifth and sixth parameters, start and stop, set the
114-
* angles between which to draw the arc. Arcs are always drawn clockwise from
115-
* start to stop. By default, angles are given in radians, but if angleMode
114+
* angles between which to draw the arc. By default, angles are given in radians, but if angleMode
116115
* (DEGREES) is set, the function interprets the values in degrees.
117116
*
118117
* The seventh parameter, `mode`, is optional. It determines the arc's fill

src/core/shape/vertex.js

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ let isFirstContour = true;
116116
* </code>
117117
* </div>
118118
*/
119-
p5.prototype.beginContour = function() {
119+
p5.prototype.beginContour = function () {
120120
if (this._renderer.isP3D) {
121121
this._renderer.beginContour();
122122
} else {
@@ -515,7 +515,7 @@ p5.prototype.beginContour = function() {
515515
* </code>
516516
* </div>
517517
*/
518-
p5.prototype.beginShape = function(kind) {
518+
p5.prototype.beginShape = function (kind) {
519519
p5._validateParameters('beginShape', arguments);
520520
if (this._renderer.isP3D) {
521521
this._renderer.beginShape(...arguments);
@@ -802,7 +802,7 @@ p5.prototype.beginShape = function(kind) {
802802
* @param {Number} z4 z-coordinate of the anchor point.
803803
* @chainable
804804
*/
805-
p5.prototype.bezierVertex = function(...args) {
805+
p5.prototype.bezierVertex = function (...args) {
806806
p5._validateParameters('bezierVertex', args);
807807
if (this._renderer.isP3D) {
808808
this._renderer.bezierVertex(...args);
@@ -1210,7 +1210,7 @@ p5.prototype.bezierVertex = function(...args) {
12101210
* </code>
12111211
* </div>
12121212
*/
1213-
p5.prototype.curveVertex = function(...args) {
1213+
p5.prototype.curveVertex = function (...args) {
12141214
p5._validateParameters('curveVertex', args);
12151215
if (this._renderer.isP3D) {
12161216
this._renderer.curveVertex(...args);
@@ -1319,7 +1319,7 @@ p5.prototype.curveVertex = function(...args) {
13191319
* </code>
13201320
* </div>
13211321
*/
1322-
p5.prototype.endContour = function() {
1322+
p5.prototype.endContour = function () {
13231323
if (this._renderer.isP3D) {
13241324
return this;
13251325
}
@@ -1342,7 +1342,7 @@ p5.prototype.endContour = function() {
13421342
};
13431343

13441344
/**
1345-
* Begins adding vertices to a custom shape.
1345+
* Stops adding vertices to a custom shape.
13461346
*
13471347
* The <a href="#/p5/beginShape">beginShape()</a> and `endShape()` functions
13481348
* allow for creating custom shapes in 2D or 3D.
@@ -1417,6 +1417,37 @@ p5.prototype.endContour = function() {
14171417
*
14181418
* <div>
14191419
* <code>
1420+
* function setup() {
1421+
* createCanvas(200, 100);
1422+
*
1423+
* background(240);
1424+
*
1425+
* noFill();
1426+
* stroke(0);
1427+
*
1428+
* // Open shape (left)
1429+
* beginShape();
1430+
* vertex(20, 20);
1431+
* vertex(80, 20);
1432+
* vertex(80, 80);
1433+
* endShape(); // Not closed
1434+
*
1435+
* // Closed shape (right)
1436+
* beginShape();
1437+
* vertex(120, 20);
1438+
* vertex(180, 20);
1439+
* vertex(180, 80);
1440+
* endShape(CLOSE); // Closed
1441+
*
1442+
* describe(
1443+
* 'Two right-angled shapes on a light gray background. The left shape is open with three lines. The right shape is closed, forming a triangle.'
1444+
* );
1445+
* }
1446+
* </code>
1447+
* </div>
1448+
*
1449+
* <div>
1450+
* <code>
14201451
* // Note: A "uniform" is a global variable within a shader program.
14211452
*
14221453
* // Create a string with the vertex shader program.
@@ -1504,7 +1535,7 @@ p5.prototype.endContour = function() {
15041535
* </code>
15051536
* </div>
15061537
*/
1507-
p5.prototype.endShape = function(mode, count = 1) {
1538+
p5.prototype.endShape = function (mode, count = 1) {
15081539
p5._validateParameters('endShape', arguments);
15091540
if (count < 1) {
15101541
console.log('🌸 p5.js says: You can not have less than one instance');
@@ -1807,7 +1838,7 @@ p5.prototype.endShape = function(mode, count = 1) {
18071838
* @param {Number} y3
18081839
* @param {Number} z3 z-coordinate of the anchor point.
18091840
*/
1810-
p5.prototype.quadraticVertex = function(...args) {
1841+
p5.prototype.quadraticVertex = function (...args) {
18111842
p5._validateParameters('quadraticVertex', args);
18121843
if (this._renderer.isP3D) {
18131844
this._renderer.quadraticVertex(...args);
@@ -2034,7 +2065,7 @@ p5.prototype.quadraticVertex = function(...args) {
20342065
* @param {Number} [v] v-coordinate of the vertex's texture. Defaults to 0.
20352066
* @chainable
20362067
*/
2037-
p5.prototype.vertex = function(x, y, moveTo, u, v) {
2068+
p5.prototype.vertex = function (x, y, moveTo, u, v) {
20382069
if (this._renderer.isP3D) {
20392070
this._renderer.vertex(...arguments);
20402071
} else {
@@ -2245,7 +2276,7 @@ p5.prototype.vertex = function(x, y, moveTo, u, v) {
22452276
* @param {Number} z z-component of the vertex normal.
22462277
* @chainable
22472278
*/
2248-
p5.prototype.normal = function(x, y, z) {
2279+
p5.prototype.normal = function (x, y, z) {
22492280
this._assert3d('normal');
22502281
p5._validateParameters('normal', arguments);
22512282
this._renderer.normal(...arguments);

src/core/transform.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ p5.prototype.shearX = function(angle) {
11811181
* function draw() {
11821182
* background(200);
11831183
*
1184-
* // Shear the coordinate system along the x-axis.
1184+
* // Shear the coordinate system along the y-axis.
11851185
* shearY(QUARTER_PI);
11861186
*
11871187
* // Draw the square.
@@ -1204,7 +1204,7 @@ p5.prototype.shearX = function(angle) {
12041204
* function draw() {
12051205
* background(200);
12061206
*
1207-
* // Shear the coordinate system along the x-axis.
1207+
* // Shear the coordinate system along the y-axis.
12081208
* shearY(45);
12091209
*
12101210
* // Draw the square.

0 commit comments

Comments
 (0)