"""Author the fixed slide-shaped grid demonstration tiles; not real microscopy or device control."""
from pathlib import Path
import json
P=Path(__file__).resolve().parent
points=[(29,8),(101,12),(57,21),(14,26),(85,33)]
def value(x,y):
    if any((x==cx and abs(y-cy)<=3) or (y==cy and abs(x-cx)<=3) for cx,cy in points):
        return 240
    if x%12==0 or y%10==0:
        return 132
    return 54+((x//4+y//4)%2)*21
tiles=[]
for r in range(2):
    for c in range(4):
        ox,oy=c*28,r*20
        tiles.append(dict(id=f'R{r}C{c}',column=c,row=r,originMm=[8+ox*.5,2+oy*.5],widthPx=32,heightPx=24,
            pixels=[value(ox+x,oy+y) for y in range(24) for x in range(32)]))
fixture={'schema':'bts.vs200-inert-mosaic-input.v1','slideId':'CAL-VS200-GRID-001','revision':1,'source':'Original fixed synthetic grid, not generated by any scanner','slideMm':[76,26,1],'mosaicOriginMm':[8,2],'mosaicSizePx':[116,44],'pixelMm':.5,'tiles':tiles}
(P/'fixture.json').write_text(json.dumps(fixture,separators=(',',':'))+'\n')
