-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Add draw.aalines width argument #3154
base: main
Are you sure you want to change the base?
Conversation
All stuff needed before implementing width Docs
And initial stuff
Screenshot
I think |
Change some functions to be inline
D'oh!
Additional extreme test for new changesimport pygame
import numpy as np
def curve_points(a, b, pea, t):
sin_p = np.sin(pea)
cos_p = np.cos(pea)
x = a * np.cos(t)
y = b * np.sin(t)
x_rot = x * cos_p - y * sin_p
y_rot = y * cos_p + x * sin_p
return np.stack((x_rot, y_rot), axis=1)
points1 = [[200.1, 300],
[220.1, 300.1],
[240.1, 300.2],
[260.1, 300.4],
[280.1, 300.6],
[300.1, 300.8]]
points2 = [[400.7, 300.1],
[420.3, 300.5],
[440.6, 305.1],
[460.4, 315.2],
[480.2, 330.5],
[500.1, 360.7],
[550.4, 360.5],
[550.8, 400.2]]
points_num = 200
t = np.linspace(-np.pi, np.pi, points_num)
points3 = curve_points(250, 150, 0.3, t) + np.array([350, 350])
pygame.init()
screen = pygame.display.set_mode((700, 700))
clock = pygame.time.Clock()
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
screen.fill("black")
pygame.draw.aalines(screen, "White", False, points1, 4)
pygame.draw.aalines(screen, "White", False, points2, 4)
pygame.draw.aalines(screen, "White", False, points3, 4)
pygame.display.flip()
clock.tick(60)
pygame.quit() Why does curve look 'wobbly': Why are lines somewhere thinner: |
I was told on discord by Mzivic they are planning to modify the algorithm for this, so I am marking as a draft. |
This PR adds width argument to
draw.aalines
with miter edges.Closes #1225
Left:
draw.lines
without miter edges,Right:
draw.aalines
with miter edges.draw.lines
will get miter edges in new PR, anddraw.aapolygon
in #3126.Sample code
How it works, pseudocode
Working python implementation