- 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:
1 parent
4fd2641c80
commit
7501fc3ad9
11 files changed
+212
-34
No files matched your search
@@ -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]
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
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 |
Reference in new issue
Block a user