python 用turtle库画图

 

http://www.bilibili.com/video/av35915497?share_medium=android&share_source=copy_link&bbid=NlVnAmNSY1AyATZXK1crinfoc&ts=1542169889670

  1 """
  2 Created on Tue Oct 30 21:46:05 2018
  3 
  4 @author: 木公子
  5 """
  6 
  7 import turtle as t
  8 
  9 t.pensize(2)
 10 t.colormode(255)
 11 t.setup(800,600)
 12 t.speed(0)
 13 t.Turtle().screen.delay(0)
 14 #
 15 t.pu()
 16 t.goto(-310,150)
 17 t.pd()
 18 t.seth(15) # 笔的角度为-30°
 19 t.begin_fill() # 外形填充的开始标志
 20 t.color("black",(153,153,101))
 21 a=1.3
 22 for i in range(90):
 23 a-=0.005
 24 t.fd(a)
 25 t.rt(0.5)
 26 t.seth(-90)
 27 t.fd(40)
 28 a=1.3
 29 for i in range(70):
 30 a-=0.005
 31 t.fd(a)
 32 t.lt(0.15)
 33 t.seth(180)
 34 a=1.3
 35 for i in range(80):
 36 if(i<=20):
 37 a-=0.005
 38 t.fd(a)
 39 t.rt(0.5)
 40 else:
 41 a+=0.005
 42 t.fd(a)
 43 t.lt(0.5)
 44 t.goto(-310,150)
 45 t.end_fill()
 46 #
 47 t.pu()
 48 t.goto(-240,50)
 49 t.pd()
 50 t.seth(45)
 51 t.begin_fill()
 52 t.color("black",(250,209,189))
 53 t.fd(28)
 54 t.seth(0)
 55 t.fd(10)
 56 t.seth(-45)
 57 t.fd(15)
 58 t.seth(-60)
 59 t.fd(13)
 60 t.seth(180)
 61 t.circle(15,86)
 62 t.seth(105)
 63 t.fd(24)
 64 t.seth(45)
 65 t.fd(8)
 66 t.seth(-135)
 67 t.fd(17)
 68 t.pu()
 69 t.goto(-240,50)
 70 t.pd()
 71 t.seth(-60)
 72 t.circle(12,130)
 73 t.end_fill()
 74 #橘色衣服
 75 t.pu()
 76 t.goto(-209,37)
 77 t.pd()
 78 t.begin_fill()
 79 t.color("black",(255,213,75))
 80 t.seth(-90)
 81 t.fd(15)
 82 t.seth(-19)
 83 t.fd(100)
 84 t.seth(93)
 85 a=1
 86 for i in range(20):
 87 t.fd(a)
 88 t.rt(1)
 89 t.seth(180)
 90 t.circle(-20,90)
 91 t.seth(160)
 92 t.fd(70)
 93 t.seth(-30)
 94 t.circle(-40,30)
 95 t.end_fill()
 96 
 97 #头发
 98 t.pu()
 99 t.goto(-130,138)
100 t.pd()
101 t.begin_fill()
102 t.seth(67)
103 t.color("black","black")
104 t.circle(-136,105)
105 t.end_fill()
106 
107 
108 t.pu()
109 t.goto(-111,6)
110 t.pd()
111 t.begin_fill()
112 t.color("black",(252,158,8))
113 t.seth(-105)
114 for i in range(100):
115 t.fd(0.1)
116 t.lt(0.02)
117 t.seth(-80)
118 for i in range(200):
119 t.fd(0.1)
120 t.lt(0.02)
121 t.seth(0)
122 for i in range(50):
123 t.fd(1)
124 t.rt(0.05)
125 t.hideturtle()
126 t.end_fill()
127 
128 t.pu()
129 t.goto(-133.5,28.5)
130 t.pd()
131 t.begin_fill()
132 t.color("black",(250,207,190))
133 t.seth(93)
134 t.circle(-20,110)
135 t.seth(170)
136 t.circle(20,30)
137 t.seth(125)
138 t.circle(-80,30)
139 t.seth(95)
140 for i in range(300):
141 t.fd(0.1)
142 t.rt(0.04)
143 t.circle(-65,60)
144 t.seth(80)
145 t.circle(-30,30)
146 t.seth(-85)
147 t.fd(13)
148 t.seth(45)
149 t.circle(-110,40)
150 t.seth(95)
151 t.fd(14)
152 t.seth(-52)
153 t.fd(18)
154 t.seth(0)
155 t.fd(30)
156 t.seth(0)
157 t.circle(-82,90)
158 for i in range(500):
159 t.fd(0.1)
160 t.rt(0.04)
161 for i in range(500):
162 t.fd(0.09)
163 t.lt(0.07)
164 t.seth(-89)
165 t.circle(-72,90)
166 for i in range(600):
167 t.fd(0.1)
168 t.rt(0.02)
169 t.circle(-104,47)
170 t.seth(160)
171 for i in range(200):
172 t.fd(0.1)
173 t.rt(0.07)
174 t.circle(-12,15)
175 t.hideturtle()
176 t.end_fill()
177 
178 
179 t.pu()
180 t.goto(-50,80)
181 t.pd()
182 t.begin_fill()
183 t.color("black",(255,255,255))
184 t.seth(0)
185 t.circle(20)
186 t.pu()
187 t.goto(20,80)
188 t.pd()
189 t.circle(20)
190 t.end_fill()
191 
192 t.pu()
193 t.goto(-40,90)
194 t.pd()
195 t.begin_fill()
196 t.color("black",(0,0,0))
197 t.seth(0)
198 t.circle(10)
199 t.end_fill()
200 
201 t.pu()
202 t.goto(10,90)
203 t.pd()
204 t.begin_fill()
205 t.color("black",(0,0,0))
206 t.seth(0)
207 t.circle(10)
208 t.end_fill()
209 
210 t.pu()
211 t.goto(-35,30)
212 t.pd()
213 t.begin_fill()
214 t.color("black",(255,255,255))
215 t.seth(-60)
216 t.circle(35,120)
217 t.end_fill()
218 
219 t.pu()
220 t.goto(540,-320)
221 t.pd()
222 t.write('木公子',font = ('华文隶书' ,10 ,'q',9,'normal'))
223 t.pendown()
224 #隐藏画笔箭头
225 
226 t.hideturtle()
227 #关闭turtle
228 t.done()

 

posted @ 2018-11-13 23:31  木公子  阅读(1011)  评论(0编辑  收藏  举报