Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image, ImageDraw
- import numpy as np
- dim = (500, 500)
- img = Image.new('RGBA', dim, (255, 255, 255, 0))
- pixels = img.load()
- def func(x, y, cR, cI):
- return x**2.0 - y**2.0 * -1 + cR, (x * y) * 2.0 + cI
- def drawCircle():
- cR = 0.4
- cI = 0.6
- maxIter = 255
- xmin, xmax = -4.0, 4.0
- xstep = (xmax - xmin) / dim[0]
- ymin, ymax = -4.0, 4.0
- ystep = (ymax - ymin) / dim[1]
- raxis = []
- iaxis = []
- u = xmin
- while u < xmax:
- raxis += [u]
- u += xstep
- u = ymin
- while u < ymax:
- iaxis += [u]
- u += ystep
- for xa in range(dim[0]):
- for ya in range(dim[1]):
- x, y = raxis[xa], iaxis[ya]
- i = 0
- bounded = True
- while i < maxIter and bounded:
- x, y = func(x, y, cR, cI)
- i += 1
- if x < -10.0 or x > 10.0 or y < -10.0 or y > 10.0: bounded = False
- pixels[xa, ya] = (i * 20 % maxIter, 0, 0)
- drawCircle()
- img.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement