Skip to content

Commit a852280

Browse files
authored
Merge pull request #5596 from Zearin/issue-5139/math
docs(src/math): Use `describe()` instead of `@alt`
2 parents b90e768 + 861cf74 commit a852280

File tree

6 files changed

+84
-100
lines changed

6 files changed

+84
-100
lines changed

src/math/calculation.js

+53-58
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ import p5 from '../core/main';
2222
*
2323
* print(x); // -3
2424
* print(y); // 3
25+
*
26+
* describe(`no image displayed`);
2527
* }
2628
* </code></div>
27-
*
28-
* @alt
29-
* no image displayed
3029
*/
3130
p5.prototype.abs = Math.abs;
3231

@@ -61,11 +60,11 @@ p5.prototype.abs = Math.abs;
6160
* noStroke();
6261
* text(nfc(ax, 2), ax, ay - 5);
6362
* text(nfc(bx, 1), bx, by - 5);
63+
*
64+
* describe(`2 horizontal lines & number sets. increase with
65+
* mouse x. bottom to 2 decimals`);
6466
* }
6567
* </code></div>
66-
*
67-
* @alt
68-
* 2 horizontal lines & number sets. increase with mouse x. bottom to 2 decimals
6968
*/
7069
p5.prototype.ceil = Math.ceil;
7170

@@ -102,11 +101,11 @@ p5.prototype.ceil = Math.ceil;
102101
* ellipse(xm, 33, 9, 9); // Not Constrained
103102
* fill(0);
104103
* ellipse(xc, 66, 9, 9); // Constrained
104+
*
105+
* describe(`2 vertical lines. 2 ellipses move with mouse X,
106+
* 1 does not move past lines`);
105107
* }
106108
* </code></div>
107-
*
108-
* @alt
109-
* 2 vertical lines. 2 ellipses move with mouse X 1 does not move passed lines
110109
*/
111110
p5.prototype.constrain = function(n, low, high) {
112111
p5._validateParameters('constrain', arguments);
@@ -152,11 +151,11 @@ p5.prototype.constrain = function(n, low, high) {
152151
* text(nfc(d, 1), 0, -5);
153152
* pop();
154153
* // Fancy!
154+
*
155+
* describe(`2 ellipses joined by line. 1 ellipse moves with
156+
* mouse X&Y. Distance displayed.`);
155157
* }
156158
* </code></div>
157-
*
158-
* @alt
159-
* 2 ellipses joined by line. 1 ellipse moves with mouse X&Y. Distance displayed.
160159
*/
161160
/**
162161
* @method dist
@@ -220,11 +219,10 @@ p5.prototype.dist = function(...args) {
220219
* endShape();
221220
* line(0, 0, 0, height);
222221
* line(0, height - 1, width, height - 1);
222+
*
223+
* describe(`ellipse moves along a curve with mouse x. e^n displayed.`);
223224
* }
224225
* </code></div>
225-
*
226-
* @alt
227-
* ellipse moves along a curve with mouse x. e^n displayed.
228226
*/
229227
p5.prototype.exp = Math.exp;
230228

@@ -258,11 +256,11 @@ p5.prototype.exp = Math.exp;
258256
* noStroke();
259257
* text(nfc(ax, 2), ax, ay - 5);
260258
* text(nfc(bx, 1), bx, by - 5);
259+
*
260+
* describe(`2 horizontal lines & number sets.
261+
* increase with mouse x. bottom to 2 decimals`);
261262
* }
262263
* </code></div>
263-
*
264-
* @alt
265-
* 2 horizontal lines & number sets. increase with mouse x. bottom to 2 decimals
266264
*/
267265
p5.prototype.floor = Math.floor;
268266

@@ -302,11 +300,11 @@ p5.prototype.floor = Math.floor;
302300
* point(c, y);
303301
* point(d, y);
304302
* point(e, y);
303+
*
304+
* describe(`5 points horizontally staggered mid-canvas.
305+
* mid 3 are grey, outer black`);
305306
* }
306307
* </code></div>
307-
*
308-
* @alt
309-
* 5 points horizontally staggered mid-canvas. mid 3 are grey, outer black
310308
*/
311309
p5.prototype.lerp = function(start, stop, amt) {
312310
p5._validateParameters('lerp', arguments);
@@ -360,11 +358,11 @@ p5.prototype.lerp = function(start, stop, amt) {
360358
* endShape();
361359
* line(0, 0, 0, height);
362360
* line(0, height / 2, width, height / 2);
361+
*
362+
* describe(`ellipse moves along a curve with mouse x.
363+
* natural logarithm of n displayed.`);
363364
* }
364365
* </code></div>
365-
*
366-
* @alt
367-
* ellipse moves along a curve with mouse x. natural logarithm of n displayed.
368366
*/
369367
p5.prototype.log = Math.log;
370368

@@ -395,11 +393,10 @@ p5.prototype.log = Math.log;
395393
* print(mag(x1, y2)); // Prints "72.80109889280519"
396394
* line(0, 0, x2, y2);
397395
* print(mag(x2, y2)); // Prints "106.3014581273465"
396+
*
397+
* describe(`4 lines of different length radiate from top left of canvas.`);
398398
* }
399399
* </code></div>
400-
*
401-
* @alt
402-
* 4 lines of different length radiate from top left of canvas.
403400
*/
404401
p5.prototype.mag = function(x, y) {
405402
p5._validateParameters('mag', arguments);
@@ -426,6 +423,7 @@ p5.prototype.mag = function(x, y) {
426423
* let value = 25;
427424
* let m = map(value, 0, 100, 0, width);
428425
* ellipse(m, 50, 10, 10);
426+
* describe(`10×10 white ellipse with in mid left canvas`);
429427
</code></div>
430428
*
431429
* <div><code>
@@ -441,12 +439,11 @@ p5.prototype.mag = function(x, y) {
441439
* //after setting withinBounds to true
442440
* let x2 = map(mouseX, 0, width, 0, 100, true);
443441
* ellipse(x2, 75, 25, 25);
442+
*
443+
* describe(`Two 25×25 white ellipses move with mouse x.
444+
* Bottom has more range from X`);
444445
* }
445446
</code></div>
446-
*
447-
* @alt
448-
* 10 by 10 white ellipse with in mid left canvas
449-
* 2 25 by 25 white ellipses move with mouse x. Bottom has more range from X
450447
*/
451448
p5.prototype.map = function(n, start1, stop1, start2, stop2, withinBounds) {
452449
p5._validateParameters('map', arguments);
@@ -490,11 +487,11 @@ p5.prototype.map = function(n, start1, stop1, start2, stop2, withinBounds) {
490487
* // Draw the Maximum value in the array.
491488
* textSize(32);
492489
* text(max(numArray), maxX, maxY);
490+
*
491+
* describe(`Small text at top reads: Array Elements 2 1 5 4 8 9.
492+
* Large text at center: 9`);
493493
* }
494494
* </code></div>
495-
*
496-
* @alt
497-
* Small text at top reads: Array Elements 2 1 5 4 8 9. Large text at center: 9
498495
*/
499496
/**
500497
* @method max
@@ -538,11 +535,11 @@ p5.prototype.max = function(...args) {
538535
* // Draw the Minimum value in the array.
539536
* textSize(32);
540537
* text(min(numArray), maxX, maxY);
538+
*
539+
* describe(`Small text at top reads: Array Elements 2 1 5 4 8 9.
540+
* Large text at center: 1`);
541541
* }
542542
* </code></div>
543-
*
544-
* @alt
545-
* Small text at top reads: Array Elements 2 1 5 4 8 9. Large text at center: 1
546543
*/
547544
/**
548545
* @method min
@@ -598,11 +595,11 @@ p5.prototype.min = function(...args) {
598595
* let normalY = 40;
599596
* let normalX = 20;
600597
* text(normalized, normalX, normalY);
598+
*
599+
* describe(`ellipse moves with mouse. 0 shown left, 100 right,
600+
* and updating values center`);
601601
* }
602602
* </code></div>
603-
*
604-
* @alt
605-
* ellipse moves with mouse. 0 shown left & 100 right and updating values center
606603
*/
607604
p5.prototype.norm = function(n, start, stop) {
608605
p5._validateParameters('norm', arguments);
@@ -635,11 +632,10 @@ p5.prototype.norm = function(n, start, stop) {
635632
* ellipse(eLoc * 4, eLoc * 4, pow(eSize, 3), pow(eSize, 3));
636633
*
637634
* ellipse(eLoc * 8, eLoc * 8, pow(eSize, 4), pow(eSize, 4));
635+
*
636+
* describe(`small to large ellipses radiating from top left of canvas`);
638637
* }
639638
* </code></div>
640-
*
641-
* @alt
642-
* small to large ellipses radiating from top left of canvas
643639
*/
644640
p5.prototype.pow = Math.pow;
645641

@@ -655,10 +651,12 @@ p5.prototype.pow = Math.pow;
655651
* <div><code>
656652
* let x = round(3.7);
657653
* text(x, width / 2, height / 2);
654+
* describe(`"4" written in middle of canvas`);
658655
* </code></div>
659656
* <div><code>
660657
* let x = round(12.782383, 2);
661658
* text(x, width / 2, height / 2);
659+
* describe(`"12.78" written in middle of canvas`);
662660
* </code></div>
663661
* <div><code>
664662
* function draw() {
@@ -682,13 +680,10 @@ p5.prototype.pow = Math.pow;
682680
* noStroke();
683681
* text(nfc(ax, 2), ax, ay - 5);
684682
* text(nfc(bx, 1), bx, by - 5);
683+
*
684+
* describe(`two horizontal lines rounded values displayed on top.`);
685685
* }
686686
* </code></div>
687-
*
688-
* @alt
689-
* "4" written in middle of canvas
690-
* "12.78" written in middle of canvas
691-
* two horizontal lines rounded values displayed on top.
692687
*/
693688
p5.prototype.round = function(n, decimals) {
694689
if (!decimals) {
@@ -734,11 +729,11 @@ p5.prototype.round = function(n, decimals) {
734729
* fill(0);
735730
* text('x = ' + x1, 0, y1 + spacing);
736731
* text('sq(x) = ' + x2, 0, y2 + spacing);
732+
*
733+
* describe(`horizontal center line squared values displayed on
734+
* top and regular on bottom.`);
737735
* }
738736
* </code></div>
739-
*
740-
* @alt
741-
* horizontal center line squared values displayed on top and regular on bottom.
742737
*/
743738
p5.prototype.sq = n => n * n;
744739

@@ -779,11 +774,11 @@ p5.prototype.sq = n => n * n;
779774
* let spacing = 15;
780775
* text('x = ' + x1, 0, y1 + spacing);
781776
* text('sqrt(x) = ' + x2, 0, y2 + spacing);
777+
*
778+
* describe(`horizontal center line squareroot values displayed on
779+
* top and regular on bottom.`);
782780
* }
783781
* </code></div>
784-
*
785-
* @alt
786-
* horizontal center line squareroot values displayed on top and regular on bottom.
787782
*/
788783
p5.prototype.sqrt = Math.sqrt;
789784

@@ -839,16 +834,16 @@ function hypot(x, y, z) {
839834
* <div><code>
840835
* text(7345.73472742, 10, 25);
841836
* text(fract(7345.73472742), 10, 75);
837+
* describe(`first row having a number and the second having
838+
* the fractional part of the number`);
842839
* </code></div>
843840
*
844841
* <div><code>
845842
* text(1.4215e-15, 10, 25);
846843
* text(fract(1.4215e-15), 10, 75);
844+
* describe(`first row having a number expressed in scientific
845+
* notation and the second having the fractional part of the number`);
847846
* </code></div>
848-
*
849-
* @alt
850-
* first row having a number and the second having the fractional part of the number
851-
* first row having a number expressed in scientific notation and the second having the fractional part of the number
852847
*/
853848
p5.prototype.fract = function(toConvert) {
854849
p5._validateParameters('fract', arguments);

src/math/math.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ import p5 from '../core/main';
3030
* function draw() {
3131
* background(255);
3232
* line(v1.x, v1.y, mouseX, mouseY);
33+
* describe(`draws a line from center of canvas to mouse pointer position.`);
3334
* }
3435
* </code></div>
35-
*
36-
* @alt
37-
* draws a line from center of canvas to mouse pointer position.
3836
*/
3937
p5.prototype.createVector = function(x, y, z) {
4038
if (this instanceof p5) {

src/math/noise.js

+7-10
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ let perlin; // will be initialized lazily by noise() or noiseSeed()
7676
* xoff = xoff + 0.01;
7777
* let n = noise(xoff) * width;
7878
* line(n, 0, n, height);
79+
* describe(`vertical line moves left to right with updating
80+
* noise values.`);
7981
* }
8082
* </code>
8183
* </div>
@@ -89,13 +91,11 @@ let perlin; // will be initialized lazily by noise() or noiseSeed()
8991
* stroke(noiseVal*255);
9092
* line(x, mouseY+noiseVal*80, x, height);
9193
* }
94+
* describe(`horizontal wave pattern effected by mouse x-position
95+
* & updating noise values.`);
9296
* }
9397
* </code>
9498
* </div>
95-
*
96-
* @alt
97-
* vertical line moves left to right with updating noise values.
98-
* horizontal wave pattern effected by mouse x-position & updating noise values.
9999
*/
100100

101101
p5.prototype.noise = function(x, y = 0, z = 0) {
@@ -224,12 +224,11 @@ p5.prototype.noise = function(x, y = 0, z = 0) {
224224
* point(x + width / 2, y);
225225
* }
226226
* }
227+
* describe(`2 vertical grey smokey patterns affected by
228+
* mouse x-position and noise.`);
227229
* }
228230
* </code>
229231
* </div>
230-
*
231-
* @alt
232-
* 2 vertical grey smokey patterns affected my mouse x-position and noise.
233232
*/
234233
p5.prototype.noiseDetail = function(lod, falloff) {
235234
if (lod > 0) {
@@ -261,12 +260,10 @@ p5.prototype.noiseDetail = function(lod, falloff) {
261260
* xoff = xoff + .01;
262261
* let n = noise(xoff) * width;
263262
* line(n, 0, n, height);
263+
* describe(`vertical grey lines drawing in pattern affected by noise.`);
264264
* }
265265
* </code>
266266
* </div>
267-
*
268-
* @alt
269-
* vertical grey lines drawing in pattern affected by noise.
270267
*/
271268
p5.prototype.noiseSeed = function(seed) {
272269
// Linear Congruential Generator

src/math/p5.Vector.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ import * as constants from '../core/constants';
4141
* ellipse(v2.x, v2.y, 50, 50);
4242
* v1.add(v2);
4343
* ellipse(v1.x, v1.y, 50, 50);
44+
*
45+
* describe(`2 white ellipses. One center-left the other
46+
* bottom right and off canvas`);
4447
* </code>
4548
* </div>
46-
*
47-
* @alt
48-
* 2 white ellipses. One center-left the other bottom right and off canvas
4949
*/
5050
p5.Vector = function Vector() {
5151
let x, y, z;

0 commit comments

Comments
 (0)