Categories
SMArt Codes

E3 – “Puppy”

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 = []
x4_data = []
y4_data = []
x5_data = []
y5_data = []
x6_data = []
y6_data = []
x7_data = []
y7_data = []
x8_data = []
y8_data = []
x9_data = []
y9_data = []
x10_data = []
y10_data = []
x11_data = []
y11_data = []

fig, ax = plt.subplots()
#ax.set_xlim(-10000, 10000)
#ax.set_ylim(-10000, 10000)
line, = ax.plot(0,0)
line2, = ax.plot(0,0)
line3, = ax.plot(0,0)
line4, = ax.plot(0,0)
line5, = ax.plot(0,0)
line6, = ax.plot(0,0)
line7, = ax.plot(0,0)
line8, = ax.plot(0,0)
line9, = ax.plot(0,0)
line10, = ax.plot(0,0)
line11, = ax.plot(0,0)
r=1.2
r2=1.5
r3=1.5

count=1
count2=0
count3=0
def animation_frame(i):
    print(i)
    print(np.sin(i))
    x=round(i/30)+0.02
    x2=round(x/30)+0.1
    y_data.append(abs((x+50)/120*np.sin(i*np.pi/15)))
    x_data.append(-(x+50)/300*(np.sin(i*np.pi/15/2)*np.sin(i*np.pi/15)+3*np.sin(i*np.pi/15/2)))
    x2_data.append(x/100*np.sin(i*np.pi/30))
    y2_data.append(-0.5+x/100*np.cos(i*np.pi/30))
    x5_data.append(0.35+x/1200*np.sin(i*np.pi/30))
    y5_data.append(x/1200*np.cos(i*np.pi/30))
    x6_data.append(-0.35-x/1200*np.sin(i*np.pi/30))
    y6_data.append(-x/1200*np.cos(i*np.pi/30))
    y7_data.append(-1.5+abs(x/250*np.sin(i*np.pi/15)))
    x7_data.append(0.8-x/1000*(np.sin(i*np.pi/15/2)*np.sin(i*np.pi/15)+3*np.sin(i*np.pi/30/2)))
    y8_data.append(-1.5+abs(x/250*np.sin(i*np.pi/15)))
    x8_data.append(-0.8+x/1000*(np.sin(i*np.pi/15/2)*np.sin(i*np.pi/15)+3*np.sin(i*np.pi/30/2)))
    #y4_data.append(x/60*np.cos(i*np.pi/30))
    #x4_data.append(x/200*(np.cos(i*np.pi/30/2)*np.cos(i*np.pi/30)))
    #x3_data.append(x/220*np.sin(i*np.pi/30))
    #y3_data.append(-0.5-abs(x/70*(np.sin(i*np.pi/30)*np.sin(i*np.pi/30))))
    #x4_data.append(x/125*np.sin(i*np.pi/30))
    #y4_data.append(-0.3-abs(x/105*(np.sin(i*np.pi/30)*np.sin(i*np.pi/30))))
    x9_data.append(x/500*np.sin(i*np.pi/30))
    y9_data.append(-1+abs(x/800*(np.sin(i*np.pi/30)*np.sin(i*np.pi/30))))
    ##LIGHTNINGBOLT
    #x10_data.append(x/100-x2)
    #y10_data.append(x/100+
    ##WHISKERS
    #x10_data.append(0.05+(x2/200*30*(np.sin(i*np.pi/30)*np.sin(i*np.pi/30))))
    #y10_data.append(-0.7+x2/1000*30*np.sin(i*np.pi/30))
    #x11_data.append(-0.05-(x2/200*30*(np.sin(i*np.pi/30)*np.sin(i*np.pi/30))))
    #y11_data.append(-0.7+x2/1000*30*np.sin(i*np.pi/30))
    #x4_data.append((x/1000*np.cos(i))+2)
    #y4_data.append((x/1000*np.sin(i))-1.5)
    ##Loveheart nose
    y10_data.append(-0.5+x/800*np.sin(i*np.pi/30))
    x10_data.append(x/1500*(np.sin(i*np.pi/30/2)*np.sin(i*np.pi/30)+np.sin(i*np.pi/60)))
    line.set_xdata(x2_data)
    line.set_ydata(y2_data)
    line2.set_xdata(x_data)
    line2.set_ydata(y_data)
    line3.set_xdata(x3_data)
    line3.set_ydata(y3_data)
    line4.set_xdata(x4_data)
    line4.set_ydata(y4_data)
    line5.set_xdata(x5_data)
    line5.set_ydata(y5_data)
    line6.set_xdata(x6_data)
    line6.set_ydata(y6_data)
    line7.set_xdata(x7_data)
    line7.set_ydata(y7_data)
    line8.set_xdata(x8_data)
    line8.set_ydata(y8_data)
    line9.set_xdata(x9_data)
    line9.set_ydata(y9_data)
    line10.set_xdata(x10_data)
    line10.set_ydata(y10_data)
    line11.set_xdata(x11_data)
    line11.set_ydata(y11_data)
    ax.set_xlim(-2,2)
    ax.set_ylim(-1.5,1.5)
    line2.set_linewidth(3)
    line10.set_linewidth(0.5)
    line10.set_linewidth(0.5)

    line2.set_color('saddlebrown')
    line.set_color('chocolate')
    line3.set_color('chocolate')
    line4.set_color('chocolate')
    line5.set_color('black')
    line6.set_color('black')
    line7.set_color('saddlebrown')
    line8.set_color('saddlebrown')
    line9.set_color('black')
    line10.set_color('black')
    line11.set_color('black')
    return line, line3, line4, line2, line5, line6, line7, line8, line9, line10, line11

z_data = []
#counter=2000*np.pi
counter=0
#counter=1000*np.pi
for z in range(1, round(5000*np.pi)):
    counter=counter+1
    z_data.append(counter)


animation = FuncAnimation(fig, func=animation_frame, frames=z_data, interval=60, blit=True)


animation.save('puppy2.mp4', dpi=500, bitrate=-1, codec="libx264", extra_args=['-pix_fmt','yuv420p'])
#plt.show()
end = time.time()
print(end - start)
#print("done", "frame=",animation.frame_seq)

By Kasimir Gregory

PhD Candidate at the University of Newcastle investigating specific-ion effects.
https://scholar.google.com.au/citations?user=O65PgjUAAAAJ&hl=en&oi=ao

Leave a Reply

Your email address will not be published. Required fields are marked *