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#
| Param | Description |
|---|---|
predicate | Function: A predicate function ({ row, col, value }) => boolean selecting cells to fill |
value1 | Any: A valid JavaScript value |