Skip to content

Commit fa1e024

Browse files
committed
Added tutorial copy
1 parent fde69b2 commit fa1e024

File tree

8 files changed

+900
-0
lines changed

8 files changed

+900
-0
lines changed

src/data/en.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,137 @@ learn:
351351
p5-screen-reader-title: p5 with a screen reader
352352
p5-screen-reader: Setting up p5 so that it can be used easily with a screen reader.
353353
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?
387+
labeling-canvases-best-practices-what-requires-labeling-1: >-
388+
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.
390+
labeling-canvases-best-practices-what-requires-labeling-2: >-
391+
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
394+
the overall shape you made.
395+
labeling-canvases-best-practices-what-requires-labeling-3: >-
396+
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
398+
change occurs.
399+
labeling-canvases-best-practices-what-requires-labeling-4: >-
400+
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
412+
labeling-canvases-best-practices-using-labels-all-canvases-1: >-
413+
No matter the canvas’ purpose or contents, you should <i>always</i> use a label to supply an overall summary of the canvas. Most often,
414+
you’ll use the <a class = "code" href="https://p5js.org/reference/#/p5/describe">describe()</a> function for this summary.
415+
labeling-canvases-best-practices-using-labels-all-canvases-2: >-
416+
The summary should provide a general understanding of the visuals inside the canvas.
417+
labeling-canvases-best-practices-using-labels-simple: For simple, non-animated canvases
418+
labeling-canvases-best-practices-using-labels-simple-1: >-
419+
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.
424+
labeling-canvases-best-practices-using-labels-simple-2: >-
425+
Keep in mind the context and objective of the canvas’ contents when choosing which function(s) to use: Is it better to describe the flower
426+
as eight circles and a rectangle, or as a flower with red petals and a green stem? What kind of labeling will provide the best
427+
description of your canvas?
428+
labeling-canvases-best-practices-using-labels-simple-3: >-
429+
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
432+
labeling-canvases-best-practices-using-labels-interactive-1: >-
433+
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.
438+
labeling-canvases-best-practices-using-labels-interactive-2: >-
439+
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.
441+
labeling-canvases-best-practices-using-labels-interactive-3: >-
442+
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
446+
labeling-canvases-best-practices-using-labels-complex-1: >-
447+
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.
452+
labeling-canvases-best-practices-using-labels-complex-ul-2: >-
453+
Canvases with content that requires the user’s attention if it is changed or altered by another element, especially if that element is not
454+
embedded in the canvas’ code.
455+
labeling-canvases-best-practices-using-labels-complex-ul-3: >-
456+
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.
458+
labeling-canvases-best-practices-using-labels-complex-2: >-
459+
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.
469+
labeling-canvases-how-not-to-use-labels-info-overkill-3: >-
470+
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!
354485
using-local-server: 'How to set up a local server on Mac OSX, Windows, or Linux.'
355486
p5js-wiki-title: p5.js wiki
356487
p5js-wiki: Additonal documentation and tutorials contributed by the community

0 commit comments

Comments
 (0)