turtle画五角星

 1 import turtle
 2 
 3 
 4 def mygoto(x,y):
 5     turtle.up()
 6     turtle.goto(x,y)
 7     turtle.down()
 8 
 9 
10 def drawstar(l):
11     turtle.fillcolor('yellow')
12     turtle.color('yellow')
13     turtle.begin_fill()
14     for i in range(5):
15         turtle.forward(l)
16         turtle.right(144)
17     turtle.end_fill()
18 
19 
20 mygoto(-320,-260)
21 turtle.color('red')
22 turtle.fillcolor('red')
23 turtle.begin_fill()
24 for i in range(2):
25     turtle.forward(660)
26     turtle.left(90)
27     turtle.forward(440)
28     turtle.left(90)
29 turtle.end_fill()
30 
31 mygoto(-270,100)
32 drawstar(100)
33 
34 for i in range(4):
35     x = 1
36     if i in [0,3]:
37         x = 0
38     mygoto(-150+x*50,150-i*40)
39     turtle.left(15-i*15)
40     drawstar(30)
41 
42 mygoto(0,0)
43 turtle.hideturtle()
44 turtle.done()

posted @ 2018-03-20 17:40  225倪伟锐  阅读(630)  评论(0编辑  收藏  举报