Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import numpy as np
- from PIL import Image # Pillow fork of PIL
- w, h = 1200, 960
- xc, yc, scale = - 0.35, 0.005, 1.1
- imax, zmax = 100, 100
- x,y=np.ogrid[xc - scale: xc + scale: 1j * w,
- (yc - scale) * h/w: (yc + scale) * h/w: 1j * h]
- c = x + 1j*y
- ones = np.ones_like(x*y)
- its = np.zeros_like(ones)
- z = c * 0
- np.warnings.filterwarnings('ignore', '(overflow|invalid)')
- for n in range(imax):
- mask = abs(z.real) < zmax
- m = np.where(mask)
- its[m] = n
- z[m] = np.pi * np.cos(z[m]) + c[m]
- backgnd = np.log(its - np.log(np.log(abs(z.imag))) / 3) / 3
- np.putmask(backgnd, mask, 0*ones)
- tones = np.array(3*[backgnd]).T
- val = np.maximum(0.0, 1.0 - abs(1.0 - backgnd))
- blues = np.array((val**4, val**2.5, val)).T
- sepias = np.array((val, val**1.5, val**3)).T
- color = np.where(tones<1.0, blues, sepias)
- rgb = np.uint8(np.minimum(1.0, color) * 255)
- img = Image.fromarray(rgb, mode="RGB")
- img.save("mand.png")
- img.show()
Advertisement
Add Comment
Please, Sign In to add comment