Hi,
I don't remember noticing this behavior before, but it seems that the
lines' widths are chosen so that the ends, which are also axis-aligned, are
the given width. Thus, the lines can be up to about 29% thinner than one
would expect.
Here's an example image; note esp. how the diagonal line appears too thin:
The code that generates this is attached.
This doesn't seem very useful behavior, and it make it hard to e.g. add
endcaps yourself. At the very least, it's *weird* and the documentation
doesn't lead one to expect it. Having squared-off miter joints, and the
line's thickness refer to the thickness of the actual line, would be a vast
improvement.
Ian
import pygame
from pygame.locals import *
pygame.init()
screen_size = [600,600]
surface = pygame.display.set_mode(screen_size)
def cappedline(surface, color, p0,p1, width=1):
pygame.draw.line(surface, color, p0,p1, width)
def get_input():
for event in pygame.event.get():
if event.type == QUIT: return False
elif event.type == KEYDOWN:
if event.key == K_ESCAPE: return False
elif event.key == K_s: pygame.image.save(surface,"test.png")
return True
def draw():
surface.fill((0,0,0))
width = 50
pygame.draw.line(surface, (255,0,0), (300,100),(500,100), width)
pygame.draw.line(surface, (255,0,0), (200,100),(500,300), width)
pygame.draw.line(surface, (255,0,0), (200,200),(500,500), width)
pygame.draw.line(surface, (255,0,0), (100,200),(300,500), width)
pygame.draw.line(surface, (255,0,0), (100,300),(100,500), width)
pygame.display.flip()
def main():
while True:
if not get_input(): break
draw()
pygame.quit()
if __name__ == "__main__": main()