Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draw.aacircle() #2800

Merged
merged 8 commits into from
May 25, 2024
Merged

draw.aacircle() #2800

merged 8 commits into from
May 25, 2024

Conversation

mzivic7
Copy link
Contributor

@mzivic7 mzivic7 commented Apr 14, 2024

Pygame-ce has only gfxdraw.aacircle function for drawing antialiased circles, but it has several problems:

and it is intended to be deprecated/removed in future.

All these problems are fixed in draw.aacircle, that is implemented in this commit.

Changes:

  • Added draw.aacircle function that has same inputs and outputs as draw.circle
  • Added algorithms for drawing thin and thick antialiased circles, adapted from:
    https://cgg.mff.cuni.cz/~pepca/ref/WU.pdf
  • Added to documentation
  • Added to code_examples
  • Added to tests

…draw.circle()

- Added algorithms for drawing thin and thick antialiased circles, 
adapted from:
https://cgg.mff.cuni.cz/~pepca/ref/WU.pdf
- Added to documentation
- Added to code_examples
- Added to tests
@mzivic7 mzivic7 requested a review from a team as a code owner April 14, 2024 02:05
@oddbookworm
Copy link
Member

Looks like you need to run python setup.py format

Copy link
Member

@oddbookworm oddbookworm left a comment

Choose a reason for hiding this comment

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

Just a few comments, looking good so far!

Comment on lines +34 to +44
def aacircle(
surface: Surface,
color: ColorValue,
center: Coordinate,
radius: float,
width: int = 0,
draw_top_right: bool = False,
draw_top_left: bool = False,
draw_bottom_left: bool = False,
draw_bottom_right: bool = False,
) -> Rect: ...
Copy link
Member

Choose a reason for hiding this comment

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

I think it would actually be better to have two signatures here. One without the bools, and one with

Copy link
Member

Choose a reason for hiding this comment

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

Why? circle above just has one signature.

src_c/draw.c Show resolved Hide resolved
src_c/draw.c Outdated Show resolved Hide resolved
src_c/draw.c Outdated Show resolved Hide resolved
src_c/draw.c Outdated Show resolved Hide resolved
test/draw_test.py Show resolved Hide resolved
- Run `python setup.py format`
- Added another signature to buildconfig/stubs/pygame/draw.pyi
- Removed unnecesary doubles
- Renamed eight_pixels function
- Post-increment -> pre-increment
- Renamed method names and the docstrings to use aacircle

Note:
`python setup.py format` formatted some other files I havent touched.
buildconfig/stubs/pygame/draw.pyi Show resolved Hide resolved
src_c/draw.c Outdated Show resolved Hide resolved
src_c/SDL_gfx/SDL_gfxPrimitives.c Outdated Show resolved Hide resolved
fixed pre-increment
added @overload to stubs
src_c/draw.c Outdated Show resolved Hide resolved
src_c/draw.c Outdated Show resolved Hide resolved
src_c/draw.c Outdated Show resolved Hide resolved
@yunline yunline added New API This pull request may need extra debate as it adds a new class or function to pygame draw pygame.draw labels May 9, 2024
Copy link
Member

@oddbookworm oddbookworm left a comment

Choose a reason for hiding this comment

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

I got a couple small comments, but this looks good!

src_c/draw.c Outdated Show resolved Hide resolved
src_c/draw.c Outdated Show resolved Hide resolved
Copy link
Member

@MyreMylar MyreMylar left a comment

Choose a reason for hiding this comment

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

This looks really good to me! 👍

Will enable us to shim the old gfxdraw version completely at some point and has features on top of that that make it consistent with draw.circle.

No notes! 🥇

@oddbookworm oddbookworm added this to the 2.5.0 milestone May 25, 2024
@oddbookworm oddbookworm merged commit dd11ffc into pygame-community:main May 25, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
draw pygame.draw New API This pull request may need extra debate as it adds a new class or function to pygame
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants