summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-08-29 09:38:53 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-08-29 09:38:53 -0700
commitd1be60df24677c5e3fd4e7d363696cfbfb20d70d (patch)
treec8a1fc635ff18d256a741b3e64587c4c6dceade9 /src
parent4c04ba8a2f75ac1ece7e0bb407f0298a5686850f (diff)
modules/pixbounce: filter same-tick movements
This needs a bit more work, but at least filtering the same-tick renders avoids the many-movements-per-frame potential when used as something like a checkers::fill_module
Diffstat (limited to 'src')
-rw-r--r--src/modules/pixbounce/pixbounce.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/modules/pixbounce/pixbounce.c b/src/modules/pixbounce/pixbounce.c
index 7dfceaf..6fac758 100644
--- a/src/modules/pixbounce/pixbounce.c
+++ b/src/modules/pixbounce/pixbounce.c
@@ -303,16 +303,18 @@ static void pixbounce_render_fragment(til_module_context_t *context, til_stream_
}
/* 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->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->til_module_context.seed);
+ if (ticks != context->last_ticks) {
+ 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->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->til_module_context.seed);
+ }
+ ctxt->x = ctxt->x+ctxt->x_dir;
+ ctxt->y = ctxt->y+ctxt->y_dir;
}
- ctxt->x = ctxt->x+ctxt->x_dir;
- ctxt->y = ctxt->y+ctxt->y_dir;
}
int pixbounce_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
© All Rights Reserved