Skip to content

Commit aa47d50

Browse files
authored
Merge pull request #5577 from Zearin/issue-5139-docs-alt-to-describe
docs(src/color/): Use `describe('…')` over `@alt`
2 parents 52a20ba + 5a5983e commit aa47d50

File tree

3 files changed

+64
-91
lines changed

3 files changed

+64
-91
lines changed

src/color/creating_reading.js

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ import '../core/friendly_errors/fes_core';
3131
* let value = alpha(c); // Sets 'value' to 102
3232
* fill(value);
3333
* rect(50, 15, 35, 70);
34+
* describe('Left half of canvas light blue and right half light charcoal grey.');
3435
* </code>
3536
* </div>
36-
*
37-
* @alt
38-
* Left half of canvas light blue and right half light charcoal grey.
3937
*/
4038
p5.prototype.alpha = function(c) {
4139
p5._validateParameters('alpha', arguments);
@@ -58,11 +56,10 @@ p5.prototype.alpha = function(c) {
5856
* let blueValue = blue(c);
5957
* fill(0, 0, blueValue);
6058
* rect(50, 20, 35, 60); // Draw right rectangle
59+
* describe('Left half of canvas light purple and right half a royal blue.');
6160
* </code>
6261
* </div>
6362
*
64-
* @alt
65-
* Left half of canvas light purple and right half a royal blue.
6663
*/
6764
p5.prototype.blue = function(c) {
6865
p5._validateParameters('blue', arguments);
@@ -88,6 +85,8 @@ p5.prototype.blue = function(c) {
8885
* let value = brightness(c); // Sets 'value' to 255
8986
* fill(value);
9087
* rect(50, 20, 35, 60);
88+
* describe(`Left half of canvas salmon pink and the right half with its
89+
* brightness colored white.`);
9190
* </code>
9291
* </div>
9392
*
@@ -101,12 +100,10 @@ p5.prototype.blue = function(c) {
101100
* let value = brightness(c); // A 'value' of 50% is 127.5
102101
* fill(value);
103102
* rect(50, 20, 35, 60);
103+
* describe(`Left half of canvas olive colored and the right half with its
104+
* brightness color gray.`);
104105
* </code>
105106
* </div>
106-
*
107-
* @alt
108-
* Left half of canvas salmon pink and the right half with its brightness colored white.
109-
* Left half of canvas olive colored and the right half with its brightness color gray.
110107
*/
111108
p5.prototype.brightness = function(c) {
112109
p5._validateParameters('brightness', arguments);
@@ -144,6 +141,8 @@ p5.prototype.brightness = function(c) {
144141
* fill(c);
145142
* noStroke();
146143
* rect(30, 20, 55, 55);
144+
* describe(`Yellow rect in middle right of canvas,
145+
* with 55 pixel width and height.`);
147146
* </code>
148147
* </div>
149148
*
@@ -157,6 +156,8 @@ p5.prototype.brightness = function(c) {
157156
* c = color(65);
158157
* fill(c);
159158
* ellipse(75, 75, 80, 80);
159+
* describe(`Yellow ellipse in top left of canvas, black ellipse in bottom
160+
* right, both 80×80.`);
160161
* </code>
161162
* </div>
162163
*
@@ -167,6 +168,7 @@ p5.prototype.brightness = function(c) {
167168
* fill(c);
168169
* noStroke();
169170
* rect(20, 20, 60, 60);
171+
* describe('Bright fuchsia rect in middle of canvas, 60 pixel width and height.');
170172
* </code>
171173
* </div>
172174
*
@@ -180,6 +182,7 @@ p5.prototype.brightness = function(c) {
180182
* c = color('#00ff00');
181183
* fill(c);
182184
* rect(55, 10, 45, 80);
185+
* describe('Two bright green rects on opposite sides of the canvas, both 45×80.');
183186
* </code>
184187
* </div>
185188
*
@@ -201,6 +204,7 @@ p5.prototype.brightness = function(c) {
201204
* c = color('rgba(0%, 0%, 100%, 1)');
202205
* fill(c);
203206
* rect(55, 55, 35, 35); // Draw rectangle
207+
* describe('Four blue rects in each corner of the canvas, each are 35×35.');
204208
* </code>
205209
* </div>
206210
*
@@ -214,6 +218,8 @@ p5.prototype.brightness = function(c) {
214218
* c = color('hsla(160, 100%, 50%, 0.5)');
215219
* fill(c);
216220
* rect(55, 10, 45, 80); // Draw rectangle
221+
* describe(`Bright sea green rect on left and darker rect on right of canvas,
222+
* both 45×80.`);
217223
* </code>
218224
* </div>
219225
*
@@ -227,6 +233,8 @@ p5.prototype.brightness = function(c) {
227233
* c = color('hsba(160, 100%, 50%, 0.5)');
228234
* fill(c);
229235
* rect(55, 10, 45, 80); // Draw rectangle
236+
* describe(`Dark green rect on left and lighter green rect on right of canvas,
237+
* both 45×80.`);
230238
* </code>
231239
* </div>
232240
*
@@ -240,18 +248,10 @@ p5.prototype.brightness = function(c) {
240248
* c = color(50, 55, 100);
241249
* fill(c);
242250
* rect(55, 10, 45, 80);
251+
* describe(`Dark blue rect on left and light teal rect on right of canvas,
252+
* both 45×80.`);
243253
* </code>
244254
* </div>
245-
*
246-
* @alt
247-
* Yellow rect in middle right of canvas, with 55 pixel width and height.
248-
* Yellow ellipse in top left of canvas, black ellipse in bottom right,both 80×80.
249-
* Bright fuchsia rect in middle of canvas, 60 pixel width and height.
250-
* Two bright green rects on opposite sides of the canvas, both 45×80.
251-
* Four blue rects in each corner of the canvas, each are 35×35.
252-
* Bright sea green rect on left and darker rect on right of canvas, both 45×80.
253-
* Dark green rect on left and lighter green rect on right of canvas, both 45×80.
254-
* Dark blue rect on left and light teal rect on right of canvas, both 45×80.
255255
*/
256256

257257
/**
@@ -312,11 +312,10 @@ p5.prototype.color = function() {
312312
* print(greenValue); // Print "75.0"
313313
* fill(0, greenValue, 0); // Use 'greenValue' in new fill
314314
* rect(50, 20, 35, 60); // Draw right rectangle
315+
* describe(`blue rect on left and green on right, both with black outlines
316+
* & 35×60.`);
315317
* </code>
316318
* </div>
317-
*
318-
* @alt
319-
* blue rect on left and green on right, both with black outlines & 35×60.
320319
*/
321320
p5.prototype.green = function(c) {
322321
p5._validateParameters('green', arguments);
@@ -347,11 +346,10 @@ p5.prototype.green = function(c) {
347346
* let value = hue(c); // Sets 'value' to "0"
348347
* fill(value);
349348
* rect(50, 20, 35, 60);
349+
* describe('salmon pink rect on left and black on right, both 35×60.');
350350
* </code>
351351
* </div>
352352
*
353-
* @alt
354-
* salmon pink rect on left and black on right, both 35×60.
355353
*/
356354
p5.prototype.hue = function(c) {
357355
p5._validateParameters('hue', arguments);
@@ -394,11 +392,10 @@ p5.prototype.hue = function(c) {
394392
* rect(50, 20, 20, 60);
395393
* fill(to);
396394
* rect(70, 20, 20, 60);
395+
* describe(`4 rects one tan, brown, brownish purple, purple, with white
396+
* outlines & 20×60`);
397397
* </code>
398398
* </div>
399-
*
400-
* @alt
401-
* 4 rects one tan, brown, brownish purple, purple, with white outlines & 20×60
402399
*/
403400

404401
p5.prototype.lerpColor = function(c1, c2, amt) {
@@ -468,11 +465,10 @@ p5.prototype.lerpColor = function(c1, c2, amt) {
468465
* let value = lightness(c); // Sets 'value' to 50
469466
* fill(value);
470467
* rect(50, 20, 35, 60);
468+
* describe(`light pastel green rect on left and dark grey rect on right,
469+
* both 35×60.`);
471470
* </code>
472471
* </div>
473-
*
474-
* @alt
475-
* light pastel green rect on left and dark grey rect on right, both 35×60.
476472
*/
477473
p5.prototype.lightness = function(c) {
478474
p5._validateParameters('lightness', arguments);
@@ -497,6 +493,8 @@ p5.prototype.lightness = function(c) {
497493
* print(redValue); // Print "255.0"
498494
* fill(redValue, 0, 0); // Use 'redValue' in new fill
499495
* rect(50, 20, 35, 60); // Draw right rectangle
496+
* describe(`yellow rect on left and red rect on right, both with black
497+
* outlines and 35×60.`);
500498
* </code>
501499
* </div>
502500
*
@@ -507,12 +505,9 @@ p5.prototype.lightness = function(c) {
507505
* colorMode(RGB, 1); // Sets the range for red, green, and blue to 1
508506
* let myColor = red(c);
509507
* print(myColor); // 0.4980392156862745
508+
* describe('grey canvas');
510509
* </code>
511510
* </div>
512-
*
513-
* @alt
514-
* yellow rect on left and red rect on right, both with black outlines and 35×60.
515-
* grey canvas
516511
*/
517512
p5.prototype.red = function(c) {
518513
p5._validateParameters('red', arguments);
@@ -542,11 +537,9 @@ p5.prototype.red = function(c) {
542537
* let value = saturation(c); // Sets 'value' to 126
543538
* fill(value);
544539
* rect(50, 20, 35, 60);
540+
* describe('deep pink rect on left and grey rect on right, both 35×60.');
545541
* </code>
546542
* </div>
547-
*
548-
* @alt
549-
*deep pink rect on left and grey rect on right, both 35×60.
550543
*/
551544
p5.prototype.saturation = function(c) {
552545
p5._validateParameters('saturation', arguments);

src/color/p5.Color.js

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ p5.Color = function(pInst, vals) {
7373
* text(myColor.toString(), 0, -5);
7474
* text(myColor.toString('#rrggbb'), 0, -30);
7575
* text(myColor.toString('rgba%'), 0, -55);
76+
* describe('A canvas with 3 text representation of their color.');
7677
* </code>
7778
* </div>
7879
*
@@ -82,9 +83,6 @@ p5.Color = function(pInst, vals) {
8283
* text(myColor.toString('#rrggbb'), 25, 25);
8384
* </code>
8485
* </div>
85-
*
86-
* @alt
87-
* A canvas with 3 text representation of their color.
8886
*/
8987
p5.Color.prototype.toString = function(format) {
9088
const a = this.levels;
@@ -270,12 +268,10 @@ p5.Color.prototype.toString = function(format) {
270268
* function draw() {
271269
* backgroundColor.setRed(128 + 128 * sin(millis() / 1000));
272270
* background(backgroundColor);
271+
* describe('canvas with gradually changing background color');
273272
* }
274273
* </code>
275274
* </div>
276-
*
277-
* @alt
278-
* canvas with gradually changing background color
279275
*/
280276
p5.Color.prototype.setRed = function(new_red) {
281277
this._array[0] = new_red / this.maxes[constants.RGB][0];
@@ -294,12 +290,11 @@ p5.Color.prototype.setRed = function(new_red) {
294290
* function draw() {
295291
* backgroundColor.setGreen(128 + 128 * sin(millis() / 1000));
296292
* background(backgroundColor);
293+
* describe('canvas with gradually changing background color');
297294
* }
298295
* </code>
299296
* </div>
300297
*
301-
* @alt
302-
* canvas with gradually changing background color
303298
**/
304299
p5.Color.prototype.setGreen = function(new_green) {
305300
this._array[1] = new_green / this.maxes[constants.RGB][1];
@@ -318,12 +313,11 @@ p5.Color.prototype.setGreen = function(new_green) {
318313
* function draw() {
319314
* backgroundColor.setBlue(128 + 128 * sin(millis() / 1000));
320315
* background(backgroundColor);
316+
* describe('canvas with gradually changing background color');
321317
* }
322318
* </code>
323319
* </div>
324320
*
325-
* @alt
326-
* canvas with gradually changing background color
327321
**/
328322
p5.Color.prototype.setBlue = function(new_blue) {
329323
this._array[2] = new_blue / this.maxes[constants.RGB][2];
@@ -345,12 +339,10 @@ p5.Color.prototype.setBlue = function(new_blue) {
345339
* squareColor.setAlpha(128 + 128 * sin(millis() / 1000));
346340
* fill(squareColor);
347341
* rect(13, 13, width - 26, height - 26);
342+
* describe('a square with gradually changing opacity on a gray background');
348343
* }
349344
* </code>
350345
* </div>
351-
*
352-
* @alt
353-
* a square with gradually changing opacity on a gray background
354346
**/
355347
p5.Color.prototype.setAlpha = function(new_alpha) {
356348
this._array[3] = new_alpha / this.maxes[this.mode][3];
@@ -777,11 +769,10 @@ const colorPatterns = {
777769
* <div>
778770
* <code>
779771
* // todo
772+
* //
773+
* // describe('');
780774
* </code>
781775
* </div>
782-
*
783-
* @alt
784-
* //todo
785776
*/
786777
p5.Color._parseInputs = function(r, g, b, a) {
787778
const numArgs = arguments.length;

0 commit comments

Comments
 (0)