animated horse :)

This commit is contained in:
Debian @ Home
2026-09-05 22:42:26 +02:00
parent 2feb4d44bb
commit 3815739887
6 changed files with 33 additions and 71 deletions
+32 -69
View File
@@ -27,8 +27,8 @@
#------------------------------- Constants -----------------------------------------
NB_ANIM_STEPS = 360;
NB_REFRESHS_BETWEEN_ANIMS = 1;
NB_ANIM_STEPS = 4;
NB_REFRESHS_BETWEEN_ANIMS = 10;
@@ -41,8 +41,6 @@ progress_time = 0;
progress_pct = 0;
# Variables for glow rotation animation
anim_start_time = NULL;
anim_status = "stopped";
refresh_iter = 0;
anim_iter = 0;
@@ -70,6 +68,16 @@ debugsprite_bottom.SetPosition(0, (Window.GetHeight (0) - 20), 1);
debugsprite_medium = Sprite();
debugsprite_medium.SetPosition(0, (Window.GetHeight (0) - 100), 1);
animation_first_frame = 0;
animation_last_frame = 3;
animation_current_frame = 0;
for (frame = animation_first_frame; frame <= animation_last_frame; frame++) {
animation_images[frame] = Image("frame_" + frame + ".png");
}
# General purpose function to create text
fun WriteText (text, colour) {
image = Image.Text (text, colour.red, colour.green, colour.blue);
@@ -231,28 +239,13 @@ fun StringToInteger (str) {
return int;
}
#-----------------------------------------------------------------------------
# Top background colour -> RGB/256
# #263a47 --> 0.1484, 0.2266, 0.2773
# Bottom background colour
# #263a47 --> 0.1484, 0.2266, 0.2773
#horse = Image("falbella.png");
fun calchorse(horse_base) {
x0 = Window.GetWidth();
y0 = Window.GetHeight();
xhorse = horse_base.GetWidth();
yhorse = horse_base.GetHeight();
Window.SetBackgroundTopColor (0.05, 0.05, 0.05); # Nice colour on top of the screen fading to
Window.SetBackgroundBottomColor (0.05, 0.05, 0.05); # an equally nice colour on the bottom
dim.horse.xsize = x0;
dim.horse.ysize = y0;
return dim;
}
horse = Image("falbella.png");
Window.SetBackgroundTopColor (0.0, 1.0, 1.0); # Nice colour on top of the screen fading to
Window.SetBackgroundBottomColor (1.0, 1.0, 0.0); # an equally nice colour on the bottom
first_line_height = ImageFromTintedText ("AfpqtM").GetHeight();
top_of_the_text = TextYOffset();
bits_per_pixel = Window.GetBitsPerPixel ();
password_dot_filename = "password_dot.png";
@@ -263,21 +256,23 @@ message_notification[1].image = ImageFromTintedText ("");
status = "normal";
# use a fixed string with ascending and descending stems to calibrate the
# bounding box for the first message, so the messages below don't move up
# and down according to *their* height.
first_line_height = ImageFromTintedText ("AfpqtM").GetHeight();
animation_sprite = Sprite();
# if the user has a 640x480 or 800x600 display, we can't quite fit everything
# (including passphrase prompts) with the target spacing, so scoot the text up
# a bit if needed.
top_of_the_text = TextYOffset();
# align the animation in the centre of the screen (optional)
animation_width = animation_images[animation_first_frame].GetWidth();
animation_height = animation_images[animation_first_frame].GetHeight();
animation_sprite.SetX((Window.GetWidth() / 2) - (animation_width / 2));
animation_sprite.SetY((Window.GetHeight() / 2) - (animation_height / 2));
animation_sprite.SetZ(0);
horse_dim = calchorse(horse);
horse = horse.Scale(Window.GetWidth(), Window.GetHeight());
horse_sprite = Sprite(horse);
SetPosition(horse_sprite, 0, 0, 0);
# now to animate we can change the image used in the sprite each frame,
fun update_horse () {
animation_current_frame += 1;
if (animation_current_frame > animation_last_frame) {
animation_current_frame = animation_first_frame;
}
animation_sprite.SetImage(animation_images[animation_current_frame]);
}
#-------------------------------Progress Indicator-----------------------------
# Implement in boot progress callback
@@ -521,36 +516,6 @@ Plymouth.SetUpdateStatusFunction (update_status_callback);
#
#Plymouth.SetDisplayQuestionFunction (display_question_callback);
#fun rotate_img(source_img, current_step, nb_steps) {
# angle = Math.Sin(current_step / nb_steps * Math.Pi / 2) * 2 * Math.Pi;
# #debug_sin = Math.Sin(current_step / nb_steps * Math.Pi / 2);
# #DebugMedium("Sin = " + debug_sin);
# rotated_img = source_img.Rotate(angle);
# return rotated_img;
#}
fun update_horse () {
# if (global.anim_iter > NB_ANIM_STEPS) {
# global.anim_iter = 0;
# }
# #DebugMedium("iter = " + global.anim_iter);
# #glow_opacity = 0.6 + 0.3 * Math.Cos(global.anim_iter / NB_ANIM_STEPS * 2 * Math.Pi);
# #Debug("glow_opacity = " + glow_opacity);
# if (global.anim_start_time != global.progress_time && global.anim_status != "running") {
# global.anim_start_time = global.progress_time;
# global.anim_iter = 0;
# global.anim_status = "running";
# }
#
# if (global.anim_status == "running") {
# global.glow_sprite.SetOpacity(glow_opacity);
# global.anim_iter++;
#
# if (global.anim_iter >= NB_ANIM_STEPS) {
# global.anim_status = "stopped";
# }
# }
}
#-----------------------------------------Refresh stuff --------------------------------
@@ -589,9 +554,7 @@ fun display_normal_callback ()
if (message_notification[1].sprite) {
show_message (1);
}
}
Plymouth.SetDisplayNormalFunction (display_normal_callback);
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

+1 -2
View File
@@ -1,4 +1,3 @@
#!/bin/sh
#plymouth-set-default-theme falbella;
plymouthd; plymouth --show-splash; sleep 5; pkill plymouth
plymouth-set-default-theme falbella; plymouthd; plymouth --show-splash; sleep 5; pkill plymouth