23 lines
1.6 KiB
Python
23 lines
1.6 KiB
Python
from PIL import Image, ImageDraw, ImageFont, ImageChops
|
|
from pathlib import Path
|
|
p=Path(r'C:\projects\wheel\models\integer_profiles')
|
|
im=Image.new('RGB',(2000,1250),'white'); d=ImageDraw.Draw(im)
|
|
title=ImageFont.truetype(r'C:\Windows\Fonts\msyh.ttc',43)
|
|
font=ImageFont.truetype(r'C:\Windows\Fonts\msyh.ttc',28)
|
|
small=ImageFont.truetype(r'C:\Windows\Fonts\msyh.ttc',24)
|
|
d.text((35,20),'方向盘底座:型材整数下料尺寸',font=title,fill='#162c44')
|
|
d.text((35,90),'保留原电机与纵梁位置;轴承横梁通过角码连接纵梁。',font=font,fill='#415a70')
|
|
pic=Image.open(p/'assembly.png').convert('RGB'); bg=Image.new('RGB',pic.size,'white'); box=ImageChops.difference(pic,bg).getbbox()
|
|
if box:pic=pic.crop(box)
|
|
pic.thumbnail((950,970),Image.Resampling.LANCZOS);im.paste(pic,(35+(950-pic.width)//2,180+(970-pic.height)//2))
|
|
d.text((1030,190),'型材下料清单',font=title,fill='#162c44')
|
|
items=[('底部纵梁','3030','255 mm','2 根'),('轴承板横梁','3030','71 mm','2 根'),('电机两侧型材','2020','110 mm','2 根'),('开关下方横梁','2020','132 mm','1 根')]
|
|
for i,item in enumerate(items):
|
|
y=285+i*115
|
|
d.rectangle((1020,y,1940,y+83),fill=('#f1f5f8' if i%2==0 else '#fbfcfd'))
|
|
for x,t in zip((1040,1350,1540,1760),item):d.text((x,y+20),t,font=font,fill='#172c3f')
|
|
d.text((1030,810),'横梁两端保留细小装配间隙,角码连接。',font=font,fill='#344d62')
|
|
d.text((1030,870),'孔槽位置和轴承板沿用上一版。',font=font,fill='#344d62')
|
|
d.text((65,1170),'注:图中开关为示意包络,真实槽型、滑块和开关外形尚未完整建模。',font=small,fill='#8a4141')
|
|
im.save(p/'整数型材_3D装配示意.png')
|