Skip to content

Commit 52a20ba

Browse files
authored
Merge branch 'useDescribeOnPrimitives' into main
2 parents 9814cd2 + 00b8dc1 commit 52a20ba

File tree

3 files changed

+146
-90
lines changed

3 files changed

+146
-90
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>

0 commit comments

Comments
 (0)