Python系列 | Turtle绘图学习之呲牙emoji

绘图之前先要安装turtle模块:
python 2:

pip install turtle

python 3:

pip3 install turtle

效果图展示:

请添加图片描述

效果图代码:

import turtle

# 嘴
def mouth():
    turtle.colormode(255)
    turtle.pencolor((195,49,0))
    turtle.pensize(6)
    turtle.fillcolor("white")
    turtle.begin_fill()
    for i in range(180):
        turtle.right(1)
        turtle.forward(1.7)
    turtle.right(90)
    turtle.forward(195)
    turtle.end_fill()

# 眼睛
def eye():
    turtle.colormode(255)
    turtle.pencolor((136,64,10))
    turtle.pensize(10)
    for i in range(180):
        turtle.right(1)
        turtle.forward(0.4)

# 眉毛
def eyebrow():
    turtle.colormode(255)
    turtle.pencolor((136, 64, 10))
    turtle.pensize(10)
    for i in range(160):
        turtle.right(1)
        turtle.forward(0.3)

# 牙齿 l为长度 x是横坐标
def teeth(l,x):
    turtle.colormode(255)
    turtle.pencolor((187,144,107))
    turtle.pensize(6)
    tp(x,120)
    turtle.forward(l)

# 横纵坐标
def tp(x,y):
    turtle.penup()
    turtle.goto(x,y)
    turtle.pendown()

#隐藏箭头
turtle.hideturtle()
turtle.speed(9)
turtle.delay(0)
turtle.pensize(10)
turtle.colormode(255)
turtle.pencolor((226,139,1))
turtle.fillcolor((251,218,50))
turtle.begin_fill()

# 外部圆
turtle.circle(120)
turtle.end_fill()

# 调整嘴部位置
turtle.right(90)
tp(98,120)
mouth()

# 调整眼睛位置
# 右
tp(30,170)
turtle.left(90)
eye()
# 左
tp(-75,170)
turtle.right(180)
eye()
# 调整牙缝位置
teeth(90,20)
teeth(71,60)
teeth(89,-20)
teeth(69,-60)
tp(-95,120)
turtle.pensize(5)
turtle.colormode(255)
turtle.pencolor((195, 49, 0))
turtle.left(90)
turtle.forward(193)
# 调整眉毛位置
tp(35,230)
turtle.left(90)
eyebrow()
tp(-75,240)
turtle.right(230)
eyebrow()
# 细节
turtle.colormode(255)
turtle.pencolor((206,85,62))

turtle.right(40)
tp(-90,150)
turtle.fd(20)
tp(-70,150)
turtle.fd(20)
tp(110,150)
turtle.fd(20)
tp(90,150)
turtle.fd(20)
tp(-140,-100)

# 等待用户关闭
turtle.exitonclick()
  • 1
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值