"""F1 zero-threshold diff of the lossless native destination screenshots, int32 math, top 64 px masked."""
import sys, pathlib, numpy as np
from PIL import Image, ImageDraw
root = pathlib.Path(sys.argv[1]); out = pathlib.Path(sys.argv[2])
for theme, b, h in (('dark', 'bd', 'hd'), ('light', 'bl', 'hl')):
    arrs = []
    for d in (b, h):
        im = Image.open(root / d / 'destination.png').convert('RGB')
        ImageDraw.Draw(im).rectangle((0, 0, im.width - 1, 63), fill='#808080')
        arrs.append(np.asarray(im).astype(np.int32))
    nd = np.abs(arrs[0] - arrs[1])
    img = np.minimum(nd * 255, 255).astype(np.uint8)
    Image.fromarray(img).save(out / f'F1-{theme}-lossless-diff0.png')
    changed = nd.max(2) > 0
    ys = np.where(changed.any(1))[0]
    print(theme, 'size', nd.shape[1], 'x', nd.shape[0], 'changed', int(changed.sum()),
          'rows', (int(ys.min()), int(ys.max())) if len(ys) else None,
          'outside y2242-2320', int(changed[:2242].sum() + changed[2321:].sum()))
