## [Python] on the double eleven, I'll draw a single dog for myself with the turtle

python double ll draw single

It's time for me to stand up

What kind of state is it to be single ？

All of us have been single ,

But maybe only a few people have actually experienced .

The content of the short video is totally fake , The whole process is one person's operation ,

You have to have a good cell phone 、 A good copywriting idea .

# Turtle

Turtle Kuo is Python A very popular function library of drawing image in language , Imagine a little turtle , On a horizontal axis x、 The vertical axis is y In the coordinate system of , From the origin (0,0) Position start , It's based on a set of function instructions , Moving in this plane coordinate system , So it draws a graph on its crawling path .

# Turtle function

There are many functions for manipulating turtle drawing , These functions can be divided into 3 Kind of ： One is the brush control function , One is motion control function , There is also a directional control function .

## Brush control function

Function name

effect

turtle.penup()

Lift up the brush. , No painting

turtle.pendown()

Drop the brush , Start painting , The first two appear in pairs

turtle.pencolor()

Painting colors

turtle.pensize()

Brush thickness

## Motion control function

Function name

effect

turtle.forward(d)

Move forward , Go straight ,d It can be negative

turtle.circle(r,extent=None)

With r Draw for radius extent Arc of angle ,extent It can be defaulted , By default, the whole circle is drawn .r Being positive , That is, draw on the left side of the forward direction , Negative , That is, draw on the right side .

## Directional control function

Function name

effect

Change the direction of travel , But not marching , For absolute angles

turtle.left(angel)

The turtle turns left ,angel The angle of rotation in the turtle's current direction of travel

turtle.right(angel)

The turtle turns right ,angel The angle of rotation in the turtle's current direction of travel

# Painting a single dog

```import turtle as t
t.screensize(500, 500)
t.pensize(5)
t.home()
t.seth(0)
t.pd() #pendown
t.color('black')
t.circle(20, 80) # 0
t.circle(200, 30) # 1
t.circle(30, 60) # 2
t.circle(200, 29.5) # 3
t.color('black')
t.circle(20, 60) # 4
t.circle(-150, 22) # 5
t.circle(-50, 10) # 6
t.circle(50, 70) # 7
# Determine the approximate position of the nose t.xcor and t.ycor Where the tortoise started
x_nose = t.xcor()
y_nose = t.ycor()
t.circle(30, 62) # 8
t.circle(200, 15) # 9
# 【 nose 】
t.pu() #penup
t.goto(x_nose, y_nose + 25)
t.seth(90)
t.pd()
t.begin_fill()
t.circle(8)
t.end_fill()
# 【 eyes 】
t.pu()
t.goto(x_nose + 48, y_nose + 55)
t.seth(90)
t.pd()
t.begin_fill()
t.circle(8)
t.end_fill()
# 【 Ears 】
t.pu()
t.color('#444444')
t.goto(x_nose + 100, y_nose + 110)
t.seth(182)
t.pd()
t.circle(15, 45)
t.color('black')
t.circle(10, 15)
t.circle(90, 70)
t.circle(25, 110)
t.rt(4)
t.circle(90, 70)
t.circle(10, 15)
t.color('#444444')
t.circle(15, 45)
# 【 The body 】
t.pu()
t.color('black')
t.goto(x_nose + 90, y_nose - 30)
t.seth(-130)
t.pd()
t.circle(250, 28)
t.circle(10, 140)
t.circle(-250, 25)
t.circle(-200, 25)
t.circle(-50, 85)
t.circle(8, 145)
t.circle(90, 45)
t.circle(550, 5)
# 【 tail 】
t.seth(0)
t.circle(60, 85)
t.circle(40, 65)
t.circle(40, 60)
t.lt(150) #left
t.circle(-40, 90)
t.circle(-25, 100)
t.lt(5)
t.fd(20)
t.circle(10, 60)
# 【 back 】
t.rt(80) #right
t.circle(200, 35)
# 【 a collar for a horse 】
t.pensize(20)
t.color('#F03C3F')
t.lt(10)
t.circle(-200, 25)
# 【 Love bell 】
t.pu()
t.fd(18)
t.lt(90)
t.fd(18)
t.pensize(6)
t.color('#FDAF17')
t.begin_fill()
t.lt(135)
t.fd(6)
t.right(180) # The brush turns around
t.circle(6, -180)
t.backward(8)
t.right(90)
t.forward(6)
t.circle(-6, 180)
t.fd(15)
t.end_fill()
# 【 The front leg 】
t.pensize(5)
t.pu()
t.color('black')
t.goto(x_nose + 100, y_nose - 125)
t.pd()
t.seth(-50)
t.fd(25)
t.circle(10, 150)
t.fd(25)
# 【 Posterior crus 】
t.pensize(4)
t.pu()
t.goto(x_nose + 314, y_nose - 125)
t.pd()
t.seth(-95)
t.fd(25)
t.circle(-5, 150)
t.fd(2)
t.hideturtle()
t.done()
```

The result is as follows ：

* This article has been included GitHub, Portal ~[1] , There are also large factory interview and complete examination points , welcome Star. *

### Reference

[1]

Portal ~: https://github.com/MaoliRUNsen/runsenlearnpy100

` Past highlights `