pygame-ce icon indicating copy to clipboard operation
pygame-ce copied to clipboard

Add warning when using negative rect dimensions in draw module

Open mzivic7 opened this issue 1 year ago • 5 comments
trafficstars

Using negative rect dimension values have some undesirable results as shown in #2727. This PR adds deprecation warning to these draw functions: draw.rect, draw.ellipse, draw.arc when using negative value for rect width and height. And prevents anything from being drawn at wrong position. Warnings are also added to docs and tests. This warning will also be added to draw.aaellipse in #3016 Closes #2727

Sample code
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.rect(screen, "white", (150, 150, -50, 30), 0)
  pygame.draw.ellipse(screen, "white", (150, 150, -50, 30), 0)
  pygame.draw.arc(screen, "white", (150, 150, -50, 30), 0, 180, 0)
  pygame.display.flip()
  clock.tick(60)
pygame.quit()

mzivic7 avatar Oct 09 '24 23:10 mzivic7