Skip to content

rounding corners with pg.draw.rect is broken with negative values #2285

Open
@AndreyVarvar

Description

@AndreyVarvar

Environment:
(Those are probably irrelevant, but still)

  • Operating system: MacOS
  • Python version: 3.9.9
  • SDL version: 2.26.4
  • PyGame version: pygame-ce 2.3.0

Current behavior:
pygame.draw.rect() has a set of parameters, responsible for rounding the corners. There is a border_radius parameter, which is responsible for all 4 corners, and then there are 4 parameters, that are responsible for a single corner assigned to them. Default value of each parameter is -1, however, if every parameter, responsible for rounding the corners, is negative, and one of them is positive, the shape becomes weird (as in the image)

Screen Shot 2023-07-03 at 22 15 47

This behaviour is NOT present, when all values are negative, no matter what they are, as long as they are negative, which led me to conclusion, that this behaviour is not expected

Expected behaviour:

no broken corners

Steps to reproduce:

  1. type pg.draw.rect(surface, color, rect, 0, -n, -n, +n, -n, -n)
    where n is any number
  2. run the script and view the result

NOTE: only the "master" border_radius parameter sets the size of the drawn corners, each individual parameter responsible for only a single corner does not affect the outcome.

Test code

import pygame as pg
pg.init()
running = True
display = pg.display.set_mode((600, 600))


while running:
    for event in pg.event.get():
        if event.type == pg.QUIT:
            pg.quit()
            quit()

    display.fill("black")

    pg.draw.rect(display, (255, 255, 255), (100, 100, 50, 50), 4, -100, -10, -10, 1, -10)
    pg.draw.rect(display, (255, 255, 255), (100, 400, 50, 50), 100, -100, -10, -10, 1, -10)
    pg.draw.rect(display, (255, 255, 255), (400, 400, 50, 50), 0, -100, -10, -10, 1, -10)

    pg.display.update()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugNot working as intendeddrawpygame.draw

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions