Files
wheel/scripts/render_washer_panel_4x2.py

20 lines
1.5 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 PIL import Image,ImageDraw,ImageFont
from pathlib import Path
p=Path(r'C:\projects\wheel\models\washer_panel_4x2'); im=Image.new('RGB',(1600,800),'white');d=ImageDraw.Draw(im); f=r'C:\Windows\Fonts\msyh.ttc'; F=lambda n:ImageFont.truetype(f,n)
d.text((55,35),'一体式 4×2 双厚度垫片',font=F(43),fill='#1c2938')
d.text((55,102),'48 × 24 mm 薄板;沿虚线裁切,分成 8 片',font=F(25),fill='#405367')
ox,oy,u=80,210,17; width=48*u;height=24*u;cell=12*u
d.rectangle((ox,oy,ox+width,oy+cell),fill='#a5c4e8');d.rectangle((ox,oy+cell,ox+width,oy+height),fill='#cfdbed')
for row in range(2):
for col in range(4):
cx=ox+(12*col+6)*u;cy=oy+height-(12*row+6)*u;r=2.2*u
d.rectangle((cx,cy-6*u,cx+6*u,cy),fill='white');d.ellipse((cx-r,cy-r,cx+r,cy+r),fill='white')
for i in range(1,4):
x=ox+i*cell
for a in range(0,height,20):d.line((x,oy+a,x,oy+min(a+10,height)),fill='#5a6070',width=2)
for a in range(0,width,20):d.line((ox+a,oy+cell,ox+min(a+10,width),oy+cell),fill='#5a6070',width=2)
d.rectangle((ox,oy,ox+width,oy+height),outline='#172a40',width=4)
d.text((970,220),'1 mm 厚 × 4 片',font=F(28),fill='#214e82');d.text((970,430),'0.5 mm 厚 × 4 片',font=F(28),fill='#50627e')
for y,t in [(280,'每片按 12 × 12 mm 布置'),(325,'中心孔 Ø4.4 mm,90° 开口'),(370,'虚线仅作裁切参考'),(490,'四个安装点统一调整厚度'),(535,'切割后按缺口方向装配'),(580,'薄板能否打印由商家确认')]:d.text((970,y),t,font=F(22),fill='#a03a35' if y==580 else '#283a4c')
im.save(p/'一体板_裁切示意.png')