【发布时间】:2020-08-11 17:02:10
【问题描述】:
你如何改变乌龟看起来的颜色,而不是笔?我希望乌龟在屏幕上绘制白色,但如果我将颜色更改为“白色”,我就再也看不到乌龟了。有turtle.turtlecolor之类的吗?
【问题讨论】:
-
记得接受答案。
标签: python python-3.x turtle-graphics python-turtle
你如何改变乌龟看起来的颜色,而不是笔?我希望乌龟在屏幕上绘制白色,但如果我将颜色更改为“白色”,我就再也看不到乌龟了。有turtle.turtlecolor之类的吗?
【问题讨论】:
标签: python python-3.x turtle-graphics python-turtle
我们可以使用用户光标定义函数将光标的颜色(轮廓和填充)与光标绘制的颜色(轮廓和填充)断开:
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()
这个海龟光标是橙色的,带有蓝色轮廓,但它画了一条白线:
【讨论】:
肯定有!
turtle.shape("turtle")
turtle.fillcolor("red")
现在你得到了一只红海龟。
【讨论】: