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

Deprecating gfxdraw module #3005

Open
5 of 15 tasks
mzivic7 opened this issue Jul 18, 2024 · 6 comments
Open
5 of 15 tasks

Deprecating gfxdraw module #3005

mzivic7 opened this issue Jul 18, 2024 · 6 comments
Labels

Comments

@mzivic7
Copy link
Contributor

mzivic7 commented Jul 18, 2024

These functions must be implemented to pygame.draw module in order to deprecate pygame.gfxdraw module:

Each aa- function should be interchangeable with regular function, in terms of arguments and capabilities.

* - this feature is hard to implement or not possible

gfxdraw can be deprecated after implementing all above listed main functions, and it gets removed in pygame-ce 3 or later.
Thickness and filled features are still very important.

Deprecating gfxdraw closes:

@bilhox
Copy link
Contributor

bilhox commented Jul 18, 2024

Hello,

First of all, thank you for the list. IMO, gfxdraw.pie shouldn't be ported to draw as it can be reproduced easily with existing draw functions.

@mzivic7
Copy link
Contributor Author

mzivic7 commented Jul 18, 2024

Ok, removing draw.pie from the list, because it can be drawn with draw.arc and 2 draw.lines.

@mzivic7
Copy link
Contributor Author

mzivic7 commented Jul 19, 2024

Idea for draw.aapolygon:

If width == 1:
    1. Draw closed aalines with width=1 
Else:
    1. Draw closed aalines with width=1
    2. Now for each point:
        3. calculate bisecting vector of angle at that point such that it points toward inside of polygon
        4. Get point moved by 1px along that vector in its direction
        This will result in 1px smaller polygon
    5. With new points draw another aalines
    If filled:
        6. Draw regular filled polygon with same points from 5.
    Else:
        6. Repeat 2.-5. with draw.lines until layer == width-2, in ecah iteration with each layer polygon will get smaller
        7. Draw another aalines with 1px smaller polygon than previous
        8. Repeat 7.

Why this:
Closed shapes must expand width towards inside, and it is expected for polygon to have sharp edges.
Step 1. alone is enough to deprecate gfxdraw.aapolygon. Other steps are for width and filled, which is IMO more important than just aapolygon.

@damusss
Copy link
Contributor

damusss commented Jul 19, 2024

Ok, removing draw.pie from the list, because it can be drawn with draw.arc and 2 draw.lines.

that's how I replaced it in my shim

@bilhox
Copy link
Contributor

bilhox commented Jul 19, 2024

#586 - draw.aacircle is also segfaulting
It doesn't segfault for me both on Windows and Ubuntu (In the case of pygame.draw.aacircle), it tells me this on Windows : 💀

pygame-ce 2.5.0 (SDL 2.30.3, Python 3.12.0)
Traceback (most recent call last):
  File "c:\Users\...\pygame-ce\a.py", line 8, in <module>
    aacircle(
OverflowError: Python int too large to convert to C long

and this on Ubuntu :

pygame-ce 2.5.1.dev1 (SDL 2.30.0, Python 3.12.3)
Traceback (most recent call last):
  File "/home/rakoon/pygame-ce/a.py", line 8, in <module>
    aacircle(
OverflowError: signed integer is greater than maximum

Update :
Nevermind, it appeared that pygame.draw.aacircle had a different signature than pygame.gfxdraw.aacircle, it segfaults now.

what I found while debugging :

Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
get_antialiased_color (surf=0xf0c6b0, x=317, y=255, original_color=224, brightness=1) at ../src_c/draw.c:1135
1135        SDL_GetRGBA(pixels[(y * surf->w) + x], surf->format, &background_color[0],

@mzivic7
Copy link
Contributor Author

mzivic7 commented Jul 19, 2024

#586 turned out to be unrelated to gfxdraw.
The problem was with get_antialiased_color.
Will be fixed in #3008

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants