Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src_c/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ aacircle(PyObject *self, PyObject *args, PyObject *kwargs)
}
else {
draw_circle_xiaolinwu(surf, surf_clip_rect, surf_format, posx,
posy, radius, width, color, 1, 1, 1, 1,
posy, radius, width - 1, color, 1, 1, 1, 1,
drawn_area);
}
}
Expand All @@ -1029,7 +1029,7 @@ aacircle(PyObject *self, PyObject *args, PyObject *kwargs)
}
else {
draw_circle_xiaolinwu(surf, surf_clip_rect, surf_format, posx,
posy, radius, width, color, top_right,
posy, radius, width - 1, color, top_right,
top_left, bottom_left, bottom_right,
drawn_area);
}
Expand Down Expand Up @@ -3489,6 +3489,9 @@ draw_circle_xiaolinwu(SDL_Surface *surf, SDL_Rect surf_clip_rect,
int thickness, Uint32 color, int top_right, int top_left,
int bottom_left, int bottom_right, int *drawn_area)
{
/* The final drawn thickness will be 1 pixel greater than the value of the
* “thickness” parameter, as the iteration is performed over a closed
* interval. */
for (int layer_radius = radius - thickness; layer_radius <= radius;
Copy link
Member

@ankith26 ankith26 Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would be better to just fix the logic here instead, maybe we should do a radius - thickness + 1 initialization?

EDIT: Just saw your comment about centre of solid circles, but I'm still not convinced. This function should ideally do the "right thing" and the centre special case could be handled separately? I need to do a bit more testing though to understand things in more detail.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I played around a bit with this, and now I have a clearer understanding.

Basically the main issue is that draw.aacircle always draws an extra pixel at the centre, so a 1 radius circle needs a 3x3 box, a 2 radius circle needs a 5x5 box and so on (yes, just like #1487). So there's always going to be a jump somewhere and this PR is just shifting that jump from 1 -> 3 to (r - 2) -> r. I personally think this is a reasonable compromise given the status quo.

layer_radius++) {
int x = 0;
Expand Down
Loading