我希望了解如何循环函数以重新创建相同的形状/模式(谷歌照片标志),但旋转、位置和颜色等变量不同。以下是一段代码,它可以让我使用正确的角度之一来制作调色板,但比例不精确。而且,最好不要使用任何goto/home函数,因为我需要稍后重复这个绘图。我是否应该使用左/右方向而不是设置heading?
def photo():
speed(1) # turtle speed (debugging)
#speed(0)
length = 50
penup()
color("#4688f4") #Blue petal
begin_fill()
setheading(25)
forward(length/5.5)
setheading(0)
forward(length)
setheading(227)
forward(length*0.87)
setheading(135)
forward(length*0.8)
end_fill()
color("#3d6ec9") #Blue petal
begin_fill()
setheading(250)
forward(length/5)
setheading(270)
forward(length/2.6)
setheading(0)
forward(length/1.6)
end_fill()
这里您可以看到来自代码的绘图...
更新:
tilt(angle)
方法是用来倾斜海龟图像的,而不是改变它的方向或者正在绘制的图形的方向。使用right(90)
更可能会达到想要的效果。 - cdlane