summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-01-09 19:17:20 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-01-10 10:11:01 -0800
commitcffc3da34523b996393f730bed5a65934b499167 (patch)
tree7e853630bdd616f5261e0d887a6e28031cd7b7cf /src
parent428a4bb896c04e0089339a5e2d2e734a2403c09f (diff)
modules/stars: add taps for some vars
Wiring up some minimal taps to see how this will work... This only initializes the taps and changes the render to access the rates indirectly via the tapped pointers.
Diffstat (limited to 'src')
-rw-r--r--src/modules/stars/stars.c69
1 files changed, 45 insertions, 24 deletions
diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c
index 8e6a5d0..12de4ed 100644
--- a/src/modules/stars/stars.c
+++ b/src/modules/stars/stars.c
@@ -12,6 +12,7 @@
#include "til_fb.h"
#include "til_module_context.h"
#include "til_settings.h"
+#include "til_tap.h"
#include "draw.h"
@@ -27,12 +28,29 @@ struct points {
typedef struct stars_context_t {
til_module_context_t til_module_context;
struct points* points;
+
+ struct {
+ til_tap_t rot_rate;
+ til_tap_t rot_angle;
+ til_tap_t offset_x;
+ til_tap_t offset_y;
+ til_tap_t offset_angle;
+ } taps;
+
+ struct {
+ float rot_rate;
+ float rot_angle;
+ float offset_x;
+ float offset_y;
+ float offset_angle;
+ } vars;
+
float rot_adj;
- float rot_rate;
- float rot_angle;
- float offset_x;
- float offset_y;
- float offset_angle;
+ float *rot_rate;
+ float *rot_angle;
+ float *offset_x;
+ float *offset_y;
+ float *offset_angle;
unsigned seed;
} stars_context_t;
@@ -67,11 +85,14 @@ static til_module_context_t * stars_create_context(unsigned seed, unsigned ticks
ctxt->points = NULL;
ctxt->seed = seed;
ctxt->rot_adj = ((stars_setup_t *)setup)->rot_adj;
- ctxt->rot_rate = 0.00;
- ctxt->rot_angle = 0;
- ctxt->offset_x = 0.5;
- ctxt->offset_y = 0;
- ctxt->offset_angle = 0.01;
+ ctxt->vars.offset_x = 0.5;
+ ctxt->vars.offset_angle = 0.01;
+
+ ctxt->taps.rot_rate = til_tap_init_float(&ctxt->rot_rate, 1, &ctxt->vars.rot_rate, "rot_rate");
+ ctxt->taps.rot_angle = til_tap_init_float(&ctxt->rot_angle, 1, &ctxt->vars.rot_angle, "rot_angle");
+ ctxt->taps.offset_x = til_tap_init_float(&ctxt->offset_x, 1, &ctxt->vars.offset_x, "offset_x");
+ ctxt->taps.offset_y = til_tap_init_float(&ctxt->offset_y, 1, &ctxt->vars.offset_y, "offset_y");
+ ctxt->taps.offset_angle = til_tap_init_float(&ctxt->offset_angle, 1, &ctxt->vars.offset_angle, "offset_angle");
//add a bunch of points
for(z=0.01; z<1; z=z+0.01) {
@@ -152,11 +173,11 @@ static void stars_render_fragment(til_module_context_t *context, unsigned ticks,
x = (iterator->x / (1.f - iterator->z))*x_mult;
y = (iterator->y / (1.f - iterator->z))*y_mult;
- rot_x = (x*cosf(ctxt->rot_angle))-(y*sinf(ctxt->rot_angle));
- rot_y = (x*sinf(ctxt->rot_angle))+(y*cosf(ctxt->rot_angle));
+ rot_x = (x*cosf(*ctxt->rot_angle))-(y*sinf(*ctxt->rot_angle));
+ rot_y = (x*sinf(*ctxt->rot_angle))+(y*cosf(*ctxt->rot_angle));
- pos_x = ((rot_x+ctxt->offset_x+1.f)*.5f)*(float)width;
- pos_y = ((rot_y+ctxt->offset_y+1.f)*.5f)*(float)height;
+ pos_x = ((rot_x+*ctxt->offset_x+1.f)*.5f)*(float)width;
+ pos_y = ((rot_y+*ctxt->offset_y+1.f)*.5f)*(float)height;
if(iterator->z<0.1)
opacity = iterator->z*10;
@@ -202,19 +223,19 @@ static void stars_render_fragment(til_module_context_t *context, unsigned ticks,
}
// handle rotation parameters
- if(ctxt->rot_angle>M_PI_4)
- ctxt->rot_rate=ctxt->rot_rate-ctxt->rot_adj;
+ if(*ctxt->rot_angle>M_PI_4)
+ *ctxt->rot_rate=*ctxt->rot_rate-ctxt->rot_adj;
else
- ctxt->rot_rate=ctxt->rot_rate+ctxt->rot_adj;
- ctxt->rot_angle=ctxt->rot_angle+ctxt->rot_rate;
+ *ctxt->rot_rate=*ctxt->rot_rate+ctxt->rot_adj;
+ *ctxt->rot_angle=*ctxt->rot_angle+*ctxt->rot_rate;
// handle offset parameters
- float tmp_x = (ctxt->offset_x*cosf(ctxt->offset_angle))-
- (ctxt->offset_y*sinf(ctxt->offset_angle));
- float tmp_y = (ctxt->offset_x*sinf(ctxt->offset_angle))+
- (ctxt->offset_y*cosf(ctxt->offset_angle));
- ctxt->offset_x = tmp_x;
- ctxt->offset_y = tmp_y;
+ float tmp_x = (*ctxt->offset_x*cosf(*ctxt->offset_angle))-
+ (*ctxt->offset_y*sinf(*ctxt->offset_angle));
+ float tmp_y = (*ctxt->offset_x*sinf(*ctxt->offset_angle))+
+ (*ctxt->offset_y*cosf(*ctxt->offset_angle));
+ *ctxt->offset_x = tmp_x;
+ *ctxt->offset_y = tmp_y;
}
int stars_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