Files
Aislo/resources/tester/test_b07_basin_badge.py
T
eomsangdonandClaude Opus 5.5 97940baa8e fix(B07): 배수유역도 풍선 숫자 흰·검은 바탕 모두 읽히게
- 원판 #ffffff(CAD 자동색 — 흰 바탕에서 검정으로 뒤집혀 #111111 숫자 묻힘) → #909090 회색(테마가 안 바꾸는 밝기)
- 화면 픽셀 실측: 밝은 테마 대비 약 1.1:1 → 5.9:1 · 어두운 테마 5.9:1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013rJwJMVL4EE31y77TB11AP
2026-10-06 17:59:21 +09:00

32 lines
1.2 KiB
Python

"""B07 유역도 풍선 — 흰·검은 바탕 어느 쪽에서도 숫자가 읽히는 색 (59-5).
CAD 그리기 규칙(openwebcad `theme.ts` paintColor): 자동색(#000000·#ffffff·#f5f7fa)은
바탕 따라 흑백이 뒤집히고, 흰 바탕에서는 단순 휘도 0.58 초과 색을 어둡게 누른다.
"""
from B07_DesignDetail.B07_DesignDetail_Engine_Cad_Basin import _BADGE_FILL, _BADGE_TEXT_COLOR
_AUTO = {"#000000", "#ffffff", "#f5f7fa"}
def _rgb(color: str) -> tuple[int, int, int]:
return tuple(int(color[index : index + 2], 16) for index in (1, 3, 5))
def _wcag(color: str) -> float:
def channel(value: int) -> float:
value /= 255
return value / 12.92 if value <= 0.03928 else ((value + 0.055) / 1.055) ** 2.4
r, g, b = (channel(v) for v in _rgb(color))
return 0.2126 * r + 0.7152 * g + 0.0722 * b
def test_badge_colors_survive_both_themes() -> None:
for color in (_BADGE_FILL, _BADGE_TEXT_COLOR):
assert color.lower() not in _AUTO
r, g, b = _rgb(color)
assert (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255 <= 0.58
fill, text = _wcag(_BADGE_FILL), _wcag(_BADGE_TEXT_COLOR)
assert (max(fill, text) + 0.05) / (min(fill, text) + 0.05) >= 4.5