diff --git a/index.js b/index.js index 807d148..15094a2 100644 --- a/index.js +++ b/index.js @@ -188,9 +188,9 @@ function colorDelta(img1, img2, k, m, yOnly) { if (!da && !dr && !dg && !db) return 0; if (a1 < 255 || a2 < 255) { // blend pixels with background - const rb = 255; - const gb = 255; - const bb = 255; + const rb = 48 + 159 * (k % 2); + const gb = 48 + 159 * ((k / 1.618033988749895 | 0) % 2); + const bb = 48 + 159 * ((k / 2.618033988749895 | 0) % 2); dr = (r1 * a1 - r2 * a2 - rb * da) / 255; dg = (g1 * a1 - g2 * a2 - gb * da) / 255; db = (b1 * a1 - b2 * a2 - bb * da) / 255; diff --git a/test/fixtures/5diff.png b/test/fixtures/5diff.png index 04b664d..d7f3461 100644 Binary files a/test/fixtures/5diff.png and b/test/fixtures/5diff.png differ diff --git a/test/fixtures/8a.png b/test/fixtures/8a.png new file mode 100644 index 0000000..6f003e9 Binary files /dev/null and b/test/fixtures/8a.png differ diff --git a/test/fixtures/8diff.png b/test/fixtures/8diff.png new file mode 100644 index 0000000..9627f6f Binary files /dev/null and b/test/fixtures/8diff.png differ diff --git a/test/test.js b/test/test.js index da653bb..1b9af70 100644 --- a/test/test.js +++ b/test/test.js @@ -20,10 +20,11 @@ diffTest('2a', '2b', '2diff', { }, 12437); diffTest('3a', '3b', '3diff', options, 212); diffTest('4a', '4b', '4diff', options, 36049); -diffTest('5a', '5b', '5diff', options, 0); +diffTest('5a', '5b', '5diff', options, 6); diffTest('6a', '6b', '6diff', options, 51); diffTest('6a', '6a', '6empty', {threshold: 0}, 0); diffTest('7a', '7b', '7diff', {diffColorAlt: [0, 255, 0]}, 2448); +diffTest('8a', '5b', '8diff', options, 32896); test('throws error if image sizes do not match', () => { assert.throws(() => match(new Uint8Array(8), new Uint8Array(9), null, 2, 1), 'Image sizes do not match');