前言:
目前大家对“python做艺术字”都比较珍视,看官们都想要学习一些“python做艺术字”的相关资讯。那么小编也在网摘上搜集了一些有关“python做艺术字””的相关知识,希望小伙伴们能喜欢,你们一起来了解一下吧!前言:
前段时间,非常火的抖音艺术字,利用眼睛的盲区,让人很难识别写的数字。其实正确的办法,找准一个点,就很容易区分了。下面用Python的Turtle库绘制,一个同样效果的图片。实现也是非常的简单,先画出一个依次增加的长方形,让后用直线绘制出你想要的数字即可。
效果图:
第一眼看过去,你绝对想不到,它是有几个长方形,和几条竖线构成的吧?
一、绘制五条直线:
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的数字都可以绘制出来。
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.本文的代码复制可以,可能还需要你手动换一下行。
版权声明:
本站文章均来自互联网搜集,如有侵犯您的权益,请联系我们删除,谢谢。
标签: #python做艺术字 #python艺术字体生成 #python怎么画字