运用turtle库绘制哆啦A梦

运用turtle库绘制哆啦A梦

六一儿童节到来之际,作为 90后的我不免想起儿时的动漫剧。于是,打开电脑,开启了哆啦A梦的绘制之旅。OK,废话不多说,直接上代码。

import turtle as t
 
t.speed(200)
t.pensize(4)
t.hideturtle()
t.screensize(500, 500, bg='white')
 
# 猫脸
# 填充的颜色
t.fillcolor('#00A1E8')
t.begin_fill()
# 数字表示半径
t.circle(130)
t.end_fill()

# 笔的粗细
t.pensize(4)
t.fillcolor('white')
t.begin_fill()
t.circle(100)
t.end_fill()

# 提起笔
t.pu()
# 回到原始坐标系的位置, 即(0,0)
t.home()
# 移动到的坐标
t.goto(0, 134)
# 落下笔
t.pd()
t.pensize(4)
t.fillcolor("#EA0014")
t.begin_fill()
t.circle(18)
t.end_fill()
 
t.pu()
t.goto(7, 155)
t.pensize(2)
# 笔的颜色和填充颜色
t.color('white', 'white')
t.pd()
t.begin_fill()
t.circle(4)
t.end_fill()
 
    
# 眼睛
t.pu()
t.goto(-30, 160)
t.pensize(4)
t.pd()
t.color('black', 'white')
t.begin_fill()
a = 0.4
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a+0.08
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    else:
        a = a-0.08
        t.lt(3)
        t.fd(a)
t.end_fill()
 
t.pu()
t.goto(30, 160)
t.pensize(4)
t.pd()
t.color('black', 'white')
t.begin_fill()
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a+0.08
        t.lt(3)  # 向左转3度
        t.fd(a)  # 向前走a的步长
    else:
        a = a-0.08
        t.lt(3)
        t.fd(a)
t.end_fill()
 
t.pu()
t.goto(-38,190)
t.pensize(8)
t.pd()
t.right(-30)
t.forward(15)
t.right(70)
t.forward(15)
 
t.pu()
t.goto(15, 185)
t.pensize(4)
t.pd()
t.color('black', 'black')
t.begin_fill()
t.circle(13)
t.end_fill()
 
t.pu()
t.goto(13, 190)
t.pensize(2)
t.pd()
t.color('white', 'white')
t.begin_fill()
t.circle(5)
t.end_fill()


# 右边的胡子
t.pu()
t.home()
t.goto(0, 134)
t.pensize(4)
t.pencolor('black')
t.pd()
t.right(90)
t.forward(40)
 
t.pu()
t.home()
t.goto(0, 124)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(10)
t.forward(80)
 
t.pu()
t.home()
t.goto(0, 114)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(6)
t.forward(80)
 
t.pu()
t.home()
t.goto(0,104)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(0)
t.forward(80)
 
# 左边的胡子
t.pu()
t.home()
t.goto(0,124)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(170)
t.forward(80)
 
t.pu()
t.home()
t.goto(0, 114)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(174)
t.forward(80)
 
t.pu()
t.home()
t.goto(0, 104)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(180)
t.forward(80)

# 嘴
t.pu()
t.goto(-70, 70)
t.pd()
t.color('black', 'red')
t.pensize(4)
t.seth(-60)
t.begin_fill()
t.circle(80,40)
t.circle(80,80)
t.end_fill()
 
t.pu()
t.home()
t.goto(-80,70)
t.pd()
t.forward(160)
 
t.pu()
t.home()
t.goto(-50,50)
t.pd()
t.pensize(1)
t.fillcolor("#eb6e1a")
t.seth(40)
t.begin_fill()
t.circle(-40, 40)
t.circle(-40, 40)
t.seth(40)
t.circle(-40, 40)
t.circle(-40, 40)
t.seth(220)
t.circle(-80, 40)
t.circle(-80, 40)
t.end_fill()
 
# 身体
t.pu()
t.goto(0, -20)
t.pendown()
t.pensize(3)
t.seth(0)
t.circle(150, 50)
t.seth(30)
t.fd(40)
t.seth(70)
t.circle(-30, 270)
 
 
t.fillcolor('#00A1E8')
t.begin_fill()
 
t.seth(230)
t.fd(80)
t.seth(90)
t.circle(1000, 1)
t.seth(-89)
t.circle(-1000, 10)
 

 
t.seth(180)
t.fd(70)
t.seth(90)
t.circle(30, 180)
t.seth(180)
t.fd(70)
 

t.seth(100)
t.circle(-1000, 9)
 
t.seth(-86)
t.circle(1000, 2)
t.seth(230)
t.fd(40)
 
 
t.circle(-30, 230)
t.seth(45)
t.fd(81)
t.seth(0)
t.fd(203)
t.circle(5, 90)
t.fd(10)
t.circle(5, 90)
t.fd(7)
t.seth(40)
t.circle(150, 10)
t.seth(30)
t.fd(40)
t.end_fill()
 
# 右手
t.pu()
t.seth(72)
t.pd()
t.fillcolor('#ffffff')
t.begin_fill()
t.circle(-30)
t.end_fill()
 
# 脚
t.pu()
t.goto(103.74, -202.59)
t.pd()
t.seth(0)
t.fillcolor('#ffffff')
t.begin_fill()
t.fd(15)
t.circle(-15, 180)
t.fd(90)
t.circle(-15, 180)
t.fd(10)
t.end_fill()

t.pu()
t.goto(-96.26, -202.59)
t.pd()
t.seth(180)
t.fillcolor('#ffffff')
t.begin_fill()
t.fd(15)
t.circle(15, 180)
t.fd(90)
t.circle(15, 180)
t.fd(10)
t.end_fill()
 
# 左手
t.pu()
t.goto(-151, -121.81)
t.pd()
t.seth(20)
t.fillcolor('#ffffff')
t.begin_fill()
t.circle(30)
t.end_fill()
 
# 口袋
t.pu()
t.goto(-103.42, 10)
t.pd()
t.seth(0)
t.fd(38)
t.seth(230)
t.begin_fill()
t.circle(90, 260)
t.end_fill()

t.pu()
t.goto(5, -40)
t.pd()
t.seth(0)
t.fd(70)
t.seth(-90)
t.circle(-70, 180)
t.seth(0)
t.fd(70)

# 领带
t.pu()
t.home()
t.goto(-100, 14)
t.pd()
t.pensize(4)
t.pencolor('black')
t.fillcolor('#e70010')
t.begin_fill()
t.seth(0)
t.fd(204)
t.circle(-5, 90)
t.fd(10)
t.circle(-5, 90)
t.fd(204)
t.circle(-5, 90)
t.fd(10)
t.circle(-5, 90)
t.end_fill()



# 铃铛
t.pu()
t.home()
t.goto(-15, -15)
t.pd()
t.seth(70)
t.fillcolor('#ffd200')
t.begin_fill()
t.circle(-20)
t.end_fill()
t.seth(170)
t.fillcolor('#ffd200')
t.begin_fill()
t.circle(-2, 180)
t.seth(10)
t.circle(-100, 22)
t.circle(-2, 180)
t.seth(180-10)
t.circle(100, 22)
t.end_fill()

t.pu()
t.goto(-15, -15)
t.pd()
t.seth(250)
t.circle(20, 110)
t.seth(90)
t.fd(15)
t.dot(10) 
 
t.done()

在这里插入图片描述
哈哈哈,怎么样?还行吧,有鼻子有眼~

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值