Hook
More breakout videos from this creator.
import numpy as np import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation fig, ax = plt.subplots(figsize=(8, 8)) fig.patch.set_facecolor("black") ax.set_facecolor("black") ax.set_xlim([-22, 22]) ax.set_ylim([-22, 22]) ax.axis("off") t = np.linspace(0, 2*np.pi, 90) y = ( 14*np.cos(t) - 5*np.cos(2*t) - 2*np.cos(3*t) - np.cos(4*t) ) x = 1.15 y *= 1.15 texts = [] for i in range(len(t)): txt = ax.text( x[i], y[i], "I LOVE YOU", fontsize=8, color="red", ha="center", va="center", fontweight="bold" ) texts.append(txt) def update(frame): for i, txt in enumerate(texts): base_x = x[i] base_y = y[i] move_x = np.sin(frame*0.05 + i*0.4) * 0.7 move_y = np.cos(frame*0.05 + i*0.4) * 0.7 final_x = base_x + move_x final_y = base_y + move_y txt.set_position((final_x, final_y)) return texts ani = FuncAnimation( fig, update, frames=5000, interval=16, blit=True ) plt.show()