Python character painting is a simple and interesting small program, which is very suitable for beginners to learn (Zhang) and learn (BI). The principle of Python character painting generation is very simple. In a word, it is to replace the picture pixels with different characters, so as to transform the picture composed of pixels into a character painting composed of characters. In order to make the character painting display effect the same as the picture as much as possible. Pixels with high gray values are represented by visually darker characters (such as $), and pixels with low gray values are represented by visually lighter characters
Running in Python 3, you can generate character pictures by inputting pictures. The general principle is mentioned in the notes. I didn’t have a deep understanding of the specific relationship between pixel and symbol conversion.
python3 draw.py –width 60 –height 30 test.png
The following is the rendering:
Python beginners can confide in me if they don’t understand anything – I just sorted out a set of 2021’s latest 0 basic introduction and advanced tutorials and shared them selflessly.
Access method: private letter editor’s reply: there are development tools, installation packages and system learning roadmap in the data (click on the small editor’s Avatar and send private letters in the upper right corner).Therefore, it is necessary for students who want to learn to listen to the teacher’s class and receive Python fulio. Students who want to learn can go to Wai Xin of Mengya teacher (homonym): the front group is mengy and the back group is 7762. Just combine the above two groups of letters in order, and she will arrange learning.
The display effect may be different in different environments. Whether the font displayed on the terminal is an equal width font, the line height and line width displayed on the terminal, the width and height of the input and output image, etc. all these will affect the display effect.
In addition, the character set used in the character drawing has a total of 70 characters, that is, the following line of code:
The more types and numbers of characters, the more colors they show, and the better the sense of hierarchy of character painting. You can debug them repeatedly according to the effect of character painting.