fill(value)

Fills all empty cells in the quadrille with the specified value — filled cells are never overwritten (to re-value those, use replace(value); to start over, clear first). Returns the quadrille (chainable).

Example

(click or press a key to toggle between filling empty cells and resetting to random colors)

edit, then run

Note

Empty cells appear black because the background is set to black (background(0)), while the fill color is white (fill(255)).

Note

One value, one instance. A non-factory value is stored as-is in every cell: all cells filled by the call share the same instance. That single fact powers two idioms elsewhere in the API — strict search matches across cells (===), and flood fill/flood clear treat them as one connected region, since the flood matches the start cell's value by identity. Per-cell instances instead — e.g. a fresh color('green') per cell via Quadrille.factory — would strict-match nothing and flood nowhere. When sharing is the point, Quadrille.singleton(value) names the intent in code: a pure identity function — the value passes through unmodified — that reads as the semantic mirror of Quadrille.factory.

Syntax

fill(value)

Parameters

Param Description
value1 Any: A valid JavaScript value
  1. A plain function value is stored, not called — it becomes a per-cell display routine, invoked with the options object alone — ({ row, col, origin }) => { ... } — and with this bound to the drawing context (see display functions). To have a function evaluated per cell at fill time — a fresh object or a varied tile per cell — tag it: Quadrille.factory(({ row, col }) => new Object(...)), which marks the function in place and returns that same function. ↩
What this page's examples use
p5.quadrille
drawQuadrille createQuadrille cellLength rand fill
p5.js
createCanvas background color

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.