Replaces all cells containing value1
with value2
in the quadrille.
Example #
(click on any cell to replace all cells with the same value with a 🙈; press any key to reset)
code
Quadrille.cellLength = 40;
let quadrille;
let red, lime, blue, cyan;
function setup() {
createCanvas(400, 400);
red = color('red');
lime = color('lime');
blue = color('blue');
cyan = color('cyan');
reset();
}
function draw() {
background('black');
drawQuadrille(quadrille);
}
function mouseClicked() {
const row = quadrille.mouseRow;
const col = quadrille.mouseCol;
const value = quadrille.read(row, col);
quadrille.replace(value, '🙈');
}
function keyPressed() {
reset();
}
function reset() {
quadrille = createQuadrille(10, 10, 25, red);
quadrille.rand(25, lime).rand(25, blue);
}
To replacevalue1
withvalue2
, all cells containingvalue1
must share the same memory reference, see search().
Syntax #
replace(value1, value2)
Parameters #
Param | Description |
---|---|
value1 | Any: A valid JavaScript value |
value2 | Any: A valid JavaScript value |