打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
用 Python 画一个捂脸表情

来源:Python 技术「ID: pythonall」

微信中的捂脸表情相信大家都不陌生,我见过以及自己使用这个表情的频率都是比较高的,可以说这个表情算是大部分人的主打表情之一了,本文我使用 Python 来画一下这个表情,我们使用到的库还是 turtle。

实现

因微信中的表情较小,我到网上找了一个大一点的,一起来看一下:

从图中我们可以看出这个表情由:脸框(那个大圆圈)、手、眼睛、眼泪、嘴(包括牙齿),下面我们看一下如何使用 Python 来画它。

首先,我们来画脸框,代码实现如下:

turtle.speed(5)
turtle.setup(500500)
turtle.pensize(5)
turtle.right(90)
turtle.penup()
turtle.fd(100)
turtle.left(90)
turtle.pendown()
turtle.begin_fill()
turtle.pencolor("#B8860B")
turtle.circle(150)
turtle.fillcolor("#FFFF99")
turtle.end_fill()

看一下效果:

接着来画嘴(包括牙齿),代码实现如下:

turtle.penup()
turtle.goto(7720)
turtle.pencolor("#B8860B")
turtle.goto(050)
turtle.right(30)
turtle.fd(110)
turtle.right(90)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor("#925902")
turtle.circle(-97160)
turtle.goto(92-3)
turtle.end_fill()
turtle.penup()
turtle.goto(77-25)
# 牙齿
turtle.pencolor("white")
turtle.begin_fill()
turtle.fillcolor("white")
turtle.goto(77-24)
turtle.goto(-8129)
turtle.goto(-7043)
turtle.goto(77-8)
turtle.end_fill()
turtle.penup()
turtle.goto(0-100)
turtle.setheading(0)
turtle.pendown()

看一下效果:

再接着来画眼泪,代码实现如下:

# 左边眼泪
turtle.left(90)
turtle.pensize(3)
turtle.penup()
turtle.fd(150)
turtle.right(60)
turtle.fd(-150)
turtle.pendown()
turtle.left(20)
turtle.pencolor("#155F84")
turtle.fd(150)
turtle.right(180)
position1 = turtle.position()
turtle.begin_fill()
turtle.fillcolor("#B0E0E6")
turtle.fd(150)
turtle.right(20)
turtle.left(270)
turtle.circle(-15018)
turtle.right(52)
turtle.fd(110)
position2 = turtle.position()
turtle.goto(-3390)
turtle.end_fill()
# 右边眼泪
turtle.penup()
turtle.goto(00)
turtle.setheading(0)
turtle.left(90)
turtle.fd(50)
turtle.right(150)
turtle.fd(150)
turtle.left(150)
turtle.fd(100)
turtle.pendown()
turtle.begin_fill()
turtle.fd(-100)
turtle.fillcolor("#B0E0E6")
turtle.right(60)
turtle.circle(15015)
turtle.left(45)
turtle.fd(66)
turtle.goto(7720)
turtle.end_fill()

看一下效果:

再接着画眼睛,代码实现如下:

turtle.pensize(5)
turtle.penup()
turtle.pencolor("black")
turtle.goto(-6575)
turtle.setheading(0)
turtle.left(27)
turtle.fd(30)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor("black")
turtle.left(90)
turtle.circle(3086)
turtle.goto(position2[0], position2[1])
turtle.goto(position1[0], position1[1])
turtle.end_fill()

看一下效果:

最后,我们来画手,代码实现如下:

turtle.pencolor("#B8860B")
turtle.fillcolor("#FFFF99")
arc(-11010110-4030)
turtle.begin_fill()
turtle.circle(30035)
turtle.circle(13120)
turtle.setheading(-50)
turtle.fd(20)
turtle.setheading(130)
turtle.circle(20015)
turtle.circle(12180)
turtle.fd(40)
turtle.setheading(137)
turtle.circle(20016)
turtle.circle(12160)
turtle.setheading(-35)
turtle.fd(45)
turtle.setheading(140)
turtle.circle(20013)
turtle.circle(11160)
turtle.setheading(-35)
turtle.fd(40)
turtle.setheading(145)
turtle.circle(2009)
turtle.circle(10180)
turtle.setheading(-31)
turtle.fd(50)
turtle.setheading(-45)
turtle.pensize(7)
turtle.right(5)
turtle.circle(18035)
turtle.end_fill()
turtle.begin_fill()
turtle.setheading(-77)
turtle.fd(50)
turtle.left(-279)
turtle.fd(16)
turtle.circle(2990)
turtle.end_fill()

看一下最终效果:

是不是有内味了。

总结

本文我们使用 Python 画了一个捂脸表情,如果大家对实现效果不满意的话,可以自己动手将它修改成自己满意的样子。

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
刚刚出炉的冬奥会吉祥物:冰墩墩,附源码...
海龟绘图:python绘制百变表情包
Python — — turtle 常用代码
python 标准库
【每周一坑】阿姆斯特朗数
笛卡尔函数
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服