1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
Window.GetMaxWidth = fun () {
i = 0;
width = 0;
while (Window.GetWidth(i)) {
width = Math.Max(width, Window.GetWidth(i));
i++;
}
return width;
};
Window.GetMaxHeight = fun () {
i = 0;
height = 0;
while (Window.GetHeight(i)) {
height = Math.Max(height, Window.GetHeight(i));
i++;
}
return height;
};
anim.imagecount = 20;
anim.target_width = Window.GetWidth();
anim.target_height = Window.GetHeight();
fun RotatedImage (index) {
index = Math.Int(index);
if (!RotatedImageCache[index])
RotatedImageCache[index] = anim.original_image.Rotate((Math.Pi * 2 * index) / anim.imagecount).Scale(anim.target_width, anim.target_height);
return RotatedImageCache[index];
}
if (Plymouth.GetMode() == "suspend" || Plymouth.GetMode() == "resume") {
background.original_image = ImageNew("suspend.png");
// Window.SetBackgroundTopColor(1, 0, 0);
// Window.SetBackgroundBottomColor(0, 1, 0);
}
else {
logo.original_image = ImageNew("logo.png");
background.original_image = ImageNew("background.png");
// Window.SetBackgroundTopColor(0.180, 0.545, 0.020);
// Window.SetBackgroundBottomColor(0.439, 0.573, 0.333);
anim.image = ImageNew("animation.png");
anim.original_image = anim.image.Scale(anim.target_width, anim.target_width);
anim.sprite = SpriteNew();
anim.sprite.SetImage(RotatedImage (0));
anim.sprite.SetX((Window.GetX() + Window.GetWidth() - RotatedImage(0).GetWidth()) / 2);
anim.sprite.SetY(Window.GetY() + Window.GetHeight() * 0.35);
anim.angle = 0;
anim.index = 0;
}
ratio = logo.original_image.GetWidth() / logo.original_image.GetHeight();
reduction = 0.10;
logo.image = logo.original_image.Scale(reduction * Window.GetMaxWidth(), reduction / ratio * Window.GetMaxWidth());
logo.sprite = SpriteNew();
logo.sprite.SetImage(logo.image);
logo.opacity_angle = 0;
logo.sprite.SetX((Window.GetX() + Window.GetMaxWidth() - logo.image.GetWidth()) / 2);
logo.sprite.SetY(Window.GetY() + Window.GetHeight() * 0.35);
background.image = background.original_image.Scale(Window.GetMaxWidth(), Window.GetMaxHeight());
background.sprite = SpriteNew();
background.sprite.SetImage(background.image);
background.sprite.SetPosition(Window.GetX(), Window.GetY(), -10);
fun refresh_callback () {
if (status == "normal") {
anim.index += 1;
anim.index %= anim.imagecount;
anim.sprite.SetImage(RotatedImage (anim.index));
}
else {
anim.sprite.SetOpacity(0);
}
}
if (Plymouth.GetMode() != "suspend" && Plymouth.GetMode() != "resume") {
Plymouth.SetRefreshFunction (refresh_callback);
}
/* -------------------------------------- Progress Bar ----------------------------------- */
progress_box.image = Image("progress_box.png");
progress_box.sprite = Sprite(progress_box.image);
progress_box.x = Window.GetX() + Window.GetWidth() / 2 - progress_box.image.GetWidth() / 2;
progress_box.y = Window.GetY() + Window.GetHeight() * 0.6 - progress_box.image.GetHeight() / 2;
progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0);
progress_bar.original_image = Image("progress_bar.png");
progress_bar.sprite = Sprite();
progress_bar.x = Window.GetX() + Window.GetWidth() / 2 - progress_bar.original_image.GetWidth() / 2;
progress_bar.y = Window.GetY() + Window.GetHeight() * 0.6 - progress_box.image.GetHeight() / 2 + (progress_box.image.GetHeight() - progress_bar.original_image.GetHeight()) / 2;
progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 2);
fun progress_callback (duration, progress) {
if (progress_bar.image.GetWidth () != Math.Int (progress_bar.original_image.GetWidth () * progress)) {
progress_bar.image = progress_bar.original_image.Scale(progress_bar.original_image.GetWidth(progress_bar.original_image) * progress, progress_bar.original_image.GetHeight());
progress_bar.sprite.SetImage (progress_bar.image);
}
}
Plymouth.SetBootProgressFunction(progress_callback);
/* ----------------------------------------- Quit ---------------------------------------- */
fun quit_callback () {
anim.sprite.SetOpacity (0);
}
Plymouth.SetQuitFunction(quit_callback);
|