-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathTest.py
More file actions
47 lines (30 loc) · 1.15 KB
/
Test.py
File metadata and controls
47 lines (30 loc) · 1.15 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
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.animation import FuncAnimation
fig, ax = plt.subplots()
fig.set_facecolor('black')
ax.set_aspect('equal')
t = np.linspace(0, 2 * np.pi, 1000)
x = 16 * np.sin(t) ** 3
y = 13 * np.cos(t) - 5 * np.cos(2 * t) - 2 * np.cos(3 * t) - np.cos(4 * t)
heart_line, = ax.plot(x, y, color='pink', linewidth=3)
small_hearts = []
for i in range(12):
small_heart, = ax.plot([], [], color='pink', linewidth=0.5)
small_hearts.append(small_heart)
def update(i):
for small_heart in small_hearts:
small_heart.set_data([], [])
text.set_text("RAWAN")
angles = np.linspace(0, 2 * np.pi, len(small_hearts))
radius = 20
small_x = radius * np.sin(angles + i * 0.1)
small_y = radius * np.cos(angles + i * 0.1)
for small_heart, small_x_val, small_y_val in zip(small_hearts, small_x, small_y):
small_heart.set_data(x + small_x_val, y + small_y_val)
animation = FuncAnimation(fig, update, frames=100, interval=50, repeat="true")
text = ax.text(0, -5, "", color='pink', fontsize=20, ha='center')
ax.set_xlim(-35, 35)
ax.set_ylim(-35, 35)
ax.axis('off')
plt.show()