用Python画小女孩放风筝的示例
我就废话不多说了,直接上代码吧!
#coding:utf-8
2importturtleast
3importrandom
4#画心
5defxin():
6defcurvemove():
7foriinrange(200):
8t.right(1)
9t.forward(0.5)
10t.color('red','red')
11t.begin_fill()
12t.left(140)
13t.forward(60)
14curvemove()
15t.left(120)
16curvemove()
17t.forward(60)
18t.end_fill()
19#心里面的十字
20defshizi():
21t.pu()
22t.goto(170,285)
23t.seth(0)
24t.pd()
25t.color("black","black")
26t.circle(1.5)
27t.pensize(2)
28t.fd(55)
29t.pensize(4)
30t.circle(1.5)
31t.pu()
32t.seth(-90)
33t.goto(198,295)
34t.seth(-90)
35t.pensize(2)
36t.pd()
37t.fd(65)
38t.circle(1.5)
39t.circle(160,40)
40t.circle(-130,27)
41t.circle(-60,40)
42t.circle(80,60)
43#夹子
44defjiazi2():
45defjiazi(angle):
46t.pd()
47t.pensize(1)
48t.color("black","brown")
49t.begin_fill()
50t.seth(angle)
51t.fd(20)
52t.seth(angle-240)
53t.fd(10)
54t.seth(angle-120)
55t.fd(20)
56t.seth(angle-240)
57t.fd(10)
58t.end_fill()
59t.pu()
60#画夹子
61t.pu()
62t.goto(216,180)
63jiazi(180)
64t.goto(230,150)
65jiazi(200)
66t.goto(250,125)
67jiazi(220)
68t.goto(265,95)
69jiazi(200)
70t.goto(275,55)
71jiazi(160)
72#人
73defpeople():
74t.pensize(2)
75#皇冠
76defhuangguan():
77t.pu()
78t.goto(-200,0)
79t.color("gold","gold")
80t.pd()
81t.begin_fill()
82t.seth(120)
83t.fd(32)
84t.seth(-120)
85t.fd(15)
86t.seth(150)
87t.fd(10)
88t.seth(-120)
89t.fd(10)
90t.seth(160)
91t.fd(15)
92t.seth(-60)
93t.fd(32)
94t.seth(50)
95t.circle(-40,60)
96t.end_fill()
97#脸
98defface():
99t.pu()
100t.goto(-212,-3)
101t.color("black","white")
102t.pd()
103t.circle(-40,150)
104#头发
105defhair():
106t.pu()
107t.color("black","black")
108t.goto(-212,-3)
109angle=-160
110foriinrange(32):
111t.pd()
112angle+=1.4
113t.seth(angle)
114t.circle(60,50)
115t.fd(random.randint(40,45))
116t.pu()
117t.goto(-212,-3)
118angle=-50
119foriinrange(32):
120t.pd()
121angle-=1.5
122t.seth(angle)
123t.circle(-60,50)
124t.fd(random.randint(38,40))
125t.pu()
126t.goto(-212,-5)
127#脖子
128defnick():
129t.pu()
130t.goto(-200,-78)
131t.pd()
132t.seth(-90)
133t.fd(10)
134t.seth(-45)
135t.fd(20)
136t.seth(180)
137t.fd(30)
138t.seth(55)
139t.fd(15)
140t.circle(10,80)
141#下半身
142defbody():
143t.pu()
144t.goto(-185,-100)
145t.seth(-65)
146t.pd()
147foriinrange(120):
148t.fd(1.5)
149t.right(0.1)
150t.seth(220)
151t.circle(-130,70)
152t.seth(75)
153foriinrange(130):
154t.fd(1.5)
155t.right(0.06)
156#腿
157defleg():
158t.pu()
159t.goto(-220,-300)
160t.pd()
161t.seth(-90)
162t.fd(80)
163t.pensize(5)
164t.color("red","red")
165t.fd(8)
166t.seth(-30)
167t.pensize(6)
168t.color("black","black")
169t.fd(5)
170t.pu()
171t.pensize(2)
172t.goto(-185,-300)
173t.pd()
174t.seth(-90)
175t.fd(80)
176t.pensize(5)
177t.color("red","red")
178t.fd(8)
179t.seth(-30)
180t.pensize(6)
181t.color("black","black")
182t.fd(5)
183huangguan()
184face()
185nick()
186body()
187leg()
188hair()
189#手
190t.pu()
191t.goto(-190,-165)
192t.pensize(2)
193t.pd()
194t.seth(49)
195t.fd(160)
196t.circle(-10,80)
197#眼睛
198t.pu()
199t.goto(-185,-30)
200t.seth(90)
201t.pd()
202t.circle(5,180)
203#星星
204defstar(x,y):
205color=["blue","yellow","red","gold","orange","pink","green","purple"]
206t.pencolor(random.choice(color))
207t.pu()
208t.goto(x,y)
209t.pd()
210t.seth(90)
211t.fd(8)
212t.bk(4)
213t.seth(0)
214t.fd(4)
215t.bk(8)
216t.fd(4)
217t.seth(45)
218t.fd(4)
219t.bk(8)
220t.fd(4)
221t.seth(-45)
222t.fd(4)
223t.bk(8)
224if__name__=="__main__":
225t.pensize(4)#设置画笔的大小
226t.color("black")#设置画笔颜色和填充颜色(pink)
227t.setup(650,800)#设置主窗口的大小为600*800
228t.speed(10)#设置画笔速度为10
229t.pu()
230t.goto(200,220)
231t.pd()
232#心
233xin()
234#十字
235shizi()
236#夹子
237jiazi2()
238#线
239t.pu()
240t.goto(198,280)
241t.pd()
242t.seth(-120)
243t.circle(-1100,22)
244t.circle(20,90)
245t.circle(-30,50)
246t.circle(15,60)
247#人
248people()
249#裙子上的点点
250star(-230,-200)
251star(-220,-180)
252star(-200,-150)
253star(-180,-288)
254star(-160,-250)
255star(-210,-150)
256star(-210,-140)
257foriinrange(10):
258star(random.randint(-205,-170),random.randint(-300,-200))
259#隐藏画笔
260t.ht()
261t.done()
效果如下:
以上这篇用Python画小女孩放风筝的示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。
热门推荐
10 新人红包祝福语简短精辟
11 幼师给毕业祝福语简短
12 生日高考祝福语妹妹简短
13 下飞机祝福语简短英文
14 元宵发客户祝福语简短
15 爸妈金婚文案祝福语简短
16 新郎朋友红包祝福语简短
17 虎年五一祝福语大全简短
18 出阁宴祝福语姐姐简短