summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modules/pixbounce/pixbounce.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/modules/pixbounce/pixbounce.c b/src/modules/pixbounce/pixbounce.c
index 206d8a2..d200ad6 100644
--- a/src/modules/pixbounce/pixbounce.c
+++ b/src/modules/pixbounce/pixbounce.c
@@ -235,9 +235,9 @@ typedef struct pixbounce_context_t {
int multiplier;
} pixbounce_context_t;
-static uint32_t pick_color()
+static uint32_t pick_color(unsigned *seedp)
{
- return makergb(rand()%256, rand()%256, rand()%256, 1);
+ return makergb(rand_r(seedp)%256, rand_r(seedp)%256, rand_r(seedp)%256, 1);
}
static til_module_context_t * pixbounce_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
@@ -253,7 +253,7 @@ static til_module_context_t * pixbounce_create_context(unsigned seed, unsigned t
ctxt->x_dir = 0;
ctxt->y_dir = 0;
ctxt->pix = &pixbounce_pixmap[((pixbounce_setup_t *)setup)->pixmap];
- ctxt->color = pick_color();
+ ctxt->color = pick_color(&ctxt->til_module_context.seed);
ctxt->pixmap_size_factor = ((((pixbounce_setup_t *)setup)->pixmap_size)*55 + 22 )/ 100;
ctxt->multiplier = 1;
@@ -284,10 +284,10 @@ static void pixbounce_render_fragment(til_module_context_t *context, unsigned ti
}
/* randomly initialize location and direction of pixmap */
- ctxt->x = rand() % (width - ctxt->pix->width * ctxt->multiplier) + 1;
- ctxt->y = rand() % (height - ctxt->pix->height * ctxt->multiplier) + 1;
- ctxt->x_dir = (rand() % 7) - 3;
- ctxt->y_dir = (rand() % 7) - 3;
+ ctxt->x = rand_r(&ctxt->til_module_context.seed) % (width - ctxt->pix->width * ctxt->multiplier) + 1;
+ ctxt->y = rand_r(&ctxt->til_module_context.seed) % (height - ctxt->pix->height * ctxt->multiplier) + 1;
+ ctxt->x_dir = (rand_r(&ctxt->til_module_context.seed) % 7) - 3;
+ ctxt->y_dir = (rand_r(&ctxt->til_module_context.seed) % 7) - 3;
}
@@ -309,11 +309,11 @@ static void pixbounce_render_fragment(til_module_context_t *context, unsigned ti
/* update pixmap location */
if(ctxt->x+ctxt->x_dir < 0 || ctxt->x+ctxt->pix->width*ctxt->multiplier+ctxt->x_dir > width) {
ctxt->x_dir = ctxt->x_dir * -1;
- ctxt->color = pick_color();
+ ctxt->color = pick_color(&ctxt->til_module_context.seed);
}
if(ctxt->y+ctxt->y_dir < 0 || ctxt->y+ctxt->pix->height*ctxt->multiplier+ctxt->y_dir > height) {
ctxt->y_dir = ctxt->y_dir * -1;
- ctxt->color = pick_color();
+ ctxt->color = pick_color(&ctxt->til_module_context.seed);
}
ctxt->x = ctxt->x+ctxt->x_dir;
ctxt->y = ctxt->y+ctxt->y_dir;
© All Rights Reserved