drawing arrays
drawQuadrille also renders a raw 1D or 2D JS array directly, wrapping it on the fly as a live zero-copy view: a real quadrille that aliases the array — reads and writes go through; nothing is copied or repaired. The call returns the view, with mouseRow/mouseCol live on it. The exact contract and limitations vs a full quadrille:
- Empty means
null(orundefined) — neverfalse,0, or'': abool[][]renders ✅/❎ and zeros render dark; filter at draw or normalize. - Display is the only verb arrays get — no algebra, queries, or transforms on raw arrays; adopt the returned view (aliases) or createQuadrille (copies, normalizes, owns) for the rest of the API.
- Aliasing is cell-deep, not shape-deep:
fill/clear/replace/flood on the view write through to the array, whilerotate/transpose/shift/sortand resizing rebuild memory and silently detach the view. - Nothing is normalized: width is row 0's length — shorter rows render their missing tail empty, longer rows truncate, holes render empty.
- One small view object is allocated per call (cell data is never copied) — fine at sketch scale.
mouseRow/mouseColare live on the instance the call just drew — capture the return value each frame rather than keeping a stale one.
Example
(click a cell to write '🧱' into the raw array — the next frame renders it live)
Note
Note how the
bool[][]row renders ✅/❎ and the zeros render dark (point 1): emptiness isnull, day one — not falsiness.
Note
The view is a quadrille, so
drawQuadrille(view)also works — adopt it once and draw it to skip even the per-call view allocation (point 5). The array form is the entry sugar; the view is what you hold.
Syntax
drawQuadrille(array, [{ params }])
Parameters
| Param | Description |
|---|---|
array |
Array: a raw 2D array (rows of arrays) or 1D array (wrapped as a single row) — aliased, never copied |
params |
Object: the same optional rendering params drawQuadrille takes for a quadrille, display functions included |
What this page's examples use
- p5.quadrille
drawQuadrillecellLength- p5.js
createCanvasbackground
Names the analysis can prove are called, and the line each one is documented on. Local variables and members of an unknown receiver are left out.