@@ -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