File tree Expand file tree Collapse file tree 2 files changed +440
-2
lines changed Expand file tree Collapse file tree 2 files changed +440
-2
lines changed Original file line number Diff line number Diff line change 1+ from turtle import *
2+
3+
4+ def nose (x ,y ):#鼻子
5+ penup ()#提起笔
6+ goto (x ,y )#定位
7+ pendown ()#落笔,开始画
8+ setheading (- 30 )#将乌龟的方向设置为to_angle/为数字(0-东、90-北、180-西、270-南)
9+ begin_fill ()#准备开始填充图形
10+ a = 0.4
11+ for i in range (120 ):
12+ if 0 <= i < 30 or 60 <= i < 90 :
13+ a = a + 0.08
14+ left (3 ) #向左转3度
15+ forward (a ) #向前走a的步长
16+ else :
17+ a = a - 0.08
18+ left (3 )
19+ forward (a )
20+ end_fill ()#填充完成
21+
22+ penup ()
23+ setheading (90 )
24+ forward (25 )
25+ setheading (0 )
26+ forward (10 )
27+ pendown ()
28+ pencolor (255 ,155 ,192 )#画笔颜色
29+ setheading (10 )
30+ begin_fill ()
31+ circle (5 )
32+ color (160 ,82 ,45 )#返回或设置pencolor和fillcolor
33+ end_fill ()
34+
35+ penup ()
36+ setheading (0 )
37+ forward (20 )
38+ pendown ()
39+ pencolor (255 ,155 ,192 )
40+ setheading (10 )
41+ begin_fill ()
42+ circle (5 )
43+ color (160 ,82 ,45 )
44+ end_fill ()
45+
46+
47+ def head (x ,y ):#头
48+ color ((255 ,155 ,192 ),"pink" )
49+ penup ()
50+ goto (x ,y )
51+ setheading (0 )
52+ pendown ()
53+ begin_fill ()
54+ setheading (180 )
55+ circle (300 ,- 30 )
56+ circle (100 ,- 60 )
57+ circle (80 ,- 100 )
58+ circle (150 ,- 20 )
59+ circle (60 ,- 95 )
60+ setheading (161 )
61+ circle (- 300 ,15 )
62+ penup ()
63+ goto (- 100 ,100 )
64+ pendown ()
65+ setheading (- 30 )
66+ a = 0.4
67+ for i in range (60 ):
68+ if 0 <= i < 30 or 60 <= i < 90 :
69+ a = a + 0.08
70+ lt (3 ) #向左转3度
71+ fd (a ) #向前走a的步长
72+ else :
73+ a = a - 0.08
74+ lt (3 )
75+ fd (a )
76+ end_fill ()
77+
78+
79+ def ears (x ,y ): #耳朵
80+ color ((255 ,155 ,192 ),"pink" )
81+ penup ()
82+ goto (x ,y )
83+ pendown ()
84+ begin_fill ()
85+ setheading (100 )
86+ circle (- 50 ,50 )
87+ circle (- 10 ,120 )
88+ circle (- 50 ,54 )
89+ end_fill ()
90+
91+ penup ()
92+ setheading (90 )
93+ forward (- 12 )
94+ setheading (0 )
95+ forward (30 )
96+ pendown ()
97+ begin_fill ()
98+ setheading (100 )
99+ circle (- 50 ,50 )
100+ circle (- 10 ,120 )
101+ circle (- 50 ,56 )
102+ end_fill ()
103+
104+
105+ def eyes (x ,y ):#眼睛
106+ color ((255 ,155 ,192 ),"white" )
107+ penup ()
108+ setheading (90 )
109+ forward (- 20 )
110+ setheading (0 )
111+ forward (- 95 )
112+ pendown ()
113+ begin_fill ()
114+ circle (15 )
115+ end_fill ()
116+
117+ color ("black" )
118+ penup ()
119+ setheading (90 )
120+ forward (12 )
121+ setheading (0 )
122+ forward (- 3 )
123+ pendown ()
124+ begin_fill ()
125+ circle (3 )
126+ end_fill ()
127+
128+ color ((255 ,155 ,192 ),"white" )
129+ penup ()
130+ seth (90 )
131+ forward (- 25 )
132+ seth (0 )
133+ forward (40 )
134+ pendown ()
135+ begin_fill ()
136+ circle (15 )
137+ end_fill ()
138+
139+ color ("black" )
140+ penup ()
141+ setheading (90 )
142+ forward (12 )
143+ setheading (0 )
144+ forward (- 3 )
145+ pendown ()
146+ begin_fill ()
147+ circle (3 )
148+ end_fill ()
149+
150+
151+ def cheek (x ,y ):#腮
152+ color ((255 ,155 ,192 ))
153+ penup ()
154+ goto (x ,y )
155+ pendown ()
156+ setheading (0 )
157+ begin_fill ()
158+ circle (30 )
159+ end_fill ()
160+
161+
162+ def mouth (x ,y ): #嘴
163+ color (239 ,69 ,19 )
164+ penup ()
165+ goto (x ,y )
166+ pendown ()
167+ setheading (- 80 )
168+ circle (30 ,40 )
169+ circle (40 ,80 )
170+
171+
172+ def setting (): #参数设置
173+ pensize (4 )
174+ hideturtle () #使乌龟无形(隐藏)
175+ colormode (255 ) #将其设置为1.0或255.随后 颜色三元组的r,g,b值必须在0 .. cmode范围内
176+ color ((255 ,155 ,192 ),"pink" )
177+ setup (840 ,500 )
178+ speed (10 )
179+
180+
181+ def main ():
182+ setting () #画布、画笔设置
183+ nose (- 100 ,100 ) #鼻子
184+ head (- 69 ,167 ) #头
185+ ears (0 ,160 ) #耳朵
186+ eyes (0 ,140 ) #眼睛
187+ cheek (80 ,10 ) #腮
188+ mouth (- 20 ,30 ) #嘴
189+ done ()
190+
191+
192+ if __name__ == '__main__' :
193+ main ()
You can’t perform that action at this time.
0 commit comments