Prepare scanner branch for merge

This commit is contained in:
AzuTear
2026-07-09 08:44:50 +02:00
parent f791d1464c
commit 8b73c01e46
69 changed files with 6700 additions and 3773 deletions
+21
View File
@@ -18,6 +18,18 @@ function bitmap(goldPixels: number, total: number): Bitmap {
return { data, width: total, height: 1 };
}
function solidPixels(pixels: Array<{ b: number; g: number; r: number }>): Bitmap {
const data = Buffer.alloc(pixels.length * 4);
pixels.forEach((pixel, index) => {
const offset = index * 4;
data[offset] = pixel.b;
data[offset + 1] = pixel.g;
data[offset + 2] = pixel.r;
data[offset + 3] = 255;
});
return { data, width: pixels.length, height: 1 };
}
describe("lockDetection", () => {
it("places the lock crop on the lock button in the substat panel", () => {
const size = { width: 2560, height: 1440 };
@@ -41,4 +53,13 @@ describe("lockDetection", () => {
expect(detectLockState(bitmap(20, 100))).toBe(true);
expect(detectLockState(bitmap(1, 100))).toBe(false);
});
it("counts the current red lock glyph but ignores grey unlocked button pixels", () => {
expect(lockSignalRatio(solidPixels([{ b: 90, g: 92, r: 235 }]))).toBe(1);
expect(lockSignalRatio({ data: Buffer.from([235, 92, 90, 255]), width: 1, height: 1 })).toBe(1);
expect(lockSignalRatio({ data: Buffer.from([255, 235, 92, 90]), width: 1, height: 1 })).toBe(1);
expect(lockSignalRatio(solidPixels([{ b: 235, g: 235, r: 235 }]))).toBe(0);
expect(lockSignalRatio({ data: Buffer.from([255, 235, 235, 235]), width: 1, height: 1 })).toBe(0);
expect(lockSignalRatio(solidPixels([{ b: 120, g: 122, r: 128 }]))).toBe(0);
});
});