turtle绘制哔哩哔哩小电视

作者:封亚飞 qq:64761294 题目来源于网络,代码自己写的

如果您有更好的方法,期待与您交流。

1.问题描述
使用turtle库绘制哔哩哔哩的小电视

2.问题分析

  • 在平面直角坐标系中,对小电视进行简单的位置分析
  • 找到特殊点位所在的坐标
  • 模拟特殊曲线

3.设置基本参数

  • 设置长度:200px
  • 设置高度:160px
  • 设置圆角半径:10px
  • 设置眼镜角度和长度:30px,20°(左),160°(右)
  • 设置天线角度和长度:50px,45°(左),135°(右)
  • 设置嘴巴弧度和半径:(-10,180)(10,180)
  • 设置足部弧度和半径:(-15,180)(15,180)
  • 设置画笔颜色:#07B0F2

4.设计思想: 模块化
5.代码
`import turtle as t
#定义绘制轮廓模块
def lunkuo():
t.seth(0)
t.pu()
t.goto(0,80)
t.pd()
t.fd(100-10)
t.circle(10,90)
t.fd(2*(80-10))
t.circle(10,90)
t.fd(1002-20)
t.circle(10,90)
t.fd(2
(80-10))
t.circle(10,90)
t.fd(100-10)
t.pu()
#定义绘制眼睛模块
def eyes():

t.seth(20)
t.goto(-50,20+160)
t.pd()
t.fd(30)
t.pu()
t.seth(160)
t.goto(50,20+160)
t.pd()
t.fd(30)
t.pu()

#定义绘制耳朵模块
def erduo():
t.seth(45)
t.goto(30,240)
t.pd()
t.fd(50)
t.pu()
t.seth(135)
t.goto(-30,240)
t.pd()
t.fd(50)
t.pu()
#定义绘制嘴巴模块
def mouth():
t.pensize(5)
t.goto(0,130)
t.pd()
t.seth(-90)
t.circle(-10,180)
t.pu()
t.goto(0,130)
t.seth(-90)
t.pd()
t.circle(10,180)
t.pu()
#定义绘制脚模块
def foot():
t.pensize(8)
t.goto(-45,80)
t.seth(-90)
t.pd()
t.begin_fill()
t.circle(-15,180)
t.end_fill()
t.pu()
t.goto(45,80)
t.seth(-90)
t.pd()
t.begin_fill()
t.circle(15,180)
t.end_fill()
t.pu()
#定义绘制图形主函数main_png()
def main_png():
t.hideturtle()
t.pensize(10)
t.color(’#07B0F2’)
lunkuo()
eyes()
erduo()
mouth()
foot()
#开始绘制图形
main_png()
#定义写字模块
def wenzi():
t.pu()
t.goto(-80,0)
t.pd()
t.write(“bilibili”,font = (“C:\Windows\Fonts\Swis721 Lt BT.ttf”, 30,“bold”))
#执行写字
wenzi()
t.done()
`
6.效果图
哔哩哔哩小电视绘制

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值