From 7cc4c4ce2191d09d7f285475727f97991558039b Mon Sep 17 00:00:00 2001 From: Pavle Portic Date: Sun, 3 Feb 2019 14:44:09 +0100 Subject: [PATCH] Print number of total iterations on the current frame --- mandelbrot.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mandelbrot.py b/mandelbrot.py index ab36e78..93f1f60 100644 --- a/mandelbrot.py +++ b/mandelbrot.py @@ -13,6 +13,7 @@ import curses import colors MAX_ITERS = 100 +ITERATIONS = 0 COLOR_COUNT = 101 MONOCHROME = False ZOOM_LEVEL = 0 @@ -33,8 +34,10 @@ def get_points(cols, rows): def calculate_point(x, y): + global ITERATIONS z = 0 for i in range(MAX_ITERS): + ITERATIONS += 1 z = z ** 2 + complex(x, y) if abs(z) >= 2: return i @@ -43,6 +46,8 @@ def calculate_point(x, y): def calculate_set(cols, rows): + global ITERATIONS + ITERATIONS = 0 x, y = get_points(cols, rows) matrix = np.zeros([rows, cols]) for i in range(rows): @@ -64,7 +69,7 @@ def print_set(screen, cols, rows, matrix, char): color_index = 2 if color_index < 2 else color_index screen.addstr(i, j, ' ', curses.color_pair(color_index)) - screen.addstr(rows, 0, f'Iterations: {MAX_ITERS}, Zoom: {ZOOM_LEVEL}, Char: {char}', curses.color_pair(COLOR_COUNT)) + screen.addstr(rows, 0, f'Max Iterations: {MAX_ITERS}, Zoom: {ZOOM_LEVEL}, Iterations: {ITERATIONS}, Char: {char}', curses.color_pair(COLOR_COUNT)) screen.refresh()