如何用Python画一只狗狗——turtle基础

                         如何用Python画一只狗狗——turtle基础_第1张图片

这只小狗主要用了turtle库里的circle()头有些方正,比较自然。

话不多说,展示代码:

from turtle import *
pensize(5)
seth(0)
pd()
color('black')
circle(20, 80) 
circle(200, 30)  
circle(30, 60)  
circle(200, 29.5) 
circle(20, 60) 
circle(-150, 22) 
circle(-50, 10)  
circle(50, 70)  
x_nose = xcor()
y_nose = ycor()
circle(30, 62)  
circle(200, 15)  
pu()
goto(x_nose, y_nose+25)
pd()
begin_fill()
circle(8)
end_fill()
pu()
goto(x_nose+48, y_nose+55)
pd()
begin_fill()
circle(8)
end_fill()
pu()
goto(x_nose+100, y_nose+110)
seth(182)
pd()
circle(15, 45) 
circle(10, 15) 
circle(90, 70) 
circle(25, 110) 
circle(90, 70) 
circle(10, 15) 
circle(15, 45)  
pu()
goto(x_nose+90, y_nose-30)
seth(-130)
pd()
circle(250, 28)  
circle(10, 140)  
circle(-250, 25)  
circle(-200, 25)  
circle(-50, 85)  
circle(8, 145)  
circle(90, 45)  
circle(550, 5)  
seth(0)
circle(60, 85)
circle(40, 65)  
circle(40, 60) 
lt(150)
circle(-40, 90)  
circle(-25, 100)  
lt(5)
fd(20)
circle(10, 60)  
rt(80)
circle(200, 35)
pensize(20)
color('#F03C3F')
lt(10)
circle(-200, 25)  
pu()
fd(18)
lt(90)
fd(18)
pensize(6)
seth(35)
color('#FDAF17')
begin_fill()
lt(135)
fd(6)
right(180) 
circle(6, -180)
backward(8)
right(90)
forward(6)
circle(-6, 180)
fd(15)
end_fill()
pensize(5)
pu()
color('black')
goto(x_nose+100, y_nose-125)
pd()
seth(-50)
fd(25)
circle(10, 150)
fd(25)
pu()
goto(x_nose+314, y_nose-125)
pd()
seth(-95)
fd(25)
circle(-5, 150)

你可能感兴趣的:(python)