* @module Environment * @submodule Environment * @for p5
(p5, fn)
| 5 | */ |
| 6 | |
| 7 | function describe(p5, fn){ |
| 8 | const descContainer = '_Description'; //Fallback container |
| 9 | const fallbackDescId = '_fallbackDesc'; //Fallback description |
| 10 | const fallbackTableId = '_fallbackTable'; //Fallback Table |
| 11 | const fallbackTableElId = '_fte_'; //Fallback Table Element |
| 12 | const labelContainer = '_Label'; //Label container |
| 13 | const labelDescId = '_labelDesc'; //Label description |
| 14 | const labelTableId = '_labelTable'; //Label Table |
| 15 | const labelTableElId = '_lte_'; //Label Table Element |
| 16 | |
| 17 | /** |
| 18 | * Creates a screen reader-accessible description of the canvas. |
| 19 | * |
| 20 | * The first parameter, `text`, is the description of the canvas. |
| 21 | * |
| 22 | * The second parameter, `display`, is optional. It determines how the |
| 23 | * description is displayed. If `LABEL` is passed, as in |
| 24 | * `describe('A description.', LABEL)`, the description will be visible in |
| 25 | * a div element next to the canvas. If `FALLBACK` is passed, as in |
| 26 | * `describe('A description.', FALLBACK)`, the description will only be |
| 27 | * visible to screen readers. This is the default mode. |
| 28 | * |
| 29 | * Read |
| 30 | * <a href="/learn/accessible-labels.html">Writing accessible canvas descriptions</a> |
| 31 | * to learn more about making sketches accessible. |
| 32 | * |
| 33 | * @method describe |
| 34 | * @param {String} text description of the canvas. |
| 35 | * @param {(FALLBACK|LABEL)} [display] either LABEL or FALLBACK. |
| 36 | * |
| 37 | * @example |
| 38 | * function setup() { |
| 39 | * background('pink'); |
| 40 | * |
| 41 | * // Draw a heart. |
| 42 | * fill('red'); |
| 43 | * noStroke(); |
| 44 | * circle(67, 67, 20); |
| 45 | * circle(83, 67, 20); |
| 46 | * triangle(91, 73, 75, 95, 59, 73); |
| 47 | * |
| 48 | * // Add a general description of the canvas. |
| 49 | * describe('A pink square with a red heart in the bottom-right corner.'); |
| 50 | * } |
| 51 | * |
| 52 | * @example |
| 53 | * function setup() { |
| 54 | * background('pink'); |
| 55 | * |
| 56 | * // Draw a heart. |
| 57 | * fill('red'); |
| 58 | * noStroke(); |
| 59 | * circle(67, 67, 20); |
| 60 | * circle(83, 67, 20); |
| 61 | * triangle(91, 73, 75, 95, 59, 73); |
| 62 | * |
| 63 | * // Add a general description of the canvas |
| 64 | * // and display it for debugging. |
no test coverage detected