随机之美
python代码
生成一颗独一无二的‘眼睛’
-----------------------------------------------------------------
#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as mp
import random as r
def calc_lissa(A,a,t,c):
x=A*np.sin(a*t+np.pi/2)
y=A*np.sin(a*t)
mp.plot(x,y,c=c)
def main():
t1 =r.randint(1,200)
t2 =r.randint(1,200)
t=np.linspace(t1*-1,t1,t2)
I=0
N=r.randint(1,200)
while I<N:
D=r.randint(1,200)
A=r.randint(1,D)
a=r.randint(1,D)
d =r.randint(1,10)/10.0
e =r.randint(1,10)/10.0
f =r.randint(1,10)/10.0
c=(d,e,f)
calc_lissa(A,a,t,c)
I+=1
mp.show()
if __name__=='__main__':
main()