用Python画一只溜达小狗——turtle库基础入门

一只脑门有点方的小狗,其实还可以把脑门和后脑勺完善一下,更圆润一些。 但这样也挺可爱,就保有这样不完美但独一无二的它吧。绘制过程主要就是拼接和调整圆弧,尽量做到过度自然。

小狗的绘制主要使用了turtle库的circle()函数,初接触时可能会略有不适应,但用起来之后会发现它很强大!对circle()函数用法还不熟悉的同学可参考这篇博客:《如何用Python画一只兔子——turtle库circle()画圆函数的详细用法介绍》,文中有详细用法讲解,包学包会^_^。

以下附上绘画成果和代码:

 


 


from turtle import *    python资料领取学习q裙:821871075
screensize(500,500)
 
#【头部轮廓】
pensize(5)
home()
seth(0)
pd()
 
color('black')
circle(20,80)#0
circle(200,30)#1
circle(30,60)#2
circle(200,29.5)#3
color('black')
circle(20,60)#4
circle(-150,22)#5
circle(-50,10)#6
circle(50,70)#7
 
#确定鼻头大概位置
x_nose= xcor()
y_nose= ycor()
 
circle(30,62)#8
circle(200,15)#9
 
#【鼻子】
pu()
goto(x_nose,y_nose+25)
seth(90)
pd()
begin_fill()
circle(8)
end_fill()
 
#【眼睛】
pu()
goto(x_nose+48,y_nose+55)
seth(90)
pd()
begin_fill()
circle(8)
end_fill()
 
#【耳朵】
pu()
color('#444444')
goto(x_nose+100,y_nose+110)
seth(182)
pd()
circle(15,45)#1
 
color('black')
circle(10,15)#2
circle(90,70)#3
circle(25,110)#4
rt(4)
circle(90,70)#5
circle(10,15)#6
 
color('#444444')
circle(15,45)#7
 
#【身体】
pu()
color('black')
goto(x_nose+90,y_nose-30)
seth(-130)
pd()
circle(250,28)#1
circle(10,140)#2
circle(-250,25)#3
circle(-200,25)#4
circle(-50,85)#5
circle(8,145)#6
circle(90,45)#7
circle(550,5)#8
 
#【尾巴】
seth(0)
circle(60,85)#1
circle(40,65)#2
circle(40,60)#3
 
lt(150)
circle(-40,90)#4
circle(-25,100)#5
 
lt(5)
fd(20)
 
circle(10,60)#6
 
#【背部】
rt(80)
circle(200,35)
 
 
#【项圈】
pensize(20)
color('#F03C3F')
lt(10)
circle(-200,25)#5
 
#【爱心铃铛】
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)
 
#【后小腿】
pensize(4)
pu()
goto(x_nose+314,y_nose-125)
pd()
 
seth(-95)
fd(25)
circle(-5,150)
fd(2)
 
hideturtle()
done()
发布了29 篇原创文章 · 获赞 2 · 访问量 1149

猜你喜欢

转载自blog.csdn.net/qun821871075/article/details/102491015