在
turtle.end_fill()
无论是否不重叠多边形或多个形状的重叠区域取决于操作系统的图形,重叠的类型和重叠的数量。
绘制恒星的外边缘,因此它不是自我截断的多边形:
import turtle
def red_star(t, side):
t.fillcolor('red')
t.pencolor('black') # to highlight the lines
t.pendown()
t.width(3)
t.begin_fill()
for i in range(5):
t.fd(side)
t.left(72)
t.forward(side)
t.right(144)
t.end_fill()
t = turtle.Turtle()
s = t.screen
s.delay(0)
t.hideturtle()
t.penup()
red_star(t, 50)
s.exitonclick()
s.mainloop()
输出:
无工作!!!!!!
import turtle
def red_star(t, side):
t.fillcolor('red')
t.pencolor('black') # to highlight the lines
t.pendown()
t.width(3)
t.begin_fill()
for i in range(5):
t.fd(side)
t.left(72)
t.forward(side)
t.right(144)
t.end_fill()
t = turtle.Turtle()
s = t.screen
s.delay(0)
t.hideturtle()
t.penup()
red_star(t, 50)
s.exitonclick()
s.mainloop()