From 42016a81c9cb86f54a8df6a0dd11b01b376f7729 Mon Sep 17 00:00:00 2001 From: smarq8 Date: Thu, 9 Mar 2023 09:32:39 +0100 Subject: [PATCH 1/2] Fix circle rendering (#106) --- src/hagl_circle.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hagl_circle.c b/src/hagl_circle.c index a258849..f2d836b 100644 --- a/src/hagl_circle.c +++ b/src/hagl_circle.c @@ -55,13 +55,13 @@ hagl_draw_circle(void const *surface, int16_t xc, int16_t yc, int16_t r, hagl_co hagl_put_pixel(surface, xc - y, yc - x, color); while (y >= x) { - x++; - if (d > 0) { - y--; d = d + 4 * (x - y) + 10; + y--; + x++; } else { d = d + 4 * x + 6; + x++; } hagl_put_pixel(surface, xc + x, yc + y, color); From 302b01233d910fc1d95e3e6cb961662f350e0d7e Mon Sep 17 00:00:00 2001 From: Mika Tuupola Date: Thu, 16 Mar 2023 17:02:30 +0700 Subject: [PATCH 2/2] Adjust filled circle dimensions to match circle (#109) Co-authored-by: smarq8 --- src/hagl_circle.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/hagl_circle.c b/src/hagl_circle.c index f2d836b..e49c617 100644 --- a/src/hagl_circle.c +++ b/src/hagl_circle.c @@ -87,13 +87,14 @@ hagl_fill_circle(void const *surface, int16_t x0, int16_t y0, int16_t r, hagl_co hagl_draw_hline(surface, x0 - x, y0 - y, x * 2, color); hagl_draw_hline(surface, x0 - y, y0 + x, y * 2, color); hagl_draw_hline(surface, x0 - y, y0 - x, y * 2, color); - x++; - if (d > 0) { - y--; - d = d + 4 * (x - y) + 10; - } else { + if (d <= 0) { d = d + 4 * x + 6; + x++; + } else { + d = d + 4 * (x - y) + 10; + x++; + y--; } } }