Skip to main content
 首页 » 编程设计

python之如何在 Pygame 中用浮点半径画一个圆

2024年11月24日20落叶

所以我需要在 Pygame 中画一个浮点半径的圆。 这是我正在尝试做的事情的简要说明。

pygame.draw.cricle(surface,(255,0,0),(15,15),13.41234) 

这是我得到的错误。

TypeError: integer argument expected, got float 

有什么办法可以解决这个问题吗?

请您参考如下方法:

如果你想在半径中使用 float ,你可以画一个椭圆。 像这样:

x = 10.123 #flote 
y = 11.123 #flote 
 
radius = 13.41234 #flote 
 
pygame.draw.ellipse(surface, (255,0,0), (x, y, radius, radius))