replace(value1, value2)

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 replace value1 with value2, all cells containing value1 must share the same memory reference, see search().

Syntax #

replace(value1, value2)

Parameters #

ParamDescription
value1Any: A valid JavaScript value
value2Any: A valid JavaScript value