Skip to content

Instantly share code, notes, and snippets.

@bensadeghi
Created August 24, 2013 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bensadeghi/6326973 to your computer and use it in GitHub Desktop.
Save bensadeghi/6326973 to your computer and use it in GitHub Desktop.
a quick python gist for generating fractals using compositions of sin() and another function
from PyQt4.QtGui import QApplication
from pylab import *
ion()
ny = 600
r = 1.25
nx = ny*r
iters = 10
grid = pi*2/3
ay = flipud(linspace(-grid, grid, ny))
ax = linspace(-grid*r, grid*r, nx)
z = complex128(tile(ax,(ny,1)) + transpose(tile(ay, (nx,1))*1j))
u = exp(2*pi*1j*rand(1))
subplot(121)
im_abs = imshow(abs(z))
subplot(122)
im_angle = imshow(angle(z))
for n in range(iters):
z = sin(u*z)
im_abs.set_data(abs(z))
im_angle.set_data(angle(z))
title(n+1)
draw()
QApplication.processEvents()
print("done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment