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
Copy file name to clipboardExpand all lines: src/data/en.yml
+131Lines changed: 131 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -351,6 +351,137 @@ learn:
351
351
p5-screen-reader-title: p5 with a screen reader
352
352
p5-screen-reader: Setting up p5 so that it can be used easily with a screen reader.
353
353
using-local-server-title: Using a local server
354
+
labeling-canvases-title: How to label your p5.js code
355
+
labeling-canvases: Using labels to make your code accessible to screen readers.
356
+
labeling-canvases-intro-1: 'This tutorial will teach you how to use the'
357
+
labeling-canvases-intro-2: and
358
+
labeling-canvases-intro-3: functions in your code so your canvases are readible by screen readers and other assistive technology.
359
+
labeling-canvases-what-is-labeling: What is screen reader labeling?
360
+
labeling-canvases-what-is-labeling-1: >-
361
+
The canvas HTML element compresses the visuals created by your p5 code into a bitmap. This
362
+
bitmap on its own doesn't provide any significant meaning or description about its contents to
363
+
screen readers. That’s why the p5.js <a class = "code" href="https://p5js.org/reference/#/p5/describe">describe()</a>,
364
+
<a class = "code" href="https://p5js.org/reference/#/p5/describeElement">describeElement()</a>, <a class = "code" href="https://p5js.org/reference/#/p5/gridOutput">gridOutput()</a>,
365
+
and <a class = "code" href="https://p5js.org/reference/#/p5/textOutput">textOutput()</a>
366
+
functions exist-- these allow you to manually add screen reader-accessible descriptions to your
367
+
code so that screen reader technologies can describe the canvas’ content in a meaningful way.
368
+
labeling-canvases-what-is-labeling-2: >-
369
+
Because a screen reader cannot naturally interpret the contents of a canvas bitmap, these functions
370
+
add labels into your code that instruct the screen reader on how to describe certain elements
371
+
within your canvas.
372
+
labeling-canvases-what-is-labeling-3: >-
373
+
For more further information about p5.js screen reader accessibility, please read
374
+
labeling-canvases-available-labels: Screen reader labels for p5.js
375
+
labeling-canvases-available-labels-1: p5.js offers four different functions for labeling your canvas
376
+
labeling-canvases-available-labels-li-1: <a class = "code" href="https://p5js.org/reference/#/p5/describe">describe()</a> provides an overall description of the canvas contents.
377
+
labeling-canvases-available-labels-li-2: <a class = "code" href="https://p5js.org/reference/#/p5/describeElement">describeElement()</a> describes a specific element or a specific grouping of elements in a canvas.
378
+
labeling-canvases-available-labels-li-3: >-
379
+
<a class = "code" href="https://p5js.org/reference/#/p5/textOutput">textOutput()</a> generates a list providing a canvas description and its (visual) elements, including the canvas' size,
380
+
canvas color, as well as each visual element’s color, position, and the amount of area the element covers within the canvas.
381
+
labeling-canvases-available-labels-li-4: >-
382
+
<a class = "code" href="https://p5js.org/reference/#/p5/gridOutput">gridOutput()</a>, like <a class = "code" href="https://p5js.org/reference/#/p5/textOutput">textOutput()</a>, generates a list of the canvas and its (visual) elements, only this function
383
+
arranges its output in a HTML table that plots the spatial location of each shape within the canvas. It also provides a basic
384
+
description of the canvas, including the canvas' size, canvas color, the number of visual elements, and the different visual element types inside the canvas.
385
+
labeling-canvases-best-practices: Labeling best practices
386
+
labeling-canvases-best-practices-what-requires-labeling: What requires labeling?
As a good rule of thumb, any visual element that is important to the overall context or purpose
389
+
of the canvas should be mentioned by the <a class = "code" href="https://p5js.org/reference/#/p5/describe">describe()</a> and/or <a class = "code" href="https://p5js.org/reference/#/p5/describeElement">describeElement()</a> functions.
Consider the overall purpose of the p5.js canvas and its contents in question, and label them in a way that makes
392
+
sense for the message, functionality, and/or purpose of the canvas and its elements. In the code block below, a heart is made within the canvas by placing two circles on top of a triangle.
393
+
Instead of individually labeling each shape used to make the heart, you should use one <a class = "code" href="https://p5js.org/reference/#/p5/describeElement">describeElement()</a> function to describe
If, at any point, an element in your canvas undergoes a change or alteration in its visual appearance (and this change is
397
+
important to the overall meaning and context of the canvas), it’s best to also update the <a class = "code" href="https://p5js.org/reference/#/p5/describeElement">describeElement()</a> label when that
The canvas HTML element will also rasterize any text within it. Use the <a class = "code" href="https://p5js.org/reference/#/p5/describeElement">describeElement()</a> function to translate any significant
401
+
text within your canvas.
402
+
labeling-canvases-best-practices-what-requires-labeling-5: In short, any significant visual, textual, or animated information within the canvas should be labeled with a screen reader label.
403
+
labeling-canvases-best-practices-dont-label: What DOESN'T need labeling
404
+
labeling-canvases-best-practices-dont-label-1: >-
405
+
Individual interactive elements, such as HTML buttons, dropdowns, or inputs, <i>do not</i> need to be labeled.
406
+
In the DOM, these elements are built outside of the p5.js canvas, and therefore can be interpreted by screen readers.
407
+
labeling-canvases-best-practices-dont-label-2: >-
408
+
This means the <a class = "code" href="https://p5js.org/reference/#/p5/gridOutput">gridOutput()</a> and <a class = "code" href="https://p5js.org/reference/#/p5/textOutput">textOutput()</a> functions will not provide any information about these interactive inputs in their
409
+
reports of the canvas, should you use them.
410
+
labeling-canvases-best-practices-using-labels: How to use labels
411
+
labeling-canvases-best-practices-using-labels-all-canvases: For all canvases
For canvases without any changing, moving, or interactive elements, you may use either the <a class = "code" href="https://p5js.org/reference/#/p5/describeElement">describeElement()</a>,
420
+
<a class = "code" href="https://p5js.org/reference/#/p5/gridOutput">gridOutput()</a>, or <a class = "code" href="https://p5js.org/reference/#/p5/textOutput">textOutput()</a>
421
+
functions to label the canvas’ visual content. However, keep in mind that <a class = "code" href="https://p5js.org/reference/#/p5/gridOutput">gridOutput()</a> and textOutput() generate their information based on
422
+
the rudimentary code of the visual element, such as its size, color, and shape-- these functions won’t be able to interpret your
423
+
intention in using such a shape within a larger visual built using multiple shapes.
If you are creating larger, multi-shaped visuals, then it would be best to use <a class = "code" href="https://p5js.org/reference/#/p5/describeElement">describeElement()</a> to define each visual grouping
430
+
present within the canvas.
431
+
labeling-canvases-best-practices-using-labels-interactive: For interactive or animated canvases
If your canvas contains any animated elements or elements that change their visual form via user input (the click of a button, a
434
+
dropdown selection, etc.), be sure that any descriptions of such elements update with their changes or animations. If you are using
435
+
<a class = "code" href="https://p5js.org/reference/#/p5/textOutput">textOutput()</a> or <a class = "code" href="https://p5js.org/reference/#/p5/gridOutput">gridOutput()</a> to describe the contents of your canvas, so long as these functions are placed within the draw() function, they
436
+
will automatically update with the shape’s new information. If you are using <a class = "code" href="https://p5js.org/reference/#/p5/describeElement">describeElement()</a>, use concatenation or another form of
437
+
variable input to update the element’s description.
If this interaction or animation is crucial to the overall purpose and/or message of the canvas, be sure to mention in either the <a class = "code" href="https://p5js.org/reference/#/p5/describe">describe()</a>
440
+
label or the individual element’s label that this element is (or can be) animated.
Naturally-interactive HTML elements, such as buttons or inputs, <i>do not</i> need to have a label. Instead, follow the proper role and ID
443
+
syntax for these elements when possible. For more information about how to properly label and ID HTML
444
+
interactive elements, visit <a href= "https://developer.mozilla.org/en-US/docs/Learn/Accessibility/HTML">Mozilla’s HTML: A good basis for accessibility</a>.
445
+
labeling-canvases-best-practices-using-labels-complex: For complex canvases
The p5 functions listed above do not afford the more complicated features of ARIA labeling, such as <span class="code">aria-live</span> or <span class="code">aria-atomic</span>.
448
+
For advanced canvases, using vanilla ARIA labeling and custom-built fallback content might better convey the canvas’
449
+
information to screen readers. Some cases where the canvas’ content cannot be accurately described (or represented) through p5.js’ supplied
450
+
screen reader labels include:
451
+
labeling-canvases-best-practices-using-labels-complex-ul-1: Canvases with content that changes extensively via external interactive elements.
Canvases with complex element layouts that cannot be accurately represented using the <a class = "code" href="https://p5js.org/reference/#/p5/describe">describe()</a>, <a class = "code" href="https://p5js.org/reference/#/p5/describeElement">describeElement()</a>,
457
+
<a class = "code" href="https://p5js.org/reference/#/p5/textOutput">textOutput()</a>, or <a class = "code" href="https://p5js.org/reference/#/p5/gridOutput">gridOutput()</a> functions.
For more information about fallback content, visit <a href="https://www.w3.org/html/wg/wiki/DefinitionFallBackContent">W3C’s Wiki</a>. For more information about complex ARIA labeling,
460
+
visit <a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes">Mozilla’s ARIA states and properties</a>.
461
+
labeling-canvases-how-not-to-use-labels: How NOT to use labels
462
+
labeling-canvases-how-not-to-use-labels-sub: As a substitution for poorly organized code
463
+
labeling-canvases-how-not-to-use-labels-sub-1: >-
464
+
Screen reader labels should not be used as a way of commenting your code. These labels
465
+
should only be used to summarize the resulting visual elements within a canvas.
466
+
labeling-canvases-how-not-to-use-labels-info-overkill: As information overkill
467
+
labeling-canvases-how-not-to-use-labels-info-overkill-1: If you overuse screen reader labels in your code, you may end up overly complicating the screen reader’s interpretation of the canvas rather than helping it.
468
+
labeling-canvases-how-not-to-use-labels-info-overkill-2: Within reason, less is more with screen reader labeling. Be concise, accurate, and short with your label descriptions.
Do not use both the <a class = "code" href="https://p5js.org/reference/#/p5/textOutput">textOutput()</a> and <a class = "code" href="https://p5js.org/reference/#/p5/gridOutput">gridOutput()</a> functions in the same canvas. You only need to use one or the other to describe the canvas elements.
471
+
Using both will cause redundancy in the screen readers’ translation of your code. This also pertains to using <a class = "code" href="https://p5js.org/reference/#/p5/textOutput">textOutput()</a> or
472
+
<a class = "code" href="https://p5js.org/reference/#/p5/gridOutput">gridOutput()</a> with additional <a class = "code" href="https://p5js.org/reference/#/p5/describeElement">describeElement()</a>
473
+
labels. It’s best to choose one strategy of labeling for your entire canvas, and stick with it.
474
+
labeling-canvases-testing-labels: Testing labels during development
475
+
labeling-canvases-testing-labels-1: >-
476
+
All these functions have a display parameter that either keeps its output only available to screen readers <span class="code">(FALLBACK)</span> or presents the output as text
477
+
adjacent to the canvas <span class="code">(LABEL)</span>. If you would like to see the output during development, add <span class="code">LABEL</span> as the last parameter for the function. <span class="code">FALLBACK</span> is the default parameter.
478
+
labeling-canvases-testing-labels-2: >-
479
+
When testing your labels, consider the following questions: Do your canvas labels provide enough information for someone to understand its purpose? If this canvas
480
+
exists on a website, or among any other content, would someone have a good understanding of how the canvas’ content interacts and/or pertains to the surrounding context?
481
+
labeling-canvases-testing-labels-3: >-
482
+
In order to reduce redundancy, be sure to reset the display parameter to <span class="code">FALLBACK</span> once you’ve tested the output. With <span class="code">LABEL</span> active, screen readers will read the fallback text
483
+
and the visible label text when focused on the canvas.
484
+
labeling-canvases-note: Notice any errors or typos? Please let us know. If you would like to contribute to this tutorial, feel free to issue a pull request!
354
485
using-local-server: 'How to set up a local server on Mac OSX, Windows, or Linux.'
355
486
p5js-wiki-title: p5.js wiki
356
487
p5js-wiki: Additonal documentation and tutorials contributed by the community
0 commit comments