Friday, December 13, 2019

"Pattern" Drawing by Functions 4


import numpy,pylab; pi=numpy.pi 
def randi(nmin,nmax): return numpy.random.randint(nmin,nmax)
def t(i): return numpy.arange((i-1)*pi/24,i*pi/24,1/10**4)
def x(a,b,i,k): return numpy.cos(t(i)+k*pi/6)+numpy.cos(a*t(i))/2+numpy.sin((a+b)*t(i))/3
def y(a,b,i,k): return numpy.sin(t(i)+k*pi/6)+numpy.sin(a*t(i))/2+numpy.cos((a+b)*t(i))/3
A,B=randi(5,15),randi(10,36
pylab.figure(figsize=(10,10)); ax=pylab.gca(); ax.set_facecolor('ghostwhite')
for i in range(48):
  col=[numpy.random.random(3)]
  for k in range(12): pylab.scatter(x(A,B,i,k),y(A,B,i,k),s=.1**3,c=col)
pylab.title('a=%d; b=%d'%(A,B)); pylab.grid(); pylab.show()

No comments:

Post a Comment