Coder Social home page Coder Social logo

zh2emoji's Introduction

介绍 zh2emoji可以将一个汉字,在终端输出成由emoji表情组成的该字。 emoji表情可以自己随意定制: ❤️ 🐀 🐂 🐅 🐇 🐶 🐱 🐻 ...

也可以将emoji表情替换成ASCII,或者单个汉字,或者其他(Just Try It)

比如执行以下几行代码, 使用不同的填充方法显示来展示"茴"字:

print image2print(word2image(u'茴'), u'❤️ ')
print image2print(word2image(u'茴'), u'W ')
print image2print(word2image(u'茴'), u'茴', width=40)

其中, 对于ascii 建议后面多一个空格填充;

对于emoji表情, 可能跟终端的打印方式有关, 对比后自行决定后面需不需要加上空格填充;

对于汉字,输出正好.

输出结果如下:

image image image

更多输出:

image image

扩展

基于zh2emoji,自己实现了一个可能有点儿用的扩展: demo_show_animation.py.

它可以将一句话在终端依次打印出来,使用你决定的emoji或者其他字符.

比如你试着执行 python ./demo_show_animation.py 喜欢就点个赞呗, 将在终端执行一段展示文字的动画, 展示的文字就是你刚才输入的话.

zh2emoji 还支持更换字体,不过在终端打印出来也差别不大.

安装

zh2emoji依赖于PIL库, 该库可通过安装Pillow引入.

pip install Pillow==2.9.0

如果安装过程中提示错误, 可通过添加一些系统依赖来解决.

以CentOS为例, 其他类型的系统类比:

yum install -y libjpeg* libpng-devel libtiff-devel

上面代码安装了一些开发图片绘制相关的系统依赖。如果系统还想支持一些webp等图片格式, 那么还需要安装:

yum install -y freetype-devel
yum install -y libwebp-devel

其他

如果你对这有兴趣, 而且有一些有意思的建议, 如果我能够实现, 我会在后续中贡献出更加有趣的内容.

Come On! 有的话可以联系我: [email protected]

zh2emoji's People

Stargazers

hxkdyw avatar

Watchers

hxkdyw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.