python画小狗代码_用Python画一只有点方的小狗狗——turtle库circle()函数实践

这篇博客通过Python的turtle库,详细展示了如何绘制一只带有方形头部特征的小狗。利用circle()函数的不同参数组合,逐步描绘出小狗的头部、身体、四肢、尾巴等细节,展现了turtle库在图形绘制中的灵活性和实用性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一只脑门有点方的小狗,其实还可以把脑门和后脑勺完善一下,更圆润一些。 但这样也挺可爱,就保有这样不完美但独一无二的它吧。绘制过程主要就是拼接和调整圆弧,尽量做到过度自然。turtle库的circle()函数虽然初接触会略有不适应,但用起来之后会发现它很强大!

image.png

代码如下

from turtle import *

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()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值