[Turtle series] for my birthday, the object gave me a golden flag. It says "Happy Birthday".

Keywords: Python turtle

   Introduction

​see? Recently, my brother's partner is going to have a birthday. He came to me to get lessons - there must be various ways to make up that story.

Now I wrote a questionnaire and sent it to my wechat friends, as well as this kind of birthday gift, which really made me laugh all night. Let's have a look!

Look at the different birthday presents——

🎂 khdudb: you can't imagine that my boyfriend sent me a brocade flag on my birthday. It clearly says "Happy Birthday" in four big characters. I always think my boyfriend is a straight man. Good. This time there is evidence. After all, looking at the blessing brocade flag of "Happy Birthday" always reminds me of the "wonderful hand rejuvenation" hanging in the hospital.

Haha, Miss haha, your boyfriend may be really straight, but you must be relieved. After all, he didn't give you a "wonderful hand".

🎂 Bai pangzi: I fell in love with the male god for a year. I gave me a gift on my birthday. When I opened it, I thought it was a love letter. The result was "sister, I've noticed you for a long time. Please don't stare at me. I don't like you. I have a girlfriend." what did you think I should say at that time?

Although I don't know why your male God doesn't like you, because he is my fan representative, I want to tell you that I like you, ha ha ha.

🎂 Ghost: on my birthday, I said I had a surprise for me, and then took out a box of cakes. I was very happy. I thought it was a net red cake. It could pull out money. As a result, it was really a net red cake. It would fly and paste people's face with a click of cream. I almost became an ex boyfriend.

Ha ha ha, you should know that he loves you for sure. After all, the cream paste face is also a warm experience~

🎂 Sister Lulu: on my birthday, I came back from a dusty place. I wondered if he would surprise me. He drew a cake on the wall of his room and wrote happy birthday.

Who else has received more wonderful gifts than this? What you received is still kind. What I received was a fake cake painted on the wall.

After identification, your boyfriend is a straight man. Such an excellent surprise is really scary...

Ha ha ha! Here are some short stories to give you a busy time to knock the code! Now let's talk about Xiaobian's views ~ what's better for a birthday gift?

text

Actually! It must be a gift for your birthday! What gift? 🎂🎂🎂🎂🎂🎂

​

First of all, don't ask the object? Why? Because the general answer she would say, "you look to buy?" as long as you ask this sentence, the activity in your heart is you look. For so long, you don't even know what I like... Balabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabalabala! Do not spray.

Every time a friend's birthday, Xiaobian sends a red envelope directly ~ I feel this is more practical ha ha ha ~ how much do you ask me?

The more the better, the happier the person who receives it! This is absolutely not wrong~

Ah - it seems that if you send red envelopes directly every year, you don't pay much attention to it. Of course - you still lack the necessities for your birthday 🎂🎂🎂🎂🎂🎂 Cake!

​

Start typing Code:

import turtle as t
import math as m
import random as r


def drawX(a, i):
    angle = m.radians(i)
    return a * m.cos(angle)


def drawY(b, i):
    angle = m.radians(i)
    return b * m.sin(angle)



t.bgcolor("#d3dae8")
t.setup(1000, 800)
t.penup()
t.goto(150, 0)
t.pendown()
# 1
t.pencolor("white")
t.begin_fill()
for i in range(360):
    x = drawX(150, i)
    y = drawY(60, i)
    t.goto(x, y)
t.fillcolor("#fef5f7")
t.end_fill()
# 2
t.begin_fill()
for i in range(180):
    x = drawX(150, -i)
    y = drawY(70, -i)
    t.goto(x, y)
for i in range(180, 360):
    x = drawX(150, i)
    y = drawY(60, i)
    t.goto(x, y)
t.fillcolor("#f2d7dd")
t.end_fill()
# 3
t.pu()
t.goto(120, 0)
t.pd()
t.begin_fill()
for i in range(360):
    x = drawX(120, i)
    y = drawY(48, i)
    t.goto(x, y)
t.fillcolor("#cbd9f9")
t.end_fill()
# 4
t.begin_fill()
t.pencolor("#fee48c")
for i in range(540):
    x = drawX(120, i)
    y = drawY(48, i) + 70
    t.goto(x, y)
t.goto(-120, 0)
t.fillcolor("#cbd9f9")
t.end_fill()
# 5
t.pu()
t.goto(120, 70)
t.pd()
t.pencolor("#fff0f3")
t.begin_fill()
for i in range(360):
    x = drawX(120, i)
    y = drawY(48, i) + 70
    t.goto(x, y)
t.fillcolor("#fff0f3")
t.end_fill()
# 6
t.pu()
t.goto(110, 70)
t.pd()
t.pencolor("#fff9fb")
t.begin_fill()
for i in range(360):
    x = drawX(110, i)
    y = drawY(44, i) + 70
    t.goto(x, y)
t.fillcolor("#fff9fb")
t.end_fill()
# 14
t.pu()
t.goto(120, 0)
t.pd()
t.begin_fill()
t.pencolor("#ffa79d")
for i in range(180):
    x = drawX(120, -i)
    y = drawY(48, -i) + 10
    t.goto(x, y)
t.goto(-120, 0)
for i in range(180, 360):
    x = drawX(120, i)
    y = drawY(48, i)
    t.goto(x, y)
t.fillcolor("#ffa79d")
t.end_fill()
# 8
t.pu()
t.goto(120, 70)
t.pd()
t.begin_fill()
t.pensize(4)
t.pencolor("#fff0f3")
for i in range(1800):
    x = drawX(120, 0.1 * i)
    y = drawY(-18, i) + 10
    t.goto(x, y)
t.goto(-120, 70)
t.pensize(1)
for i in range(180, 360):
    x = drawX(120, i)
    y = drawY(48, i) + 70
    t.goto(x, y)
t.fillcolor("#fff0f3")
t.end_fill()

t.pu()
t.goto(-56, 180)
t.pd()
t.pencolor("#b1c9e9")
t.begin_fill()
for i in range(360):
    x = drawX(4, i) - 60
    y = drawY(1, i) + 120
    t.goto(x, y)
t.goto(-56, 170)
for i in range(540):
    x = drawX(4, i) - 60
    y = drawY(1, i) + 170
    t.goto(x, y)
t.goto(-64, 120)
t.fillcolor("#b1c9e9")
t.end_fill()
t.pencolor("white")
t.pensize(2)
for i in range(1, 6):
    t.goto(-56, 120 + 10 * i)
    t.pu()
    t.goto(-64, 120 + 10 * i)
    t.pd()
t.pu()
t.goto(-60, 170)
t.pd()
t.goto(-60, 180)
t.pensize(1)
#
t.pu()
t.goto(-56, 190)
t.pd()
t.pencolor("#f1add1")
t.begin_fill()
for i in range(360):
    x = drawX(4, i) - 60
    y = drawY(10, i) + 190
    t.goto(x, y)
t.fillcolor("#f1add1")
t.end_fill()

t.pu()
t.goto(0, 130)
t.pd()
t.pencolor("#b1c9e9")
t.begin_fill()
for i in range(360):
    x = drawX(4, i)
    y = drawY(1, i) + 130
    t.goto(x, y)
t.goto(4, 180)
for i in range(540):
    x = drawX(4, i)
    y = drawY(1, i) + 180
    t.goto(x, y)
t.goto(-4, 130)
t.fillcolor("#b1c9e9")
t.end_fill()
t.pencolor("white")
t.pensize(2)
for i in range(1, 6):
    t.goto(4, 130 + 10 * i)
    t.pu()
    t.goto(-4, 130 + 10 * i)
    t.pd()
t.pu()
t.goto(0, 180)
t.pd()
t.goto(0, 190)
t.pensize(1)
#
t.pu()
t.goto(4, 200)
t.pd()
t.pencolor("#f1add1")
t.begin_fill()
for i in range(360):
    x = drawX(4, i)
    y = drawY(10, i) + 200
    t.goto(x, y)
t.fillcolor("#f1add1")
t.end_fill()
# 16
t.pu()
t.goto(30, 110)
t.pd()
t.pencolor("#b1c9e9")
t.begin_fill()
for i in range(360):
    x = drawX(4, i) + 30
    y = drawY(1, i) + 110
    t.goto(x, y)
t.goto(34, 160)
for i in range(540):
    x = drawX(4, i) + 30
    y = drawY(1, i) + 160
    t.goto(x, y)
t.goto(26, 110)
t.fillcolor("#b1c9e9")
t.end_fill()
t.pencolor("white")
t.pensize(2)
for i in range(1, 6):
    t.goto(34, 110 + 10 * i)
    t.pu()
    t.goto(26, 110 + 10 * i)
    t.pd()

t.goto(30, 160)
t.pd()
t.goto(30, 170)
t.pensize(1)
#
t.pu()
t.goto(34, 180)
t.pd()
t.pencolor("#f1add1")
t.begin_fill()
for i in range(360):
    x = drawX(4, i) + 30
    y = drawY(10, i) + 180
    t.goto(x, y)
t.fillcolor("#f1add1")
t.end_fill()
# 17
t.pu()
t.goto(-30, 110)
t.pd()
t.pencolor("#b1c9e9")
t.begin_fill()
for i in range(360):
    x = drawX(4, i) - 30
    y = drawY(1, i) + 110
    t.goto(x, y)
t.goto(-26, 160)
for i in range(540):
    x = drawX(4, i) - 30
    y = drawY(1, i) + 160
    t.goto(x, y)
t.goto(-34, 110)
t.fillcolor("#b1c9e9")
t.end_fill()
t.pencolor("white")
t.pensize(2)
for i in range(1, 6):
    t.goto(-26, 110 + 10 * i)
    t.pu()
    t.goto(-34, 110 + 10 * i)
    t.pd()
t.pu()

t.pd()
t.goto(-30, 170)
t.pensize(1)
#
t.pu()
t.goto(-26, 180)
t.pd()
t.pencolor("#f1add1")
t.begin_fill()
for i in range(360):
    x = drawX(4, i) - 30
    y = drawY(10, i) + 180
    t.goto(x, y)
t.fillcolor("#f1add1")
t.end_fill()

t.pu()
t.goto(0, 0)
t.fd(-240)
t.left(90)
t.fd(190)
t.pd()
t.write("Happy Birthday\n\n", font=("Curlz MT", 50))
t.write("To  Cutie", font=("Curlz MT", 20))
t.done()

The effect is as follows——

Send it to your friends after packing ~ of course, it's more suitable for red envelopes~

summary

🎂 Happy birthday, the star is the love letter from the Milky way to the moon. You are a gift from the world to me!

hey! What about? Want to try the code? Welcome!

The complete project source code free collar: attention to the Xiaobian official account: Python Gu Muzi

Your support is my biggest motivation!!

Posted by derekbelcher on Mon, 01 Nov 2021 17:33:53 -0700