added clear (alpha) parameter to draw animation trails.

This commit is contained in:
Antonio Carzaniga 2019-07-29 15:48:15 +02:00
parent b2c96f75c1
commit 370ac137ff

View File

@ -39,6 +39,8 @@ unsigned int n_balls = 50;
static double g_y = 20; static double g_y = 20;
static double g_x = 0; static double g_x = 0;
static double clear_alpha = 1.0;
void random_velocity(struct ball * p) { void random_velocity(struct ball * p) {
double r2; double r2;
do { do {
@ -154,7 +156,7 @@ static void draw_balls_onto_window () {
cr = gdk_cairo_create(window->window); cr = gdk_cairo_create(window->window);
/* clear pixmap */ /* clear pixmap */
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0); cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, clear_alpha);
cairo_paint(cr); cairo_paint(cr);
draw_gravity_vector(); draw_gravity_vector();
@ -239,7 +241,8 @@ void print_usage (const char * progname) {
"\tfy=<y-force>\n" "\tfy=<y-force>\n"
"\tradius=<min-radius>-<max-radius>\n" "\tradius=<min-radius>-<max-radius>\n"
"\tv=<min-velocity>-<max-velocity>\n" "\tv=<min-velocity>-<max-velocity>\n"
"\tdelta=<frame-delta-time>\n", "\tdelta=<frame-delta-time>\n"
"\tclear=<clear-alpha>\n"
progname); progname);
} }
@ -283,6 +286,8 @@ int main (int argc, const char *argv[]) {
continue; continue;
if (sscanf(argv[i], "delta=%lf", &delta) == 1) if (sscanf(argv[i], "delta=%lf", &delta) == 1)
continue; continue;
if (sscanf(argv[i], "clear=%lf", &clear_alpha) == 1)
continue;
print_usage(argv[0]); print_usage(argv[0]);
return 1; return 1;
} }