i can't figure out how to zoom in mandelbrot set and how to change coordinates to zoom. I wondering should i set center of image in for example: x= -0.3123 and y = -0.1212 and now zooming it or to change x,y by any number? Can anyone please explain it to me? My code:
import math
from PIL import Image
height = 360
width = 640
#plot window
X_START = -2.5
X_END = 2.5
Y_START = -1.5
Y_END = 1.5
base_zoom = 1
for i in range(1,30):
img = Image.new("HSV", (width, height), 0)
X_START = -2.5 * base_zoom
X_END = 2.5 * base_zoom
Y_START = -1.5 * base_zoom
Y_END = 1.5 * base_zoom
maxIter = 100
pixels = img.load()
for x in range(width):
print(f"Did: {math.floor(x / width * 1000 / 10)} % of picture nr {i}")
for y in range(height):
a = (x / width) * (X_END - X_START) + X_START
b = (y/ height) * (Y_END - Y_START) + Y_START
ca = a
cb = b
n = 0
while n<maxIter:
aa = -2
bb = 2 * a * b
if abs(aa + bb) > 4:
bright = int(255 * n % maxIter)
saturation = 185
value = 218
pixels[x, y] = (bright, saturation, value)
a = aa
b = bb
n+=1
base_zoom *= 0.5
# img.show()
img.convert('RGB').save(f'pictures_mandelbrot\picture{i}.BMP')