♚ \
Ahab grocery store, dedicated to Python development technology, regular punching LeetCode, training programming skills
Expression “package” is now a very popular way of communication, words can’t express or through a picture can not easy to express emotions to representation, expression package once born, dominated the social circle of the Chinese people, especially young people, their way of social networking is the so-called “days don’t chat and figure a must fight”, almost any dialog will appear expression package, If you don’t agree with each other, you may send a few memes in the chat, but there will always be some misunderstandings, such as the picture below
A lot of friends mistakenly think that this is also made by me in Python after seeing this emoticon. In fact, it is not. This picture is just a common emoticon on the Internet, but today I will use Python to make several emoticon. \
Today’s emojis are made using the Turtle library as mentioned before. We can learn more advanced grammar from Turtle in addition to drawing Peppa. Today’s case is a little review. Without further ado, picture above \
\
Turtle this is a facepap emoji, which can express thousands of emotions running through it, using Turtle, this image can be divided into the following parts: face, mouth, teeth, tears on both sides, fingers and wrist, complete code and syntax but not much explanation, post a code for drawing faces.
1# painted face
2turtle.speed(5)
3turtle.setup(900.600.200.200)
4turtle.pensize(5)
5turtle.right(90)
6turtle.penup()
7turtle.fd(100)
8turtle.left(90)
9turtle.pendown()
10turtle.begin_fill()
11turtle.pencolor("#B26A0F") # head side color
12turtle.circle(150)
13turtle.fillcolor("#F9E549") # face color
14turtle.end_fill()
Copy the code
The second picture is a cross-eyed smile, you know what it meansThe complete code of these two emoticons has been uploaded to the background of the official account. You only need to reply [emoticons] in the background of the official account to obtain them. \
\
Take a look at the third picture, which is generated using PIL library. In fact, these two pictures are put together. First of all, we need to find two pictures, one for the background and one for the expression. We used the cute panda head as the background, and then tried to add curator Kim’s hip-hop face to the background.
Now we need to superimpose Curator Jin’s expression on the background picture of the panda head. It is important to control the superposition of Curator Jin’s expression in the code, otherwise other Outlines will be covered.
1from PIL import Image,ImageDraw,ImageFont
2
3img = Image.open("640.jpg")
4jgz = Image.open("641.jpg")
5img.paste(jgz,(63.46))
Copy the code
\
There is some blank space at the bottom of the picture, we can add some text.
1from PIL import Image,ImageDraw,ImageFont
2
3img = Image.open("640.jpg")
4jgz = Image.open("641.jpg")
5img.paste(jgz,(63.46))
6
7# Control the overlay position of the emoticons
8draw = ImageDraw.Draw(img)
9font = ImageFont.truetype("simyou.TTF".24)
10draw.text((16.200),"Hi! I feel like I've reached my climax!", fill = (0.0.0), font = font)
11# control where text is added
12img.show()
13img.save("Generated memes. JPG")
Copy the code
Ok basic so, interested in the expression of small partners can follow the following way to obtain the source code.
\
Get the whole source code
\
Long press to follow the public account below, reply emoticons can be obtained
\
\
§ § \
Python Chinese community as a decentralized global technology community, to become the world’s 200000 Python tribe as the vision, the spirit of Chinese developers currently covered each big mainstream media and collaboration platform, and ali, tencent, baidu, Microsoft, amazon and open China, CSDN industry well-known companies and established wide-ranging connection of the technical community, Have come from more than 10 countries and regions tens of thousands of registered members, members from the Ministry of Public Security, ministry of industry, tsinghua university, Beijing university, Beijing university of posts and telecommunications, the People’s Bank of China, the Chinese Academy of Sciences, cicc, huawei, BAT, represented by Google, Microsoft and other government departments, scientific research institutions, financial institutions, and well-known companies at home and abroad, nearly 200000 developers to focus on the platform.
\
More recommended
\
Python Data Visualization: netease Cloud Music Playlist \
\
Python analysis of social networks in The Romance of The Three Kingdoms \
\
Use Python to crawl financial market data \
\
Build CNN model to crack website captcha \
\
Image recognition with Python (OCR)
\
Email: [email protected]
\
**** Free membership of the Data Science Club ****