gpt4 book ai didi

Python Turtle 透明填充?

转载 作者:行者123 更新时间:2023-12-04 02:30:03 24 4
gpt4 key购买 nike

我正在尝试使用 Turtle 库重新创建这张图片:

enter image description here

但我在尝试使内圈“透明”时遇到了困难。我搜索了文档,但找不到更改圆圈填充颜色的不透明度的方法。

我尝试的是:

colors = ["black", "magenta", "pink", "blue", "green", "yellow", "orange", "red", "white"]

for i in range(8):
my_turtle.fillcolor(colors[i])
my_turtle.begin_fill()
my_turtle.circle(150)
my_turtle.end_fill()
my_turtle.fillcolor("white")
my_turtle.begin_fill()
my_turtle.circle(130)
my_turtle.end_fill()
my_turtle.fillcolor(colors[i])
my_turtle.begin_fill()
my_turtle.circle(100)
my_turtle.end_fill()
my_turtle.fillcolor("white")
my_turtle.begin_fill()
my_turtle.circle(80)
my_turtle.end_fill()
my_turtle.rt(45)

但我得到的是:

enter image description here

有什么想法吗?

最佳答案

您可以反转圆圈颜色的每个较小的圆圈:

colors = ["black", "magenta", "pink", "blue", "green", "yellow", "orange", "red", "white"]

for i in range(8):
my_turtle.fillcolor(colors[i])
my_turtle.begin_fill()
my_turtle.circle(150)
my_turtle.circle(130, -360)
my_turtle.end_fill()
my_turtle.fillcolor(colors[i])
my_turtle.begin_fill()
my_turtle.circle(100)
my_turtle.circle(80, -360)
my_turtle.end_fill()
my_turtle.rt(45)

输出:

enter image description here

关于Python Turtle 透明填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64828662/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com