From edddfe75c95b35c819c59a755b2ac190b072de97 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Tue, 12 Dec 2023 15:04:15 -0800 Subject: 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... --- src/modules/spokes/spokes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) { -- cgit v1.2.1