---
Make all the dot render metrics relative to the dot size and the dot
size relative to the DPI so the dots always have a consistent physical
size.
include/pbsplash.h | 4 ++--
src/animate.c | 39 ++++++++++++---------------------------
src/pbsplash.c | 2 +-
3 files changed, 15 insertions(+), 30 deletions(-)
diff --git a/include/pbsplash.h b/include/pbsplash.h
index bb2ba0a..b855f28 100644
--- a/include/pbsplash.h
+++ b/include/pbsplash.h
@@ -10,6 +10,6 @@ struct col {
};
};
-void animate_frame(int frame, int w, int y_off);
+void animate_frame(int frame, int w, int h, long dpi);
-#endif
\ No newline at end of file
+#endif
diff --git a/src/animate.c b/src/animate.c
index bf537ac..5026c39 100644
--- a/src/animate.c
+++ b/src/animate.c
@@ -6,47 +6,32 @@
struct col color = {.r = 255, .g = 255, .b = 255, .a = 255};
-// FIXME: calculate constants based on display size/resolution
-
#define PI 3.1415926535897932384626433832795
#define n_circles 5
-#define amplitude 40
-#define rad 12
#define speed 3
-void circles_wave(int frame, int w, int y_off) {
+void 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;
- for (unsigned int i = 0; i < n_circles; i++)
- {
- int c_dist = w * 0.05;
- int x = i * c_dist + w / 2 - c_dist * n_circles / 2.f;
- double s = sin(f / 60.0 * PI + i * 0.2 * n_circles);
- int y = y_off + s * amplitude;
- tfb_fill_rect(x - rad- 1, y_off - amplitude - rad, rad* 2 + 2, 400 +rad* 2, tfb_black);
- tfb_fill_circle(x, y, rad, t_col);
- }
-}
-void circles_wave_1x1(int frame, int w, int y_off) {
- unsigned int t_col = tfb_make_color(color.r, color.g, color.b);
- int f = -frame * speed;
- int which = (f / 120) % n_circles;
+ int rad = (int)(dpi * 4 / 96.0);
+ int dist = rad * 4;
+ int amplitude = rad * 2;
+
+ int left = (w / 2) - (dist * n_circles / 2.0);
for (unsigned int i = 0; i < n_circles; i++)
{
- int c_dist = w * 0.05;
- int x = i * c_dist + w / 2 - c_dist * n_circles / 2.f;
- double s = sin((f - 90) / 60.0 * PI);
- int y = y_off + (i == which ? s * amplitude : amplitude); // * (i == which);
- tfb_fill_rect(x - rad- 1, y_off - amplitude - rad, rad * 2 + 2, 400 + rad * 2, tfb_black);
+ int x = left + (i * dist);
+ double offset = sin(f / 60.0 * PI + i);
+ int y = y_off + offset * amplitude;
+ tfb_fill_rect(x - rad- 1, y_off - amplitude - rad, rad* 2 + 2, 400 +rad* 2, tfb_black);
tfb_fill_circle(x, y, rad, t_col);
}
}
-void animate_frame(int frame, int w, int y_off)
+void animate_frame(int frame, int w, int h, long dpi)
{
- circles_wave(frame, w, y_off - 200);
- //circles_wave_1x1(frame, w, y_off + 100);
+ circles_wave(frame, w, h * 0.75, dpi);
}
diff --git a/src/pbsplash.c b/src/pbsplash.c
index 18d3baa..b47eb3a 100644
--- a/src/pbsplash.c
+++ b/src/pbsplash.c
@@ -340,7 +340,7 @@ int main(int argc, char **argv)
int tty_mode = 0;
while (!terminate)
{
- animate_frame(frame++, w, h * 0.8);
+ animate_frame(frame++, w, h, dpi);
tfb_flush_fb();
ioctl(tty, KDGETMODE, &tty_mode);
// Login started and has reset the TTY back to text mode
--
2.36.1