Polish Bento scrolling and controls with full screen coverage

This commit is contained in:
Jonathan Sykes
2026-10-04 23:44:51 +08:00
parent 4e5b1584c6
commit 1754933f7e
9 changed files with 229 additions and 14 deletions

View File

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