forked from lukman467/coding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
heart_2.py
50 lines (40 loc) · 965 Bytes
/
heart_2.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
import turtle
import time
screen = turtle.Screen()
screen.setup(800, 800)
screen.bgcolor("pink")
t = turtle.Turtle()
t.hideturtle()
t.speed(3)
def draw_heart(x, y, size, color, thickness):
t.penup()
t.goto(x, y)
t.color(color)
t.pensize(thickness)
t.pendown()
t.begin_fill()
t.left(140)
t.forward(size)
for _ in range(200):
t.right(1)
t.forward(size * 0.009)
t.left(120)
for _ in range(200):
t.right(1)
t.forward(size * 0.009)
t.forward(size)
t.end_fill()
t.setheading(0)
hearts = [
(0, -150, 300, "#FF9999", 5),
(0, -135, 270, "#FFCCCC", 5),
(0, -120, 240, "#FFE6E6", 5),
(0, -105, 210, "#FFCCCC", 5),
(0, -90, 180, "#FF99CC", 5),
(0, -75, 150, "#FFCCFF", 5),
(0, -50, 100, "#FF6666", 5)
]
for heart in hearts:
draw_heart(*heart)
time.sleep(0.5)
screen.mainloop()