This article is participating in the “August More text challenge”, see the activity chain for details

Doraemon graphics drawing

Tool use

Development tool: pycharm development environment: python3.7, Windows10 using the tool kit: turtle

Project idea analysis

  • Draw the blue fat man in modules
  • Draw the head
  • Painted red scarf
  • Paint faces, noses, beards

Choose the right canvas The right canvas size

turtle.screensize(800, 600, "#F0F0F0")
turtle.pensize(3)
turtle.speed(20)
Copy the code

Screensize is used to set the canvas size and background color. The window and canvas are not the same concept. If the canvas is larger than the window, the scroll bar will appear.

I’m going to draw the blue fat man’s head and I’m going to draw a circle with the bottom half cut off

""" Draw a circle with the bottom half cut off """ turtle.penup() # Lift the pen Turtle.circle (150, 40) # Draw a circle with radius 150, Fillcolor ("#00a0de") # fillcolor turtle.begin_fill() # begin to fill turtle.circle(150, 280) # draw a circle, Radius 150, Angle 280 turtle.end_fill()Copy the code

Draw the blue fat man’s red scarf under the cut circle

def drawRedScarf(): """ draw scarf """ turtle.fillcolor("red") # fillcolor turtle.begin_fill() turtle.seth(0) # toward right turtle.fd(200) # forward 10 units turtle.circle(-5, 90) turtle.fd(10) turtle.circle(-5, 90) turtle.fd(207) turtle.circle(-5, 90) turtle.fd(10) turtle.circle(-5, 90) turtle.end_fill()Copy the code

Add blue Fat’s red nose to draw face data

""" """ turtle.forward(183) # forward 183 units turtle.fillcolor("white") # fillcolor for white turtle.begin_fill() # start filling turtle.left(45) # Turn left 45 degrees turtle.circle(120, 100) # The right side of the face turtle.seth(90) # Face up drawEye() # Draw the right eye Turtle.seth (180) # Face left turtle.penup() # Lift pen turtle.fd(60) # Forward 60 Turtle.pendown () # pen turtle.seth(90) # face up drawEye() # draw left eye turtle.penup() # penup turtle.seth(180) # face left turtle.fd(64) # Seth (215) # Change direction to Turtle.circle (120, Turtle.end_fill () # def drawRedNose(): FlyTo (-10, 158) turtle.fillcolor("red") # fillcolor turtle.begin_fill() turtle.circle(20) turtle.end_fill()Copy the code

Add the iconic cat mustache

flyTo(5, 148) turtle.seth(270) turtle.fd(100) turtle.seth(0) turtle.circle(120, 50) turtle.seth(230) turtle.circle(-120, 100) def beard(): """ Draw a beard, # flyTo(-37, 135) turtle.seth(165) turtle.fd(60) # flyTo(-37, 135) Turtle.seth (180) turtle.fd(60) # The third beard from the left flyTo(-37, 115) turtle.seth(193) Turtle.fd (60) # The first beard from the right flyTo(37, Turtle.seth (15) Turtle.fd (60) # flyTo(37, 125) Turtle.seth (0) Turtle.fd (60) # flyTo(37, 125) 115) turtle.seth(-13) turtle.fd(60)Copy the code

Add blue fat body outline plus two cute little hands

    flyTo(0, 0)
    turtle.seth(0)
    turtle.penup()
    turtle.circle(150, 50)
    turtle.pendown()
    turtle.seth(30)
    turtle.fd(40)
    turtle.seth(70)
    turtle.circle(-30, 270)
    turtle.fillcolor("#00a0de")
    turtle.begin_fill()
    turtle.seth(230)
    turtle.fd(80)
    turtle.seth(90)
    turtle.circle(1000, 1)
    turtle.seth(-89)
    turtle.circle(-1000, 10)
    turtle.seth(180)
    turtle.fd(70)
    turtle.seth(90)
    turtle.circle(30, 180)
    turtle.seth(180)
    turtle.fd(70)
    turtle.seth(100)
    turtle.circle(-1000, 9)
    turtle.seth(-86)
    turtle.circle(1000, 2)
    turtle.seth(230)
    turtle.fd(40)
    turtle.circle(-30, 230)
    turtle.seth(45)
    turtle.fd(81)
    turtle.seth(0)
    turtle.fd(203)
    turtle.circle(5, 90)
    turtle.fd(10)
    turtle.circle(5, 90)
    turtle.fd(7)
    turtle.seth(40)
    turtle.circle(150, 10)
    turtle.seth(30)
    turtle.fd(40)
    turtle.end_fill()
​
Copy the code

Refine blue Fat’s limbs and add blue Fat’s shoes

Seth (70) turtle.fillcolor("#FFFFFF") turtle.begin_fill() turtle.circle(-30) turtle.end_fill() # foot FlyTo (103.74, -182.59) turtle.seth(0) turtle.fillcolor("#FFFFFF") turtle.begin_fill() turtle.fd(15) turtle.circle(-15, 180) turtle.fd(90) turtle.circle(-15, 180) turtle.fd(10) turtle.end_fill() flyTo(-96.26, -182.59) turtle.seth(180) turtle.fillcolor("#FFFFFF") turtle.begin_fill() turtle.fd(15) turtle.circle(15, 180) turtle.fd(90) turtle.circle(15, 180) turtle.fd(10) turtle.end_fill() # right hand flyTo(-133.97, -91.81) turtle.seth(50) turtle.fillcolor("#FFFFFF") turtle.begin_fill() turtle.circle(30) turtle.end_fill()Copy the code

Place the magic pocket of the blue fat man and add the bell of the blue fat man to add touching eyes

# Pocket flyTo(-103.42, 15.09) turtle.seth(0) turtle.fd(38) turtle.seth(230) turtle.begin_fill() turtle.circle(90, 260) turtle.end_fill() flyTo(5, -40) turtle.seth(0) turtle.fd(70) turtle.seth(-90) turtle.circle(-70, Seth (0) turtle.fd(70) # Bellflyto (-103.42, 15.09) turtle.fd(90) turtle.seth(70) turtle.fillcolor("#ffd200") turtle.begin_fill() turtle.circle(-20) turtle.end_fill() turtle.seth(170) turtle.fillcolor("#ffd200") turtle.begin_fill() turtle.circle(-2, 180) turtle.seth(10) turtle.circle(-100, 22) turtle.circle(-2, 180) turtle.seth(180 - 10) turtle.circle(100, 22) turtle.end_fill() flyTo(-13.42, 15.09) Turtle.Seth (250) turtle.circle(20, 110) turtle.seth(90) turtle.fd(15) turtle.dot(10) flyTo(0, -150) drawBlackdrawEye()Copy the code

mapped

Easy source sharing

import turtle def flyTo(x, y): turtle.penup() turtle.goto(x, y) turtle.pendown() def drawEye(): Turtle.tracer (False) a = 2.5 for I in range(120): turtle.left(3) if 0 <= I < 30 or 60 <= I < 90: a -= 0.05 else: turtle.tracer(False) a = 2.5 for I in range(120): Turtle.left (3) if 0 <= I < 30 or 60 <= I < 90: a -= 0.05 else: Turtle.fd (a) turtle.tracer(True) def beard(): """ Draw a beard, # flyTo(-37, 135) turtle.seth(165) turtle.fd(60) # flyTo(-37, 135) Turtle.seth (180) turtle.fd(60) # The third beard from the left flyTo(-37, 115) turtle.seth(193) Turtle.fd (60) # The first beard from the right flyTo(37, Turtle.seth (15) Turtle.fd (60) # flyTo(37, 125) Turtle.seth (0) Turtle.fd (60) # flyTo(37, 125) 115) turtle.seth(-13) turtle.fd(60) def drawRedScarf(): """ draw scarf """ turtle.fillcolor("red") # fillcolor turtle.begin_fill() turtle.seth(0) # toward right turtle.fd(200) # forward 10 units turtle.circle(-5, 90) turtle.fd(10) turtle.circle(-5, 90) turtle.fd(207) turtle.circle(-5, 90) turtle.fd(10) turtle.circle(-5, 90) turtle.end_fill() def drawMouse(): flyTo(5, 148) turtle.seth(270) turtle.fd(100) turtle.seth(0) turtle.circle(120, 50) turtle.seth(230) turtle.circle(-120, 100) def drawRedNose(): flyTo(-10, Turtle.begin_fill () turtle.circle(20) turtle.end_fill() def drawBlackdrawEye(): turtle.seth(0) flyTo(-20, Turtle.fillcolor ("#000000") # fillcolor turtle.begin_fill() turtle.circle(13) turtle.end_fill() turtle.pensize(6) flyTo(20, 205) turtle.seth(75) turtle.circle(-10, 150) turtle.pensize(3) flyTo(-17, 200) turtle.seth(0) turtle.fillcolor("#ffffff") turtle.begin_fill() turtle.circle(5) turtle.end_fill() flyTo(0, 0) def drawFace(): """ """ turtle.forward(183) # forward 183 units turtle.fillcolor("white") # fillcolor for white turtle.begin_fill() # start filling turtle.left(45) # Turn left 45 degrees turtle.circle(120, 100) # The right side of the face turtle.seth(90) # Face up drawEye() # Draw the right eye Turtle.seth (180) # Face left turtle.penup() # Lift pen turtle.fd(60) # Forward 60 Turtle.pendown () # pen turtle.seth(90) # face up drawEye() # draw left eye turtle.penup() # penup turtle.seth(180) # face left turtle.fd(64) # Seth (215) # Change the direction toward Turtle. circle(120, 100) # change the left half of the face to turtle.end_fill() # def drawHead(): """ Draw a circle with the bottom half cut off """ turtle.penup() # Lift the pen Turtle.circle (150, 40) # Draw a circle with radius 150, Fillcolor ("#00a0de") # fillcolor turtle.begin_fill() # begin to fill turtle.circle(150, 280) # draw a circle, Radius 150, Angle 280 turtle.end_fill() def drawAll(): drawHead() drawRedScarf() drawFace() drawRedNose() drawMouse() beard() flyTo(0, 0) turtle.seth(0) turtle.penup() turtle.circle(150, 50) turtle.pendown() turtle.seth(30) turtle.fd(40) turtle.seth(70) turtle.circle(-30, 270) turtle.fillcolor("#00a0de") turtle.begin_fill() turtle.seth(230) turtle.fd(80) turtle.seth(90) turtle.circle(1000, 1) turtle.seth(-89) turtle.circle(-1000, 10) turtle.seth(180) turtle.fd(70) turtle.seth(90) turtle.circle(30, 180) turtle.seth(180) turtle.fd(70) turtle.seth(100) turtle.circle(-1000, 9) turtle.seth(-86) turtle.circle(1000, 2) turtle.seth(230) turtle.fd(40) turtle.circle(-30, 230) turtle.seth(45) turtle.fd(81) turtle.seth(0) turtle.fd(203) turtle.circle(5, 90) turtle.fd(10) turtle.circle(5, 90) turtle.fd(7) turtle.seth(40) turtle.circle(150, 10) turtle.seth(30) turtle.fd(40) turtle.end_fill() # left turtle.seth(70) turtle.fillcolor("#FFFFFF") turtle.begin_fill() Turtle.circle (-30) turtle.end_fill() # flyTo(103.74, Seth (0) turtle.fillcolor("#FFFFFF") turtle.begin_fill() turtle.fd(15) turtle.circle(-15, 180) turtle.fd(90) turtle.circle(-15, 180) turtle.fd(10) turtle.end_fill() flyTo(-96.26, -182.59) turtle.seth(180) turtle.fillcolor("#FFFFFF") turtle.begin_fill() turtle.fd(15) turtle.circle(15, 180) turtle.fd(90) turtle.circle(15, 180) turtle.fd(10) turtle.end_fill() # right hand flyTo(-133.97, -91.81) turtle.seth(50) turtle.fillcolor("#FFFFFF") turtle.begin_fill() turtle.circle(30) turtle.end_fill() # pocket FlyTo (-103.42, 15.09) turtle.seth(0) turtle.fd(38) turtle.seth(230) turtle.begin_fill() turtle.circle(90, 260) turtle.end_fill() flyTo(5, -40) turtle.seth(0) turtle.fd(70) turtle.seth(-90) turtle.circle(-70, Seth (0) turtle.fd(70) # Bellflyto (-103.42, 15.09) turtle.fd(90) turtle.seth(70) turtle.fillcolor("#ffd200") turtle.begin_fill() turtle.circle(-20) turtle.end_fill() turtle.seth(170) turtle.fillcolor("#ffd200") turtle.begin_fill() turtle.circle(-2, 180) turtle.seth(10) turtle.circle(-100, 22) turtle.circle(-2, 180) turtle.seth(180 - 10) turtle.circle(100, 22) turtle.end_fill() flyTo(-13.42, 15.09) Turtle.Seth (250) turtle.circle(20, 110) turtle.seth(90) turtle.fd(15) turtle.dot(10) flyTo(0, -150) drawBlackdrawEye() def main(): turtle.screensize(800, 600, "#F0F0F0") turtle.pensize(3) turtle.screen ().title(' Doraemon ') turtle.speed(15) drawAll() if __name__ == "__main__": main() turtle.mainloop()Copy the code

I am white and white I, a program yuan like to share knowledge ❤️

If you are not familiar with programming, you can leave a comment on this blog or you want to learn Python.