forked from flypythoncom/flypython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mooncake.py
76 lines (60 loc) · 1.37 KB
/
mooncake.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python2
#encoding=utf-8
import turtle as tt
import math
tt.hideturtle()
tt.speed(10)
def draw_circle(r):
tt.penup()
tt.goto(0, -r)
tt.seth(0)
tt.pendown()
tt.pensize(5)
tt.color('#F8CD32','#FBA92D')
tt.begin_fill()
tt.circle(r)
tt.end_fill()
def draw_petal(r, n):
tt.penup()
tt.goto(0, -r)
tt.seth(0)
tt.pendown()
small_r = math.sin( math.pi/n) * r
for i in range(n):
tt.penup()
tt.home()
tt.seth((360/n)*i)
tt.fd(r)
tt.left((360/n)*0.5)
tt.pendown()
tt.color('#F0BE7C')
tt.begin_fill()
tt.circle(small_r,180)
tt.end_fill()
def draw_square(d, r):
tt.penup()
tt.seth(0)
tt.goto(d/2 + r, -d/2)
tt.left(90)
tt.pendown()
for i in range(4):
tt.fd(d)
tt.circle(r, 90)
def draw_word(word, x, y):
tt.penup()
tt.goto(x, y)
tt.pendown()
tt.color("Gold")
tt.write(word, font=("微软雅黑",35, "normal"))
def draw():
tt.title("FlyPython祝您中秋快乐")
draw_circle(120)
draw_petal(120,18)
#draw_square(100,10)
draw_word("五",-50,5)
draw_word("最",0,5)
draw_word("仁",-50,-40)
draw_word("棒",0,-40)
tt.done()
if __name__ == "__main__":
draw()