29 lines
2.7 KiB
Python
29 lines
2.7 KiB
Python
"""Render evidence comparisons and a numeric table from captured browser results."""
|
|
import json,csv,hashlib
|
|
from pathlib import Path
|
|
from PIL import Image,ImageDraw,ImageFont
|
|
out=Path('../evidence/hel818');data=json.loads((out/'results.json').read_text())
|
|
font=ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf',20)
|
|
comparisons=out/'comparisons';comparisons.mkdir(exist_ok=True)
|
|
thumbs=[]
|
|
for row in data['geometry']:
|
|
theme,width,height=row['id'],row['width'],row['height']
|
|
left=Image.open(out/f'shots/reference-mapped-{theme}-{width}.png').convert('RGB');right=Image.open(out/f'shots/app-{theme}-{width}.png').convert('RGB')
|
|
im=Image.new('RGB',(width*2,height+44),'#202127');draw=ImageDraw.Draw(im);draw.text((12,10),f'Approved sample + real data/state mapping | {theme} {width}x{height}',font=font,fill='white');draw.text((width+12,10),'Application | same data/state | offline font condition',font=font,fill='white');im.paste(left,(0,44));im.paste(right,(width,44));im.save(comparisons/f'compare-{theme}-{width}.png');im.thumbnail((960,350));thumbs.append(im.copy())
|
|
# Rows follow viewport-major browser capture order, keeping labels visible.
|
|
overview=Image.new('RGB',(1920,350*((len(thumbs)+1)//2)),'#202127')
|
|
for i,im in enumerate(thumbs):overview.paste(im,((i%2)*960,(i//2)*350))
|
|
overview.save(out/'comparison-overview.png')
|
|
with (out/'geometry.csv').open('w',newline='') as f:
|
|
w=csv.writer(f);w.writerow(['theme','viewport','component','app_x','app_y','app_width','app_height','reference_x','reference_y','reference_width','reference_height','delta_width','delta_height','app_font','reference_font','app_bg','reference_bg','app_border','reference_border','app_radius','reference_radius'])
|
|
for row in data['geometry']:
|
|
for key,a in row['actual'].items():
|
|
b=row['reference'][key]
|
|
w.writerow([row['id'],row['width'],key,a['x'],a['y'],a['width'],a['height'],b['x'],b['y'],b['width'],b['height'],a['width']-b['width'],a['height']-b['height'],a['font'],b['font'],a['bg'],b['bg'],a['border'],b['border'],a['radius'],b['radius']])
|
|
references=Path('../references')
|
|
(out/'reference-sha256.json').write_text(json.dumps({p.name:hashlib.sha256(p.read_bytes()).hexdigest() for p in references.iterdir() if p.is_file()},ensure_ascii=False,indent=2))
|
|
print('BROWSER CHECKS',len(data['checks']),'PASS',sum(bool(x['pass']) for x in data['checks']),'ERRORS',len(data['errors']))
|
|
print('ANIMATION RECORDS',len(data['animations']))
|
|
for row in data['geometry']:
|
|
if row['id']=='night':print('GEOMETRY',row['width'],{k:[row['actual'][k]['width'],row['actual'][k]['height'],row['reference'][k]['width'],row['reference'][k]['height']] for k in ['title','controls','minimap','chat','entity','artifact']})
|