from numpy import complex, array
from PIL import Image
from time import process_time
import colorsys as cs

t = process_time()
SET_WIDTH = 1000


def color(i):
    SET_COLOR = 255 * array(cs.hsv_to_rgb(i / 245.0, 0.9, 0.4))
    return tuple(SET_COLOR.astype(int))


def mandelbrot(x, y):
    c1 = complex(x, y)
    c2 = 0
    for n in range(1, 900):
        if abs(c2) > 2:
            return color(n)
        c2 = c2 ** 2 + c1
    return (0, 0, 0)


image = Image.new('RGB', (SET_WIDTH, int(SET_WIDTH / 2)))
pixels = image.load()
for x in range(image.size[0]):
    for y in range(image.size[1]):
        pixels[x, y] = mandelbrot((x - (0.75 * SET_WIDTH)) / (SET_WIDTH / 4),
                                  (y - (SET_WIDTH / 4)) / (SET_WIDTH / 4))

image.show()
print(process_time() - t)

from numpy import complex, array
from PIL import Image
from time import process_time
import colorsys as cs

t = process_time()
SET_WIDTH = 1000


def color(i):
    SET_COLOR = 255 * array(cs.hsv_to_rgb(i / 245.0, 0.9, 0.4))
    return tuple(SET_COLOR.astype(int))


def mandelbrot(x, y):
    c1 = complex(x, y)
    c2 = 0
    for n in range(1, 900):
        if abs(c2) > 2:
            return color(n)
        c2 = c2 ** 2 + c1
    return (0, 0, 0)


image = Image.new('RGB', (SET_WIDTH, int(SET_WIDTH / 2)))
pixels = image.load()
for x in range(image.size[0]):
    for y in range(image.size[1]):
        pixels[x, y] = mandelbrot((x - (0.75 * SET_WIDTH)) / (SET_WIDTH / 4),
                                  (y - (SET_WIDTH / 4)) / (SET_WIDTH / 4))

image.show()
print(process_time() - t)
