Friday, December 13, 2019

Abstract "Herbal" Drawing by Functions


import numpy,pylab; pi=numpy.pi; n=36; t=numpy.arange(0,2*pi,2*pi/(360.*n))
pylab.figure(figsize=(10,10)); ax=pylab.gca(); ax.set_facecolor('black')
def randi(nmin,nmax): return numpy.random.randint(nmin,nmax)
for i in range(n):
    a,b,c,d=randi(5,11),randi(12,24),randi(25,81),randi(216,256)
    f1=(a+.9*numpy.cos(b*t+2*pi*i/n))*(1+.1*numpy.cos(c*t+2*pi*i/n))
    f2=(1+.05*numpy.cos(d*t+2*pi*i/n))*(1+numpy.sin(t+2*pi*i/n))
    x=f1*f2*numpy.cos(t); y=f1*f2*numpy.sin(t)
    pylab.scatter(x,y,s=3,c=[numpy.random.random(3)])
pylab.grid(c='white',alpha=.4); pylab.show()

No comments:

Post a Comment