Python学习笔记--画个可爱的叮当喵

参考大神的链接:你看过/写过哪些有意思的代码? - 暴走的bug的回答 - 知乎
https://www.zhihu.com/question/275611095/answer/382959285
前一段时间在知乎看到了一个大神的作品,他用turtl库画了一个小猪佩奇!刚看到我就惊呆了,看了一下代码,咦,好简单哎,这么简单的代码可以写出这么好玩的东西呀~于是心里就一直也想画一个,想画个可爱的叮当喵~
不过还在整修中……因为感觉怎么……额…没有我想的那么萌???而且大神已更新到小猪佩奇2.0我还没更新~

# coding:utf-8
import turtle as t
import time

t.pensize(4)
t.pencolor('black')
t.hideturtle()
t.setup(800,600)
t.speed(0)

# 外脸轮廓
t.penup()
t.goto(200,50)
t.color('black','blue')
t.pendown()
t.seth(30)
t.circle(100,300)#半径、角度


# 眼睛
# 左眼睛
t.penup()
t.goto(120,210)
t.pendown()
t.seth(180)
a=0.4
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.05
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    else:
        a=a-0.05
        t.lt(3)
        t.fd(a)
#左眼珠
t.pu()
t.seth(-70)
t.fd(17)
t.seth(180)
t.pd()
t.begin_fill()
a=0.15
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.02
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    else:
        a=a-0.02
        t.lt(3)
        t.fd(a)
t.color('black')
t.end_fill()
#左眼神
t.pu()
t.seth(-90)
t.fd(5)
t.pd()
t.color('white')
t.begin_fill()
t.circle(2)
t.end_fill()

# 右眼睛
t.pu()
t.goto(180,210)
t.pencolor('black')
t.pd()
t.seth(180)
a=0.4
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.05
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    else:
        a=a-0.05
        t.lt(3)
        t.fd(a)
#右眼珠
t.pu()
t.seth(-110)
t.fd(17)
t.seth(180)
t.pd()
t.begin_fill()
a=0.15
for i in range(120):
    if 0<=i<30 or 60<=i<90:
        a=a+0.02
        t.lt(3) #向左转3度
        t.fd(a) #向前走a的步长
    else:
        a=a-0.02
        t.lt(3)
        t.fd(a)
t.color('black')
t.end_fill()
#右眼神
t.pu()
t.seth(-90)
t.fd(5)
t.pd()
t.color('white')
t.begin_fill()
t.circle(2)
t.end_fill()

# 鼻子
t.pu()
t.color('black','red') # 画笔颜色,填充颜色
t.goto(150,160)
t.seth(180)
t.pd()
t.begin_fill()
t.circle(10)
t.end_fill()

t.pu()
t.seth(-90)
t.fd(5)
t.pd()
t.color('white')
t.begin_fill()
t.circle(2)
t.end_fill()

# 嘴巴
t.pu()
t.pencolor('black')
t.seth(-90)
t.fd(12)
t.pd()
t.fd(70)

t.pu()
t.seth(90)
t.fd(17)
t.seth(0)
t.fd(-60)
t.pd()
t.seth(-50)
t.circle(80,100)

# 舌头
t.pu()
t.seth(120)
t.fd(5)
t.pd()
t.seth(-60)
t.fd(10)

t.pu()
t.seth(180)
t.fd(52)
t.seth(-60)
t.fd(20)
t.pd()
t.color('black','red')
t.begin_fill()
t.seth(120)
t.circle(-40,50)
t.circle(-10,80)
t.circle(-40,50)
t.end_fill()

t.pu()
t.seth(180)
t.fd(20)
t.pd()
t.seth(-60)
t.fd(12)


# 内脸轮廓
t.pu()
t.goto(100,50)
t.color('black')
t.seth(130)
t.pd()
t.circle(-110,40)
t.circle(-70,40)
t.circle(-100,10)

t.pu()
t.goto(200,50)
t.seth(50)
t.pd()
t.circle(110,40)
t.circle(70,40)
t.circle(100,10)

#胡子
# 右边的胡子
t.pu()
t.goto(200,150)
t.seth(30)
t.pd()
t.fd(30)

t.pu()
t.seth(180)
t.fd(23)
t.seth(-90)
t.fd(25)
t.pd()
t.seth(10)
t.fd(30)

t.pu()
t.seth(180)
t.fd(28)
t.seth(-90)
t.fd(20)
t.pd()
t.seth(-10)
t.fd(30)

# 左边的胡子
t.pu()
t.goto(100,150)
t.seth(150)
t.pd()
t.fd(30)

t.pu()
t.seth(0)
t.fd(23)
t.seth(-90)
t.fd(25)
t.pd()
t.seth(170)
t.fd(30)

t.pu()
t.seth(0)
t.fd(28)
t.seth(-90)
t.fd(20)
t.pd()
t.seth(-170)
t.fd(30)

t.done()
time.sleep(1)

我的小叮当~~
这里写图片描述
不过真的还蛮开心的~~
编程很有趣嘛~

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值