Python利用turtle库绘图大熊猫

本文介绍了使用Python的turtle库详细绘制卡通大熊猫的过程,通过代码实现了一只可爱的熊猫宝宝。
摘要由CSDN通过智能技术生成

Python利用turtle库绘图大熊猫


Turtle库是Python语言中一个很流行的绘制图像的函数库,想象一个小乌龟,在一个横轴为x、纵轴为y的坐标系原点,(0,0)位置开始,它根据一组函数指令的控制,在这个平面坐标系中移动,从而在它爬行的路径上绘制了图形。
由于图片较复杂,所以用的代码较为冗长,这里不做分析

卡通大熊猫的详细代码

import turtle as t

t.title("熊猫宝宝")
t.shape("classic")
t.pensize(3)
t.color("black")
t.fillcolor("black")
t.speed(100)
t.hideturtle()
#左耳
t.penup()
t.goto(-105,97)
t.setheading(160)
t.begin_fill()
t.pendown()
t.circle(-30,230)
t.setheading(180)
t.circle(37,90)
t.end_fill()
#右耳
t.penup()
t.goto(105,97)
t.setheading(20)
t.begin_fill()
t.pendown()
t.circle(30,230)
t.setheading(0)
t.circle(-37,90)
t.end_fill()
#头部轮廓
t.penup()
t.goto(-67,140)
t.setheading(30)
t.pendown()
t.circle(-134,60)

t.penup()
t.goto(-50,-25)
t.setheading(180)
t.pendown()
t.circle(-100,30)
t.circle(-30,90)
t.setheading(100)
t.circle(-200,20)

t.penup()
t.goto(50,-25)
t.setheading(0)
t.pendown()
t.circle(100,30)
t.circle(30,90)
t.setheading(80)</
  • 30
    点赞
  • 160
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值