繁体   English   中英

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

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

你如何改变乌龟的颜色,而不是笔? 我希望乌龟在屏幕上绘制白色,但如果我将颜色更改为“白色”,我就再也看不到乌龟了。 有没有turtle.turtlecolor类的东西?

我们可以使用用户 cursor 定义函数将 cursor 绘制的颜色(包括轮廓和填充)断开cursor的颜色(包括轮廓和填充):

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()

这只乌龟 cursor 是橙色的,带有蓝色轮廓,但它画了一条白线:

在此处输入图像描述

肯定有!

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM