Advertisement
Guest User

mandel

a guest
Jan 18th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. import numpy as N
  2. import pylab as P
  3.  
  4. dx = ( .663,.007) # X start position, X width
  5. dy = (-.191,.007) # Y start position, Y width
  6. v  = N.zeros((1024,1024),'uint8')    # The color matrix
  7.  
  8. # Create the constant matrix and initialize it
  9. c  = N.zeros((1024,1024),'complex')
  10. c[:].real = N.linspace(dy[0],dy[0]+dy[1],
  11.                        c.shape[0])[:,N.newaxis]
  12. c[:].imag = N.linspace(dx[0],dx[0]+dx[1],
  13.                        c.shape[1])[N.newaxis,:]
  14. z  = c.copy()           # The z function is initialized from c
  15. for it in xrange(256):  # Use 256 colors
  16.     z *= z              # Compute z = z*z
  17.     z += c              # Compute z = z + c
  18.     # Set colors for which z has diverged
  19.     v += (N.abs(z) >= 4)*(v == 0)*it
  20. P.imgshow(v)      # Display the image
  21. P.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement