用pythonturtle画简单的动物,用python turtle画龙猫

大家好,本文将围绕用python的turtle画炫酷的图展开说明,用pythonturtle画简单的动物是一个很多人都想弄明白的事情,想搞清楚用python turtle画龙猫需要先了解以下几个事情。

这个是用python库画的小猫咪,前面一步步的画整个猫的整个身体,具体步骤都写在了注释之中。身体部分画的比较快,后面画了5个心,由于画心的时候要改变好多度数,而且每次只前进一点点,所以画心的时候会比较慢,大家在看视频的时候会发现这一点python使用turtle函数绘制树图形。这个东西花了好个小时画出来,好多地方都是几像素几像素的试出来的。不过,我画画能力一般,加上时间有限,并不能完善所有细节。但是我尽可能多的完善了一些线条和布局,弧度之类的的细节,希望大家喜欢我们的作品。from turtle import *

#两个函数用于画心

def curvemove():

for i in range(200):

right(1)

forward(0.1)

def heart(x,y,s):

pu()

goto(x,y)

seth(s)

pendown()

begin_fill()

left(140)

forward(11.1)

curvemove()

left(120)

curvemove()

forward(11.1)

end_fill()

#初始化

setup(600,600)

pu()

goto(60,100)

pensize(4)

pendown()

#画左半边的头

for i in range(150,212,2):

seth(i)

fd(3)

seth(145)

fd(50)

left(125)

fd(50)

for i in range(240,318,2):

if i==290:

seth(190)

fd(10)

seth(10)

fd(10)

elif i==300:

seth(200)

fd(10)

seth(20)

fd(10)

seth(i)

fd(3)

#画右半边的头

pu()

goto(60,100)

pendown()

seth(45)

fd(50)

right(125)

fd(50)

for i in range(-60,-138,-2):

if i==-110:

seth(-10)

fd(10)

seth(170)

fd(10)

elif i==-120:

seth(-20)

fd(10)

seth(160)

fd(10)

seth(i)

fd(3)

#头部到这里就画好外观了

seth(-40)

fd(52)

seth(-135)

fd(45)

pu()

seth(-105)

fd(5)

pendown()

fd(17)

for i in range(130,106,-3):

seth(i)

fd(2.5)

for i in range(106,30,-10):

seth(i)

fd(2)

seth(38)

fd(25)

seth(135)

fd(31)

seth(169)

fd(6)

seth(270)

fd(105)

#右边的身子画好了

#开始画左边的身子

pu()

goto(-52,-30)

pendown()

seth(220)

fd(48)#52

seth(250)

fd(3)

seth(270)

fd(3)

seth(290)

fd(2)

seth(-40)

fd(44)

seth(228)

fd(20)

seth(5)

fd(22)

#画叉腰的动作

pu()

goto(-52,-84)

seth(133)

pendown()

fd(22)

seth(90)

fd(2)

seth(60)

fd(2)

seth(45)

fd(29)

seth(0)

fd(3)

seth(-93)

fd(102)

#叉腰动作结束 接下来画嘴巴 眼睛

pu()

goto(-43,38)

seth(0)

pendown()

begin_fill()

circle(5)

end_fill()

pu()

fd(108)

pendown()

begin_fill()

circle(5)

end_fill()

#调色环节

pu()

goto(60,24)

pencolor("pink")

pensize(6)

seth(225)

pendown()

fd(7)

pu()

goto(70,24)

seth(225)

pendown()

fd(7)

#右半边调色完毕

pu()

goto(-49,24)

seth(225)

pendown()

fd(7)

#画嘴巴

pu()

pensize(4)

pencolor("black")

goto(5,21)

seth(-45)

pendown()

fd(5)

goto(5,21)

seth(225)

fd(5)

#左边的颜色

pu()

pencolor("pink")

pensize(6)

goto(-39,24)

seth(225)

pendown()

fd(7)

#给耳朵填充颜色

pu()

goto(-40,92)

seth(80)

pendown()

fillcolor("pink")

begin_fill()

circle(14,360,3)

end_fill()

pu()

goto(72,100)

seth(-74)

pendown()

begin_fill()

circle(14,360,3)

end_fill()

#酷酷的黑翅膀

pu()

pensize(4)

color('black', 'black')

begin_fill()

goto(-90,-35)

seth(135)

pendown()

fd(25)

seth(225)

fd(45)

seth(25)

fd(15)

seth(-80)

pensize(2)

fd(15)

seth(55)

fd(15)

seth(25)

fd(10)

seth(-80)

fd(15)

seth(75)

fd(15)

goto(-90,-35)

end_fill()

#最后一个翅膀

pu()

goto(125,-30)

seth(45)

pendown()

begin_fill()

fd(25)

seth(-45)

fd(45)

seth(155)

fd(15)

seth(-80)

fd(15)

seth(120)

fd(17)

seth(170)

fd(15)

seth(-80)

fd(15)

seth(120)

fd(17)

goto(125,-30)

end_fill()

#画5颗心

speed(10)

color('red', 'pink')

pensize(2)

heart(0,140,0)

heart(-125,0,30)

heart(140,0,-30)

heart(145,-85,-30)

heart(-132,-85,30)

exitonclick()

  • 24
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以使用Pythonturtle库来绘制猫咪。以下是一个简单的示例代码: ```python import turtle # 绘制猫脸 def draw_face(): turtle.penup() turtle.goto(0, -100) turtle.pendown() turtle.circle(100) # 绘制猫耳朵 def draw_ears(): turtle.penup() turtle.goto(-70, 50) turtle.pendown() turtle.right(30) turtle.forward(80) turtle.left(60) turtle.forward(80) turtle.right(30) turtle.penup() turtle.goto(70, 50) turtle.pendown() turtle.left(60) turtle.forward(80) turtle.right(60) turtle.forward(80) turtle.left(60) # 绘制猫眼睛 def draw_eyes(): turtle.penup() turtle.goto(-40, 20) turtle.pendown() turtle.begin_fill() turtle.circle(20) turtle.end_fill() turtle.penup() turtle.goto(40, 20) turtle.pendown() turtle.begin_fill() turtle.circle(20) turtle.end_fill() # 绘制猫鼻子和嘴巴 def draw_nose_mouth(): turtle.penup() turtle.goto(0, 0) turtle.pendown() turtle.begin_fill() turtle.circle(10) turtle.end_fill() turtle.penup() turtle.goto(-30, -30) turtle.pendown() turtle.right(45) turtle.forward(60) # 绘制猫胡须 def draw_whiskers(): turtle.penup() turtle.goto(-30, -30) turtle.pendown() turtle.right(135) turtle.forward(40) turtle.penup() turtle.goto(-30, -30) turtle.pendown() turtle.left(90) turtle.forward(40) turtle.penup() turtle.goto(30, -30) turtle.pendown() turtle.right(90) turtle.forward(40) turtle.penup() turtle.goto(30, -30) turtle.pendown() turtle.left(135) turtle.forward(40) # 绘制猫身体 def draw_body(): turtle.penup() turtle.goto(-100, -150) turtle.pendown() turtle.begin_fill() turtle.right(30) turtle.forward(200) turtle.right(120) turtle.forward(200) turtle.right(60) turtle.forward(200) turtle.right(120) turtle.forward(200) turtle.end_fill() # 绘制猫腿 def draw_legs(): turtle.penup() turtle.goto(-100, -150) turtle.pendown() turtle.right(30) turtle.forward(80) turtle.right(90) turtle.forward(80) turtle.penup() turtle.goto(-100, -150) turtle.pendown() turtle.right(180) turtle.forward(80) turtle.right(90) turtle.forward(80) # 绘制猫尾巴 def draw_tail(): turtle.penup() turtle.goto(100, -150) turtle.pendown() turtle.right(120) turtle.circle(80, 240) # 绘制猫咪 def draw_cat(): draw_face() draw_ears() draw_eyes() draw_nose_mouth() draw_whiskers() draw_body() draw_legs() draw_tail() # 设置布大小和背景颜色 turtle.setup(800, 600) turtle.bgcolor("#F5DEB3") # 绘制猫咪 draw_cat() # 隐藏turtle.hideturtle() # 点击关闭窗口 turtle.exitonclick() ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值