Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to draw a funny expression with Python

Shulou Source: shulou.com Published: 2022-06-01 13:41:30 10月04日 Update

This article mainly shows you "how to draw a funny expression with Python". The content is easy to understand and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn this article "how to draw a funny expression with Python".

Everyone should know that Python's turtle library can draw pictures, so we use this library to draw a smirk.

As the expression on Wechat is small and looks inconvenient, I found a larger one on the Internet, as follows:

We can see that the components of this expression include: face frame (that is, the big circle), eyebrows, eye sockets, eyes, red cheeks, mouth, below we begin to draw these parts.

First, we draw a face frame, and the code implementation is as follows:

Penup ()

Goto (- 210J 0)

Seth (- 90)

Pendown ()

Pencolor ('# FFCC33')

Pensize (4)

Begin_fill ()

Circle (210360)

Fillcolor ('# FFFF99')

End_fill ()

Pencolor ('# 330033')

Take a look at the effect:

Then the eyebrow, the code implementation is as follows:

# left eyebrow

Penup ()

Pensize (4)

Goto (- 180140)

Pencolor ('# 585858')

Pendown ()

Seth (70)

Circle (- 60140)

# right eyebrow

Penup ()

Pensize (4)

Goto (180140)

Pencolor ('# 585858')

Pendown ()

Seth (110C)

Circle (60140)

Take a look at the effect:

Then draw the eye sockets and eyeballs, and the code is as follows:

# left orbit

Penup ()

Pensize (4)

Goto (- 180,090)

Pencolor ('# 909090')

Pendown ()

Seth (40)

Begin_fill ()

Circle (- 120,5080)

Penup ()

Goto (- 180,090)

Seth (- 130C)

Pendown ()

Circle (15110)

Seth (40)

Circle (- 1063.83)

Seth (30)

Circle (18105)

Fillcolor ('white')

End_fill ()

# right orbital

Penup ()

Goto (20pl 90)

Pendown ()

Seth (40)

Begin_fill ()

Circle (- 120,5080)

Penup ()

Goto (20pl 90)

Pendown ()

Seth (- 130C)

Circle (15110)

Seth (40)

Circle (- 1063.83)

Seth (30)

Circle (18105)

Fillcolor ('white')

End_fill ()

# eyeballs

Pensize (2)

Penup ()

Goto (30pr 83)

Pendown ()

Begin_fill ()

Circle (8360)

Fillcolor ('black')

End_fill ()

Penup ()

Goto (- 1708,83)

Pendown ()

Begin_fill ()

Circle (8360)

Fillcolor ('black')

End_fill ()

Take a look at the effect:

Then draw red cheeks, and the code is implemented as follows:

Pensize (1)

Pencolor ('LightSalmon')

Begin_fill ()

Penup ()

Goto (- 160550)

Pendown ()

Seth (- 90)

For i in range (2):

For j in range (10):

Forward (j)

Left (9)

For j in range (1010, 010, 10):

Forward (j)

Left (9)

Fillcolor ('LightSalmon')

End_fill ()

Pensize (1)

Pencolor ('LightSalmon')

Begin_fill ()

Penup ()

Goto (40 and 50)

Pendown ()

Seth (- 90)

For i in range (2):

For j in range (10):

Forward (j)

Left (9)

For j in range (1010, 010, 10):

Forward (j)

Left (9)

Fillcolor ('LightSalmon')

End_fill ()

Hideturtle ()

Take a look at the effect:

Finally, we draw the mouth, and the code is implemented as follows:

Pensize (5)

Penup ()

Goto (- 1501m / m / 30)

Pencolor ('# 585858')

Pendown ()

Seth (- 90)

Circle (150180)

Take a look at the end result:

The above is all the contents of the article "how to draw a funny expression with Python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Facial expressions codes effects eye sockets funny content eyebrows eyes articles parts learning help circles that is size easy to understand more organization eyebrows knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple macOS MariaDB OPPO Reno Shulou Technology