app
AI Flow
Public Made by Adomby adom
Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board.
main
John Lauer
Publish 0.1.26
0b71841
import importlib.util,copy
from pathlib import Path
from shapely.geometry import box,Point,mapping
sp=importlib.util.spec_from_file_location('policy',Path(__file__).with_name('silkscreen-contact-policy.py'));m=importlib.util.module_from_spec(sp);sp.loader.exec_module(m)
g=dict(outline=mapping(box(0,0,10,10)),bodies={'F.SilkS':{'MC1':mapping(Point(2,5).buffer(.4))}},obstacles=[dict(reference='MC1',kind='pad-mask-or-hole',layer='F.SilkS',polygon=mapping(Point(2,5).buffer(.4)))])
def cand(x,font):
bb=[x-.2,4.8,x+.2,5.2];return dict(font=font,position=[x,5],box=bb,boxes=[bb],children=[dict(index=0,reference='MC1',layer='F.SilkS',box=bb)])
s=dict(labels=[dict(id='MC1',anchor=[2,5],candidates=[cand(.8,.4),cand(3.5,.8)])]);on=m.apply_policy(copy.deepcopy(s),g);assert len(on['labels'][0]['candidates'])==2
outer,inner=on['labels'][0]['candidates'];assert outer['contactSide']=='outside';assert inner['contactSide']=='inside';assert outer['font']*20-outer['qualityPenalty']>inner['font']*20-inner['qualityPenalty'];assert outer['children'][0]['contactBorder'];assert len(outer['boxes'])>1
off=m.apply_policy(copy.deepcopy(s),g,False);assert all(not c['children'][0].get('contactBorder') for c in off['labels'][0]['candidates']);assert off['labels'][0]['candidates'][0]['contactSide']=='outside'
print('PASS: outside preference outranks font; border strokes reserved; optional off preserves side policy')
labels=[];bodies={};obstacles=[]
for k,y in enumerate([3,5,7]):
ref=f'MC{k+1}';body=mapping(Point(2,y).buffer(.4));bodies[ref]=body;obstacles.append(dict(reference=ref,kind='pad-mask-or-hole',layer='F.SilkS',polygon=body));bb=[.5,y-.25,1.0+k*.2,y+.25]
labels.append(dict(id=ref,anchor=[2,y],orderGroup='left-column',candidates=[dict(font=.5,position=[.8,y],box=bb,boxes=[bb],children=[dict(index=k,reference=ref,layer='F.SilkS',box=bb)])]))
a=m.apply_policy(dict(labels=labels),dict(outline=mapping(box(0,0,10,10)),bodies={'F.SilkS':bodies},obstacles=obstacles))
bs=[l['candidates'][0]['sharedBorderBounds'] for l in a['labels']]
assert len({(round(b[0],5),round(b[2],5),round(b[3]-b[1],5)) for b in bs})==1
print('PASS: unequal text widths retain shared border rails and row height')