From fc2e409bc4eefe6527ae363acbc534b30a8b833f Mon Sep 17 00:00:00 2001 From: nakednous Date: Wed, 26 Jul 2023 10:10:24 -0500 Subject: [PATCH] v 1.3.4 --- demo/sketch.js | 1 + p5.quadrille.js | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/demo/sketch.js b/demo/sketch.js index acc6670..95b907f 100644 --- a/demo/sketch.js +++ b/demo/sketch.js @@ -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)); diff --git a/p5.quadrille.js b/p5.quadrille.js index 15c9fb5..5345851 100644 --- a/p5.quadrille.js +++ b/p5.quadrille.js @@ -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; } @@ -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}])`); + } } /**