Fills cells matching a predicate condition with the specified value.

Example#

(move the mouse to fill empty cells in the current row with 🐉; click to reset)

code
Quadrille.cellLength = 40;
let quadrille;

function setup() {
  createCanvas(400, 400);
  reset();
}

function draw() {
  background('black');
  drawQuadrille(quadrille);
}

function mouseMoved() {
  quadrille.fill(({ row, col, value }) => row === quadrille.mouseRow && value === null, '🐉');
}

function mouseClicked() {
  reset();
}

function reset() {
  quadrille = createQuadrille(10, 10, 15, color('purple'));
  quadrille.rand(15, color('orange')).rand(15, color('yellow'));
}

Syntax#

fill(predicate, value)

Parameters#

ParamDescription
predicateFunction: A predicate function ({ row, col, value }) => boolean selecting cells to fill
value1Any: A valid JavaScript value

  1. A plain function value is stored, not called — it becomes a per-cell display routine ({ row, col, options }) => { ... } (see options). 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(...))↩︎