mirror of
https://git.sr.ht/~calebccff/pbsplash
synced 2026-01-12 20:48:40 -09:00
DPI scaling for the dots
This commit is contained in:
parent
e5f4c50b18
commit
b6625648c9
3 changed files with 15 additions and 30 deletions
|
|
@ -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
|
#endif
|
||||||
|
|
@ -6,47 +6,32 @@
|
||||||
|
|
||||||
struct col color = {.r = 255, .g = 255, .b = 255, .a = 255};
|
struct col color = {.r = 255, .g = 255, .b = 255, .a = 255};
|
||||||
|
|
||||||
// FIXME: calculate constants based on display size/resolution
|
|
||||||
|
|
||||||
#define PI 3.1415926535897932384626433832795
|
#define PI 3.1415926535897932384626433832795
|
||||||
|
|
||||||
#define n_circles 5
|
#define n_circles 5
|
||||||
#define amplitude 40
|
|
||||||
#define rad 12
|
|
||||||
|
|
||||||
#define speed 3
|
#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);
|
unsigned int t_col = tfb_make_color(color.r, color.g, color.b);
|
||||||
int f = frame * speed;
|
int f = frame * speed;
|
||||||
|
|
||||||
|
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++)
|
for (unsigned int i = 0; i < n_circles; i++)
|
||||||
{
|
{
|
||||||
int c_dist = w * 0.05;
|
int x = left + (i * dist);
|
||||||
int x = i * c_dist + w / 2 - c_dist * n_circles / 2.f;
|
double offset = sin(f / 60.0 * PI + i);
|
||||||
double s = sin(f / 60.0 * PI + i * 0.2 * n_circles);
|
int y = y_off + offset * amplitude;
|
||||||
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_rect(x - rad- 1, y_off - amplitude - rad, rad* 2 + 2, 400 +rad* 2, tfb_black);
|
||||||
tfb_fill_circle(x, y, rad, t_col);
|
tfb_fill_circle(x, y, rad, t_col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void circles_wave_1x1(int frame, int w, int y_off) {
|
void animate_frame(int frame, int w, int h, long dpi)
|
||||||
unsigned int t_col = tfb_make_color(color.r, color.g, color.b);
|
|
||||||
int f = -frame * speed;
|
|
||||||
int which = (f / 120) % n_circles;
|
|
||||||
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);
|
|
||||||
tfb_fill_circle(x, y, rad, t_col);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void animate_frame(int frame, int w, int y_off)
|
|
||||||
{
|
{
|
||||||
circles_wave(frame, w, y_off - 200);
|
circles_wave(frame, w, h * 0.75, dpi);
|
||||||
//circles_wave_1x1(frame, w, y_off + 100);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -340,7 +340,7 @@ int main(int argc, char **argv)
|
||||||
int tty_mode = 0;
|
int tty_mode = 0;
|
||||||
while (!terminate)
|
while (!terminate)
|
||||||
{
|
{
|
||||||
animate_frame(frame++, w, h * 0.8);
|
animate_frame(frame++, w, h, dpi);
|
||||||
tfb_flush_fb();
|
tfb_flush_fb();
|
||||||
ioctl(tty, KDGETMODE, &tty_mode);
|
ioctl(tty, KDGETMODE, &tty_mode);
|
||||||
// Login started and has reset the TTY back to text mode
|
// Login started and has reset the TTY back to text mode
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue