码迷,mamicode.com
首页 > 其他好文 > 详细

罗小黑

时间:2020-03-21 18:13:20      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:pre   import   end   hide   for   onclick   closed   else   set   

技术图片
  1 import turtle as t
  2 # 画一个黑的头
  3 t.speed(50)
  4 t.pensize(5)
  5 t.color("black", "black")
  6 t.pu()
  7 t.goto(0, -80)
  8 t.pd()
  9 t.begin_fill()
 10 t.circle(100)
 11 t.end_fill()
 12 # 到眼睛
 13 t.pu()
 14 t.goto(45, -15)
 15 t.pendown()
 16 # 画两眼睛椭圆
 17 t.color("brown", "white")
 18 t.begin_fill()
 19 t.pendown()
 20 a = 0.9
 21 for i in range(120):
 22     if 0 <= i < 30 or 60 <= i < 90:
 23         a += 0.09
 24         t.left(3)
 25         t.fd(a)
 26     else:
 27         a -= 0.09
 28         t.left(3)
 29         t.fd(a)
 30 t.end_fill()
 31 t.pu()
 32 t.goto(-45, -15)
 33 t.pendown()
 34 t.begin_fill()
 35 a = 0.9
 36 for i in range(120):
 37     if 0 <= i < 30 or 60 <= i < 90:
 38         a += 0.09
 39         t.left(3)
 40         t.fd(a)
 41     else:
 42         a -= 0.09
 43         t.left(3)
 44         t.fd(a)
 45 t.end_fill()
 46 # 眼白
 47 t.color("black", "black")
 48 t.penup()
 49 t.goto(-45, 6)
 50 t.pd()
 51 x = 0.3
 52 t.speed(150)
 53 t.begin_fill()
 54 for i in range(180):
 55     if 0 <= i < 45 or 90 <= i < 135:
 56         x += 0.03
 57         t.left(2)
 58         t.fd(x)
 59     else:
 60         x -= 0.03
 61         t.left(2)
 62         t.fd(x)
 63 t.end_fill()
 64 t.pu()
 65 t.goto(45, 6)
 66 t.pd()
 67 x = 0.3
 68 t.speed(50)
 69 t.begin_fill()
 70 for i in range(180):
 71     if 0 <= i < 45 or 90 <= i < 135:
 72         x += 0.03
 73         t.left(2)
 74         t.fd(x)
 75     else:
 76         x -= 0.03
 77         t.left(2)
 78         t.fd(x)
 79 t.end_fill()
 80 t.penup()
 81 t.color("black", "black")
 82 t.goto(30, 115)
 83 t.pd()
 84 # 耳朵
 85 t.setheading(25)
 86 for i in range(100):
 87     t.right(0.3)
 88     t.fd(0.8)
 89 t.setheading(-90)
 90 t.fd(5)
 91 for i in range(52):
 92     t.right(0.3)
 93     t.fd(1.5)
 94 t.penup()
 95 t.goto(-30, 115)
 96 t.pd()
 97 
 98 t.setheading(155)
 99 for i in range(100):
100     t.left(0.3)
101     t.fd(0.8)
102 t.setheading(-90)
103 t.fd(5)
104 t.setheading(-90)
105 for i in range(52):
106     t.left(0.3)
107     t.fd(1.5)
108 t.speed(1)
109 t.penup()
110 t.color("black", "green")
111 t.begin_fill()
112 t.goto(-20, -40)
113 t.seth(0)
114 t.pd()
115 t.fd(40)
116 t.setheading(-120)
117 t.fd(40)
118 t.setheading(120)
119 t.fd(40)
120 t.end_fill()
121 t.done()
罗小黑

 

罗小黑

标签:pre   import   end   hide   for   onclick   closed   else   set   

原文地址:https://www.cnblogs.com/Calculus9/p/12540240.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!