Week ahead in the weather strip, reverse LCD at night

The weekday strip now shows today and the next six days (icon, max, min),
the current temperature and feels-like sit next to the clock, and the rain
graph spans the full width with the hour under every bar. From sunset to
sunrise the whole frame, seconds patch included, is drawn as a reverse LCD.
The rain label is now spelled DÉŠŤ.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rickzkmandClaude Opus 5.5 committed 2026-10-28 22:40:34 +01:00
1 parent 45508b1b68
commit 6c9a1420d2
10 files changed
+341 -122

No files matched your search

+12 -1
View File
@@ -3,13 +3,16 @@ from functools import lru_cache
from pathlib import Path
from typing import Sequence
from PIL import ImageDraw, ImageFont
import numpy as np
from PIL import Image, ImageDraw, ImageFont
W, H = 480, 320
BG = (170, 184, 154)
INK = (28, 36, 24)
GHOST = (158, 172, 143) # unlit segments, barely darker than the background
SLANT = 0.14
NIGHT_BG = (12, 15, 12) # reverse LCD: light segments on black
NIGHT_INK = (196, 214, 184)
FONT_PATH = Path(__file__).parent / "assets" / "fonts" / "Roboto-Bold.ttf"
SEGMENT_GAP = 1.5
@@ -20,6 +23,14 @@ DIGIT_SEGMENTS = {
}
def night(img: Image.Image) -> Image.Image:
"""The same frame as a reverse LCD: background becomes NIGHT_BG, ink NIGHT_INK, everything between in step."""
a = np.asarray(img.convert("RGB")).astype(np.float32)
t = np.clip((a[..., 0] - INK[0]) / (BG[0] - INK[0]), 0, 1)[..., None] # 0 at ink, 1 at background
ink, bg = np.array(NIGHT_INK, np.float32), np.array(NIGHT_BG, np.float32)
return Image.fromarray(np.round(ink + (bg - ink) * t).astype(np.uint8))
def _slant(points: Sequence[tuple[float, float]], base_y: float) -> list[tuple[float, float]]:
return [(x + SLANT * (base_y - y), y) for x, y in points]