Ped*_*ssi 5 python pygame rect rounded-corners
我目前正在学习pygame。在编写带圆角的矩形时,我遇到了一个问题。
pygame.draw.rect() 绘制一个矩形 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) -> 矩形 在给定的表面上绘制一个矩形。
border_radius (int) -- (可选)用于绘制圆角矩形。支持的范围是[0, min(height, width) / 2],其中0代表没有圆角的矩形。
这是pygame官方文档的描述。
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)
Run Code Online (Sandbox Code Playgroud)
这里是主要部分。但随后我收到此错误消息:
TypeError: 'border_radius' is an invalid keyword argument for this function
Run Code Online (Sandbox Code Playgroud)
我已经尝试添加“width=2”参数,但随后它说参数太多。不幸的是,获取其他数字也无济于事。我目前使用 pygame 版本 2.0.0.dev6 (SDL 2.0.10,python 3.8.1)
如果您能帮助我,我将非常高兴,非常感谢!
| 归档时间: |
|
| 查看次数: |
8302 次 |
| 最近记录: |