我就廢話(huà)不多說(shuō)了,直接上代碼吧!

# coding:utf-8
2import turtle as t
3import random
4# 畫(huà)心
5def xin():
6 def curvemove():
7 for i in range(200):
8 t.right(1)
9 t.forward(0.5)
10 t.color('red','red')
11 t.begin_fill()
12 t.left(140)
13 t.forward(60)
14 curvemove()
15 t.left(120)
16 curvemove()
17 t.forward(60)
18 t.end_fill()
19# 心里面的十字
20def shizi():
21 t.pu()
22 t.goto(170,285)
23 t.seth(0)
24 t.pd()
25 t.color("black","black")
26 t.circle(1.5)
27 t.pensize(2)
28 t.fd(55)
29 t.pensize(4)
30 t.circle(1.5)
31 t.pu()
32 t.seth(-90)
33 t.goto(198,295)
34 t.seth(-90)
35 t.pensize(2)
36 t.pd()
37 t.fd(65)
38 t.circle(1.5)
39 t.circle(160,40)
40 t.circle(-130,27)
41 t.circle(-60,40)
42 t.circle(80,60)
43# 夾子
44def jiazi2():
45 def jiazi(angle):
46 t.pd()
47 t.pensize(1)
48 t.color("black","brown")
49 t.begin_fill()
50 t.seth(angle)
51 t.fd(20)
52 t.seth(angle-240)
53 t.fd(10)
54 t.seth(angle-120)
55 t.fd(20)
56 t.seth(angle-240)
57 t.fd(10)
58 t.end_fill()
59 t.pu()
60 # 畫(huà)夾子
61 t.pu()
62 t.goto(216,180)
63 jiazi(180)
64 t.goto(230,150)
65 jiazi(200)
66 t.goto(250,125)
67 jiazi(220)
68 t.goto(265,95)
69 jiazi(200)
70 t.goto(275,55)
71 jiazi(160)
72# 人
73def people():
74 t.pensize(2)
75 # 皇冠
76 def huangguan():
77 t.pu()
78 t.goto(-200,0)
79 t.color("gold","gold")
80 t.pd()
81 t.begin_fill()
82 t.seth(120)
83 t.fd(32)
84 t.seth(-120)
85 t.fd(15)
86 t.seth(150)
87 t.fd(10)
88 t.seth(-120)
89 t.fd(10)
90 t.seth(160)
91 t.fd(15)
92 t.seth(-60)
93 t.fd(32)
94 t.seth(50)
95 t.circle(-40,60)
96 t.end_fill()
97 # 臉
98 def face():
99 t.pu()
100 t.goto(-212,-3)
101 t.color("black","white")
102 t.pd()
103 t.circle(-40,150)
104 # 頭發(fā)
105 def hair():
106 t.pu()
107 t.color("black","black")
108 t.goto(-212, -3)
109 angle = -160
110 for i in range(32):
111 t.pd()
112 angle += 1.4
113 t.seth(angle)
114 t.circle(60, 50)
115 t.fd(random.randint(40,45))
116 t.pu()
117 t.goto(-212, -3)
118 angle = -50
119 for i in range(32):
120 t.pd()
121 angle -= 1.5
122 t.seth(angle)
123 t.circle(-60, 50)
124 t.fd(random.randint(38,40))
125 t.pu()
126 t.goto(-212, -5)
127 # 脖子
128 def nick():
129 t.pu()
130 t.goto(-200,-78)
131 t.pd()
132 t.seth(-90)
133 t.fd(10)
134 t.seth(-45)
135 t.fd(20)
136 t.seth(180)
137 t.fd(30)
138 t.seth(55)
139 t.fd(15)
140 t.circle(10,80)
141 # 下半身
142 def body():
143 t.pu()
144 t.goto(-185,-100)
145 t.seth(-65)
146 t.pd()
147 for i in range(120):
148 t.fd(1.5)
149 t.right(0.1)
150 t.seth(220)
151 t.circle(-130,70)
152 t.seth(75)
153 for i in range(130):
154 t.fd(1.5)
155 t.right(0.06)
156 # 腿
157 def leg():
158 t.pu()
159 t.goto(-220,-300)
160 t.pd()
161 t.seth(-90)
162 t.fd(80)
163 t.pensize(5)
164 t.color("red","red")
165 t.fd(8)
166 t.seth(-30)
167 t.pensize(6)
168 t.color("black","black")
169 t.fd(5)
170 t.pu()
171 t.pensize(2)
172 t.goto(-185,-300)
173 t.pd()
174 t.seth(-90)
175 t.fd(80)
176 t.pensize(5)
177 t.color("red","red")
178 t.fd(8)
179 t.seth(-30)
180 t.pensize(6)
181 t.color("black","black")
182 t.fd(5)
183 huangguan()
184 face()
185 nick()
186 body()
187 leg()
188 hair()
189 # 手
190 t.pu()
191 t.goto(-190,-165)
192 t.pensize(2)
193 t.pd()
194 t.seth(49)
195 t.fd(160)
196 t.circle(-10,80)
197 # 眼睛
198 t.pu()
199 t.goto(-185,-30)
200 t.seth(90)
201 t.pd()
202 t.circle(5,180)
203# 星星
204def star(x,y):
205 color = ["blue","yellow","red","gold","orange","pink","green","purple"]
206 t.pencolor(random.choice(color))
207 t.pu()
208 t.goto(x,y)
209 t.pd()
210 t.seth(90)
211 t.fd(8)
212 t.bk(4)
213 t.seth(0)
214 t.fd(4)
215 t.bk(8)
216 t.fd(4)
217 t.seth(45)
218 t.fd(4)
219 t.bk(8)
220 t.fd(4)
221 t.seth(-45)
222 t.fd(4)
223 t.bk(8)
224if __name__ == "__main__":
225 t.pensize(4) # 設(shè)置畫(huà)筆的大小
226 t.color("black") # 設(shè)置畫(huà)筆顏色和填充顏色(pink)
227 t.setup(650, 800) # 設(shè)置主窗口的大小為600*800
228 t.speed(10) # 設(shè)置畫(huà)筆速度為10
229 t.pu()
230 t.goto(200, 220)
231 t.pd()
232 # 心
233 xin()
234 # 十字
235 shizi()
236 # 夾子
237 jiazi2()
238 #線(xiàn)
239 t.pu()
240 t.goto(198,280)
241 t.pd()
242 t.seth(-120)
243 t.circle(-1100,22)
244 t.circle(20,90)
245 t.circle(-30,50)
246 t.circle(15,60)
247 # 人
248 people()
249 # 裙子上的點(diǎn)點(diǎn)
250 star(-230, -200)
251 star(-220, -180)
252 star(-200, -150)
253 star(-180, -288)
254 star(-160, -250)
255 star(-210, -150)
256 star(-210, -140)
257 for i in range(10):
258 star(random.randint(-205,-170),random.randint(-300,-200))
259 # 隱藏畫(huà)筆
260 t.ht()
261 t.done()
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線(xiàn),公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。
當(dāng)前標(biāo)題:用Python畫(huà)小女孩放風(fēng)箏的示例-創(chuàng)新互聯(lián)
轉(zhuǎn)載源于:http://www.chinadenli.net/article28/diocjp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、軟件開(kāi)發(fā)、網(wǎng)站制作、定制網(wǎng)站、關(guān)鍵詞優(yōu)化、微信小程序
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容