Skip to content

Commit 5a5983e

Browse files
authored
Merge branch 'main' into issue-5139-docs-alt-to-describe
2 parents 78d53cd + 52a20ba commit 5a5983e

File tree

15 files changed

+314
-134
lines changed

15 files changed

+314
-134
lines changed

contributor_docs/inline_documentation.md

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ noFill();
189189
arc(50, 55, 60, 60, HALF_PI, PI);
190190
arc(50, 55, 70, 70, PI, PI+QUARTER_PI);
191191
arc(50, 55, 80, 80, PI+QUARTER_PI, TWO_PI);
192+
describe('shattered outline of ellipse created using four arcs');
192193
</code>
193194
</div>
194195
```
@@ -200,19 +201,28 @@ by a line break.
200201
```
201202
@example
202203
<div>
203-
<code>arc(50, 50, 80, 80, 0, PI+QUARTER_PI, OPEN);</code>
204+
<code>
205+
arc(50, 50, 80, 80, 0, PI+QUARTER_PI, OPEN);
206+
describe('ellipse created using arc with its top right open');
207+
</code>
204208
</div>
205209
206210
<div>
207-
<code>arc(50, 50, 80, 80, 0, PI, OPEN);</code>
211+
<code>
212+
arc(50, 50, 80, 80, 0, PI, OPEN);
213+
describe('bottom half of an ellipse created using arc');
214+
</code>
208215
</div>
209216
```
210217

211218
If you do not want the example to execute your code (i.e. you just want the code to show up), include the class "norender" in the div:
212219
```
213220
@example
214221
<div class="norender">
215-
<code>arc(50, 50, 80, 80, 0, PI+QUARTER_PI, OPEN);</code>
222+
<code>
223+
arc(50, 50, 80, 80, 0, PI+QUARTER_PI, OPEN);
224+
describe('ellipse created using arc with its top right open');
225+
</code>
216226
</div>
217227
```
218228

@@ -230,8 +240,42 @@ function setup() {
230240

231241
If you need to link to external asset files, put them in [/docs/yuidoc-p5-theme/assets](https://github.com/processing/p5.js/tree/main/docs/yuidoc-p5-theme/assets) and then link to them with "assets/filename.ext" in the code. See the [tint example](http://p5js.org/reference/#/p5/tint).
232242

233-
### Adding alt-text
234-
Finally, for every example you add, please add [alt-text](https://moz.com/learn/seo/alt-text) so visually impaired users can understand what the example is showing on the screen. This can be added with the tag `@alt` at the end of all of the examples for a given function (not an individual `@alt` tag under each), add a line break to separate the descriptions for multiple examples.
243+
### Add a canvas description using describe()
244+
Finally, for every example you add, you are required to use the p5.js function `describe()` in the example to create a screen-reader accessible description for the canvas. Include only one parameter: a string with a brief description of what is happening on the canvas. Do NOT add a second parameter.
245+
```
246+
@example
247+
<div>
248+
<code>
249+
let xoff = 0.0;
250+
function draw() {
251+
background(204);
252+
xoff = xoff + 0.01;
253+
let n = noise(xoff) * width;
254+
line(n, 0, n, height);
255+
decribe('vertical line moves left to right with updating noise values');
256+
}
257+
</code>
258+
</div>
259+
260+
<div>
261+
<code>
262+
let noiseScale=0.02;
263+
function draw() {
264+
background(0);
265+
for (let x=0; x < width; x++) {
266+
let noiseVal = noise((mouseX+x)*noiseScale, mouseY*noiseScale);
267+
stroke(noiseVal*255);
268+
line(x, mouseY+noiseVal*80, x, height);
269+
}
270+
describe('horizontal wave pattern effected by mouse x-position & updating noise values');
271+
}
272+
</code>
273+
</div>
274+
275+
```
276+
For more on `describe()` visit the [web accessibility contributor docs](https://p5js.org/contributor-docs/#/web_accessibility?id=user-generated-accessible-canvas-descriptions).
277+
278+
Previous documentation guidelines required adding [alt-text](https://moz.com/learn/seo/alt-text) to create screen-reader accessible canvas description. THIS IS NO LONGER RECOMMENDED. ALWAYS USE `describe()`. Previously, alt-text was added with the tag `@alt` at the end of all of the examples for a given function (not an individual `@alt` tag under each), and an added a line break to separate the descriptions for multiple examples.
235279
```
236280
@example
237281
<div>

src/color/setting.js

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ import './p5.Color';
4040
* <code>
4141
* // Grayscale integer value
4242
* background(51);
43-
* describe('canvas with darkest charcoal grey background.');
43+
* describe('canvas with darkest charcoal grey background');
4444
* </code>
4545
* </div>
4646
*
4747
* <div>
4848
* <code>
4949
* // R, G & B integer values
5050
* background(255, 204, 0);
51-
* describe('canvas with yellow background.');
51+
* describe('canvas with yellow background');
5252
* </code>
5353
* </div>
5454
*
@@ -57,73 +57,74 @@ import './p5.Color';
5757
* // H, S & B integer values
5858
* colorMode(HSB);
5959
* background(255, 204, 100);
60-
* describe('canvas with royal blue background.');
60+
* describe('canvas with royal blue background');
6161
* </code>
6262
* </div>
6363
*
6464
* <div>
6565
* <code>
6666
* // Named SVG/CSS color string
6767
* background('red');
68-
* describe('canvas with red background.');
68+
* describe('canvas with red background');
6969
* </code>
7070
* </div>
7171
*
7272
* <div>
7373
* <code>
7474
* // three-digit hexadecimal RGB notation
7575
* background('#fae');
76-
* describe('canvas with pink background.');
76+
* describe('canvas with pink background');
7777
* </code>
7878
* </div>
7979
*
8080
* <div>
8181
* <code>
8282
* // six-digit hexadecimal RGB notation
8383
* background('#222222');
84-
* describe('canvas with black background.');
84+
* describe('canvas with black background');
8585
* </code>
8686
* </div>
8787
*
8888
* <div>
8989
* <code>
9090
* // integer RGB notation
9191
* background('rgb(0,255,0)');
92-
* describe('canvas with bright green background.');
92+
* describe('canvas with bright green background');
9393
* </code>
9494
* </div>
9595
*
9696
* <div>
9797
* <code>
9898
* // integer RGBA notation
9999
* background('rgba(0,255,0, 0.25)');
100-
* describe('canvas with soft green background.');
100+
* describe('canvas with soft green background');
101101
* </code>
102102
* </div>
103103
*
104104
* <div>
105105
* <code>
106106
* // percentage RGB notation
107107
* background('rgb(100%,0%,10%)');
108-
* describe('canvas with red background.');
108+
* describe('canvas with red background');
109109
* </code>
110110
* </div>
111111
*
112112
* <div>
113113
* <code>
114114
* // percentage RGBA notation
115115
* background('rgba(100%,0%,100%,0.5)');
116-
* describe('canvas with light purple background.');
116+
* describe('canvas with light purple background');
117117
* </code>
118118
* </div>
119119
*
120120
* <div>
121121
* <code>
122122
* // p5 Color object
123123
* background(color(0, 0, 255));
124-
* describe('canvas with blue background.');
124+
* describe('canvas with blue background');
125125
* </code>
126126
* </div>
127+
*
127128
*/
128129

129130
/**
@@ -203,11 +204,13 @@ p5.prototype.background = function(...args) {
203204
* function mousePressed() {
204205
* clear();
205206
* background(128);
207+
* describe(
208+
* 'canvas is cleared, small white ellipse is drawn at mouse X and mouse Y'
209+
* );
206210
* }
207211
* </code>
208212
* </div>
209213
*
210-
*
211214
* @param {Number} r normalized red val.
212215
* @param {Number} g normalized green val.
213216
* @param {Number} b normalized blue val.
@@ -253,8 +256,9 @@ p5.prototype.clear = function(...args) {
253256
* point(i, j);
254257
* }
255258
* }
256-
* describe(`Green to red gradient from bottom L to top R.
257-
* Shading originates from top left.`);
259+
* describe(
260+
* 'Green to red gradient from bottom left to top right with shading from top left'
261+
* );
258262
* </code>
259263
* </div>
260264
*
@@ -280,7 +284,7 @@ p5.prototype.clear = function(...args) {
280284
* colorMode(RGB, 1);
281285
* let myColor = c._getRed();
282286
* text(myColor, 10, 10, 80, 80);
283-
* describe('unknown image.');
287+
* describe('value of color red 0.4980... written on canvas');
284288
* </code>
285289
* </div>
286290
*
@@ -293,11 +297,10 @@ p5.prototype.clear = function(...args) {
293297
* stroke(255, 0, 10, 0.3);
294298
* ellipse(40, 40, 50, 50);
295299
* ellipse(50, 50, 40, 40);
296-
* describe(`50×50 ellipse at middle L & 40×40 ellipse at center.
297-
* Translucent pink outlines.`);
300+
* describe('two translucent pink ellipse outlines at middle left and at center');
298301
* </code>
299302
* </div>
300-
303+
*
301304
*/
302305

303306
/**
@@ -373,8 +376,7 @@ p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) {
373376
* // Grayscale integer value
374377
* fill(51);
375378
* rect(20, 20, 60, 60);
376-
* describe(`60×60 dark charcoal grey rect with black outline in center
377-
* of canvas.`);
379+
* describe('dark charcoal grey rect with black outline in center of canvas');
378380
* </code>
379381
* </div>
380382
*
@@ -383,7 +385,7 @@ p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) {
383385
* // R, G & B integer values
384386
* fill(255, 204, 0);
385387
* rect(20, 20, 60, 60);
386-
* describe('60×60 yellow rect with black outline in center of canvas.');
388+
* describe('yellow rect with black outline in center of canvas');
387389
* </code>
388390
* </div>
389391
*
@@ -393,7 +395,7 @@ p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) {
393395
* colorMode(HSB);
394396
* fill(255, 204, 100);
395397
* rect(20, 20, 60, 60);
396-
* describe('60×60 royal blue rect with black outline in center of canvas.');
398+
* describe('royal blue rect with black outline in center of canvas');
397399
* </code>
398400
* </div>
399401
*
@@ -402,7 +404,7 @@ p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) {
402404
* // Named SVG/CSS color string
403405
* fill('red');
404406
* rect(20, 20, 60, 60);
405-
* describe('60×60 red rect with black outline in center of canvas.');
407+
* describe('red rect with black outline in center of canvas');
406408
* </code>
407409
* </div>
408410
*
@@ -411,7 +413,7 @@ p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) {
411413
* // three-digit hexadecimal RGB notation
412414
* fill('#fae');
413415
* rect(20, 20, 60, 60);
414-
* describe('60×60 pink rect with black outline in center of canvas.');
416+
* describe('pink rect with black outline in center of canvas');
415417
* </code>
416418
* </div>
417419
*
@@ -420,7 +422,7 @@ p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) {
420422
* // six-digit hexadecimal RGB notation
421423
* fill('#222222');
422424
* rect(20, 20, 60, 60);
423-
* describe('60×60 black rect with black outline in center of canvas.');
425+
* describe('black rect with black outline in center of canvas');
424426
* </code>
425427
* </div>
426428
*
@@ -429,7 +431,7 @@ p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) {
429431
* // integer RGB notation
430432
* fill('rgb(0,255,0)');
431433
* rect(20, 20, 60, 60);
432-
* describe('60×60 light green rect with black outline in center of canvas.');
434+
* describe('bright green rect with black outline in center of canvas');
433435
* </code>
434436
* </div>
435437
*
@@ -438,7 +440,7 @@ p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) {
438440
* // integer RGBA notation
439441
* fill('rgba(0,255,0, 0.25)');
440442
* rect(20, 20, 60, 60);
441-
* describe('60×60 soft green rect with black outline in center of canvas.');
443+
* describe('soft green rect with black outline in center of canvas');
442444
* </code>
443445
* </div>
444446
*
@@ -447,7 +449,7 @@ p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) {
447449
* // percentage RGB notation
448450
* fill('rgb(100%,0%,10%)');
449451
* rect(20, 20, 60, 60);
450-
* describe('60×60 red rect with black outline in center of canvas.');
452+
* describe('red rect with black outline in center of canvas');
451453
* </code>
452454
* </div>
453455
*
@@ -456,7 +458,7 @@ p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) {
456458
* // percentage RGBA notation
457459
* fill('rgba(100%,0%,100%,0.5)');
458460
* rect(20, 20, 60, 60);
459-
* describe('60×60 dark fuchsia rect with black outline in center of canvas.');
461+
* describe('dark fuchsia rect with black outline in center of canvas');
460462
* </code>
461463
* </div>
462464
*
@@ -465,7 +467,7 @@ p5.prototype.colorMode = function(mode, max1, max2, max3, maxA) {
465467
* // p5 Color object
466468
* fill(color(0, 0, 255));
467469
* rect(20, 20, 60, 60);
468-
* describe('60×60 blue rect with black outline in center of canvas.');
470+
* describe('blue rect with black outline in center of canvas');
469471
* </code>
470472
* </div>
471473
*/

0 commit comments

Comments
 (0)