Polish Bento scrolling and controls with full screen coverage
This commit is contained in:
@@ -19,9 +19,9 @@ function decode(buffer) {
|
||||
}
|
||||
return {width,height,channels,pixels};
|
||||
}
|
||||
function differentPixels(first,second){
|
||||
function differentPixels(first,second,channelTolerance=0){
|
||||
const a=decode(first),b=decode(second);if(a.width!==b.width||a.height!==b.height||a.channels!==b.channels)return Infinity;
|
||||
let count=0;for(let i=0;i<a.pixels.length;i+=a.channels)if(!a.pixels.subarray(i,i+a.channels).equals(b.pixels.subarray(i,i+a.channels)))count++;
|
||||
let count=0;for(let i=0;i<a.pixels.length;i+=a.channels)if([...a.pixels.subarray(i,i+a.channels)].some((value,channel)=>Math.abs(value-b.pixels[i+channel])>channelTolerance))count++;
|
||||
return count;
|
||||
}
|
||||
module.exports={differentPixels};
|
||||
|
||||
Reference in New Issue
Block a user