Suck the cat with code! This paper is participating in[Cat Essay Campaign]

1. Learn some properties of Python Turtle before you start drawing

Turtle. forward(distance) : move distance pixel length to the current paintbrush turtle.backward(distance) : move distance pixel length to the opposite direction of the current paintbrush turtle.right(degree) : Left (degree) : Counterclockwise degree turtle.left(degree) : counterclockwise degree Turtle.pendown () : Draws while moving, also draws turtle.goto(x,y) by default: Turtle.penup () : Draws a circle with a radius of positive (negative), indicating that the center of the circle is to the left (right) of the brush setx() : Sety () : Moves the current x axis to the specified position sety() : moves the current Y axis to the specified position Setheading (Angle) : sets the current orientation to Angle Home () : sets the current brush position to the origin, facing east. Dot (r) : Draws a dot with the specified diameter and color turtle.fillcolor(colorString) : Color (color1, color2): Also set pencolor=color1, Fillcolor =color2 Turtle.filling (): Returns whether it is currently filling or not turtle.begin_fill() : Ready to start filling the graph turtle.end_fill() : complete filling turtle.hideturtle() : Hide the pen's Turtle shape turtle.showTurtle () : Shows the pen's Turtle shapeCopy the code

To draw your favorite cat, let’s draw a cat to play with

Practice process

1. Initialization

Bgcolor ('Sky Blue')// Canvas background color pu() goto(60,100)// Initial position pensize(4)// Brush size pendown()// Draw graphics when movingCopy the code

2. Overall code

First the head, then the body, then the face and then the retouching

Def curvemove(): for I in range(200): Right (1) forward (0.1) def heart (x, y, s) : Begin_fill () left(140) curvemove() left(120) curvemove() End_fill () # initialize the brush canvas background # setup(600,600) BGColor ('Sky Blue') pu() goto(60,100) pensize(4) pendown() # Draw the left side of the cat's head oh for I in Seth (I) fd(3) Seth (145) fd(50) left(125) fd(50) for I in range(240,318,2): if I ==290: seth(190) fd(10) seth(10) fd(10) elif i==300: Seth (200) fd(10) Seth (20) fd(10) Seth (I) fd(3) # Draw the right side of the cat's head. fd(50) for i in range(-60,-138,-2): if i==-110: seth(-10) fd(10) seth(170) fd(10) elif i==-120: Seth (-20) fd(10) Seth (160) fd(10) Seth (I) fd(3) ## The head of our cat will be drawn here, Seth (-105) fd(5) pendown() fd(17) for I in range(130,106,-3): Seth (I) fd(2.5) for I in range(106,30,-10): Seth (I) fd(2) Seth (38) fd(25) Seth (135) fd(31) Seth (169) fd(6) Seth (270) fd(105) # pendown() seth(220) fd(48)#52 seth(250) fd(3) seth(270) fd(3) seth(290) fd(2) seth(-40) fd(44) seth(228) fd(20) seth(5) Pu () goto(-52,-84) Seth (133) pendown() fd(22) Seth (90) fd(2) Seth (60) fd(2) Seth (45) fd(29) Seth (0) fd(3) Seth (-93) fd(102) # pendown() begin_fill() circle(5) end_fill() pu() fd(108) Pendown () begin_fill() circle(5) end_fill() # color link pu() goto(60,24) pensize(6) Seth (225) pendown() fd(7) Pu () goto(70,24) Seth (225) pendown() fd(7) # left color pu() Pencolor ("pink") pensize(6) goto(-39,24) Seth (225) pendown() fd(7) # goto() pensize(4) pencolor("pink") goto(5,21) Seth (-45) pendown() fd(5) goto(5,21) Seth (225) fd(5) # Goto (-40,92) Seth (80) pendown() fillcolor("pink") Begin_fill () circle(14,360,3) end_fill() pu() goto(72,100) Seth (-74) pendown() begin_fill() circle(14,360,3) end_fill() Pensize (4) color('pink', 'pink') begin_fill() goto(-90,-35) seth(135) pendown() fd(25) seth(225) fd(45) seth(25) fd(15) seth(-80) pensize(2) Fd (15) Seth (55) fd(15) Seth (25) fd(10) Seth (-80) fd(15) Seth (75) fd(15) goto(-90,-35) end_fill() # goto(125,-30) seth(45) pendown() begin_fill() fd(25) seth(-45) fd(45) seth(155) fd(15) seth(-80) fd(15) seth(120) fd(17) Seth (170) fd(15) Seth (120) fd(17) goto(125,-30) end_fill() # # draw 5 hearts speed(100000) color('pink', 'pink') pensize(2) heart(0,140,0) heart(140,0,-30) heart(145,-85,-30) heart(-132,-85, -30) exit.onclick()  done()Copy the code

3. Effect display