Python character drawing is a simple and interesting small program, which is very suitable for beginners to take Zhuang study (BI). The principle of Python character drawing generation is very simple. In a word, —- replaces the pixels of the picture with different characters, so as to transform the picture composed of pixels into the character drawing composed of characters. In order to make the character drawing display effect as same as the picture as possible. Pixels with high grayscale values are represented by visually dark characters (such as $), and pixels with low grayscale values are represented by visually light characters

Running under Python 3, you can input an image to generate a character drawing. The general principle is mentioned in the notes. The specific pixel and symbol transformation relationship, I did not go into the depth.

Run the command:

python3 draw.py –width 60 –height 30 test.png

Here are the renderings:

If you’re a Python beginner, please email me — I’ve just put together a new set of tutorials for 2021 that will help you get started with the basics.

Access method: private Xiaobian reply: information (click open Xiaobian portrait, there is a private letter in the upper right corner) group and development tools and installation package, as well as the system learning road map. So if you want to learn Python, it is necessary to listen to the teacher’s class and get Python benefits. If you want to learn Python, you can go to the teacher’s Weixin: the first group is Mengy, the second group is 7762. Put the above two groups of letters together in order, and she will arrange the learning.

Note:

The display effect may be different in different environments, whether the font displayed by the terminal is the same width font, the line height and line width displayed by the terminal, the width and height of the input and output images, and so on, all these will affect the display effect.

In addition, the character set used for the character drawing is 70 characters, which is the following line of code:

The more the type and number of characters, the more the color of the performance, the better the level of character painting will be, and you can repeatedly debug according to the effect of character painting.