summaryrefslogtreecommitdiff
path: root/src/modules/shapes
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-05-25 09:30:46 -0700
committerVito Caputo <vcaputo@pengaru.com>2022-05-25 09:30:46 -0700
commit8cab00946cc06cb8e4925ba389f052b40298c751 (patch)
treefd7c91adff519b3f71be18b981e8a0d3b9bb3fee /src/modules/shapes
parent94b367dd6fe78fa4c6a36a484f50472322588397 (diff)
modules/shapes: slow spins down a bit
I didn't like the too fast spins where you can't even really get a read on what's going on in the shape. Suspect this will get tweaked more in the future...
Diffstat (limited to 'src/modules/shapes')
-rw-r--r--src/modules/shapes/shapes.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/modules/shapes/shapes.c b/src/modules/shapes/shapes.c
index 3726599..a1a3342 100644
--- a/src/modules/shapes/shapes.c
+++ b/src/modules/shapes/shapes.c
@@ -72,6 +72,8 @@
#define SHAPES_DEFAULT_PINCH_SPIN .5
#define SHAPES_DEFAULT_PINCHES 2
+#define SHAPES_SPIN_BASE .0025f
+
typedef enum shapes_type_t {
SHAPES_TYPE_CIRCLE,
SHAPES_TYPE_PINWHEEL,
@@ -171,7 +173,7 @@ static void shapes_render_fragment(void *context, unsigned ticks, unsigned cpu,
for (int x = xoff, X = -(size >> 1); x < xoff + size; x++, X++, XX += s) {
float rad = atan2f(YY, XX);
- if (Y*Y+X*X < r_sq * (1.f - fabsf(cosf(ctxt->setup.n_pinches * rad + (float)ticks * ctxt->setup.pinch_spin * .01f)) * ctxt->setup.pinch))
+ if (Y*Y+X*X < r_sq * (1.f - fabsf(cosf(ctxt->setup.n_pinches * rad + (float)ticks * ctxt->setup.pinch_spin * SHAPES_SPIN_BASE)) * ctxt->setup.pinch))
til_fb_fragment_put_pixel_unchecked(fragment, TIL_FB_DRAW_FLAG_TEXTURABLE, fragment->x + x, fragment->y + y, 0xffffffff);
else if (!fragment->cleared)
til_fb_fragment_put_pixel_unchecked(fragment, 0, fragment->x + x, fragment->y + y, 0x0);
@@ -190,9 +192,9 @@ static void shapes_render_fragment(void *context, unsigned ticks, unsigned cpu,
X = -1.f;
for (unsigned x = xoff; x < xoff + size; x++, X += s) {
float rad = atan2f(Y, X);
- float r = cosf((float)ctxt->setup.n_points * (rad + (float)ticks * ctxt->setup.spin * .01f)) * .5f + .5f;
+ float r = cosf((float)ctxt->setup.n_points * (rad + (float)ticks * ctxt->setup.spin * SHAPES_SPIN_BASE)) * .5f + .5f;
- r *= 1.f - fabsf(cosf(ctxt->setup.n_pinches * rad + (float)ticks * ctxt->setup.pinch_spin * .01f)) * ctxt->setup.pinch;
+ r *= 1.f - fabsf(cosf(ctxt->setup.n_pinches * rad + (float)ticks * ctxt->setup.pinch_spin * SHAPES_SPIN_BASE)) * ctxt->setup.pinch;
if (X * X + Y * Y < r * r)
til_fb_fragment_put_pixel_unchecked(fragment, TIL_FB_DRAW_FLAG_TEXTURABLE, fragment->x + x, fragment->y + y, 0xffffffff);
@@ -218,7 +220,7 @@ static void shapes_render_fragment(void *context, unsigned ticks, unsigned cpu,
for (unsigned x = xoff; x < xoff + size; x++, X++, XX += s) {
float rad = atan2f(YY, XX);
- if (abs(Y) + abs(X) < r * (1.f - fabsf(cosf(ctxt->setup.n_pinches * rad + (float)ticks * ctxt->setup.pinch_spin * .01f)) * ctxt->setup.pinch))
+ if (abs(Y) + abs(X) < r * (1.f - fabsf(cosf(ctxt->setup.n_pinches * rad + (float)ticks * ctxt->setup.pinch_spin * SHAPES_SPIN_BASE)) * ctxt->setup.pinch))
til_fb_fragment_put_pixel_unchecked(fragment, TIL_FB_DRAW_FLAG_TEXTURABLE, fragment->x + x, fragment->y + y, 0xffffffff);
else if (!fragment->cleared)
til_fb_fragment_put_pixel_unchecked(fragment, 0, fragment->x + x, fragment->y + y, 0x0);
@@ -237,10 +239,10 @@ static void shapes_render_fragment(void *context, unsigned ticks, unsigned cpu,
X = -1.f;
for (unsigned x = xoff; x < xoff + size; x++, X += s) {
float rad = atan2f(Y, X);
- float r = (M_2_PI * asinf(sinf((float)ctxt->setup.n_points * (rad + (float)ticks * ctxt->setup.spin * .01f)) * .5f + .5f)) * .5f + .5f;
+ float r = (M_2_PI * asinf(sinf((float)ctxt->setup.n_points * (rad + (float)ticks * ctxt->setup.spin * SHAPES_SPIN_BASE)) * .5f + .5f)) * .5f + .5f;
/* ^^^^^^^^^^^^^^^^^^^ approximates a triangle wave */
- r *= 1.f - fabsf(cosf(ctxt->setup.n_pinches * rad + (float)ticks * ctxt->setup.pinch_spin * .01f)) * ctxt->setup.pinch;
+ r *= 1.f - fabsf(cosf(ctxt->setup.n_pinches * rad + (float)ticks * ctxt->setup.pinch_spin * SHAPES_SPIN_BASE)) * ctxt->setup.pinch;
if (X * X + Y * Y < r * r)
til_fb_fragment_put_pixel_unchecked(fragment, TIL_FB_DRAW_FLAG_TEXTURABLE, fragment->x + x, fragment->y + y, 0xffffffff);
© All Rights Reserved