Issue #310 closed

Cannot draw rectangles that are 1 pixel high

Blake O'Hare
created an issue

I cannot draw a rectangle if the height is 1 pixel.

This code does nothing...

pygame.draw.rect(screen, color, pygame.Rect(x, y, 100, 1))

But this code works just fine...

pygame.draw.rect(screen, color, pygame.Rect(x, y, 1, 100))

My current workaround looks something like this:

def myDrawRect(screen, color, x, y, width, height):
  if height == 1:
    pygame.draw.line(screen, color, (x, y), (x + width - 1, y))
  else:
    pygame.draw.rect(screen, color, pygame.Rect(x, y, width, height))

Comments (3)

  1. Log in to comment