summaryrefslogtreecommitdiff
path: root/src/modules/spokes
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-12-12 15:04:15 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-12-12 15:04:15 -0800
commitedddfe75c95b35c819c59a755b2ac190b072de97 (patch)
tree3384b0d9344ecb59a4bd3ebb89fe5aca28ea2761 /src/modules/spokes
parent6f9ab5d3a95500d98d2dcf0d6e50bc3e86827198 (diff)
modules/spokes: fix missing spoke in some counts
Due to floating point errors this loop would occasionally miss the last spoke as-is. A quick fix is to just round down the accumulator before comparing it... this function in general needs to all be cleaned up, esp. since the conversion to floats. An obvious repro of this issue, fixed by this commit: '--module=spokes,iterations=2,count=3,twist=0.125,thickness=2' \ '--video=sdl,ratio=full,fullscreen=off,vsync=on,size=640x480' The low count of 3 makes the missing spoke quite visible...
Diffstat (limited to 'src/modules/spokes')
-rw-r--r--src/modules/spokes/spokes.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/modules/spokes/spokes.c b/src/modules/spokes/spokes.c
index 6bc3b2b..f033cf1 100644
--- a/src/modules/spokes/spokes.c
+++ b/src/modules/spokes/spokes.c
@@ -169,7 +169,7 @@ static void spokes_render_fragment(til_module_context_t *context, til_stream_t *
/* we're setup now to draw some shit */
til_fb_fragment_clear(fragment);
- for(float i=0; i<=width+height-stride; i+=stride){ /* iterate over half the perimiter at a time... */
+ for(float i=0; floorf(i)<=((float)width+height)-stride; i+=stride){ /* iterate over half the perimiter at a time... */
float perimiter_x, perimiter_y;
if(i+fmodf(offset, stride) < width) {
© All Rights Reserved