Boot splash: cycle the moon through its phases
CI / test (push) Failing after 50s

- Replace the static moon with a 64-frame lunar phase spritesheet, generated by boot/plymouth/render-phases.py and advanced about every 0.3 s (~5 s per cycle)
- Add a glow sprite behind the moon whose opacity follows the illuminated fraction
- render.sh renders the glow SVG and the phase sheet (needs python3 with numpy and Pillow)
- install-plymouth.py removes theme files that are no longer in the source theme, and checks for the new PNGs
- Drop moon.svg and moon.png in favour of glow.svg, glow.png and moon-phases.png
This commit is contained in:
nandi committed 2026-11-29 02:39:26 -08:00
1 parent 4fd2641c80
commit 7501fc3ad9
11 files changed
+212 -34

No files matched your search

+11 -1
View File
@@ -24,7 +24,9 @@ marker = "# chandra boot splash"
# ignore-serial-consoles: console=ttyMSM0 would otherwise make Plymouth fall back to text. # 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" 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", 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", "hooks/plymouth", "hooks/rootfsdetect", "hooks/rootfsresize", "etc/kupfer/deviceinfo",
"a630_sqe.fw", "a630_gmu.bin", "a630_zap.mbn"] "a630_sqe.fw", "a630_gmu.bin", "a630_zap.mbn"]
@@ -104,6 +106,14 @@ def install_package(package):
def configure(): def configure():
shutil.copytree(theme_src, theme_dst, dirs_exist_ok=True) 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 + "/*"): for f in glob.glob(theme_dst + "/*"):
os.chmod(f, 0o644) os.chmod(f, 0o644)
write(daemon_conf, "[Daemon]\nTheme=chandra\nShowDelay=0\nDeviceTimeout=8\n") write(daemon_conf, "[Daemon]\nTheme=chandra\nShowDelay=0\nDeviceTimeout=8\n")
+1 -1
View File
@@ -1,6 +1,6 @@
[Plymouth Theme] [Plymouth Theme]
Name=Chandra 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 ModuleName=script
[script] [script]
+51 -10
View File
@@ -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; # 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. # 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)); return image.Scale(Math.Int(image.GetWidth() * art_scale), Math.Int(image.GetHeight() * art_scale));
} }
moon = load("moon.png"); glow = load("glow.png");
moon_sprite = Sprite(moon); glow_sprite = Sprite(glow);
moon_sprite.SetPosition(Math.Int(center_x - moon.GetWidth() / 2), Math.Int(center_y - moon.GetHeight() / 2), 1); 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"); track = load("track.png");
fill = load("fill.png"); fill = load("fill.png");
bar_x = Math.Int(center_x - track.GetWidth() / 2); 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(); mode = Plymouth.GetMode();
has_bar = mode == "boot"; has_bar = mode == "boot";
@@ -57,19 +99,19 @@ fun progress_callback(duration, progress) {
} }
Plymouth.SetBootProgressFunction(progress_callback); Plymouth.SetBootProgressFunction(progress_callback);
phase = 0;
ticks = 0; ticks = 0;
fun refresh_callback() { fun refresh_callback() {
if (shown < target) { if (shown < target) {
global.shown = shown + (target - shown) * 0.08; global.shown = shown + (target - shown) * 0.08;
draw_bar(); 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; global.ticks = ticks + 1;
if (ticks >= 4) { if (ticks >= 4) {
global.ticks = 0; global.ticks = 0;
global.phase = phase + 0.10; global.phase_index = phase_index + 1;
moon_sprite.SetOpacity(0.86 + 0.14 * Math.Cos(phase)); if (phase_index >= phase_count) global.phase_index = 0;
set_phase(phase_index);
} }
} }
Plymouth.SetRefreshFunction(refresh_callback); Plymouth.SetRefreshFunction(refresh_callback);
@@ -79,7 +121,6 @@ fun quit_callback() {
global.target = 1; global.target = 1;
global.shown = 1; global.shown = 1;
draw_bar(); draw_bar();
moon_sprite.SetOpacity(1);
} }
Plymouth.SetQuitFunction(quit_callback); Plymouth.SetQuitFunction(quit_callback);
Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

+11
View File
@@ -0,0 +1,11 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="480" height="480">
<defs>
<radialGradient id="glow">
<stop offset="0%" stop-color="#9bb5ff" stop-opacity="0.30"/>
<stop offset="42%" stop-color="#7c9cff" stop-opacity="0.24"/>
<stop offset="72%" stop-color="#7c9cff" stop-opacity="0.07"/>
<stop offset="100%" stop-color="#7c9cff" stop-opacity="0"/>
</radialGradient>
</defs>
<circle cx="32" cy="32" r="32" fill="url(#glow)"/>
</svg>

After

Width:  |  Height:  |  Size: 487 B

-17
View File
@@ -1,17 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="480" height="480">
<!-- The favicon's moon without its tile; boot/plymouth/render.sh turns it into chandra/moon.png. -->
<defs>
<linearGradient id="moon" x1="0.15" y1="0.1" x2="0.85" y2="0.9">
<stop offset="0%" stop-color="#eef4ff"/>
<stop offset="48%" stop-color="#a5bdff"/>
<stop offset="100%" stop-color="#7c9cff"/>
</linearGradient>
<radialGradient id="glow">
<stop offset="45%" stop-color="#7c9cff" stop-opacity="0.22"/>
<stop offset="100%" stop-color="#7c9cff" stop-opacity="0"/>
</radialGradient>
</defs>
<circle cx="32" cy="32" r="32" fill="url(#glow)"/>
<path transform="translate(-1 0)" fill="url(#moon)"
d="M 30.66 13.15 A 19 19 0 1 0 50.44 39.53 A 16.5 16.5 0 0 1 30.66 13.15 Z"/>
</svg>

Before

Width:  |  Height:  |  Size: 827 B

+118
View File
@@ -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()
+16 -2
View File
@@ -1,5 +1,19 @@
#!/bin/sh #!/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 set -e
cd "$(dirname "$0")" 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
+4 -3
View File
@@ -1,11 +1,12 @@
# Boot splash (OnePlus 6T) # Boot splash (OnePlus 6T)
The handset boots with [Plymouth](https://www.freedesktop.org/wiki/Software/Plymouth/) showing the 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, Chandra moon cycling through its phases over a progress bar, from the initramfs until greetd starts
without the bar, covers reboot and power off. 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 - [`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. - [`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, Plymouth estimates progress from the previous boot (`/var/lib/plymouth/boot-duration`). Without one,