Skip to content

Commit

Permalink
Check avg of color channels
Browse files Browse the repository at this point in the history
  • Loading branch information
davepagurek committed Jan 10, 2025
1 parent 26265be commit 3dc5eb9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/unit/visual/visualTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ export async function checkMatch(actual, expected, p5) {

let ok = true;
for (let i = 0; i < diff.pixels.length; i += 4) {
let diffSum = 0;
for (let off = 0; off < 3; off++) {
if (diff.pixels[i+off] > COLOR_THRESHOLD) {
ok = false;
break;
}
diffSum += diff.pixels[i+off]
}
diffSum /= 3;
if (diffSum > COLOR_THRESHOLD) {
ok = false;
break;
}
if (!ok) break;
}

return { ok, diff };
Expand Down

0 comments on commit 3dc5eb9

Please sign in to comment.