I'm working with PyGame and attempting to create a zoomable/scaleable Mandelbrot Set. I have this set up for square windows and coordinates that only from -1 to 1 on both axes in the complex plane. The way I do this is for every pixel on the screen I call this function:
#Import pygame and initialize
xSize = 50
ySize = 50
scale = 20
size = width, height = (xSize * scale), (ySize * scale)
screen = pygame.display.set_mode(size)
def getCoords(x, y):
complexX = (x/((xSize * scale)/2)) - 1
complexY = (y/((ySize * scale)/2)) - 1
return complexX, complexY
And here is the loop where I actually plot the pixels:
for y in range(0, (ySize * scale)):
for x in range(0, (xSize * scale)):
i = 0
z = getCoords(x, y)
complexNum = complex(z[0], z[1])
zOld = 0
blowsUp = False
#Check to see if (z^2 + c) "blows up"
if blowsUp:
screen.set_at((x, y), color1)
else:
screen.set_at((x, y), color0)
Essentially what I want to be able to do is to have two tuples (one for x and one for y) that contain the maximum and minimum values that get plotted from the complex plane (i.e. here I'm just plotting 1 to -1 on both the real and imaginary axes). I imagine that this would be done by editing the getCoords() function, but after much tinkering with the expression there I can't seem to find a way to do this properly.