Python character drawing is a simple and fun little program that is ideal for beginners to learn bi. The principle of python character painting generation is very simple. In a word, —- replaces the image pixels with different characters, thus transforming the image composed of pixels into character paintings composed of characters. In order to make the character painting display as similar as the image. Pixels with high grayscale values are represented by visually darker characters (such as $), and pixels with low grayscale values are represented by visually lighter characters

Running under python3, you can generate character drawings by entering images. The general principle is mentioned in the notes. I did not have a thorough understanding of the conversion relationship between pixels and symbols.

Run the command:

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

Here are the renderings:

If you don’t know anything about Python, please send me a message – I’ve just put together a new set of 2021 basic beginner and advanced tutorials.

There are also development tools and installation packages in the group, as well as the system learning roadmap. ** So if you want to learn Python, it is necessary to listen to the teacher’s class and receive the benefits of Python. If you want to learn Python, you can go to The weixin (same pronunciation) of Teacher Mengya: the front group is: Mengy, the back group is: 7762, and she will arrange to learn the above two groups of letters in order.

Note:

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

In addition, the character set used by the character drawing, there are 70 characters in total, which is the following line of code:

The more types and numbers of characters, the more colors will be displayed, and the better the layering of character painting will be. You can debug it repeatedly according to the effect of character painting.