I am currently learning pygame. When programming rectangles with rounded corners I encountered a problem.
pygame.draw.rect()
draw a rectangle
rect(surface, color, rect) -> Rect
rect(surface, color, rect, width=0, border_radius=0, border_radius=-1, border_top_left_radius=-1, border_top_right_radius=-1, border_bottom_left_radius=-1) -> Rect
Draws a rectangle on the given surface.
border_radius (int) -- (optional) used for drawing rectangle with rounded corners. The supported range is [0, min(height, width) / 2], with 0 representing a rectangle without rounded corners.
This is the description of the official pygame documentation.
username_rect = pg.rect.Rect(screenwidth/2 - 1/8*screenwidth, screenheight*1/5, 1/4*screenwidth, username_title_render.get_height() + 10)
pg.draw.rect(screen, (0,0,0), username_rect,border_radius = 15)
Here the main part. But then I get this error message:
TypeError: 'border_radius' is an invalid keyword argument for this function
I already tried to add a "width=2" argument but then it says that there are too many arguments. Unfortunately taking other numbers does not help either.
I am currently using pygame version 2.0.0.dev6 (SDL 2.0.10, python 3.8.1)
I would be very happy if you could help me, thanks a lot in advance!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…