Read

read() #

Returns the contents of the quadrille cell at (row, col). Returns undefined if the cell doesn’t exist.

Example #

code
let quadrille;
let al;

function preload() {
  al = loadImage('../abraham_lincoln.jpg');
}

function setup() {
  createCanvas(200, 300);
  quadrille = createQuadrille([['hi', 100],
                               [null, color('magenta')],
                               [al]]);
  fill('yellow');
}

function draw() {
  background('green');
  drawQuadrille(quadrille);
  const row = quadrille.mouseRow;
  const col = quadrille.mouseCol;
  const cell = quadrille.read(row, col);
  const x = col * Quadrille.cellLength + 5;
  const y = row * Quadrille.cellLength + 15;
  text(cell === null ? 'null' : quadrille.isImage(row, col) ? 
                                'abraham' : cell, x, y);
}

Syntax #

read(row, col)

Parameters #

paramdescription
rowNumber: col number of the cell to be read [0..height]
colNumber: row number of the cell to be read [0..width]