Python_turtle绘图实例(持续更新)

  • 小蛇

 1 import turtle as t
 2 t.setup(650, 350)
 3 t.penup()
 4 t.fd(-250)
 5 t.pendown()
 6 t.pensize(25)
 7 t.pencolor("pink")
 8 t.seth(-40)
 9 for i in range(4):
10     t.circle(40, 80)
11     t.circle(-40, 80)
12 t.circle(40, 80 / 2)
13 t.fd(40)
14 t.circle(16, 180)
15 t.fd(40 * 2 / 3)
16 t.done()
View Code
  •  五角星

 

 

 1 import turtle as t
 2 t.setup(650, 350)
 3 t.color('pink','pink')
 4 t.begin_fill()
 5 for i in range(5):
 6     t.fd(200)
 7     t.rt(144)
 8 
 9 t.end_fill()
10 t.done()
View Code
  •  小猪佩奇

 

  1 from turtle import *
  2 def nose(x,y):
  3     pu()
  4     goto(x,y)
  5     pd()
  6     seth(-30)
  7     begin_fill()
  8     a=0.4
  9     for i in range(120):
 10         if 0<=i<30 or 60<=i<90:
 11             a=a+0.08
 12             lt(3)
 13             fd(a)
 14         else:
 15             a=a-0.08
 16             lt(3)
 17             fd(a)
 18     end_fill()
 19 
 20     pu()
 21     seth(90)
 22     fd(25)
 23     seth(0)
 24     fd(10)
 25     pd()
 26     pencolor(255,155,192)
 27     seth(10)
 28     begin_fill()
 29     circle(5)
 30     color(160,82,45)
 31     end_fill()
 32 
 33     pu()
 34     seth(0)
 35     fd(20)
 36     pd()
 37     pencolor(255,155,192)
 38     seth(10)
 39     begin_fill()
 40     circle(5)
 41     color(160,82,45)
 42     end_fill()
 43 
 44 def head(x,y):
 45     color((255,155,192),"pink")
 46     pu()
 47     goto(x,y)
 48     seth(0)
 49     pd()
 50     begin_fill()
 51     seth(180)
 52     circle(300,-30)
 53     circle(100,-60)
 54     circle(80,-100)
 55     circle(150,-20)
 56     circle(60,-95)
 57     seth(161)
 58     circle(-300,15)
 59     pu()
 60     goto(-100,100)
 61     pd()
 62     seth(-30)
 63     a=0.4
 64     for i in range(60):
 65         if 0<=i<30 or 60<=i<90:
 66             a=a+0.08
 67             lt(3)
 68             fd(a)
 69         else:
 70             a=a-0.08
 71             lt(3)
 72             fd(a)
 73     end_fill()
 74 
 75 def ears(x,y):
 76     color((255,155,192),"pink")
 77     pu()
 78     goto(x,y)
 79     pd()
 80     begin_fill()
 81     seth(100)
 82     circle(-50,50)
 83     circle(-10,120)
 84     circle(-50,54)
 85     end_fill()
 86 
 87     pu()
 88     seth(90)
 89     fd(-12)
 90     seth(0)
 91     fd(30)
 92     pd()
 93     begin_fill()
 94     seth(100)
 95     circle(-50,50)
 96     circle(-10,120)
 97     circle(-50,56)
 98     end_fill()
 99 
100 def eyes(x,y):
101     color((255,155,192),"white")
102     pu()
103     seth(90)
104     fd(-20)
105     seth(0)
106     fd(-95)
107     pd()
108     begin_fill()
109     circle(15)
110     end_fill()
111 
112     color("black")
113     pu()
114     seth(90)
115     fd(12)
116     seth(0)
117     fd(-3)
118     pd()
119     begin_fill()
120     circle(3)
121     end_fill()
122 
123     color((255,155,192),"white")
124     pu()
125     seth(90)
126     fd(-25)
127     seth(0)
128     fd(40)
129     pd()
130     begin_fill()
131     circle(15)
132     end_fill()
133 
134     color("black")
135     pu()
136     seth(90)
137     fd(12)
138     seth(0)
139     fd(-3)
140     pd()
141     begin_fill()
142     circle(3)
143     end_fill()
144 
145 def cheek(x,y):
146     color((255,155,192))
147     pu()
148     goto(x,y)
149     pd()
150     seth(0)
151     begin_fill()
152     circle(30)
153     end_fill()
154 
155 def mouth(x,y):
156     color(239,69,19)
157     pu()
158     goto(x,y)
159     pd()
160     seth(-80)
161     circle(30,40)
162     circle(40,80)
163 
164 def body(x,y):
165     color("red",(255,99,71))
166     pu()
167     goto(x,y)
168     pd()
169     begin_fill()
170     seth(-130)
171     circle(100,10)
172     circle(300,30)
173     seth(0)
174     fd(230)
175     seth(90)
176     circle(300,30)
177     circle(100,3)
178     color((255,155,192),(255,100,100))
179     seth(-135)
180     circle(-80,63)
181     circle(-150,24)
182     end_fill()
183 
184 def hands(x,y):
185     color((255,155,192))
186     pu()
187     goto(x,y)
188     pd()
189     seth(-160)
190     circle(300,15)
191     pu()
192     seth(90)
193     fd(15)
194     seth(0)
195     fd(0)
196     pd()
197     seth(-10)
198     circle(-20,90)
199 
200     pu()
201     seth(90)
202     fd(30)
203     seth(0)
204     fd(237)
205     pd()
206     seth(-20)
207     circle(-300,15)
208     pu()
209     seth(90)
210     fd(20)
211     seth(0)
212     fd(0)
213     pd()
214     seth(-170)
215     circle(20,90)
216 
217 def foot(x,y):
218     pensize(10)
219     color((240,128,128))
220     pu()
221     goto(x,y)
222     pd()
223     seth(-90)
224     fd(40)
225     seth(-180)
226     color("black")
227     pensize(15)
228     fd(20)
229 
230     pensize(10)
231     color((240,128,128))
232     pu()
233     seth(90)
234     fd(40)
235     seth(0)
236     fd(90)
237     pd()
238     seth(-90)
239     fd(40)
240     seth(-180)
241     color("black")
242     pensize(15)
243     fd(20)
244 
245 def tail(x,y):
246     pensize(4)
247     color((255,155,192))
248     pu()
249     goto(x,y)
250     pd()
251     seth(0)
252     circle(70,20)
253     circle(10,330)
254     circle(70,30)
255     
256     
257 def setting():
258     pensize(4)
259     hideturtle()
260     colormode(255)
261     color((255,155,192),"pink")
262     setup(840,500)
263     speed(10)
264 
265 def main():
266     setting()
267     nose(-100,100)
268     head(-69,167)
269     ears(0,160)
270     eyes(0,140)
271     cheek(80,10)
272     mouth(-20,30)
273     body(-32,-8)
274     hands(-56,-45)
275     foot(2,-177)
276     tail(148,-155)
277     done()
278 
279 main()
View Code

 参考:https://www.cnblogs.com/andrew3/p/10604218.html

原文地址:https://www.cnblogs.com/Aoke/p/13387267.html