#E2_A import numpy as np import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation import time import random print("starting") start = time.time() x_data = [] y_data = [] x2_data = [] y2_data = [] x3_data = [] y3_data = [] fig, ax = plt.subplots() ax.set_xlim(-1.5, 1.5) ax.set_ylim(-1.5,1.5) line, = ax.plot(0,0) line2, = ax.plot(0,0) line3, = ax.plot(0,0) r=1 r2=1.2 r3=1.5 def animation_frame(i): print(i) x=round(i/500)r2=r*(x+1)if ((x % 2 == 0)): x2_data.append(x*r2*np.cos(i)) y2_data.append(x*r2*np.sin(i)) elif ((x % 3 == 0)): x_data.append((x*r2*np.cos(i))) y_data.append((x*r2*np.sin(i))) else: x3_data.append((x*r2*np.cos(i))) y3_data.append((x*r2*np.sin(i)))line.set_xdata(x_data) line.set_ydata(y_data) line2.set_xdata(x2_data) line2.set_ydata(y2_data) line3.set_xdata(x3_data) line3.set_ydata(y3_data) line.set_linewidth(1) line2.set_linewidth(0.3) line3.set_linewidth(0.3)ax.set_xlim(-(i/500+1)*(i/500+1),(i/500+1)*(i/500+1)) ax.set_ylim(-(i/500+1)*(i/500+1),(i/500+1)*(i/500+1)) line.set_color('orange') line2.set_color('purple') line3.set_color('green')return line, line2, line3 z_data = [] count=0 for z in range(1, 6500):count=count+2.2z_data.append(count) animation = FuncAnimation(fig, func=animation_frame, frames=z_data, interval=10, blit=True) animation.save('passiflora2.mp4', dpi=500, bitrate=-1, codec="libx264", extra_args=['-pix_fmt','yuv420p']) #plt.show() end = time.time() print(end - start)
Categories