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 ----------------------------------------- #------------------------------- Constants -----------------------------------------
NB_ANIM_STEPS = 360; NB_ANIM_STEPS = 4;
NB_REFRESHS_BETWEEN_ANIMS = 1; NB_REFRESHS_BETWEEN_ANIMS = 10;
@@ -41,8 +41,6 @@ progress_time = 0;
progress_pct = 0; progress_pct = 0;
# Variables for glow rotation animation # Variables for glow rotation animation
anim_start_time = NULL;
anim_status = "stopped";
refresh_iter = 0; refresh_iter = 0;
anim_iter = 0; anim_iter = 0;
@@ -70,6 +68,16 @@ debugsprite_bottom.SetPosition(0, (Window.GetHeight (0) - 20), 1);
debugsprite_medium = Sprite(); debugsprite_medium = Sprite();
debugsprite_medium.SetPosition(0, (Window.GetHeight (0) - 100), 1); 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 # General purpose function to create text
fun WriteText (text, colour) { fun WriteText (text, colour) {
image = Image.Text (text, colour.red, colour.green, colour.blue); image = Image.Text (text, colour.red, colour.green, colour.blue);
@@ -231,28 +239,13 @@ fun StringToInteger (str) {
return int; return int;
} }
#----------------------------------------------------------------------------- #horse = Image("falbella.png");
# Top background colour -> RGB/256
# #263a47 --> 0.1484, 0.2266, 0.2773
# Bottom background colour
# #263a47 --> 0.1484, 0.2266, 0.2773
fun calchorse(horse_base) { Window.SetBackgroundTopColor (0.05, 0.05, 0.05); # Nice colour on top of the screen fading to
x0 = Window.GetWidth(); Window.SetBackgroundBottomColor (0.05, 0.05, 0.05); # an equally nice colour on the bottom
y0 = Window.GetHeight();
xhorse = horse_base.GetWidth();
yhorse = horse_base.GetHeight();
dim.horse.xsize = x0; first_line_height = ImageFromTintedText ("AfpqtM").GetHeight();
dim.horse.ysize = y0; top_of_the_text = TextYOffset();
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
bits_per_pixel = Window.GetBitsPerPixel (); bits_per_pixel = Window.GetBitsPerPixel ();
password_dot_filename = "password_dot.png"; password_dot_filename = "password_dot.png";
@@ -263,21 +256,23 @@ message_notification[1].image = ImageFromTintedText ("");
status = "normal"; status = "normal";
# use a fixed string with ascending and descending stems to calibrate the animation_sprite = Sprite();
# 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();
# if the user has a 640x480 or 800x600 display, we can't quite fit everything # align the animation in the centre of the screen (optional)
# (including passphrase prompts) with the target spacing, so scoot the text up animation_width = animation_images[animation_first_frame].GetWidth();
# a bit if needed. animation_height = animation_images[animation_first_frame].GetHeight();
top_of_the_text = TextYOffset(); 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); # now to animate we can change the image used in the sprite each frame,
horse = horse.Scale(Window.GetWidth(), Window.GetHeight()); fun update_horse () {
horse_sprite = Sprite(horse); animation_current_frame += 1;
if (animation_current_frame > animation_last_frame) {
SetPosition(horse_sprite, 0, 0, 0); animation_current_frame = animation_first_frame;
}
animation_sprite.SetImage(animation_images[animation_current_frame]);
}
#-------------------------------Progress Indicator----------------------------- #-------------------------------Progress Indicator-----------------------------
# Implement in boot progress callback # Implement in boot progress callback
@@ -521,36 +516,6 @@ Plymouth.SetUpdateStatusFunction (update_status_callback);
# #
#Plymouth.SetDisplayQuestionFunction (display_question_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 -------------------------------- #-----------------------------------------Refresh stuff --------------------------------
@@ -589,9 +554,7 @@ fun display_normal_callback ()
if (message_notification[1].sprite) { if (message_notification[1].sprite) {
show_message (1); show_message (1);
} }
} }
Plymouth.SetDisplayNormalFunction (display_normal_callback); 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 #!/bin/sh
#plymouth-set-default-theme falbella; plymouth-set-default-theme falbella; plymouthd; plymouth --show-splash; sleep 5; pkill plymouth
plymouthd; plymouth --show-splash; sleep 5; pkill plymouth