Tuttle series: villains launch love, express their words, and an arrow pierces the heart. All you want is in this small program ~ (super value)

Introduction

"Because of you, I am willing to be a better person and don't want to be your burden, so I work hard,

Just to prove that I'm good enough for you. " - "listening"

Hello, hello! I'm kimiko~

I have written a confession copy before: Tuttle draws many source code projects of villain, love and villain love! And children's shoes, remember

Yeah? If you don't remember, you can go to Kangkang again. The link is as follows:

If I have time today, I want to upgrade the project of villain launching love. Want to learn - follow Xiaobian

Make a noise~

text

Before drawing, it is also necessary to understand the basic operation. The operation can be divided into three categories: motion operation, setting operation and global control

Operation. I didn't know what was mentioned in that small project before. Let's do it again.

1) Brush movement operation


turtle.forward(distance)

turtle.fd(distance)

Moves distance pixels in the direction of the current brush

turtle.backward(distance)

turtle.back(distance)

turtle.bk(distance)

Moves distance pixels in the opposite direction of the current brush

turtle.right(degree)

turtle.rt(degree)

Rotate degree ° clockwise

turtle.left(degree)

turtle.lt(degree)

Rotate degree ° counterclockwise

turtle.theading(angle)

turtle.th(angle)

Set the brush direction to angle

Standard mode: 0 - east 90 - North 180 - West 270 - South

Sign mode 0 - North 90 - east 180 - South 270 - West

turtle.pendown()

turtle.down()

turtle.pd()

Write

turtle.penup()

turtle.up()

turtle.pu()

write

turtle.goto(x,y)

turtle.steps(x,y)

turtle.setposition(x,y)

Move the brush to coordinates x, y
turtle.home()Move the brush to the coordinate origin

2) Brush setting operation

turtle.fillcolor(colorstring)The fill color of the drawing
turtle.color(color1, color2)Set pencolor = Color1 and fillcolor = color2 at the same time
turtle.filling()Returns whether it is currently filled
turtle.begin_fill()Ready to start filling the drawing
turtle.end_fill()Filling is completed;
turtle.hideturtle()Hide arrow display;
turtle.showturtle()Do not draw graphics when moving. Lift the pen for drawing in another place

3) Global operation

turtle.clear()Clear the turtle window, but the position and status of the turtle will not change
turtle.reset()Clear the window and reset the turtle state to the initial state
turtle.undo()Undo the last turtle action
turtle.isvisible()Returns whether the current turtle is visible
stamp()Copy current drawing
turtle.write(s[,font=("font-name",font_size,"font_type")])Write text, s is the text content, font is the font parameter, which is the font name, size and type respectively; Font is optional, and the parameter of font is also optional


1, Upgrade project

1) Effect display (video display at the end of the article)

1.1 interface countdown——

1.2Interface text——

1.3 result display——

2) The code display steps are as follows

2.1 draw villains and launch love

def draw_people(x, y):
    turtle.penup()
    turtle.goto(x, y)
    turtle.pendown()
    turtle.pensize(2)
    turtle.color('black')
    turtle.setheading(0)
    turtle.circle(35, 360)
    turtle.penup()
    turtle.pensize(3)
    turtle.setheading(90)
    turtle.fd(45)
    turtle.setheading(180)
    turtle.fd(20)
    turtle.setheading(0)
    turtle.fd(35)
    turtle.pendown()
    turtle.circle(4, 360)
    turtle.penup()
    turtle.goto(x, y)
    turtle.pensize(2)
    turtle.setheading(0)
    turtle.fd(20)
    turtle.setheading(90)
    turtle.fd(20)
    turtle.setheading(-90)
    turtle.pendown()
    turtle.circle(5, 180)
    turtle.penup()
    turtle.goto(x, y)
    turtle.setheading(-90)
    turtle.pendown()
    turtle.fd(20)
    turtle.setheading(0)
    turtle.fd(35)
    turtle.setheading(60)
    turtle.fd(10)
    turtle.penup()
    turtle.goto(x, y)
    turtle.setheading(-90)
    turtle.pendown()
    turtle.fd(40)
    turtle.setheading(0)
    turtle.fd(35)
    turtle.setheading(-60)
    turtle.fd(10)
    turtle.penup()
    turtle.goto(x, y)
    turtle.setheading(-90)
    turtle.pendown()
    turtle.fd(60)
    turtle.setheading(-135)
    turtle.fd(60)
    turtle.bk(60)
    turtle.setheading(-45)
    turtle.fd(30)
    turtle.setheading(-135)
    turtle.fd(35)
    turtle.penup()

2.2 draw an arrow through the heart

def draw_heart(size):
    turtle.color('red', 'pink')
    turtle.pensize(2)
    turtle.pendown()
    turtle.setheading(150)
    turtle.begin_fill()
    turtle.fd(size)
    turtle.circle(size * -3.745, 45)
    turtle.circle(size * -1.431, 165)
    turtle.left(120)
    turtle.circle(size * -1.431, 165)
    turtle.circle(size * -3.745, 45)
    turtle.fd(size)
    turtle.end_fill()


# Draw arrow feather
def draw_feather(size):
    angle = 30  # Inclination of arrow
    feather_num = size // 6 # number of feathers
    feather_length = size // 3 # feather length
    feather_gap = size // 10 # feather spacing
    for i in range(feather_num):
        draw_line(feather_gap, angle + 180, False)  # Arrow handle, no turning back
        draw_line(feather_length, angle + 145, True)  # Wings, turn back
    draw_line(feather_length, angle + 145, False)
    draw_line(feather_num * feather_gap, angle, False)
    draw_line(feather_length, angle + 145 + 180, False)
    for i in range(feather_num):
        draw_line(feather_gap, angle + 180, False)  # Arrow handle, no turning back
        draw_line(feather_length, angle - 145, True)  # Wings, turn back
    draw_line(feather_length, angle - 145, False)
    draw_line(feather_num * feather_gap, angle, False)
    draw_line(feather_length, angle - 145 + 180, False)


# Draw an arrow through the heart. At last, the head of the arrow is not drawn. It is replaced by a turtle
def arrow_heart(x, y, size):
    go_start(x, y, False)
    draw_heart(size * 1.15)
    turtle.setheading(-150)
    turtle.penup()
    turtle.fd(size * 2.2)
    draw_heart(size)
    turtle.penup()
    turtle.setheading(150)
    turtle.fd(size * 2.2)
    turtle.color('black')
    draw_feather(size)
    turtle.pensize(4)
    turtle.setheading(30)
    turtle.pendown()
    turtle.fd(size * 2)
    turtle.penup()
    turtle.setheading(29)
    turtle.fd(size * 5.7)
    turtle.color('black')
    turtle.pensize(4)
    turtle.pendown()
    turtle.fd(size * 1.2)

2.3 display countdown 3-1

def draw_0(i):
    turtle.speed(0)
    turtle.penup()
    turtle.hideturtle()  # Hide arrow display
    turtle.goto(-50, -100)
    turtle.color('red')
    write = turtle.write(i, font=('Song typeface', 200, 'normal'))
    time.sleep(1)

2.4 show cute and accept

def draw_1():
    turtle.penup()
    turtle.hideturtle()  # Hide arrow display
    turtle.goto(-250, 0)
    turtle.color('red')
    write = turtle.write('Cute, take it', font=('Song typeface', 60, 'normal'))
    time.sleep(2)

2.5 display ❤ Qinghuan in the world ❤

def draw_3():
    turtle.penup()
    turtle.hideturtle()  # Hide arrow display
    turtle.goto(-220, 50)
    turtle.color('red')
    write = turtle.write('❤human world', font=('Song typeface', 60, 'normal'))
    turtle.penup()
    turtle.goto(0, -50)
    write = turtle.write('Qinghuan❤', font=('Song typeface', 60, 'normal'))
    time.sleep(2)

2.6 display an arrow through the heart and text wood ❤ Fans

def draw_4():
    turtle.speed(10)
    turtle.penup()
    turtle.goto(-210, -200)
    turtle.color('blue')
    turtle.pendown()
    turtle.write('Muzi      Fans', font=('wisdom', 50, 'normal'))
    turtle.speed(1)
    turtle.penup()
    turtle.color("red")
    turtle.goto(-31, -200)
    turtle.write('❤', font=('wisdom', 50, 'normal'))
    arrow_heart(20, -60, 51)
    turtle.showturtle()

3) The video display effect is as follows

Turtle collection applet: Here's everything you want~

summary

OK, OK ~ this is a combined applet. Hey, do you like it? If you don't like it, continue to upgrade you next time~

🎯 Complete free source code collection: find me!

Didi, I can acridine!

🎉 Recommended reading in previous periods——

Item 1.5: villain's love confession (including multiple source codes)

My good brother asked me what cool way to express myself? Schedule [white source code]

Item 1.9: confession collection 💘

[collection of Python expressing love] - "the story is very long. I'll make a long story short. I like you for a long time" (♡ ʟ ᴏᴠᴇ ᴜ ᴛ ʜʀ ᴇᴇ ᴛ ʜ ᴏᴜsᴀ ɴ ᴅ♡)

Project 2.0} confession collection (multiple source codes)

[confession collection] confession Copy + applet is ready. Where can I get the object? (including multiple source codes) take it.

Project 1.0 fireworks Rose (including multiple source codes)

Python confession Code: "all the fireworks on the starry and moonlit nights belong to you, and I belong to you" (fireworks are in full bloom, with roses outside)

Project 1.1 Love Guide (including multiple source codes)

[Python love guide] two small programs for sweetness burst table are released - are you afraid you can't find an object?

🎄 Article summary——

Item 1.0 Python-2021 | summary of existing articles | continuously updated. It's enough to read this article directly

(more content + source code are summarized in the article!! welcome to read ~)

Keywords: Python turtle

Added by cvjacques on Sat, 01 Jan 2022 14:40:10 +0200