"""Ramp-A P3 / P3-1 갈고리 치수 확인 이미지 — Rhino Front 뷰 캡처(결과/캡처/hookA_p3, hookB_p31)에 모델 실측값(r, 호 길이, 각도, 곧은 구간)을 표시.""" import json from pathlib import Path from PIL import Image, ImageDraw, ImageFont ROOT = Path(r"D:\★Pier 자료\프로그램\Pier_T") CAP = ROOT / "Code" / "검토수정" / "결과" / "캡처" OUT = ROOT / "검토파일" / "수정후_캡처" FONT = r"C:\Windows\Fonts\malgun.ttf" FONTB = r"C:\Windows\Fonts\malgunbd.ttf" F = lambda s, b=False: ImageFont.truetype(FONTB if b else FONT, s) def make(key, title, drawing): cj = json.loads((CAP / ("%s_capture.json" % key)).read_text(encoding="utf-8")) img = Image.open(CAP / ("%s.png" % key)).convert("RGB") d = ImageDraw.Draw(img) P = {k: tuple(v) for k, v in cj["px"].items()} cx, cy = P["center"] for k, col in (("arc_start", (200, 0, 200)), ("arc_end", (200, 0, 200))): d.line([(cx, cy), P[k]], fill=col, width=3) d.ellipse([cx - 7, cy - 7, cx + 7, cy + 7], fill=(255, 255, 0), outline=(0, 0, 0)) for k in ("arc_start", "arc_end", "tail_end"): x, y = P[k] d.ellipse([x - 7, y - 7, x + 7, y + 7], outline=(0, 0, 0), fill=(255, 140, 0)) lines = ["모델 실측: 반지름 r = %.1f" % cj["radius"], "호 각도 = %.2f° → 호 길이 c = %.1f" % (cj["angle_deg"], cj["arc_len"]), "곧은 구간 d = %.1f" % cj["tail_len"], "도면: " + drawing] y = 20 for i, t in enumerate(lines): w = d.textlength(t, font=F(30, True)) d.rectangle([14, y - 4, 14 + w + 16, y + 38], fill=(255, 255, 255)) d.text((22, y), t, font=F(30, True), fill=(0, 100, 0) if i < 3 else (160, 30, 30)) y += 48 d.text((14, img.height - 44), "노랑 점 = 호 중심, 자홍 선 = 반지름, 주황 점 = 호 시작·끝·곧은 구간 끝 (말뚝 PL01/PL02 표시, 철근 1본 확대)", font=F(24), fill=(255, 255, 255)) banner = Image.new("RGB", (img.width, 70), (30, 120, 60)) ImageDraw.Draw(banner).text((14, 12), title, font=F(38, True), fill=(255, 255, 255)) out = Image.new("RGB", (img.width, img.height + 70), (255, 255, 255)) out.paste(banner, (0, 0)) out.paste(img, (0, 70)) p = OUT / ("RampA_%s_갈고리_치수확인.png" % ("P3-1" if "31" in key else "P3")) out.save(p) return p print(make("hookA_p3", "Ramp-A교 P3 갈고리 — 모델 실측 (수정5)", "r60 · c141 · d100").name) print(make("hookB_p31", "Ramp-A교 P3-1 갈고리 — 모델 실측 (수정5)", "r135 · c165 · d150").name)