我目前正在学习pygame。在编写带有圆角的矩形时,我遇到了一个问题。
pygame.draw.rect()画一个矩形rect(表面,颜色,矩形)-> Rect rect(表面,颜色,矩形,宽度= 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)
这里主要部分。但是然后我收到此错误消息:
TypeError: 'border_radius' is an invalid keyword argument for this function
我已经尝试添加“ width = 2”参数,但是随后它说参数太多。不幸的是,采用其他数字也无济于事。我当前正在使用pygame版本2.0.0.dev6(SDL 2.0.10,python 3.8.1)
如果您能帮助我,我将非常高兴,在此先感谢您!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句