如何更改乌龟的颜色,而不是笔的颜色?

How do I change the color of the turtle, not the pen?

如何改变乌龟看起来而不是钢笔的颜色?我想让乌龟在屏幕上画成白色,但如果我将颜色更改为 'white',我就再也看不到乌龟了。有没有类似turtle.turtlecolor之类的东西?

当然有!

turtle.shape("turtle")
turtle.fillcolor("red")

现在你得到了一只红海龟。

我们可以断开光标颜色(轮廓和填充)与光标绘制的颜色(轮廓和填充) fill) 使用用户光标定义函数:

from turtle import Screen, Shape, Turtle

screen = Screen()
screen.bgcolor('black')

turtle = Turtle()
turtle.shape("turtle")
polygon = turtle.get_shapepoly()

fixed_color_turtle = Shape("compound")
fixed_color_turtle.addcomponent(polygon, "orange", "blue")

screen.register_shape('fixed', fixed_color_turtle)

turtle.shape('fixed')
turtle.color('white')
turtle.circle(150)

screen.exitonclick()

这个乌龟光标是橙色的,有蓝色的轮廓,但是它画了一条白线: