feat: 워치 스킨 가운데를 날씨 따라 비구름·천둥 구름·눈구름으로 — 초단기예보 낙뢰(LGT)로 2시간 안 천둥을 워치에 알림

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
HyeongBaeYangandClaude Opus 5.5 committed 2026-10-13 11:00:39 +09:00
1 parent a74e3b49d0
commit c0e0363759
10 files changed
+236 -37

No files matched your search

+47 -9
View File
@@ -77,6 +77,33 @@ def sun_rays():
<Transform target="angle" value="360 * fract([SECOND_MILLISECOND] / 60)"/>
</PartDraw>'''
# 비·눈·천둥 때 해 대신 가운데 구름: 몸통, 아래 그늘. 점수가 흰 글씨라 눈구름도 너무 밝지 않게
CLOUD_ORB = {"rain": ("#FF8796B0", "#4D394A66"), "thunder": ("#FF5F6684", "#66232A45"), "snow": ("#FF9FB2D3", "#40394A66")}
def cloud_orb(kind):
"""해 구슬 자리에 몽실한 구름 하나 (봉우리 셋 + 둥근 바닥). 천둥이면 오른쪽 아래로 번개, 5초에 한 번 화면이 번쩍"""
body, shade = CLOUD_ORB[kind]
k = ORB / 136
puffs = [(10, 34, 60), (36, 8, 80), (80, 44, 52)]
shapes = "".join(f'<Ellipse x="{int(x * k)}" y="{int(y * k)}" width="{int(d * k)}" height="{int(d * k)}"><Fill color="{body}"/></Ellipse>' for x, y, d in puffs)
shapes += f'<RoundRectangle x="{int(4 * k)}" y="{int(64 * k)}" width="{int(128 * k)}" height="{int(56 * k)}" cornerRadiusX="{int(28 * k)}" cornerRadiusY="{int(28 * k)}"><Fill color="{body}"/></RoundRectangle>'
shapes += f'<RoundRectangle x="{int(4 * k)}" y="{int(96 * k)}" width="{int(128 * k)}" height="{int(24 * k)}" cornerRadiusX="{int(12 * k)}" cornerRadiusY="{int(12 * k)}"><Fill color="{shade}"/></RoundRectangle>'
shapes += f'<Ellipse x="{int(48 * k)}" y="{int(16 * k)}" width="{int(34 * k)}" height="{int(22 * k)}"><Fill color="#59FFFFFF"/></Ellipse>'
out = f'<PartDraw x="{CX - ORB // 2}" y="{CY - ORB // 2}" width="{ORB}" height="{ORB}">{AMB0}{shapes}</PartDraw>'
if kind == "thunder":
bolt = [(26, 2), (12, 28), (28, 28), (14, 54)]
lines = "".join(f'<Line startX="{a[0]}" startY="{a[1]}" endX="{b[0]}" endY="{b[1]}"><Stroke thickness="7" color="#FFFFD23F" cap="ROUND"/></Line>' for a, b in zip(bolt, bolt[1:]))
out += f'<PartDraw x="{CX + 20}" y="{CY + ORB // 2 - 26}" width="40" height="56">{AMB0}{lines}</PartDraw>'
out += (f'<PartDraw x="0" y="0" width="{W}" height="{W}" alpha="0">{AMB0}<Rectangle x="0" y="0" width="{W}" height="{W}"><Fill color="#FFFFFFFF"/></Rectangle>'
f'<Transform target="alpha" value="fract([SECOND_MILLISECOND] / 5) &lt; 0.04 ? 110 : 0"/></PartDraw>')
return out
NIGHT_EXPR = "[HOUR_0_23] < 5 || [HOUR_0_23] >= 21"
def sun_or_moon():
"""맑을 때(또는 앱 값이 아직 없을 때) 가운데: 밤엔 달빛 구슬, 낮엔 햇살 두른 해"""
return f'<Compare expression="night">{orb_fill(MOON)}</Compare><Default>{sun_rays()}{orb_fill(SUN)}</Default>'
def mode_block(colors, pos, ink, night=False):
parts = [sky(colors, pos)]
if night:
@@ -156,7 +183,8 @@ def chip(x, w, icon, expr):
def precip_slot():
"""화면 전체를 덮는 숨은 칸. 날씨각 앱(RainComplicationService)이 글자 = 기온, 제목 = 비 소식을 주면
아래에 기온·비 칩을 그리고, 비 소식이 "비 와요"·"곧 비"면 빗줄기, "눈 와요"면 눈송이를 그린다.
아래에 기온·비 칩을 그리고, 비 소식이 "비 와요"·"곧 비"면 빗줄기와 비구름, "천둥 쳐요"면 빗줄기와 번개 구름,
"눈 와요"면 눈송이와 눈구름을 가운데 해 자리에 그린다. 날씨 값은 이 칸 안에서만 읽혀서 맑을 때 해·달 구슬도 여기서 그린다.
터치는 막지 않게 BoundingOval 을 1px 로 둔다. 주기는 60 의 약수여야 분이 바뀔 때 튀지 않는다."""
import random
r = random.Random(7)
@@ -185,22 +213,37 @@ def precip_slot():
<Complication type="SHORT_TEXT">
<Condition>
<Expressions>
<Expression name="thunder"><![CDATA[[COMPLICATION.TITLE] == "천둥 쳐요"]]></Expression>
<Expression name="rain"><![CDATA[[COMPLICATION.TITLE] == "비 와요" || [COMPLICATION.TITLE] == "곧 비"]]></Expression>
<Expression name="snow"><![CDATA[[COMPLICATION.TITLE] == "눈 와요"]]></Expression>
<Expression name="night"><![CDATA[{NIGHT_EXPR}]]></Expression>
</Expressions>
<Compare expression="thunder">
{shade("#80394766")}
{"".join(drops)}
{cloud_orb("thunder")}
</Compare>
<Compare expression="rain">
{shade("#66485A78")}
{"".join(drops)}
{cloud_orb("rain")}
</Compare>
<Compare expression="snow">
{shade("#40A0AEC4")}
{"".join(flakes)}
{cloud_orb("snow")}
</Compare>
{sun_or_moon()}
</Condition>
{chip(108, 104, "thermo", "[COMPLICATION.TEXT]")}
{chip(220, 122, "umbrella", "[COMPLICATION.TITLE]")}
</Complication>
<Complication type="EMPTY"/>
<Complication type="EMPTY">
<Condition>
<Expressions><Expression name="night"><![CDATA[{NIGHT_EXPR}]]></Expression></Expressions>
{sun_or_moon()}
</Condition>
</Complication>
</ComplicationSlot>'''
def event_slot():
@@ -230,7 +273,7 @@ exprs = "\n ".join(f'<Expression name="{k}"><![CDATA[{v[0].replace("&gt
compares = "\n ".join(f'<Compare expression="{k}">\n {mode_block(v[1], v[2], v[3])}\n </Compare>' for k, v in MODES.items())
xml = f'''<?xml version="1.0" encoding="UTF-8"?>
<!-- 날씨각 워치 스킨: 시간대 하늘, 해 구슬(1위), 둘레 링(2~7위), 날짜 밑 근처 축제 한 줄, 아래 기온·비 칩. 링을 누르면 앱이 그 각 상세로 열린다. 점수는 날씨각 앱의 RankNComplicationService 가 공급한다.
<!-- 날씨각 워치 스킨: 시간대 하늘, 해 구슬(1위, 비·눈·천둥이면 구름), 둘레 링(2~7위), 날짜 밑 근처 축제 한 줄, 아래 기온·비 칩. 링을 누르면 앱이 그 각 상세로 열린다. 점수는 날씨각 앱의 RankNComplicationService 가 공급한다.
직접 고치지 말고 watch/watchface/gen_watchface.py 를 고친 뒤 다시 만든다: python3 gen_watchface.py src/main/res/raw/watchface.xml -->
<WatchFace width="{W}" height="{W}">
<Metadata key="CLOCK_TYPE" value="DIGITAL"/>
@@ -247,13 +290,8 @@ xml = f'''<?xml version="1.0" encoding="UTF-8"?>
</Default>
</Condition>
<!-- 주의: 칸(ComplicationSlot) 순서·slotId 를 바꿔 덮어 설치하면 기존 기기에서 공급원이 한 칸씩 밀린다 (에뮬레이터에서 확인). 새 칸은 맨 뒤에 붙인다 -->
<!-- 가운데 해·달·구름은 날씨 칸 안에서 비 막 위에 그린다 -->
{precip_slot()}
<!-- 해 구슬은 비 막 위에 (밤엔 달빛) -->
<Condition>
<Expressions><Expression name="night"><![CDATA[[HOUR_0_23] < 5 || [HOUR_0_23] >= 21]]></Expression></Expressions>
<Compare expression="night">{orb_fill(MOON)}</Compare>
<Default>{sun_rays()}{orb_fill(SUN)}</Default>
</Condition>
{clock("#FFFFFFFF", ambient_visible=True)}
{orb_slot()}
{"".join(ring_slot(i, a) for i, a in enumerate(ANGLES))}