Skip to content

Commit 1a7e337

Browse files
committed
minor cleanup / comments
1 parent e916190 commit 1a7e337

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function pixelmatch(img1, img2, output, width, height, options) {
5151

5252
const pos = (y * width + x) * 4;
5353

54-
// squared YUV distance between colors at this pixel position
54+
// squared YUV distance between colors at this pixel position, negative if the img2 pixel is darker
5555
const delta = colorDelta(img1, img2, pos, pos);
5656

5757
// the color difference is above the threshold
@@ -64,9 +64,9 @@ function pixelmatch(img1, img2, output, width, height, options) {
6464
if (output && !options.diffMask) drawPixel(output, pos, ...options.aaColor);
6565

6666
} else {
67-
// found substantial difference not caused by anti-aliasing; draw it as red
67+
// found substantial difference not caused by anti-aliasing; draw it as such
6868
if (output) {
69-
drawPixel(output, pos, ...(options.diffColorAlt && delta < 0 ? options.diffColorAlt : options.diffColor));
69+
drawPixel(output, pos, ...(delta < 0 && options.diffColorAlt || options.diffColor));
7070
}
7171
diff++;
7272
}
@@ -207,6 +207,7 @@ function colorDelta(img1, img2, k, m, yOnly) {
207207

208208
const delta = 0.5053 * y * y + 0.299 * i * i + 0.1957 * q * q;
209209

210+
// encode whether the pixel lightens or darkens in the sign
210211
return y1 > y2 ? -delta : delta;
211212
}
212213

0 commit comments

Comments
 (0)