This is my 12th day of the August Genwen Challenge

preface

Today I would like to share a picture of pikachu with you. I hope you have a happy day. Let’s have a good time

Results show

The development tools

Python version: 3.6.4

Related modules:

Turtle module.

Environment set up

Install Python and add it to the environment variables.

Introduction of the principle

Turtle documents:

https://docs.python.org/zh-cn/3.7/library/turtle.html
Copy the code

If you don’t understand the code, please refer to the turtle documentation.

Seth: Set the orientation;

Fd: forward;

Circle c.

Fillcolor: fillcolor;

Pensize: brush thickness;

Speed C.

Hideturtle:

Screensize: sets the screensize.

Begin_fill: begin to fill;

End_fill: end filling;

Penup: the pen is lifted;

Pendown: The pen falls (moving at this point draws a line).

Define a function to draw a nose:

# to draw the nose
def drawNose() :
	turtle.penup()
	turtle.seth(90)
	turtle.fd(100)
	turtle.pendown()
	turtle.begin_fill()
	turtle.fillcolor('black')
	turtle.seth(45)
	turtle.fd(25)
	turtle.seth(135)
	turtle.circle(25.95)
	turtle.seth(315)
	turtle.fd(25)
	turtle.end_fill()
Copy the code

And then the function to draw the eye:

# draw eyes
def drawEyes(seth, fd, r) :
	turtle.penup()
	turtle.seth(seth)
	turtle.fd(fd)
	turtle.pendown()
	turtle.begin_fill()
	turtle.fillcolor('black')
	turtle.circle(50)
	turtle.end_fill()
	turtle.penup()
	turtle.circle(50, r)
	turtle.pendown()
	turtle.begin_fill()
	turtle.fillcolor('white')
	turtle.circle(20)
	turtle.end_fill()
Copy the code

And then the face painting:

# painted face
def drawFace(seth, fd) :
	turtle.penup()
	turtle.seth(seth)
	turtle.fd(fd)
	turtle.pendown()
	turtle.begin_fill()
	turtle.fillcolor('red')
	turtle.circle(70)
	turtle.end_fill()
Copy the code

Draw the mouth:

# drawing mouth
def drawLip() :
	turtle.penup()
	turtle.seth(135)
	turtle.fd(250)
	turtle.pendown()
	turtle.seth(-300)
	turtle.circle(30, -65)
	turtle.begin_fill()
	turtle.fillcolor('Firebrick')
	turtle.seth(165)
	turtle.fd(140)
	turtle.seth(195)
	turtle.fd(140)
	turtle.seth(-360)
	turtle.circle(30, -65)
	turtle.penup()
	turtle.seth(-60)
	turtle.circle(30.65)
	turtle.pendown()
	turtle.seth(-70)
	turtle.fd(240)
	turtle.circle(55.140)
	turtle.seth(70)
	turtle.fd(240)
	turtle.end_fill()
	turtle.seth(-110)
	turtle.fd(80)
	turtle.begin_fill()
	turtle.fillcolor('Firebrick')
	turtle.seth(120)
	turtle.circle(120.123)
	turtle.seth(-70)
	turtle.fd(165)
	turtle.circle(55.140)
	turtle.seth(72)
	turtle.fd(165)
	turtle.end_fill()
Copy the code

And then I’ll draw it after I initialize it in the main function

This is the end of the article, thank you for watching, Python paint, next article share a five-star red flag

To thank you readers, I’d like to share some of my recent programming favorites to give back to each and every one of you in the hope that they can help you.

Dry goods mainly include:

① Over 2000 Python ebooks (both mainstream and classic books should be available)

②Python Standard Library (Most Complete Chinese version)

③ project source code (forty or fifty interesting and classic practice projects and source code)

④Python basic introduction, crawler, Web development, big data analysis video (suitable for small white learning)

⑤ A Roadmap for Learning Python

All done~ See personal homepage introduction to obtain the complete source code.