Closed mzivic7 closed 1 month ago
Looks correct for me. Good job !
Because this implementation uses Bresenham's algorithm for drawing thick lines, it does not support float values for coordinates. New PR will be open with new implementation, using modified Xiaolin Wu's algorithm.
draw.aaline
with width argument has 2 problems: First: I used floats to detect steepines, butdraw.line
converts values to ints before math. That's why added aalines, when width > 1, are drawn at wrong position. (left on the image) Second: I used floats for original line coordinates to calculate positions for antialiased lines. Butdraw.line
converts values to ints, so antialiased lines got a little too far and created gaps. (right on the image)Sample code
```py import pygame pygame.init() screen = pygame.display.set_mode((300, 300)) clock = pygame.time.Clock() run = True while run: for event in pygame.event.get(): if event.type == pygame.QUIT: run = False screen.fill((0, 0, 0)) pygame.draw.aaline(screen, "white", (140, 259.93), (150, 269.47), 20) pygame.draw.aaline(screen, "white", (170, 259.93), (190, 269.47), 20) pygame.display.flip() clock.tick(60) pygame.quit() ```