aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


tools/client/compare_bb_fonts.py (1165B)


      1 """Compare the identical chat lines in the saved 13.6 and 14.9.1 BB frames."""
      2 
      3 import hashlib
      4 import json
      5 import pathlib
      6 
      7 import PIL.Image
      8 
      9 
     10 root = pathlib.Path(__file__).resolve().parents[2]
     11 results = []
     12 masks = []
     13 for version in ['13.6', '14.9.1']:
     14     path = root / f'docs/images/bronto-burger-{version}.png'
     15     screenshot = PIL.Image.open(path).convert('RGB')
     16     assert screenshot.size == (1024, 768)
     17 
     18     # Exact foreground colors separate the text from the changing world behind it.
     19     mask = bytes(1 if pixel == (255, 255, 255) else 2 if pixel == (255, 0, 0) else 0
     20                  for pixel in screenshot.crop((0, 690, 250, 750)).get_flattened_data())
     21     assert 1 in mask and 2 in mask
     22     masks.append(mask)
     23     results.append({'version': version, 'image_sha256': hashlib.sha256(path.read_bytes()).hexdigest(),
     24                     'text_mask_sha256': hashlib.sha256(mask).hexdigest()})
     25 
     26 report = {'captures': results, 'different_text_pixels': sum(a != b for a, b in zip(*masks))}
     27 output = root / 'local/client/fonts/bb-font-comparison.json'
     28 output.write_text(json.dumps(report, indent=2) + '\n', encoding='ascii')
     29 print(json.dumps(report, indent=2))