Here's the patchset that makes it look like in the video [1], when used
together with the logo [2]. After making the video I've tweaked the
font placement some more, the line at the bottom is now smaller and at
the very bottom; and the other description text is just above that
bottom line. I'd suggest now to also include the "Loading..." text while
displaying the animation, it looks good now IMHO. I'll write remaining
TODOs for integrating this into postmarketOS into the pmaports MR [3].
[1]: https://fosstodon.org/@ollieparanoid/108727375211035890
[2]: https://gitlab.com/postmarketOS/artwork/-/blob/master/logo/pmos-splash-screen.svg
[3]: https://gitlab.com/postmarketOS/pmaports/-/merge_requests/2878
Oliver Smith (13):
usage: fix argument line
getopt: fix error msg for invalid dpi
getopt: remove unneeded check for -d
getopt: make logo_size_max configurable with -q
animate: fix fill_rect height
Tweak the animation and placement
Support multiple message lines
include: add missing declarations
nanosvg: build implementation in extra c file
nsvgGetTextShapes: fix uninitialized values
Support message line at the bottom
Move regular message further down
Add argument to disable animation
include/nanosvg.h | 6 ++-
include/nanosvgrast.h | 8 +++-
include/pbsplash.h | 2 +-
src/animate.c | 18 ++++----
src/meson.build | 3 +-
src/nanosvg.c | 9 ++++
src/pbsplash.c | 101 ++++++++++++++++++++++++++++++++----------
7 files changed, 110 insertions(+), 37 deletions(-)
create mode 100644 src/nanosvg.c
--
2.34.3
Remove the extra check for a value after specifying -d, as getopt() is
already taking care of it:
pbsplash: option requires an argument: d
---
src/pbsplash.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/pbsplash.c b/src/pbsplash.c
index 5b16e93..2cce927 100644
--- a/src/pbsplash.c+++ b/src/pbsplash.c
@@ -225,10 +225,6 @@ int main(int argc, char **argv)
}
break;
case 'd':
- if (!optarg) {- fprintf(stderr, "--dpi requires an argument\n");- return usage();- } dpi = strtol(optarg, &end, 10);
if (end == optarg) {
fprintf(stderr, "Invalid dpi: %s\n",
--
2.34.3
[PATCH 04/13] getopt: make logo_size_max configurable with -q
* Move the animation between the logo and the text
* Move text further below
* Change circles to 3 (like ...) and increase speed to 5
* Change circles radius, distance, amplitude
* Draw empty circles instead of full circles, to be used with a logo
that also has an outline
---
include/pbsplash.h | 2 +-src/animate.c | 16 ++++++++--------src/pbsplash.c | 5 +++--
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/include/pbsplash.h b/include/pbsplash.h
index b855f28..99a496f 100644
--- a/include/pbsplash.h+++ b/include/pbsplash.h
@@ -10,6 +10,6 @@ struct col {
};
};
-void animate_frame(int frame, int w, int h, long dpi);+void animate_frame(int frame, int w, int y_off, long dpi);#endif
diff --git a/src/animate.c b/src/animate.c
index 99e46b5..9f03a66 100644
--- a/src/animate.c+++ b/src/animate.c
@@ -8,18 +8,18 @@ struct col color = { .r = 255, .g = 255, .b = 255, .a = 255 };
#define PI 3.1415926535897932384626433832795
-#define n_circles 5+#define n_circles 3-#define speed 3+#define speed 5void circles_wave(int frame, int w, int y_off, long dpi)
{
unsigned int t_col = tfb_make_color(color.r, color.g, color.b);
int f = frame * speed;
- int rad = (int)(dpi * 4 / 96.0);- int dist = rad * 4;- int amplitude = rad * 2;+ int rad = (int)(dpi * 3 / 96.0);+ int dist = rad * 3;+ int amplitude = rad * 1; int left = (w / 2) - (dist * (n_circles - 1) / 2.0);
for (unsigned int i = 0; i < n_circles; i++) {
@@ -28,11 +28,11 @@ void circles_wave(int frame, int w, int y_off, long dpi)
int y = y_off + offset * amplitude;
tfb_fill_rect(x - rad - 1, y_off - amplitude - rad, rad * 2 + 2,
amplitude * 2 + rad * 2 + 1, tfb_black);
- tfb_fill_circle(x, y, rad, t_col);+ tfb_draw_circle(x, y, rad, t_col); }
}
-void animate_frame(int frame, int w, int h, long dpi)+void animate_frame(int frame, int w, int y_off, long dpi){
- circles_wave(frame, w, h * 0.75, dpi);+ circles_wave(frame, w, y_off, dpi);}
diff --git a/src/pbsplash.c b/src/pbsplash.c
index 7c80085..8ab8667 100644
--- a/src/pbsplash.c+++ b/src/pbsplash.c
@@ -340,7 +340,7 @@ int main(int argc, char **argv)
&textHeight);
int tx = w / 2.f - textWidth / 2.f;
- int ty = y + image_h + textHeight * 0.5f + MM_TO_PX(dpi, 2);+ int ty = y + image_h + textHeight * 0.5f + MM_TO_PX(dpi, 20); draw_text(font, message, tx, ty, textWidth, textHeight, fontsz,
tfb_gray);
@@ -351,8 +351,9 @@ int main(int argc, char **argv)
int frame = 0;
int tty = open(active_tty, O_RDWR);
+ float y_off = y + image_h + MM_TO_PX(dpi, 5); while (!terminate) {
- animate_frame(frame++, w, h, dpi);+ animate_frame(frame++, w, y_off, dpi); tfb_flush_fb();
}
--
2.34.3
Speed up development iterations by building the nanosvg implementation
only once. Especially on the PinePhone it takes a bit.
---
src/meson.build | 3 ++-src/nanosvg.c | 9 +++++++++src/pbsplash.c | 2 --
3 files changed, 11 insertions(+), 3 deletions(-)
create mode 100644 src/nanosvg.c
diff --git a/src/meson.build b/src/meson.build
index 77f2b51..52b2bf3 100644
--- a/src/meson.build+++ b/src/meson.build
@@ -1,6 +1,7 @@
src = [
- 'pbsplash.c', 'animate.c',
+ 'nanosvg.c',+ 'pbsplash.c',]
executable('pbsplash', src,
diff --git a/src/nanosvg.c b/src/nanosvg.c
new file mode 100644
index 0000000..ecf037a
--- /dev/null+++ b/src/nanosvg.c
@@ -0,0 +1,9 @@
+/* Build the nanosvg implementation here, to build it only once and have other+ * C files build fast during development. */+#include <stdio.h>++#define NANOSVG_IMPLEMENTATION+#include "nanosvg.h"++#define NANOSVGRAST_IMPLEMENTATION+#include "nanosvgrast.h"
diff --git a/src/pbsplash.c b/src/pbsplash.c
index fb8eca7..def186e 100644
--- a/src/pbsplash.c+++ b/src/pbsplash.c
@@ -13,9 +13,7 @@
#include <string.h>
#include <math.h>
#define NANOSVG_ALL_COLOR_KEYWORDS // Include full list of color keywords.
-#define NANOSVG_IMPLEMENTATION // Expands implementation#include "nanosvg.h"
-#define NANOSVGRAST_IMPLEMENTATION#include "nanosvgrast.h"
#include "pbsplash.h"
--
2.34.3
Use calloc to zero ret, because ret[i] does not get written if
NSVG_FLAGS_VISIBLE is unset. Found with valgrind.
---
include/nanosvg.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/nanosvg.h b/include/nanosvg.h
index 2534a78..35d492f 100644
--- a/include/nanosvg.h+++ b/include/nanosvg.h
@@ -2966,7 +2966,7 @@ static void nsvg__scaleToViewbox(NSVGparser* p, const char* units)
NSVGshape** nsvgGetTextShapes(NSVGimage* image, char* text, int textLen)
{
NSVGshape *shape = NULL;
- NSVGshape **ret = malloc(sizeof(NSVGshape*)*textLen); // array of paths, text to render+ NSVGshape **ret = calloc(textLen, sizeof(shape)); // array of paths, text to render int i;
// make list of paths representing glyphs to render
--
2.34.3
Give the splash image + animation more splace by moving the message
further down. Now they are right above the very bottom message (which
has a different font size).
Write the messages from bottom up, so the space towards the bottom is
always the same while avoiding more complicated logic to calculate the
position.
---
src/pbsplash.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/pbsplash.c b/src/pbsplash.c
index 6cbbcd0..6ce6754 100644
--- a/src/pbsplash.c+++ b/src/pbsplash.c
@@ -359,14 +359,15 @@ int main(int argc, char **argv)
float fontsz = ((float)font_size * PT_TO_MM) /
(font->fontAscent - font->fontDescent) *
pixels_per_milli;
- int ty = y + image_h + MM_TO_PX(dpi, 20);- for (unsigned int i=0; i < message_count; i++) {+ int ty = h - MM_TO_PX(dpi, 5);++ for (int i = message_count - 1; i >= 0; i--) { getTextDimensions(font, message[i], fontsz, &textWidth,
&textHeight);
int tx = w / 2.f - textWidth / 2.f;
- ty += textHeight * 0.5f + MM_TO_PX(dpi, 2);+ ty -= textHeight * 0.5f + MM_TO_PX(dpi, 2); draw_text(font, message[i], tx, ty, textWidth,
textHeight, fontsz, tfb_gray);
--
2.34.3