Files
wheel/scripts/render_washer_panel_4x4.py

37 lines
1.9 KiB
Python
Raw 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
import math
O=Path(r'C:\projects\wheel\models\washer_panel_4x4')
im=Image.new('RGB',(1680,1100),'white');d=ImageDraw.Draw(im)
font=r'C:\Windows\Fonts\msyh.ttc'
F=lambda s:ImageFont.truetype(font,s)
d.text((60,38),'一体式 4×4 双厚度垫片',font=F(43),fill='#1c2938')
d.text((60,106),'48 × 48 mm 薄板;沿虚线裁切,分成 16 片',font=F(25),fill='#405367')
ox,oy,unit=100,190,17
side=48*unit; cell=12*unit
# Project y-positive to screen up: rows 1–2 thin at the bottom in drawing.
d.rectangle((ox,oy,ox+side,oy+side),fill='#a5c4e8')
d.rectangle((ox,oy+side/2,ox+side,oy+side),fill='#cfdbed')
for row in range(4):
for col in range(4):
cx=ox+(12*col+6)*unit; cy=oy+side-(12*row+6)*unit; r=2.2*unit
# NE quadrant and bore removed; neighboring cells remain connected around them.
d.rectangle((cx,cy-6*unit,cx+6*unit,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; y=oy+i*cell
for a in range(0,side,20):
d.line((x,oy+a,x,oy+min(a+10,side)),fill='#5a6070',width=2)
d.line((ox+a,y,ox+min(a+10,side),y),fill='#5a6070',width=2)
d.rectangle((ox,oy,ox+side,oy+side),outline='#172a40',width=4)
d.text((980,205),'1 mm 厚 × 8 片',font=F(29),fill='#214e82')
d.text((980,600),'0.5 mm 厚 × 8 片',font=F(29),fill='#50627e')
d.text((980,270),'每片按 12 × 12 mm 布置',font=F(23),fill='#283a4c')
d.text((980,316),'中心孔 Ø4.4 mm',font=F(23),fill='#283a4c')
d.text((980,362),'开口保留原 90° 扇形',font=F(23),fill='#283a4c')
d.text((980,410),'虚线仅作裁切参考',font=F(23),fill='#283a4c')
d.text((980,452),'模型没有预制割缝',font=F(23),fill='#283a4c')
d.text((980,700),'切割后按缺口方向装配',font=F(23),fill='#283a4c')
d.text((980,742),'先确认打印商能否制作',font=F(23),fill='#a03a35')
im.save(O/'一体板_裁切示意.png')