Files
starmen1265 f256e7113a feat(ai-art): 路径C扩展东/北立面+阳台侧面标准件
- 工具: _run_pathc_fuse 参数化 south/north/east/west 四立面(英文key)
- 标准件: 新增阳台侧面(bside),厨卫窄窗注释改为山墙/北立面
- prompt: 东立面/北立面路径C窗户字汇表 v1
- 生成结果: 东立面/北立面 fusion 首图各1张+阳台侧面标准件
2026-06-25 18:46:38 +08:00

94 lines
3.6 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
拼「窗户标准件合集图」(windows spec sheet) = 路径C组装prompt的【图3:窗户字汇表】。
纵向排列 3 个正投影标准件,每件下方加中英标签 + 尺度注释。
轴测件不进合集(它表达立体关系,最小闭环靠文字描述)。
需要 Pillow: pip install Pillow
"""
import sys
import io
from pathlib import Path
# Windows 控制台 UTF-8(避免 print emoji/中文时 GBK 崩溃)
if sys.platform == "win32":
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace")
from PIL import Image, ImageDraw, ImageFont
RESEARCH = Path(__file__).resolve().parent.parent
PARTS_DIR = RESEARCH / "生成结果" / "窗户标准件"
OUT = PARTS_DIR / "标准件合集图.png"
# (文件名, 中文, 英文, 尺度注释)
ITEMS = [
("标准件-普通窗-卧室.png", "卧室普通窗", "Bedroom window — 2-panel sliding", "约1.4m宽 · 两扇推拉 · 每扇宽高比1:2 · 把手在两端"),
("260623-160342_gpt-image-2_gen.png", "阳台正面", "Balcony front — 6-panel sliding", "约4.2m宽 · 三对推拉共6扇 · 每扇宽高比1:2"),
("260624-134345_gpt-image-2_gen.png", "阳台侧面", "Balcony side — 2-panel", "外凸阳台端墙 · 约1.2m宽 · 矮墙+1对窗 · 比正面窄得多"),
("260623-181251_gpt-image-2_gen.png", "楼梯间窗", "Stairwell window", "横向小条窗 · 宽>高约2:1 · 楼梯休息平台处的小窗"),
("标准件-窄窗-厨卫-新版.png", "厨卫窄窗", "Kitchen/bath narrow window", "约0.7m宽 · 单扇外开 · 宽高比1:2(山墙/北立面用)"),
]
def font(size):
for f in ["C:/Windows/Fonts/msyh.ttc", "C:/Windows/Fonts/simhei.ttf",
"C:/Windows/Fonts/arial.ttf"]:
if Path(f).exists():
try:
return ImageFont.truetype(f, size)
except Exception:
pass
return ImageFont.load_default()
ROW_H = 820
LABEL_H = 170
PAD = 50
CANVAS_W = 1700
rows = []
for fn, zh, en, note in ITEMS:
p = PARTS_DIR / fn
if not p.exists():
print(f"⚠️ 缺文件,跳过: {fn}")
continue
img = Image.open(p).convert("RGB")
w, h = img.size
scale = ROW_H / h
nw, nh = int(w * scale), ROW_H
maxw = CANVAS_W - 2 * PAD
if nw > maxw:
s2 = maxw / nw
nw, nh = int(nw * s2), int(nh * s2)
rows.append((img.resize((nw, nh), Image.LANCZOS), zh, en, note, nw))
n = len(rows)
unit = ROW_H + LABEL_H
canvas_h = unit * n + PAD * 2 + 30 * (n - 1) + 70 # +70 给顶部标题
canvas = Image.new("RGB", (CANVAS_W, canvas_h), "white")
draw = ImageDraw.Draw(canvas)
# 顶部标题:强调"尺寸仅供识别窗型,非真实比例"
draw.text((PAD, 18),
"窗户标准件字汇表 Windows Spec Sheet",
fill="black", font=font(34))
draw.text((PAD, 58),
"正投影·平涂结构图。图中窗的视觉大小仅供识别窗型,不代表真实比例;真实面宽见组装prompt的文字布局。",
fill="#666", font=font(24))
y = 100
for img2, zh, en, note, nw in rows:
x = (CANVAS_W - nw) // 2
canvas.paste(img2, (x, y))
ly = y + ROW_H + 6
draw.text((PAD, ly), zh, fill="black", font=font(46))
draw.text((PAD, ly + 58), en, fill="#555", font=font(28))
draw.text((PAD, ly + 96), note, fill="#555", font=font(26))
y += unit + 30
canvas.save(OUT)
print(f"✅ 合集图已生成: {OUT}")
print(f" 尺寸: {canvas.size}")