from PIL import Image from apscheduler.schedulers.background import BackgroundScheduler w, h, zoom = 1920, 1080, 1 # creating the new image in RGB mode bitmap = Image.new("RGB", (w, h), "white") pix = bitmap.load() cX, cY = -0.7, 0.27015 moveX, moveY = 0.0, 0.0 maxIter = 255 sched = BackgroundScheduler() def dots(): print("...") sched.add_job(dots, 'interval', seconds=5) sched.start() for x in range(w): for y in range(h): zx = 1.5 * (x - w / 2) / (0.5 * zoom * w) + moveX zy = 1.0 * (y - h / 2) / (0.5 * zoom * h) + moveY i = maxIter while zx * zx + zy * zy < 4 and i > 1: tmp = zx * zx - zy * zy + cX zy, zx = 2.0 * zx * zy + cY, tmp i -= 1 # convert byte to RGB (3 bytes) RedGreenBlue pix[x, y] = (i << 21) + (i << 10) + i * 8 bitmap.show() sched.shutdown()