forked from arpit456jain/Getting-Started-with-open-source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
heart.py
70 lines (48 loc) · 1.03 KB
/
heart.py
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
# Import turtle package
import turtle
# Creating a turtle object(pen)
pen = turtle.Turtle()
# Defining a method to draw curve
def curve():
for i in range(200):
# Defining step by step curve motion
pen.right(1)
pen.forward(1)
# Defining method to draw a full heart
def heart():
# Set the fill color to red
pen.fillcolor('red')
# Start filling the color
pen.begin_fill()
# Draw the left line
pen.left(140)
pen.forward(113)
# Draw the left curve
curve()
pen.left(120)
# Draw the right curve
curve()
# Draw the right line
pen.forward(112)
# Ending the filling of the color
pen.end_fill()
# Defining method to write text
def txt():
# Move turtle to air
pen.up()
# Move turtle to a given position
pen.setpos(-68, 95)
# Move the turtle to the ground
pen.down()
# Set the text color to lightgreen
pen.color('lightgreen')
# Write the specified text in
# specified font style and size
pen.write("Ivy Barley", font=(
"Verdana", 12, "bold"))
# Draw a heart
heart()
# Write text
txt()
# To hide turtle
pen.ht()