diff --git a/boot/install-plymouth.py b/boot/install-plymouth.py
index d209424..e516848 100644
--- a/boot/install-plymouth.py
+++ b/boot/install-plymouth.py
@@ -24,7 +24,9 @@ marker = "# chandra boot splash"
# ignore-serial-consoles: console=ttyMSM0 would otherwise make Plymouth fall back to text.
cmdline = "quiet splash loglevel=3 plymouth.ignore-serial-consoles vt.global_cursor_default=0"
needed = ["usr/bin/plymouthd", "usr/lib/plymouth/script.so", "usr/lib/plymouth/renderers/drm.so",
- "usr/share/plymouth/themes/chandra/chandra.script", "usr/share/plymouth/themes/chandra/moon.png",
+ "usr/share/plymouth/themes/chandra/chandra.script",
+ "usr/share/plymouth/themes/chandra/glow.png",
+ "usr/share/plymouth/themes/chandra/moon-phases.png",
"hooks/plymouth", "hooks/rootfsdetect", "hooks/rootfsresize", "etc/kupfer/deviceinfo",
"a630_sqe.fw", "a630_gmu.bin", "a630_zap.mbn"]
@@ -104,6 +106,14 @@ def install_package(package):
def configure():
shutil.copytree(theme_src, theme_dst, dirs_exist_ok=True)
+ expected = set(os.listdir(theme_src))
+ for name in os.listdir(theme_dst):
+ if name not in expected:
+ path = os.path.join(theme_dst, name)
+ if os.path.isdir(path) and not os.path.islink(path):
+ shutil.rmtree(path)
+ else:
+ os.remove(path)
for f in glob.glob(theme_dst + "/*"):
os.chmod(f, 0o644)
write(daemon_conf, "[Daemon]\nTheme=chandra\nShowDelay=0\nDeviceTimeout=8\n")
diff --git a/boot/plymouth/chandra/chandra.plymouth b/boot/plymouth/chandra/chandra.plymouth
index a619050..ebc2b0f 100644
--- a/boot/plymouth/chandra/chandra.plymouth
+++ b/boot/plymouth/chandra/chandra.plymouth
@@ -1,6 +1,6 @@
[Plymouth Theme]
Name=Chandra
-Description=The Chandra moon over a boot progress bar
+Description=The Chandra moon cycling through its phases over a boot progress bar
ModuleName=script
[script]
diff --git a/boot/plymouth/chandra/chandra.script b/boot/plymouth/chandra/chandra.script
index 5c22d09..9e357b3 100644
--- a/boot/plymouth/chandra/chandra.script
+++ b/boot/plymouth/chandra/chandra.script
@@ -1,4 +1,4 @@
-# Chandra boot splash: the moon, and a progress bar under it while booting.
+# Chandra boot splash: the moon cycling through its phases, and a progress bar under it while booting.
#
# Plymouth estimates the progress from how long the last boot took (/var/lib/plymouth/boot-duration;
# 60 s until it has seen one boot). The bar eases towards that estimate and never moves backwards.
@@ -19,14 +19,56 @@ fun load(name) {
return image.Scale(Math.Int(image.GetWidth() * art_scale), Math.Int(image.GetHeight() * art_scale));
}
-moon = load("moon.png");
-moon_sprite = Sprite(moon);
-moon_sprite.SetPosition(Math.Int(center_x - moon.GetWidth() / 2), Math.Int(center_y - moon.GetHeight() / 2), 1);
+glow = load("glow.png");
+glow_sprite = Sprite(glow);
+glow_sprite.SetPosition(Math.Int(center_x - glow.GetWidth() / 2), Math.Int(center_y - glow.GetHeight() / 2), 0);
+
+phase_cols = 8;
+phase_rows = 8;
+phase_count = phase_cols * phase_rows;
+
+fun load_phases() {
+ local.sheet = Image("moon-phases.png");
+ local.cell_w = Math.Int(sheet.GetWidth() / phase_cols);
+ local.cell_h = Math.Int(sheet.GetHeight() / phase_rows);
+ local.scaled_w = Math.Int(cell_w * art_scale);
+ local.scaled_h = Math.Int(cell_h * art_scale);
+ local.idx = 0;
+ for (local.row = 0; row < phase_rows; row++) {
+ for (local.col = 0; col < phase_cols; col++) {
+ local.cell = sheet.Crop(col * cell_w, row * cell_h, cell_w, cell_h);
+ if (art_scale != 1) {
+ cell = cell.Scale(scaled_w, scaled_h);
+ }
+ global.moon_frames[idx] = cell;
+ idx++;
+ }
+ }
+}
+
+load_phases();
+
+# Start at waxing crescent so the moon opens in an iconic silhouette, then waxes toward full.
+phase_index = 8;
+moon_sprite = Sprite(moon_frames[phase_index]);
+moon_sprite.SetPosition(
+ Math.Int(center_x - moon_frames[0].GetWidth() / 2),
+ Math.Int(center_y - moon_frames[0].GetHeight() / 2),
+ 1
+);
+
+fun set_phase(idx) {
+ moon_sprite.SetImage(moon_frames[idx]);
+ local.illum = (1 - Math.Cos(2 * Math.Pi * idx / phase_count)) / 2;
+ glow_sprite.SetOpacity(0.18 + 0.82 * illum);
+}
+
+set_phase(phase_index);
track = load("track.png");
fill = load("fill.png");
bar_x = Math.Int(center_x - track.GetWidth() / 2);
-bar_y = Math.Int(center_y + moon.GetHeight() / 2 + 120 * art_scale);
+bar_y = Math.Int(center_y + glow.GetHeight() / 2 + 120 * art_scale);
mode = Plymouth.GetMode();
has_bar = mode == "boot";
@@ -57,19 +99,19 @@ fun progress_callback(duration, progress) {
}
Plymouth.SetBootProgressFunction(progress_callback);
-phase = 0;
ticks = 0;
fun refresh_callback() {
if (shown < target) {
global.shown = shown + (target - shown) * 0.08;
draw_bar();
}
- # A slow breath, 12 times a second: the panel is drawn by the CPU.
+ # Advance one phase frame every 4 ticks (~12.5 fps, ~5.1 s per lunar cycle) to spare the CPU.
global.ticks = ticks + 1;
if (ticks >= 4) {
global.ticks = 0;
- global.phase = phase + 0.10;
- moon_sprite.SetOpacity(0.86 + 0.14 * Math.Cos(phase));
+ global.phase_index = phase_index + 1;
+ if (phase_index >= phase_count) global.phase_index = 0;
+ set_phase(phase_index);
}
}
Plymouth.SetRefreshFunction(refresh_callback);
@@ -79,7 +121,6 @@ fun quit_callback() {
global.target = 1;
global.shown = 1;
draw_bar();
- moon_sprite.SetOpacity(1);
}
Plymouth.SetQuitFunction(quit_callback);
diff --git a/boot/plymouth/chandra/glow.png b/boot/plymouth/chandra/glow.png
new file mode 100644
index 0000000..f445e83
Binary files /dev/null and b/boot/plymouth/chandra/glow.png differ
diff --git a/boot/plymouth/chandra/moon-phases.png b/boot/plymouth/chandra/moon-phases.png
new file mode 100644
index 0000000..d56189f
Binary files /dev/null and b/boot/plymouth/chandra/moon-phases.png differ
diff --git a/boot/plymouth/chandra/moon.png b/boot/plymouth/chandra/moon.png
deleted file mode 100644
index 8712ef8..0000000
Binary files a/boot/plymouth/chandra/moon.png and /dev/null differ
diff --git a/boot/plymouth/glow.svg b/boot/plymouth/glow.svg
new file mode 100644
index 0000000..e4601d2
--- /dev/null
+++ b/boot/plymouth/glow.svg
@@ -0,0 +1,11 @@
+
diff --git a/boot/plymouth/moon.svg b/boot/plymouth/moon.svg
deleted file mode 100644
index b872121..0000000
--- a/boot/plymouth/moon.svg
+++ /dev/null
@@ -1,17 +0,0 @@
-
diff --git a/boot/plymouth/render-phases.py b/boot/plymouth/render-phases.py
new file mode 100755
index 0000000..400e23f
--- /dev/null
+++ b/boot/plymouth/render-phases.py
@@ -0,0 +1,118 @@
+#!/usr/bin/python3
+"""Render a 64-frame lunar phase spritesheet (8x8 grid, 300x300 cells) for Plymouth."""
+import math
+import os
+import numpy as np
+from PIL import Image
+
+COLS = 8
+ROWS = 8
+FRAMES = COLS * ROWS
+CELL = 300
+RADIUS = 142.5
+CENTER = (CELL - 1) / 2.0 # 149.5
+
+
+def make_base_textures():
+ """Precompute shared geometry, surface gradients, maria mask, and earthshine."""
+ coords = np.arange(CELL, dtype=np.float64)
+ yy, xx = np.meshgrid(coords, coords, indexing="ij")
+ u = (xx - CENTER) / RADIUS
+ v = (yy - CENTER) / RADIUS
+ r2 = u * u + v * v
+ r = np.sqrt(r2)
+
+ disc_alpha = np.clip((1.0 - r) * RADIUS + 0.5, 0.0, 1.0)
+ nz = np.sqrt(np.maximum(0.0, 1.0 - r2))
+
+ # Diagonal gradient aligned with Chandra's moon.svg: (0.15, 0.1) -> (0.85, 0.9)
+ gx = (u + 1.0) * 0.5
+ gy = (v + 1.0) * 0.5
+ dx, dy = 0.70, 0.80
+ grad_t = np.clip(((gx - 0.15) * dx + (gy - 0.10) * dy) / (dx * dx + dy * dy), 0.0, 1.0)
+
+ c0 = np.array([238.0, 244.0, 255.0]) # #eef4ff
+ c1 = np.array([165.0, 189.0, 255.0]) # #a5bdff
+ c2 = np.array([124.0, 156.0, 255.0]) # #7c9cff
+
+ lit_grad = np.empty((CELL, CELL, 3), dtype=np.float64)
+ low = grad_t <= 0.48
+ t_low = np.where(low, grad_t / 0.48, 0.0)[..., None]
+ t_high = np.where(~low, (grad_t - 0.48) / 0.52, 0.0)[..., None]
+ lit_grad = np.where(low[..., None], c0 * (1.0 - t_low) + c1 * t_low, c1 * (1.0 - t_high) + c2 * t_high)
+
+ # Subtle 3D limb darkening and gentle upper-left specular sheen
+ limb_shade = 0.88 + 0.12 * (nz ** 0.45)
+ spec_dist2 = (u + 0.32) ** 2 + (v + 0.34) ** 2
+ spec = 0.05 * np.exp(-spec_dist2 / 0.22) * nz
+ lit_rgb = np.clip(lit_grad * limb_shade[..., None] + spec[..., None] * 255.0, 0.0, 255.0)
+
+ # Minimalist, soft translucent lunar maria (overlapping Gaussian basins)
+ maria_specs = [
+ # (u0, v0, su, sv, angle_rad, weight)
+ (-0.22, -0.32, 0.24, 0.20, -0.3, 0.65), # Mare Imbrium
+ (-0.45, -0.02, 0.22, 0.34, 0.2, 0.55), # Oceanus Procellarum
+ (0.14, -0.30, 0.17, 0.15, 0.2, 0.55), # Mare Serenitatis
+ (0.32, -0.06, 0.18, 0.15, -0.4, 0.52), # Mare Tranquillitatis
+ (0.58, -0.22, 0.10, 0.13, 0.1, 0.48), # Mare Crisium
+ (-0.16, 0.26, 0.20, 0.16, 0.3, 0.42), # Mare Nubium
+ (0.46, 0.18, 0.13, 0.17, -0.2, 0.40), # Mare Fecunditatis
+ ]
+ maria = np.zeros((CELL, CELL), dtype=np.float64)
+ for u0, v0, su, sv, ang, weight in maria_specs:
+ du = u - u0
+ dv = v - v0
+ ca, sa = math.cos(ang), math.sin(ang)
+ ru = (du * ca + dv * sa) / su
+ rv = (-du * sa + dv * ca) / sv
+ maria += weight * np.exp(-(ru * ru + rv * rv))
+ maria_blend = np.clip(maria, 0.0, 1.0) * 0.15 # ~15% max darkening toward #5a77d4
+ maria_tint = np.array([90.0, 119.0, 212.0]) # #5a77d4
+ lit_rgb = lit_rgb * (1.0 - maria_blend[..., None]) + maria_tint * maria_blend[..., None]
+
+ # Earthshine dark side: #1d2c52 (upper-left) -> #111a33 (lower-right) + faint silver-blue rim
+ d0 = np.array([29.0, 44.0, 82.0]) # #1d2c52
+ d1 = np.array([17.0, 26.0, 51.0]) # #111a33
+ dark_rgb = d0 * (1.0 - grad_t[..., None]) + d1 * grad_t[..., None]
+ rim_glow = 0.20 * np.exp(-((np.maximum(0.0, 1.0 - r)) / 0.025) ** 2)
+ dark_rgb = dark_rgb * (1.0 - rim_glow[..., None]) + c2 * rim_glow[..., None]
+
+ return u, nz, disc_alpha, lit_rgb, dark_rgb
+
+
+def main():
+ here = os.path.dirname(os.path.abspath(__file__))
+ out_path = os.path.join(here, "chandra", "moon-phases.png")
+
+ nx, nz, disc_alpha, lit_rgb, dark_rgb = make_base_textures()
+ alpha_u8 = np.round(disc_alpha * 255.0).astype(np.uint8)
+ inside = disc_alpha > 0.0
+
+ sheet = np.zeros((ROWS * CELL, COLS * CELL, 4), dtype=np.uint8)
+
+ for idx in range(FRAMES):
+ p = idx / float(FRAMES)
+ ang = 2.0 * math.pi * p
+ sx = math.sin(ang)
+ sz = -math.cos(ang)
+
+ ndotl = nx * sx + nz * sz
+ t = np.clip(ndotl / 0.11, 0.0, 1.0)
+ lit = t * t * (3.0 - 2.0 * t)
+
+ rgb = dark_rgb * (1.0 - lit[..., None]) + lit_rgb * lit[..., None]
+ rgb[~inside] = 0.0
+
+ row = idx // COLS
+ col = idx % COLS
+ y0, y1 = row * CELL, (row + 1) * CELL
+ x0, x1 = col * CELL, (col + 1) * CELL
+ sheet[y0:y1, x0:x1, :3] = np.round(np.clip(rgb, 0.0, 255.0)).astype(np.uint8)
+ sheet[y0:y1, x0:x1, 3] = alpha_u8
+
+ Image.fromarray(sheet, "RGBA").save(out_path, optimize=True)
+ print(f"wrote {out_path} ({os.path.getsize(out_path)} bytes)")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/boot/plymouth/render.sh b/boot/plymouth/render.sh
index 87cee69..4b08428 100755
--- a/boot/plymouth/render.sh
+++ b/boot/plymouth/render.sh
@@ -1,5 +1,19 @@
#!/bin/sh
-# Render the theme's PNGs from the SVGs beside this script (needs rsvg-convert).
+# Render the theme's PNGs from the SVGs and lunar-phase generator beside this script
+# (needs rsvg-convert and python3 with numpy + Pillow).
set -e
cd "$(dirname "$0")"
-for f in moon track fill; do rsvg-convert "$f.svg" -o "chandra/$f.png"; done
+for f in glow track fill; do rsvg-convert "$f.svg" -o "chandra/$f.png"; done
+
+py=""
+for candidate in python3 /usr/bin/python3; do
+ if command -v "$candidate" >/dev/null 2>&1 && "$candidate" -c "import numpy, PIL" 2>/dev/null; then
+ py="$candidate"
+ break
+ fi
+done
+if [ -z "$py" ]; then
+ echo "render.sh: python3 with numpy and PIL is required" >&2
+ exit 1
+fi
+"$py" ./render-phases.py
diff --git a/docs/boot-splash.md b/docs/boot-splash.md
index 3119dc2..9cbcf5b 100644
--- a/docs/boot-splash.md
+++ b/docs/boot-splash.md
@@ -1,11 +1,12 @@
# Boot splash (OnePlus 6T)
The handset boots with [Plymouth](https://www.freedesktop.org/wiki/Software/Plymouth/) showing the
-Chandra moon and a progress bar, from the initramfs until greetd starts the session. The same theme,
-without the bar, covers reboot and power off.
+Chandra moon cycling through its phases over a progress bar, from the initramfs until greetd starts
+the session. The same theme, without the bar, covers reboot and power off.
- [`boot/plymouth/chandra/`](../boot/plymouth/chandra) is the theme (Plymouth's `script` plugin). Its
- PNGs come from the SVGs beside it: `boot/plymouth/render.sh`.
+ PNGs come from the SVGs and lunar-phase generator beside it: `boot/plymouth/render.sh` (calls
+ `rsvg-convert` and `boot/plymouth/render-phases.py`).
- [`boot/install-plymouth.py`](../boot/install-plymouth.py) installs it on a Kupfer phone.
Plymouth estimates progress from the previous boot (`/var/lib/plymouth/boot-duration`). Without one,