I am trying to print the Mandelbrot set in the following code but it print half screen white and half black. I have gone through the code many times but I don't know where I am going wrong. Can someone please help
from tkinter import *
size = 400
black = "#000000"
window = Tk()
canvas = Canvas(window, width=size, height=size, bg="white")
canvas.pack()
img = PhotoImage(width=size, height=size)
canvas.create_image((size/2, size/2), image=img, state="normal")
# constants:
MaxValue = 4
MaxIterations = 50
planeWidth = 4
for x in range(0, size):
for y in range(0, size): # for each pixel do:
cReal = (x * planeWidth / size) - 2
cImg = (y * planeWidth / size) - 2
zReal = 0
zImg = 0
count = 0
while (zReal*zReal + zImg*zImg) <= MaxValue and count < MaxIterations:
temp = (zReal * zReal) - (zImg * zImg) + cReal
zImg = 2 * zReal * zImg * cImg
zReal = temp
count += 1
if count == MaxIterations:
img.put(black, (x,y))
window.mainloop()