Repository navigation
feat(clock,system): PixelArt sprites for clock_derived + system_monitor_{battery,cpu} - #262
Conversation
Adds eight 16x16 moon-phase sprites and four season sprites under `src/fetcher/clock/sprites.rs`, mirroring the authoring pattern from weather: ASCII grids + palette decoded once via `OnceLock`. `clock_derived` learns `Shape::PixelArt`. When the user picks `kind = "moon_phase"` or `kind = "season"`, `compute()` emits the matching sprite (hemisphere-aware for seasons). Other kinds (numeric / textual: iso_week, day_of_year, julian_day, unix_epoch, time_of_day, rokuyou, jp_season, zodiac, chinese_zodiac) fall back to a 1x1 placeholder labelled with the kind name so the misconfiguration is visible rather than silent. `moon_phase` is refactored to share its phase index with the sprite catalog through a new `pub(crate) moon_phase_index()`, keeping the text label and the sprite in lockstep. Refs #261. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Introduces `src/fetcher/system/sprites.rs` housing five battery sprites (horizontal cell + terminal + inner ratio bar, colour shifting red → orange → yellow → lime → green) and five CPU sprites (chip silhouette with four symmetric pins (cols 3, 6, 9, 12) above and below the package, a 6×4 core that shifts blue → lime → yellow → orange → red with load). A shared `bucket_index()` maps a 0..=1 ratio into five 20-percent buckets used by both `battery_sprite()` and `cpu_sprite()`. The module registration is the only system/mod.rs change in this commit; the battery and cpu fetchers gain their PixelArt branches in the next two commits so the sprite library landing stays independently reviewable and bisect-clean. Refs #261. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Extends `system_monitor_battery` with `Shape::PixelArt`. The battery ratio routes through `sprites::battery_sprite()`, picking one of five buckets and labelling it with the formatted percent + state (`"42% · Discharging"`). Hosts without a battery render the AC-power case as the full-tier sprite labelled `"AC"`. Refs #261. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Extends `system_monitor_cpu` with `Shape::PixelArt`. The CPU usage ratio routes through `sprites::cpu_sprite()`, picking one of five buckets (sleepy → relaxed → normal → busy → overheating) and labelling it with the formatted percent (`"42%"`). Refs #261. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe pull request adds pixel-art sprite rendering support to two clock and system fetcher families. Clock-derived sprites render moon phases and seasons from ASCII grids; system sprites render battery charge and CPU load from ratio-bucketed variants. Each fetcher declares PixelArt as a supported shape and branches compute/sample_body logic accordingly. ChangesClock PixelArt Support
System PixelArt Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #262 +/- ##
==========================================
- Coverage 95.62% 95.62% -0.01%
==========================================
Files 250 252 +2
Lines 68372 68815 +443
==========================================
+ Hits 65382 65803 +421
- Misses 2990 3012 +22
🚀 New features to boost your workflow:
|
Implements #261. Stacks on top of #260 (
feat/pixel-art-shape) — merge that first.Summary
Extends three existing fetchers with the
PixelArtshape now that the renderer is in place:clock_derived— eight 16×16 moon-phase sprites (new → waxing crescent → first quarter → waxing gibbous → full → waning gibbous → last quarter → waning crescent) and four season sprites (spring cherry blossom, summer sun, autumn maple, winter snowflake — hemisphere-aware). Unsupportedkinds (zodiac, iso_week, day_of_year, …) fall back to a 1×1 placeholder labelled with the kind name so the misconfiguration is visible.system_monitor_battery— horizontal battery silhouette with terminal cap and an inner ratio bar that grows + colour-shifts (red → orange → yellow → lime → green) across the 5 buckets. AC hosts render the full-tier sprite labelled "AC".system_monitor_cpu— chip silhouette with four symmetric pins (cols 3, 6, 9, 12) above and below the package and a 6×4 core whose colour tracks load (blue → lime → yellow → orange → red).Sprites live in
src/fetcher/{clock,system}/sprites.rs, authored as ASCII grids + palette decoded once viaOnceLock. Same pattern asweather/sprites.rs.After merge: tick the relevant rows on #62 (System / clock fetchers); the renderer roadmap (#61) already gets ticked by #260.
Out of scope
kind = "zodiac"(12 sprites) andkind = "chinese_zodiac"(12 sprites) — animal / constellation art deserves a dedicated PR's worth of drawing time.clock_derivedreference (mirror of/reference/fetchers/clock/clock_derived/)A single value derived from today's date, picked by
kind. New shape entry:pixel_artkind = "moon_phase"orkind = "season"; other kinds fall back to a 1×1 placeholder labelled with the kind name.Compatible renderer:
media_pixel.system_monitor_batteryreferencepixel_art"42% · Discharging". AC hosts render the full-tier sprite labelled"AC".system_monitor_cpureferencepixel_artTest plan
cargo test --lib— 3264 pass, 0 failcargo clippy --all-targets -- -D warnings— cleancargo fmt --all -- --check— cleanbasic_read_storewidget reads 16 of the 22 generated sprites over a 4×4 grid (moon × 4, season × 4, battery × 4, cpu × 4). All buckets render with the expected colour transitions and labels.Summary by CodeRabbit