简体   繁体   中英

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

How do you change what color the turtle looks , not the pen? I want the turtle to draw white on the screen, but if I change the color to 'white' I can't see the turtle anymore. Is there something like turtle.turtlecolor or something?

We can disconnect the color of the cursor (both outline and fill) from the color drawn by the cursor (both outline and fill) using the user cursor definition functions:

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

This turtle cursor is orange with a blue outline but it draws a white line:

在此处输入图像描述

There sure is!

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

Now you get a red turtle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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