簡體   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