Learn Before
Code
Customizing the Border Radius on Rectangles in Pygame
There are optional parameters for specifying the radius of the rectangle's border when calling the draw.rect() function. You can set the radius of the entire rectangle's border or a specific corner (top right, top left, bottom right, or bottom left). This allows you to round a part of your rectangle's border. The supported range is 0 to min(height, width) / 2, with 0 being an unrounded border.
pygame.draw.rect(surface, color, pygame.Rect(30, 30, 60, 60), width=0, border_radius=15) #this draws the roundest possible rectangle since it's min(height, width) / 2. pygame.draw.rect(surface, color, pygame.Rect(30, 30, 60, 60), width=0, border_radius=0, border_bottom_right_radius=15) #this draws a rectangle that is unrounded on all corners except for the bottom right
0
1
Updated 2021-06-16
Tags
Python Programming Language
Data Science