@ -50,15 +50,25 @@ URL: https://github.com/Huddle/Resemble.js
return ( Math . abs ( c1 . r - c2 . r ) + Math . abs ( c1 . g - c2 . g ) + Math . abs ( c1 . b - c2 . b ) ) / 3 ;
return ( Math . abs ( c1 . r - c2 . r ) + Math . abs ( c1 . g - c2 . g ) + Math . abs ( c1 . b - c2 . b ) ) / 3 ;
}
}
function withinBoundingBox ( x , y , width , height ) {
function withinBoundingBox ( x , y , width , height , box ) {
if ( ! boundingBox ) {
return x > ( box . left || 0 ) &&
return true ;
x < ( box . right || width ) &&
y > ( box . top || 0 ) &&
y < ( box . bottom || height ) ;
}
function withinComparedArea ( x , y , width , height ) {
var isIncluded = true ;
if ( boundingBox !== undefined && ! withinBoundingBox ( x , y , width , height , boundingBox ) ) {
isIncluded = false ;
}
}
return x > ( boundingBox . left || 0 ) &&
if ( ignoredBox !== undefined && withinBoundingBox ( x , y , width , height , ignoredBox ) ) {
x < ( boundingBox . right || width ) &&
isIncluded = false ;
y > ( boundingBox . top || 0 ) &&
}
y < ( boundingBox . bottom || height ) ;
return isIncluded ;
}
}
var errorPixelTransform = {
var errorPixelTransform = {
@ -99,6 +109,7 @@ URL: https://github.com/Huddle/Resemble.js
var errorPixel = errorPixelTransform . flat ;
var errorPixel = errorPixelTransform . flat ;
var errorType ;
var errorType ;
var boundingBox ;
var boundingBox ;
var ignoredBox ;
var largeImageThreshold = 1200 ;
var largeImageThreshold = 1200 ;
var useCrossOrigin = true ;
var useCrossOrigin = true ;
var data = { } ;
var data = { } ;
@ -474,7 +485,7 @@ URL: https://github.com/Huddle/Resemble.js
}
}
var offset = ( verticalPos * width + horizontalPos ) * 4 ;
var offset = ( verticalPos * width + horizontalPos ) * 4 ;
var isWithinBoundingBox = withinBoundingBox ( horizontalPos , verticalPos , width , height ) ;
var isWithinComparedArea = withinComparedArea ( horizontalPos , verticalPos , width , height ) ;
if ( ! getPixelInfo ( pixel1 , data1 , offset , 1 ) || ! getPixelInfo ( pixel2 , data2 , offset , 2 ) ) {
if ( ! getPixelInfo ( pixel1 , data1 , offset , 1 ) || ! getPixelInfo ( pixel2 , data2 , offset , 2 ) ) {
return ;
return ;
@ -485,7 +496,7 @@ URL: https://github.com/Huddle/Resemble.js
addBrightnessInfo ( pixel1 ) ;
addBrightnessInfo ( pixel1 ) ;
addBrightnessInfo ( pixel2 ) ;
addBrightnessInfo ( pixel2 ) ;
if ( isPixelBrightnessSimilar ( pixel1 , pixel2 ) || ! isWithinBoundingBox ) {
if ( isPixelBrightnessSimilar ( pixel1 , pixel2 ) || ! isWithinComparedArea ) {
copyGrayScalePixel ( targetPix , offset , pixel2 ) ;
copyGrayScalePixel ( targetPix , offset , pixel2 ) ;
} else {
} else {
errorPixel ( targetPix , offset , pixel1 , pixel2 ) ;
errorPixel ( targetPix , offset , pixel1 , pixel2 ) ;
@ -495,7 +506,7 @@ URL: https://github.com/Huddle/Resemble.js
return ;
return ;
}
}
if ( isRGBSimilar ( pixel1 , pixel2 ) || ! isWithinBoundingBox ) {
if ( isRGBSimilar ( pixel1 , pixel2 ) || ! isWithinComparedArea ) {
copyPixel ( targetPix , offset , pixel1 ) ;
copyPixel ( targetPix , offset , pixel1 ) ;
} else if ( ignoreAntialiasing && (
} else if ( ignoreAntialiasing && (
@ -505,7 +516,7 @@ URL: https://github.com/Huddle/Resemble.js
isAntialiased ( pixel2 , data2 , 2 , verticalPos , horizontalPos , width )
isAntialiased ( pixel2 , data2 , 2 , verticalPos , horizontalPos , width )
) ) {
) ) {
if ( isPixelBrightnessSimilar ( pixel1 , pixel2 ) || ! isWithinBoundingBox ) {
if ( isPixelBrightnessSimilar ( pixel1 , pixel2 ) || ! isWithinComparedArea ) {
copyGrayScalePixel ( targetPix , offset , pixel2 ) ;
copyGrayScalePixel ( targetPix , offset , pixel2 ) ;
} else {
} else {
errorPixel ( targetPix , offset , pixel1 , pixel2 ) ;
errorPixel ( targetPix , offset , pixel1 , pixel2 ) ;
@ -629,6 +640,10 @@ URL: https://github.com/Huddle/Resemble.js
boundingBox = options . boundingBox ;
boundingBox = options . boundingBox ;
}
}
if ( options . ignoredBox !== undefined ) {
ignoredBox = options . ignoredBox ;
}
}
}
function compare ( one , two ) {
function compare ( one , two ) {