Files
wheel/scripts/render_washer_two_panels.py

31 lines
1.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
out=Path(r'C:\projects\wheel\models\washer_two_panels')
im=Image.new('RGB',(1800,1000),'white');d=ImageDraw.Draw(im)
font='C:/Windows/Fonts/msyh.ttc'
F=lambda n:ImageFont.truetype(font,n)
d.text((55,35),'双板垫片:各 8 片',font=F(44),fill='#18283a')
d.text((55,105),'每块连续薄板 48 × 24 mm,按虚线裁成 4 × 2 片',font=F(27),fill='#40546d')
def panel(x,y,title,color):
d.text((x,y-65),title,font=F(30),fill='#213b5a')
cell=155; W=4*cell;H=2*cell
d.rectangle((x,y,x+W,y+H),fill=color,outline='#22354b',width=3)
for row in range(2):
for col in range(4):
cx=x+col*cell+cell/2; cy=y+(1-row)*cell+cell/2
rr=cell*2.2/12
# original notch is +x,+y: image y is downward, so upper-right
d.ellipse((cx-rr,cy-rr,cx+rr,cy+rr),fill='white')
d.rectangle((cx,cy-cell/2,cx+cell/2,cy),fill='white')
for xx in range(1,4):
pos=x+xx*cell
for v in range(y,y+H,20): d.line((pos,v,pos,min(v+10,y+H)),fill='#476079',width=2)
for u in range(x,x+W,20):d.line((u,y+cell,min(u+10,x+W),y+cell),fill='#476079',width=2)
panel(65,260,'0.5 mm 厚 × 8 片','#c9d9e9')
panel(975,260,'1 mm 厚 × 8 片','#a7c5e5')
d.text((65,650),'两块均为一个连续实体;每片中心孔 Ø4.4 mm,保留 90° 缺口。',font=F(28),fill='#253c54')
d.text((65,710),'虚线仅用于说明,STL 无预制割线;裁切后缺口通向外侧。',font=F(28),fill='#253c54')
d.text((65,770),'先按厚度分别标记,裁切时注意刀口宽度及孔口完整。',font=F(28),fill='#253c54')
d.text((65,850),'0.5 mm 薄板能否成型、平整以及订单分类由打印商确认。',font=F(26),fill='#ae3428')
im.save(out/'两块连续板_裁切示意.png')