From b15285aab3dbb825557e8d4c426c12afa8f0cda8 Mon Sep 17 00:00:00 2001 From: nakednous Date: Sat, 30 Oct 2021 08:30:30 -0500 Subject: [PATCH] Fixes possible mask drawing issue; ver 0.3.1 --- examples/convolution/sketch.js | 7 +++++++ p5.quadrille.js | 13 ++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/examples/convolution/sketch.js b/examples/convolution/sketch.js index 38d2328..eeebe4c 100644 --- a/examples/convolution/sketch.js +++ b/examples/convolution/sketch.js @@ -22,9 +22,16 @@ function preload() { function setup() { createCanvas(800, 800); + // /* mask = createQuadrille([[0.0625, 0.125, 0.0625], [0.125, 0.25, 0.125], [0.0625, 0.125, 0.0625]]); + // */ + /* + mask = createQuadrille([ [ -1, -1, -1 ], + [ -1, 9, -1 ], + [ -1, -1, -1 ] ]); + // */ update(); } diff --git a/p5.quadrille.js b/p5.quadrille.js index d8fb022..7307851 100644 --- a/p5.quadrille.js +++ b/p5.quadrille.js @@ -21,7 +21,7 @@ class Quadrille { /** * Current library version. */ - static version = '0.3.0'; + static version = '0.3.1'; /** * @param {Quadrille} quadrille1 @@ -352,8 +352,8 @@ class Quadrille { r = constrain(r, 0, 255); g = constrain(g, 0, 255); b = constrain(b, 0, 255); - this.memory2D[row][col] = [r, g, b]; - //this.memory2D[row][col] = color(r, g, b); + //this.memory2D[row][col] = [r, g, b]; + this.memory2D[row][col] = color(r, g, b); } } @@ -373,8 +373,8 @@ class Quadrille { let g = green(pattern0) * coords.w0 + green(pattern1) * coords.w1 + green(pattern2) * coords.w2; let b = blue(pattern0) * coords.w0 + blue(pattern1) * coords.w1 + blue(pattern2) * coords.w2; let a = alpha(pattern0) * coords.w0 + alpha(pattern1) * coords.w1 + alpha(pattern2) * coords.w2; - this.memory2D[i][j] = [r, g, b, a]; - //this.memory2D[i][j] = color(r, g, b, a); + //this.memory2D[i][j] = [r, g, b, a]; + this.memory2D[i][j] = color(r, g, b, a); } } } @@ -630,8 +630,11 @@ class Quadrille { this.rect(j * LENGTH, i * LENGTH, LENGTH, LENGTH); } else if (typeof quadrille.memory2D[i][j] === 'number' && min < max) { + this.push(); + this.colorMode(this.RGB, 255); this.fill(this.color(this.map(quadrille.memory2D[i][j], min, max, 0, 255), alpha)); this.rect(j * LENGTH, i * LENGTH, LENGTH, LENGTH); + this.pop(); } } else if (board) {