Advertisement
granada

Julia set

May 21st, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. # this draws a julia set
  2. # feel free to use, modify, fly and do anything you want
  3. import numpy
  4.  
  5. screenx=800
  6. screeny=600
  7.  
  8. # This defines the set
  9. c=complex(-0.123,0.745)
  10.  
  11. real_min, real_max=-2.0,2.0
  12. imag_min, imag_max=-2.0,2.0
  13.  
  14. real_range=numpy.arange(real_min,real_max,(real_max-real_min)/screenx)
  15. imag_range=numpy.arange(imag_min,imag_max,(imag_max-imag_min)/screeny)
  16.  
  17. fout=open('julia.ppm','w')
  18. fout.write('P2\n'+str(screenx)+' '+str(screeny)+'\n255\n')
  19.  
  20. for im in imag_range:
  21.         for re in real_range:
  22.                 z=complex(re,im)
  23.                 n=255
  24.                 while abs(z)<10 and n>=5:
  25.                         z=z*z+c
  26.                         n-=5
  27.                 fout.write(str(n)+' ')
  28.         fout.write('\n')
  29. fout.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement