pip install numpy matplotlib 1. Bouncing Fruit This animation features a bouncing fruit (in this case, a simple circle representing an apple) across the screen.
import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation Fruitydelicious animations (11.02.2023)
fruit.set_data(x, y) return fruit,
import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation pip install numpy matplotlib 1
# Initialize the plot ax.set_xlim(0, 10) ax.set_ylim(0, 10) y) return fruit
# Bounce off edges if x < 0 or x > 10: vx *= -1 if y < 0 or y > 10: vy *= -1
ani = animation.FuncAnimation(fig, animate, frames=100, interval=100)