-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHBD
More file actions
147 lines (114 loc) · 3.52 KB
/
HBD
File metadata and controls
147 lines (114 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#This is a Python code to draw a three layer cake with a HBD wish
#There are confettis added
#Customize the wish by adding the name you want
#The colours can be easily changes according to your preferences
#Go to this link to get more colours; https://cs111.wellesley.edu/labs/lab02/colors
import turtle
import random
# Set the background color to black
#sc = turtle.Screen()
#turtle.colormode(255)
#sc.bgcolor(64,64,64)
turtle.bgcolor("black")
# Create a turtle object
my_turtle = turtle.Turtle()
# Set the turtle's shape to a turtle
my_turtle.shape("turtle")
# Set the turtle's color to green
my_turtle.color("green")
# Move the turtle to the starting position
my_turtle.penup()
my_turtle.goto(-150, 0)
my_turtle.pendown()
# Set the turtle's pen color to red
my_turtle.pencolor("yellow")
# Write the word "Happy"
my_turtle.write("Happy", font=("Arial", 36, "bold"))
# Move the turtle to the next position
my_turtle.penup()
my_turtle.goto(-50, -50)
my_turtle.pendown()
# Set the turtle's pen color to blue
my_turtle.pencolor("plum")
# Write the word "Birthday"
my_turtle.write("Birthday", font=("Arial", 40, "bold"))
# Move the turtle to the next position
my_turtle.penup()
my_turtle.goto(100, -150)
my_turtle.pendown()
# Set the turtle's pen color back to red
my_turtle.pencolor("red")
# Write the name
my_turtle.write("Name", font=("Arial", 65, "bold"))
# Move the turtle to the next position
my_turtle.penup()
my_turtle.goto(-250, -180)
my_turtle.pendown()
# Set the turtle's pen color back to red
my_turtle.pencolor("white")
# Write the word "Have a Blast BD"
my_turtle.write("May you enjoy a big slice of cake on your special day this year!!!!", font=("Time New Roman",12,"italic"))
# Function to draw a layer of the cake at a given position
def draw_cake_layer(x, y, color):
my_turtle.penup()
my_turtle.goto(x, y)
my_turtle.pendown()
my_turtle.fillcolor(color)
my_turtle.begin_fill()
for _ in range(2):
my_turtle.forward(200)
my_turtle.right(90)
my_turtle.forward(50)
my_turtle.right(90)
my_turtle.end_fill()
# Draw a three-layer cake
draw_cake_layer(-100, 150, "palegreen")
draw_cake_layer(-100, 200, "pink")
draw_cake_layer(-100, 250, "yellow")#top layer
# Function to draw a candle at a given position
# Draw a candle on the cake
def draw_candle(x, y):
my_turtle.penup()
my_turtle.goto(x, y)
my_turtle.pendown()
my_turtle.pencolor("red")
my_turtle.fillcolor("orange")
my_turtle.begin_fill()
my_turtle.circle(10)
my_turtle.end_fill()
my_turtle.pencolor("orange")
my_turtle.fillcolor("red")
my_turtle.begin_fill()
my_turtle.circle(6)
my_turtle.end_fill()
# Draw a candle on the cake
draw_candle(5, 320)
def draw_candlebody(x, y, color):
my_turtle.penup()
my_turtle.goto(x, y)
my_turtle.pendown()
my_turtle.fillcolor(color)
my_turtle.begin_fill()
for _ in range(2):
my_turtle.forward(10)
my_turtle.right(90)
my_turtle.forward(50)
my_turtle.right(90)
my_turtle.end_fill()
# Draw a three-layer cake
draw_candlebody(0, 300, "yellow")
# Function to draw a piece of confetti at a random position
def draw_confetti():
my_turtle.penup()
x = random.randint(-300, 200)
y = random.randint(-300, 200)
my_turtle.goto(x, y)
my_turtle.pendown()
my_turtle.dot(10, random.choice(["red", "blue", "yellow", "green", "pink"]))
# Draw 50 pieces of confetti
for _ in range(50):
draw_confetti()
# Hide the turtle when done
my_turtle.hideturtle()
# Keep the turtle window open
turtle.done()