Friday, December 13, 2019

"Pattern" Drawing by Functions 2


import numpy,pylab; pi=numpy.pi 
def randi(nmin,nmax): return numpy.random.randint(nmin,nmax)
def randc(a): return numpy.random.choice(a,1)[0]
a,c=(.5+numpy.random.random())*randc([-1,1]),.001*randi(1,99)*randc([-1,1])
b=randi(3,12); t=numpy.arange(0,16*b*pi,1/(720*b))
fx=numpy.sin(t/6)+a*numpy.sin(b*t)*numpy.cos(t)-c*numpy.sin(16*b*t)
fy=numpy.cos(t/6)+a*numpy.sin(b*t)*numpy.sin(t)-c*numpy.cos(16*b*t)
pylab.figure(figsize=(10,10)); ax=pylab.gca(); ax.set_facecolor('mintcream')
pylab.scatter(fx,fy,s=.1**4,c=[numpy.random.random(3)])
pylab.title(['a=%f'%a,'b=%d'%b,'c=%f'%c]); pylab.grid(); pylab.show()

No comments:

Post a Comment