-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Accessibility Features Proposal - Expand Web Accessibility module #6992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks @calebfoss! Tagging @limzykenneth and @davepagurek to review. |
Hi @calebfoss I am interested in taking the implementation these 3 features.
Should I submit as 3 separate Pull Requests ? |
@Forchapeatl, I appreciate you volunteering to work on this! I think before starting on those, there is a decision to be made on whether textOutput and gridOutput should remain part of the library. Above, I argue for deprecating them. If they are not removed, I include suggestions in the "Keeping textOutput() and gridOutput()" section. I would hate for you to put time and effort until something just before it gets removed anyway! @Qianqianye, is there a plan on whether to keep those functions? And if not, are there other web accessibility features that need support? I took a quick look at the current issues and p5 2.0 proposals list to see if there was anything to suggest, but I didn't immediately find anything. |
Regarding splitting this into more workable chunks, given that neither textOutput() not, here's my 2 cents (please feel free to iterate on this):
I think 4-7 and the following are blocked by additional input, as I've mentioned before, same as:
This is where I really don't feel like I have the ability to make a judgment. The more I go through into the prior research (almost a decade) on these features in p5.js, the more I feel that deciding whether to invest development in something like However, I think 1-3 above can be underway. Apologies if I missed something. What do you think @calebfoss ? |
@ksen0 - Great breakdown and feedback! Totally agree that the more open question of how to write descriptions for screen readers would greatly benefit from the testing you have planned. Before evaluating the scope for the future of textOutput() and gridOutput(), it would be important to determine how often a technical description of the shapes present on a canvas is preferable to a custom written one (via describe() / describeElement()) for people who use screen readers. My expectation would be almost never, but I do not use a screen reader. I imagine that there is data/documentation archived somewhere from the research Claire Kearney-Volpe did with screen reader users years ago that informed these features in the first place. I also found this presentation from over a decade ago with some really interesting ideas on accessible HTML5 canvas descriptions. A couple specific notes: 3 - Good point about prefers-reduced-motion, but my take is that starting paused as a default, regardless of prefers-reduced-motion, would keep the implementation simpler and not rely on the page visitor having marked that setting on their device. Bonus benefits of this beyond accessibility would be that the play button could also switch focus to the canvas element and/or initialize audio contexts, allowing keyboard input and audio playback as soon as the button is pressed. Regarding my pitch to return objects from shape functions: I should note that this is sort of a breaking change. While I don't think this was every documented on the website, I believe those functions were marked as chainable in the JSDoc. I have never seen anyone actually use this in p5, but you can technically do this: const sketch = (p) => {
p.setup = () => {
p.createCanvas(400, 400);
p.background(0)
.fill('pink')
.circle(200, 200, 100);
}
}
new p5(sketch); (this works in global mode too, but is even less useful there) |
Topic
Written for the p5.js Documentation Organization & Accessibility project, this issue proposes a plan for upcoming improvements to p5's accessibility features.
Background on Existing Features
p5's gridOutput() and textOutput() methods are very cleverly designed tools that aim to automatically describe the content on the canvas.
Current limitations and issues for these methods include:
So currently, these functions can accurately describe sketches featuring exclusively 2D primitives, each with somewhat distinct features, all on the canvas for an English-reading audience. They describe the color, approximate location, and approximate percentage of space occupied of each shape.
I would argue that this improves accessibility for a very limited selection of p5 sketches. Even those that can be accurately described.
Example
textOutput() produces the following description
The description is technically accurate, but I would argue that it is significantly less useful at conveying the content than a concise, manually written description such as
Side Note on AI
An idea I anticipate coming up in relation to the issue I presented above is to use AI-generated descriptions. I would like to take a moment to strongly advise against that because
Moving forward
I would say that these features have a fork in the road ahead. They can either be further developed to improve accuracy and warn the creator about limitations or they can be removed from p5. With respect for the contributors who developed these very impressive features, unfortunately, I think the best path forward is the latter.
Keeping textOutput() and gridOutput()
That being said, if textOutput() and gridOutput() not removed, I would recommend:
My opinion is that the above changes are a lot of work for features that would only improve accessibility in very limited situations.
Removing textOutput() and gridOutput()
Instead, I would recommend removing those methods and focusing on encouraging creators to describe their sketches effectively and to provide good resources to do so. While automating this task is an enticing idea, there is something very human about effectively conveying visual content through written language. Learning to write a helpful accessible description is just as valuable as to making strong web content as learning to generate imagery programmatically.
Already, the Writing Accessible Canvas Descriptions tutorial is a fantastic resource. Additionally, sketches featured Examples page on the new p5 site include describe(), describeElement(), textOutput(), and/or gridOutput().
Returning an Object with a Describe Method
Here is an idea that would be a big undertaking but perhaps not as big as the improvements textOutput() and gridOutput() listed above and, I would argue, would have a much bigger impact:
What if instead of returning the p5 instance, visual functions returned an object that contained information about it and a method to describe it?
Example:
This is essentially a way to more directly connect what describeElement() does to the functions producing what it describes. Storing the arguments passed into the shape functions helps the creator keep track of what those values represent.
In many cases, an "element" of the composition will be rendered using multiple functions, so describeElement() will still be useful for those cases.
A potential additional feature this could open the door for would be using isPointInPath() and/or isPointInStroke() to store in this object a boolean property indicating whether the shape was clicked this frame.
In my experience, the work required to check if a shape was clicked (either manually through collision detection algorithms or through loading a library) is a significant obstacle to p5 creators.
Performance impact would need testing, as the way I am describing this feature, those methods would need to be called every time any shape is drawn. Additionally, the mouse coordinates would need to be transformed using the current transformation matrix.
I believe that some of the existing helper functions for textOutput() and gridOutput() could be repurposed to keep track of "ingredients" and reuse HTML elements.
Color Contrast
Issue #6971 proposes a way to check whether the contrast between colors in a sketch is meeting WCAG AA or AAA.
I drafted a method to calculate contrast based on WebAIM's tool. When passed two p5.Color's, it returns the contrast ratio between them: https://editor.p5js.org/cfoss/sketches/-okUAfg7Z
Note that this does not currently account for alpha level or blend mode, and it would need to do that for accuracy.
This could be modified to check for specific AA and AAA target ratios. I would argue, though, that this information would be better placed in the reference, where it could be linked, contextualized, and updated without modifying the function itself.
@limzykenneth responded
While I think a broader accessibility checker is an exciting idea, I believe that implementing it such that it reliably gives accurate results would be a daunting task.
I am not aware of a way to check what default styles a browser has applied to an element beyond the styles set via CSS, style property, etc. On top of that, accounting for all the possible factors that would influence which element appears on top of which would be very challenging.
For those reasons, when it comes to color contrast at least, I do not think automatically checking elements is a realistic goal.
I could imagine an automatic checker for semantic structure: checking for more than one h1, mismatching h1 and title, disorganized heading levels, etc. Having a button in the p5 editor that opens such a checker would be great.
Flashing light
WCAG 2.3.2 specifies limits on flashing light.
I would propose a method for testing whether what is rendered to the canvas meets these limits written something like
that would throw a friendly error if and when the sketch fails the test. This could share a helper function with the contrast function as both are based on relative luminance.
Calculating relative luminance across the canvas every frame would likely be quite computationally expensive, but for running a test, I think that would be acceptable.
Disabling Animation
WCAG 2.3.3 specifies that "Motion animation triggered by interaction can be disabled, unless the animation is essential to the functionality or the information being conveyed."
I would propose that, by default, p5 create an HTML element that acts as a pause/play button for the sketch, connected to loop()/noLoop(). This behavior could be disabled or reenabled with methods called something like noPause() and allowPause() respectively.
(edited typos)
The text was updated successfully, but these errors were encountered: