turtle库绘制圆_Python绘画:应用Turtle库绘制“抖音艺术字”

43c6add4f0c0210e01823063d23ac4b8.png

前言:

前段时间,非常火的抖音艺术字,利用眼睛的盲区,让人很难识别写的数字。其实正确的办法,找准一个点,就很容易区分了。下面用Python的Turtle库绘制,一个同样效果的图片。实现也是非常的简单,先画出一个依次增加的长方形,让后用直线绘制出你想要的数字即可。

效果图:

314d18a43cb9257f8e623538f7121c1c.png

第一眼看过去,你绝对想不到,它是有几个长方形,和几条竖线构成的吧?

一、绘制五条直线:

import turtle# 设置画笔的大小turtle.pensize(10)turtle.pencolor("black")# 第一条直线turtle.penup()turtle.goto(-50,180)turtle.pendown()turtle.goto(50,180)# 第二条直线turtle.penup()turtle.goto(-75,90)turtle.pendown()turtle.goto(75,90)# 第三条直线turtle.penup()turtle.goto(-100,0)turtle.pendown()turtle.goto(100,0)# 第四条直线turtle.penup()turtle.goto(-125,-90)turtle.pendown()turtle.goto(125,-90)# 第五条直线turtle.penup()turtle.goto(-125,-180)turtle.pendown()turtle.goto(125,-180)

二、绘制长方形:

每个长方形,代表一个要生成的数字。三根竖线,生成两个长方形。那么四个竖线,就生成三个长方形,依次类推。

# 绘制两个长方形turtle.penup()turtle.goto(-50,180)turtle.pendown()turtle.goto(-50,90)turtle.penup()turtle.goto(0,180)turtle.pendown()turtle.goto(0,90)turtle.penup()turtle.goto(50,180)turtle.pendown()turtle.goto(50,90)# 绘制三个长方形turtle.penup()turtle.goto(-75,90)turtle.pendown()turtle.goto(-75,0)turtle.penup()turtle.goto(-25,90)turtle.pendown()turtle.goto(-25,0)turtle.penup()turtle.goto(25,90)turtle.pendown()turtle.goto(25,0)turtle.penup()turtle.goto(75,90)turtle.pendown()turtle.goto(75,0)# 绘制四个长方形turtle.penup()turtle.goto(-100,0)turtle.pendown()turtle.goto(-100,-90)turtle.penup()turtle.goto(-50,0)turtle.pendown()turtle.goto(-50,-90)turtle.penup()turtle.goto(0,0)turtle.pendown()turtle.goto(0,-90)turtle.penup()turtle.goto(50,0)turtle.pendown()turtle.goto(50,-90)turtle.penup()turtle.goto(100,0)turtle.pendown()turtle.goto(100,-90)# 绘制五个长方形turtle.penup()turtle.goto(-125,-90)turtle.pendown()turtle.goto(-125,-180)turtle.penup()turtle.goto(-75,-90)turtle.pendown()turtle.goto(-75,-180)turtle.penup()turtle.goto(-25,-90)turtle.pendown()turtle.goto(-25,-180)turtle.penup()turtle.goto(25,-90)turtle.pendown()turtle.goto(25,-180)turtle.penup()turtle.goto(75,-90)turtle.pendown()turtle.goto(75,-180)turtle.penup()turtle.goto(125,-90)turtle.pendown()turtle.goto(125,-180)

三、绘制数字:

实际上根据数码管的原理,来实现的。所以1-9的数字都可以绘制出来。

420f3f21637617c6b77f01d13b577f08.png
turtle.penup()turtle.goto(-50,150)turtle.pendown()turtle.goto(-25,150)turtle.penup()turtle.goto(-25,120)turtle.pendown()turtle.goto(0,120)turtle.penup()turtle.goto(25,150)turtle.pendown()turtle.goto(25,120)turtle.penup()turtle.goto(-75,30)turtle.pendown()turtle.goto(-50,30)turtle.penup()turtle.goto(-50,60)turtle.pendown()turtle.goto(0,60)turtle.penup()turtle.goto(0,30)turtle.pendown()turtle.goto(25,30)turtle.penup()turtle.goto(50,60)turtle.pendown()turtle.goto(50,30)turtle.penup()turtle.goto(-75,-20)turtle.pendown()turtle.goto(-75,-30)turtle.penup()turtle.goto(-100,-50)turtle.pendown()turtle.goto(-75,-50)turtle.goto(-75,-70)turtle.penup()turtle.goto(-25,0)turtle.pendown()turtle.goto(-25,-55)turtle.penup()turtle.goto(-50,-80)turtle.pendown()turtle.goto(-25,-80)turtle.penup()turtle.goto(-4,0)turtle.pendown()turtle.goto(-4,-55)turtle.penup()turtle.goto(-4,-80)turtle.pendown()turtle.goto(-4,-90)turtle.penup()turtle.goto(0,-30)turtle.pendown()turtle.goto(25,-30)turtle.penup()turtle.goto(25,-60)turtle.pendown()turtle.goto(50,-60)turtle.penup()turtle.goto(75,-30)turtle.pendown()turtle.goto(75,-60)turtle.penup()turtle.goto(-125,-150)turtle.pendown()turtle.goto(-100,-150)turtle.penup()turtle.goto(-100,-120)turtle.pendown()turtle.goto(-75,-120)turtle.penup()turtle.goto(-50,-110)turtle.pendown()turtle.goto(-50,-120)turtle.penup()turtle.goto(-75,-145)turtle.pendown()turtle.goto(-50,-145)turtle.goto(-50,-165)turtle.penup()turtle.goto(0,-90)turtle.pendown()turtle.goto(0,-145)turtle.penup()turtle.goto(-25,-170)turtle.pendown()turtle.goto(0,-170)turtle.penup()turtle.goto(21,-90)turtle.pendown()turtle.goto(21,-145)turtle.penup()turtle.goto(21,-170)turtle.pendown()turtle.goto(21,-180)turtle.penup()turtle.goto(25,-120)turtle.pendown()turtle.goto(50,-120)turtle.penup()turtle.goto(50,-150)turtle.pendown()turtle.goto(75,-150)turtle.penup()turtle.goto(100,-120)turtle.pendown()turtle.goto(100,-150)turtle.penup()turtle.goto(200,-250)turtle.hideturtle()

抖音艺术字,就绘制完成。你也可以利用这个方法,画出不同的艺术字。

资料领取:

1.如果觉得还可以,记得点击右上角的关注,随手点个转发让更多人看到哦。

2.如果你对Python感兴趣,我为你准备了一些Python教程,私信「python」领取。

3.本文的代码复制可以,可能还需要你手动换一下行。

13d69d4a17f3766e1baa0ebcb90c7c02.gif
已标记关键词 清除标记
表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页