【发布时间】:2021-10-05 02:19:28
【问题描述】:
我正在尝试用海龟填充一个形状,但是当我这样做时,一小部分最终没有被填充。我该如何解决这个问题?我试着让它上升的线越过空白区域开始的点,但这没有用。正如您可能从我的代码中看到的那样,我对 python 还是很陌生。这是我的代码...
import turtle
turtl = turtle.Turtle()
turtle.screensize(852, 508, 'white')
turtl.penup()
turtl.fillcolor("royal blue") #Every closed shape after this untill endfill() will be filled with royal blue
turtl.begin_fill()
for i in range(1):
turtl.hideturtle()
turtl.penup()
turtl.setx(-213)
turtl.sety(-75) #Moves the turtle to the correct place to start the "plus"
turtl.right(180)
turtl.pendown()
turtl.forward(427) #Makes the first line going left
turtl.right(90)
turtl.forward(150) #Width of plus
turtl.right(90)
turtl.forward(427)
turtl.left(90)
turtl.forward(253) #Going to top of plus
turtl.right(90)
turtl.forward(150) #Width of top of plus
turtl.right(90)
turtl.forward(253) #Going back down from right side of top of plus
turtl.left(90)
turtl.forward(697) #Going to the right side of the screen
turtl.right(90)
turtl.forward(150) #Width of plus / Start of bottom half of plus
turtl.right(90)
turtl.forward(697) #Going back left to to the bottom bit of the plus
turtl.left(90)
turtl.forward(253) #Going to the bottom part of plus
turtl.right(90)
turtl.forward(150)
turtl.right(90)
turtl.forward(253) #Traveling back up to center bar
turtl.end_fill()
print(turtl)
turtle.mainloop()
【问题讨论】:
标签: python turtle-graphics python-turtle