def animate(i): global vx, vy # Update fruit position x, y = fruit.get_data() x += vx y += vy
plt.show() This animation showcases a variety of fruits growing and changing sizes. Fruitydelicious animations (11.02.2023)
# Fruit (apple) properties fruit, = ax.plot(5, 5, 'ro') def animate(i): global vx, vy # Update fruit
# Bounce off edges if x < 0 or x > 10: vx *= -1 if y < 0 or y > 10: vy *= -1 def animate(i): global vx
# Fruits properties fruits = [ {'x': 2, 'y': 2, 'size': 1, 'color': 'r'}, # Apple {'x': 5, 'y': 5, 'size': 2, 'color': 'g'}, # Banana {'x': 8, 'y': 8, 'size': 3, 'color': 'b'}, # Cherry ]