Skip to content

Commit

Permalink
v 1.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
nakednous committed Jul 26, 2023
1 parent 2307bba commit fc2e409
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions demo/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function setup() {
s3 = '?'
// quadrilles
board = createQuadrille(COLS, ROWS);
console.log(board.isFilled(-1, 0));
quadrille = active(int(random(8)));
// current position
col = int(random(0, COLS - 4));
Expand Down
7 changes: 5 additions & 2 deletions p5.quadrille.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class Quadrille {
// ii. fill result with passed quadrilles
for (let i = 0; i < quadrille.height; i++) {
for (let j = 0; j < quadrille.width; j++) {
let result = operator(quadrille1.read(row < 0 ? i + row : i, col < 0 ? j + col : j), quadrille2.read(row > 0 ? i - row : i, col > 0 ? j - col : j));
let result = operator(quadrille1.read(row < 0 ? i + row : i, col < 0 ? j + col : j, false), quadrille2.read(row > 0 ? i - row : i, col > 0 ? j - col : j, false));
if (result !== undefined) {
quadrille._memory2D[i][j] = result;
}
Expand Down Expand Up @@ -672,10 +672,13 @@ class Quadrille {
* @param {number} col
* @returns {p5.Image | p5.Graphics | p5.Color | Array | object | string | number} quadrille entry or undefined id (row, col) is out of bounds
*/
read(row, col) {
read(row, col, warn = true) {
if (row >= 0 && row < this.height && col >= 0 && col < this.width) {
return this._memory2D[row][col];
}
else if (warn) {
console.warn(`undefined cell @(${row}, ${col}) which is out of bounds ([0..${this.height}], [0..${this.width}])`);
}
}

/**
Expand Down

0 comments on commit fc2e409

Please sign in to comment.