用turtle画动漫人物表白【Python】

turtle很好玩好玩turtle库。(自己画制的一幅画。)

图如下:

            

代码如下:

  1 import turtle as t
  2 import time
  3 
  4 def Move_turtle(x,y):
  5     t.up()
  6     t.goto(x,y)
  7     t.down()
  8 # ——————————————————————————————————————————————————————————
  9 # ---参数设置---
 10 t.speed(3) 
 11 t.pensize(2)             
 12 t.setup(800,700,0,0)
 13 t.bgcolor("Gainsboro")       
 14 Move_turtle(90,0)     
 15 # ——————————————————————————————————————————————————————————
 16 # ---开始绘制---
 17 # ——————————————————————————————————————————————————————————
 18 # ---脸-廓--- 
 19 t.seth(90)                       
 20 t.circle(600,10)             
 21 Move_turtle(90,0)
 22 t.seth(-92)
 23 t.circle(700,10)  
 24 t.right(20)
 25 t.circle(-100,20)
 26 t.circle(-30,10)
 27 t.seth(190)
 28 t.fd(3)
 29 t.fillcolor("black")
 30 t.begin_fill()
 31 t.circle(-300,50)       
 32 t.right(10)                              
 33 t.circle(-400,7)                   
 34 # ——————————————————————————————————————————————————————————
 35 # ---衣---
 36 t.seth(-78)                    
 37 t.circle(200,40)
 38 t.fd(10)
 39 t.circle(210,10)
 40 t.fd(80)
 41 t.end_fill()
 42 t.circle(-400,60)            
 43 # ——————————————————————————————————————————————————————————
 44 # ---嘴---
 45 Move_turtle(-10,-100)            
 46 t.seth(15)                         
 47 t.fd(10)                           
 48 t.seth(36)                         
 49 t.fd(80)                           
 50 Move_turtle(30,-100)               
 51 t.fd(30)                           
 52 # ——————————————————————————————————————————————————————————
 53 # ---调整位置---
 54 t.up()
 55 t.seth(90)
 56 t.fd(120)
 57 t.down()              
 58 # ——————————————————————————————————————————————————————————
 59 # ---鼻子---
 60 t.seth(145)                       
 61 t.fd(10)                          
 62 t.right(10)                       
 63 t.fd(20)                          
 64 t.right(20)                       
 65 t.fd(38)                         
 66 Move_turtle(54.27,37.63)          
 67 t.seth(-115)                     
 68 t.fd(37)                          
 69 t.right(50)                       
 70 t.fd(10)                          
 71 # ——————————————————————————————————————————————————————————
 72 t.speed(10)
 73 # ——————————————————————————————————————————————————————————
 74 # ---上眼眶---
 75 Move_turtle(-70,85)               
 76 t.seth(165)
 77 t.fd(10)
 78 t.seth(205)
 79 t.fd(10)
 80 t.circle(300,20)
 81 t.fd(1)                            
 82 # ——————————————————————————————————————————————————————————
 83 # ---下眼眶---
 84 t.seth(-15)                     
 85 t.circle(300,10)
 86 t.fd(2)
 87 t.left(20)
 88 t.circle(180,10)
 89 t.left(10)
 90 t.fd(10) 
 91 t.left(2)
 92 t.fd(20)                      
 93 # ——————————————————————————————————————————————————————————
 94 #  ---眼珠---
 95 t.fillcolor("gray")                 
 96 Move_turtle(-98.45,35.49)
 97 t.begin_fill()
 98 for i in range(4):
 99     t.circle(15,90)
100     t.fd(4)
101 t.end_fill()
102 #——————————————————————————————————————————————————————————
103 # ---爱心---
104 t.color('red')      
105 t.begin_fill()
106 t.seth(180)
107 t.up()
108 t.fd(30)
109 t.down()
110 t.seth(-45)
111 t.forward(15)
112 t.left(90)
113 t.forward(15)
114 t.left(45)
115 t.circle(5.3,180)
116 t.left(180)
117 t.circle(5.3,180)
118 t.end_fill()               
119 # ——————————————————————————————————————————————————————————
120 # ---衣---
121 t.pencolor("black")                   
122 Move_turtle(-196.71,-53.86)
123 t.seth(90)
124 t.circle(-300,50)
125 t.right(30)
126 t.fd(50)
127 t.right(30)
128 t.fd(40)
129 t.right(20)
130 t.left(20)
131 t.fd(10)
132 t.goto(80.88,104.19)
133 t.fillcolor("black")
134 t.begin_fill()
135 t.fd(20)
136 t.goto(90,0)
137 t.end_fill()
138 Move_turtle(99.67,97.35)
139 t.seth(120)
140 t.circle(200,20)
141 t.circle(9,10)          
142 # ——————————————————————————————————————————————————————————
143 #收尾。
144 t.hideturtle()
145 time.sleep(1)
146 Move_turtle(90,0)
147 t.pencolor("black")
148 t.write("其实",font=('楷体',50,''))
149 time.sleep(2)
150 t.undo()
151 time.sleep(4)
152 t.pencolor("red")
153 Move_turtle(200,-300)
154 t.write("
♥
我
喜
欢
你
啊
♥
!",font=('楷体',50,''))
155 # ——————————————————————————————————————————————————————————
156 
157 time.sleep(5)            #五秒后关闭

【代码中的坐标是通过turtle.pos() 获得的。】

原文地址:https://www.cnblogs.com/nicefurmine/p/12566060.html