Inclusive Design 24
15 MAY 2014 #GAAD
Mark Sadecki (@cptvitamin)
http://j.mp/a11y-canvas
The past,
the present,
and the future
walked into a bar.
It was tense.
* Looking for recruits (contact mark@w3.org)
<canvas>
<canvas>
?A 2D drawing API that includes drawing functions for rendering interactive bitmap images
<canvas id="magic"
width="350" height="196">
</canvas>
What happens in the canvas, stays in the canvas.
<canvas id="magic"
width="350" height="196">
<h1 id="magic-recipe">Making magic</h1>
<ol>
<li>Find a unicorn</li>
<li>Coax it under
your coat tails</li>
<li>Misdirect audience
(flash of smoke?)</li>
<li>Reveal unicorn like a boss</li>
</ol>
<button id="button">Abracadabra!</button>
</canvas>
<canvas>
one<canvas>
itself<canvas>
is just a bitmap/pixelsEvents
on the canvas to the associated fallback elements.addHitRegion(id, control)
removeHitRegion(id)
clearHitRegions()
<canvas>
drawFocusIfNeeded(element)
30 MAY 2014
Currently only supported by Firefox Nightly 32.0a1 (2014-05-30) with experimental flags enabled:
canvas.focusrings.enabled true
canvas.hitregions.enabled true
To enable expermental flags in Firefox, type about:config (a colon seperates the two words) in your browser's address bar and then limit the results by searching for canvas.
This will be no "Call of Duty"
Game should be:
<canvas id="game" width="150" height="200">
<p id="status" tabindex="0" aria-live="assertive">Start</p>
<p id="00"></p>
<p id="01"></p>
<p id="02"></p>
<p id="10"></p>
<p id="11"></p>
<p id="12"></p>
<p id="20"></p>
<p id="21"></p>
<p id="22"></p>
<p id="oob" tabindex="0">Out of Bounds!</p>
</canvas>
<p aria-live="polite">Score: <span id="score">0</span></p>
Drawing squares in <canvas>
is easy
// draw a 5px by 5px square
ctx.beginPath();
ctx.fillStyle = color;
ctx.rect(x, y, 5, 5);
ctx.fill();
// color grid for creeper, loop over to draw character
var creeper = [
["#7D9C79", "#008000", "#348828", ... "#366B36"],
["#599A4C", "#7D9C79", "#62A853", ... "#789776"],
["#008000", "#292929", "#2B2B2B", ... "#366B36"],
["#348828", "#2D2D2D", "#000000", ... "#93939C"],
...
["#789776", "#7D9C79", "#4A4A4A", ... "#62A853"],
];
<canvas>
element.
<p>
// draw a button and assign a Hit Region to it
function drawButton( id ) {
ctx.beginPath();
ctx.fillStyle = "green";
ctx.rect( 0, 0, 100, 30 );
ctx.fill();
ctx.addHitRegion(
{ id: id,
control: document.getElementById(id)
});
}
drawFocusIfNeeded(element)
Whenever a focus change event occurs, the drawFocusIfNeeded()
method is invoked and an indicator, consistent with the default focus indicator for the browser and operating system is drawn on the canvas.
I called this function whenever I drew a path to the Canvas that was associated with a fallback element and I wanted to move focus to it.
function drawFocus( elem ){
elem.focus();
ctx.drawFocusIfNeeded( elem );
}
canvas.focusrings.enabled
and canvas.hitregions.enabled
set to trueThis is normally where the live demo would happen. If you are not having success in your environment, or don't have a screen reader or screen magnication software installed, feel free to watch the videos on the following slides.
View "Accessible Canvas Game Demo" on Youtube http://j.mp/cnv-demo
View "Game Demo using Screenreader" on Youtube http://j.mp/cnv-scr
View "Game Demo using Screen Magnification" on Youtube http://j.mp/cnv-mag
Inclusive Design 24
15 MAY 2014 #GAAD
Mark Sadecki (@cptvitamin)
http://j.mp/a11y-canvas
View presentation:
http://j.mp/a11y-canvas
Issues and Pull Requests
are welcome:
http://j.mp/a11y-whack
The past,
the present,
and the future
walked into a bar.
It was tense.
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
f | Toggle fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
w | Pause/Resume the presentation |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |