You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve Accessibility Guidance for describe() Usage (#8101)
* Add fontWidth() and clarify textWidth vs fontWidth docs in attributes.js
* updated as per maintainers comment, only documentation is updated
* Add fontWidth() and clarify textWidth vs fontWidth docs in attributes.js; simple docs are updated, not code
* aded docs for difference between textWidth and fontWidth with respect to whitespace
* unnecesaary file introduced, removed it, cleanedup the thing i was supposed to do
* docs updated as asked
* removed things from previous pr
* i think done, if not will ask maintainer
* check, merge conflicts
* updated the docs as per suggesstion from perminder
* fixes as per review
* updated the bad code and good code examples, so actually now can diffrentiated b/w them
* fix:inverted comma typos
* invert typos
* invert typos
* invert typos
* invert typos
* invert typos
* invert typos
* invert typos
* invert typos
* invert typos
* invert typos
* invert typos
* invert typos
* invert typos
* invert typos
* invert typos
* invert typos
* invert typos
* invert typos
* invert typos to do fix
* invert typos to do fix
* invert typos to do fix
* invert typos to do fix
* invert typos to do fix
* invert typos to do fix
* invert typos to do fix
* invert typos to do fix
* invert typos to do fix
* invert typos to do fix
* invert typos to do fix
* invert typos to do fix
* invert typos to do fix
* had docs style section repeated, removed to resolve redundancy
* Tidy web accessibility updates
* Tidy updates to documentation style guide
* Tidy documentation style guide table of contents
* Tidy web accessibility references in contributor docs
* Tidy contributing documentation for describe()
* Tidy unintended change in textCore.js
* Update contributor_docs/documentation_style_guide.md
---------
Co-authored-by: kit <1304340+ksen0@users.noreply.github.com>
Co-authored-by: Perminder Singh <127239756+perminder-17@users.noreply.github.com>
Copy file name to clipboardExpand all lines: contributor_docs/contributing_to_the_p5js_reference.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -308,7 +308,7 @@ Finally, for every example you add, you are required to use the p5.js function `
308
308
* </div>
309
309
```
310
310
311
-
For more on `describe()` visit the [web accessibility contributor documentation](./web_accessibility/#describe).
311
+
For more on `describe()` visit the [web accessibility contributor documentation](./web_accessibility/#describe), and the [Writing Accessible Canvas Descriptions](https://p5js.org/tutorials/writing-accessible-canvas-descriptions/) tutorial.
312
312
313
313
With all the above you should have most of the tools needed to write and edit p5.js reference comments. However, there are a few more specialized usage of JSDoc style reference comments that you may come across in p5.js. These are situationally useful and not something that you need often.
@@ -116,7 +117,7 @@ Always use `let` to declare variables.
116
117
117
118
**Pronouns**
118
119
119
-
| Recommended |Not Recommended |
120
+
| Recommended |Not Recommended |
120
121
| -- | -- |
121
122
| they | he or she |
122
123
| them | him or her |
@@ -142,7 +143,7 @@ Always use `let` to declare variables.
142
143
143
144
The following terminology is adapted from the WordPress documentation guidelines for [Writing inclusive documentation](https://make.wordpress.org/docs/style-guide/general-guidelines/inclusivity/#accessibility-terminology). For more background on people-first language, see the CDC's guide on [Communicating With and About People with Disabilities](https://www.cdc.gov/ncbddd/disabilityandhealth/materials/factsheets/fs-communicating-with-people.html).
144
145
145
-
| Recommended |Not Recommended |
146
+
| Recommended |Not Recommended |
146
147
| -- | -- |
147
148
| person with disability | the disabled, handicapped, differently abled, challenged, abnormal |
148
149
| person without disability | normal person, healthy person, able-bodied |
@@ -230,6 +231,50 @@ let magicWord = 'Please';
230
231
231
232
```
232
233
234
+
235
+
**[⬆ back to top](#table-of-contents)**
236
+
237
+
## Accessible Canvas Labels
238
+
239
+
- Use `describe()` to in p5.js example code, to add labels to your canvas so that it’s readable for screen readers.
240
+
241
+
> Why? It makes examples accessible to screen readers, and models how to write good canvas labels.
242
+
243
+
244
+
```javascript
245
+
// Good.
246
+
functionsetup() {
247
+
createCanvas(100, 100);
248
+
describe('A red heart in the bottom right corner of a pink background.');
249
+
}
250
+
251
+
// Bad.
252
+
functionsetup() {
253
+
createCanvas(100, 100);
254
+
describe('heart shape');
255
+
}
256
+
257
+
// Good.
258
+
functiondraw() {
259
+
background(220);
260
+
fill(0, 255, 0);
261
+
ellipse(mouseX, 50, 40, 40);
262
+
// Label updates with shape's translation.
263
+
describe(`A green circle at x pos ${round(mouseX)} moving with the mouse pointer.`, LABEL);
264
+
}
265
+
```
266
+
267
+
- Don’t use screen reader labels as a way of commenting your code. Labels should only summarize the resulting visual elements within a canvas.
268
+
269
+
- Don’t overuse screen reader labels, as you may end up complicating the screen reader’s interpretation of the canvas rather than helping it.
270
+
271
+
- Do make your label descriptions short and accurate. The recommended length for label descriptions is one to two sentences. Use full sentences for your labels, and write in the present tense when describing elements.
272
+
273
+
The above examples and suggestions are based on the [Writing Accessible Canvas Descriptions tutorial](https://p5js.org/tutorials/writing-accessible-canvas-descriptions/). This tutorial gives more detailed guidance, and includes other ways to label your canvas, in addition to `describe()`: `describeElement()`, `textOutput()`, and `gridOutput()`.
274
+
275
+
To understand the structure of p5.js’ web accessibility features for contributors, see the [Web Accessibility Contributor Doc](./web_accessibility.md#user-generated-accessible-canvas-descriptions).
Copy file name to clipboardExpand all lines: contributor_docs/web_accessibility.md
+6-7Lines changed: 6 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,10 +51,10 @@ This description is followed by a list of shapes where the color, position, and
51
51
> orange circle at top left covering 1% of the canvas.\
52
52
> fuchsia square, at bottom right, covering 2% of the canvas.
53
53
54
-
Each element can be selected to get more details. A table of elements is also provided. In this table, each element’s shape, color, location, coordinates, and area are described:
54
+
Each element can be selected to get more details. A table of elements is also provided. In this table, each element’s shape, color, location, coordinates, and area are described:
55
55
56
56
> orange circle location=top left area=1%\
57
-
> fuchsia square location = bottom right area = 2%
57
+
> fuchsia square location = bottom right area = 2%
58
58
59
59
<details>
60
60
<summary>This generates the following HTML:</summary>
@@ -100,7 +100,7 @@ Each element can be selected to get more details. A table of elements is also pr
100
100
101
101
`gridOutput()` lays out the content of the canvas in the form of a grid using an HTML table element. Each shape’s location in the grid is based on its spatial location on the canvas. A brief description of the canvas is available before the table output. This description includes the color of the background, size of the canvas, number of objects, and object types:
102
102
103
-
> lavender blue canvas, 400 by 400 pixels, contains 2 shapes: 1 circle 1 square
103
+
> lavender blue canvas, 400 by 400 pixels, contains 2 shapes: 1 circle 1 square
104
104
105
105
Each shape’s description is placed in a cell of the table depending on its location on the canvas. Each description includes the color and type of shape:
106
106
@@ -123,8 +123,8 @@ The generated HTML is as follows:
The `describeElement()` function creates a screen reader-accessible description for groups of shapes that create meaning together. For example, a custom-drawn “heart” shape made out of multiple lines of code. The first parameter should be a string with the name of the element, for example, “Heart”. The second parameter should be a string with the description of the element, for example, “A red heart in the bottom-right corner.” The third parameter is optional. If a user passes `LABEL` as a third parameter, an additional `<div>` element is inserted next to the `<canvas>` element. The new \<div> will contain a visible version of the same description embedded in the `<canvas>` element.
275
+
The `describeElement()` function creates a screen reader-accessible description for groups of shapes that create meaning together. For example, a custom-drawn “heart” shape made out of multiple lines of code. The first parameter should be a string with the name of the element, for example, “Heart”. The second parameter should be a string with the description of the element, for example, “A red heart in the bottom-right corner.” The third parameter is optional. If a user passes `LABEL` as a third parameter, an additional `<div>` element is inserted next to the `<canvas>` element. The new \<div> will contain a visible version of the same description embedded in the `<canvas>` element.
276
276
277
277
`describeElement()` is supported by several functions in [src/accessibility/describe.js](https://github.com/processing/p5.js/blob/main/src/accessibility/describe.js):
278
278
@@ -300,4 +300,3 @@ function setup() {
300
300
The page will output:
301
301
302
302

0 commit comments