Skip to content

Commit

Permalink
adding bounds to limit rgb values in filter
Browse files Browse the repository at this point in the history
  • Loading branch information
nakednous committed Oct 26, 2021
1 parent 8976b0d commit 43c59e3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions p5.quadrille.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class Quadrille {
let r = 0;
let g = 0;
let b = 0;
let a = 0;
//let a = 0;
for (let imask = 0; imask < mask.height; imask++) {
for (let jmask = 0; jmask < mask.width; jmask++) {
let i = row + imask - cache_half_size;
Expand All @@ -347,11 +347,16 @@ class Quadrille {
r += red(neighbour) * weight;
g += green(neighbour) * weight;
b += blue(neighbour) * weight;
a += alpha(neighbour) * weight;
//a += alpha(neighbour) * weight;
}
}
}
this.memory2D[row][col] = [r, g, b, a];
r = constrain(r, 0, 255);
g = constrain(g, 0, 255);
b = constrain(b, 0, 255);
//a = constrain(a, 0, 255);
//this.memory2D[row][col] = [r, g, b, a];
this.memory2D[row][col] = [r, g, b];
}
}

Expand Down

0 comments on commit 43c59e3

Please sign in to comment.