Advertisement
farry

mandelbrot-variation.py

Dec 2nd, 2018
978
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import numpy as np
  3. from PIL import Image # Pillow fork of PIL
  4. x,y=np.ogrid[-5.4:0.8:950j,-1.6:1.6:500j]
  5. c = x + 1j*y
  6. ones = np.ones_like(x*y)
  7. its = np.zeros_like(ones)
  8. z = c * 0
  9. for n in range(200):
  10.   itsmax = abs(z) < 200.0
  11.   np.putmask(its, itsmax, n*ones)
  12.   np.putmask(z, itsmax,  z**2 + 0.19 * z ** 3 + c)
  13. smooth = its - np.log(np.log(np.maximum(2.0, abs(z))))/np.log(2.6)
  14. v = np.where(itsmax, 0, np.log(smooth * 1.1 + 1.0) * 0.3)
  15. greys = np.array((v,v,v)).T
  16. blues = np.array((v**4, v**2.5, v)).T
  17. w = np.maximum(0, 2-v)
  18. sepias = np.array((w, w**1.5, w**3)).T
  19. color = np.where(greys<1.0, blues, sepias)
  20. rgb = np.uint8(np.minimum(1.0, color) * 255)
  21. img = Image.fromarray(rgb, mode="RGB")
  22. img.save("mand.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement