5706ccf986777b97442b0c7935228132493987f6
- Author
- Pavle Portic <pavle.portic@tilda.center>
- Committer
- Pavle Portic <pavle.portic@tilda.center>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/.editorconfig b/.editorconfig
2new file mode 100644
3index 0000000000000000000000000000000000000000..bec95c4494f708631bfa199ac391d0938f624fca
4--- /dev/null
5+++ b/.editorconfig
6@@ -0,0 +1,9 @@
7+root = true
8+
9+[*]
10+charset = utf-8
11+end_of_line = lf
12+insert_final_newline = true
13+trim_trailing_whitespace = true
14+indent_style = space
15+indent_size = 4
16diff --git a/colors.py b/colors.py
17index d55743d6306bf226ed699119ca88b0a8b4551561..6bffccbfd837d86e00655b3f4332d181e04f5e7d 100644
18--- a/colors.py
19+++ b/colors.py
20@@ -10,505 +10,505 @@ import curses
21
22
23 def init_21_colors():
24- curses.init_color(1, 0, 0, 0)
25- curses.init_color(2, 1000, 0, 0)
26- curses.init_color(3, 1000, 333, 0)
27- curses.init_color(4, 1000, 666, 0)
28- curses.init_color(5, 1000, 1000, 0)
29- curses.init_color(6, 666, 1000, 0)
30- curses.init_color(7, 333, 1000, 0)
31- curses.init_color(8, 0, 1000, 0)
32- curses.init_color(9, 0, 1000, 333)
33- curses.init_color(10, 0, 1000, 666)
34- curses.init_color(11, 0, 1000, 1000)
35- curses.init_color(12, 0, 666, 1000)
36- curses.init_color(13, 0, 333, 1000)
37- curses.init_color(14, 0, 0, 1000)
38- curses.init_color(15, 333, 0, 1000)
39- curses.init_color(16, 666, 0, 1000)
40- curses.init_color(17, 1000, 0, 1000)
41- curses.init_color(18, 1000, 0, 666)
42- curses.init_color(19, 1000, 0, 333)
43- curses.init_color(20, 1000, 0, 0)
44- curses.init_color(21, 800, 800, 800)
45- curses.init_color(22, 50, 50, 50)
46- curses.init_pair(1, 0, 1)
47- curses.init_pair(2, 0, 2)
48- curses.init_pair(3, 0, 3)
49- curses.init_pair(4, 0, 4)
50- curses.init_pair(5, 0, 5)
51- curses.init_pair(6, 0, 6)
52- curses.init_pair(7, 0, 7)
53- curses.init_pair(8, 0, 8)
54- curses.init_pair(9, 0, 9)
55- curses.init_pair(10, 0, 10)
56- curses.init_pair(11, 0, 11)
57- curses.init_pair(12, 0, 12)
58- curses.init_pair(13, 0, 13)
59- curses.init_pair(14, 0, 14)
60- curses.init_pair(15, 0, 15)
61- curses.init_pair(16, 0, 16)
62- curses.init_pair(17, 0, 17)
63- curses.init_pair(18, 0, 18)
64- curses.init_pair(19, 0, 19)
65- curses.init_pair(20, 0, 20)
66- curses.init_pair(21, 21, 22)
67- return 21
68+ curses.init_color(1, 0, 0, 0)
69+ curses.init_color(2, 1000, 0, 0)
70+ curses.init_color(3, 1000, 333, 0)
71+ curses.init_color(4, 1000, 666, 0)
72+ curses.init_color(5, 1000, 1000, 0)
73+ curses.init_color(6, 666, 1000, 0)
74+ curses.init_color(7, 333, 1000, 0)
75+ curses.init_color(8, 0, 1000, 0)
76+ curses.init_color(9, 0, 1000, 333)
77+ curses.init_color(10, 0, 1000, 666)
78+ curses.init_color(11, 0, 1000, 1000)
79+ curses.init_color(12, 0, 666, 1000)
80+ curses.init_color(13, 0, 333, 1000)
81+ curses.init_color(14, 0, 0, 1000)
82+ curses.init_color(15, 333, 0, 1000)
83+ curses.init_color(16, 666, 0, 1000)
84+ curses.init_color(17, 1000, 0, 1000)
85+ curses.init_color(18, 1000, 0, 666)
86+ curses.init_color(19, 1000, 0, 333)
87+ curses.init_color(20, 1000, 0, 0)
88+ curses.init_color(21, 800, 800, 800)
89+ curses.init_color(22, 50, 50, 50)
90+ curses.init_pair(1, 0, 1)
91+ curses.init_pair(2, 0, 2)
92+ curses.init_pair(3, 0, 3)
93+ curses.init_pair(4, 0, 4)
94+ curses.init_pair(5, 0, 5)
95+ curses.init_pair(6, 0, 6)
96+ curses.init_pair(7, 0, 7)
97+ curses.init_pair(8, 0, 8)
98+ curses.init_pair(9, 0, 9)
99+ curses.init_pair(10, 0, 10)
100+ curses.init_pair(11, 0, 11)
101+ curses.init_pair(12, 0, 12)
102+ curses.init_pair(13, 0, 13)
103+ curses.init_pair(14, 0, 14)
104+ curses.init_pair(15, 0, 15)
105+ curses.init_pair(16, 0, 16)
106+ curses.init_pair(17, 0, 17)
107+ curses.init_pair(18, 0, 18)
108+ curses.init_pair(19, 0, 19)
109+ curses.init_pair(20, 0, 20)
110+ curses.init_pair(21, 21, 22)
111+ return 21
112
113
114 def init_21_monochrome():
115- curses.init_color(1, 0, 0, 0)
116- curses.init_color(2, 50, 50, 50)
117- curses.init_color(3, 100, 100, 100)
118- curses.init_color(4, 150, 150, 150)
119- curses.init_color(5, 200, 200, 200)
120diff --git a/mandelbrot.py b/mandelbrot.py
121index 809005c223b02645309645edb24332d284ae4f0f..5464b5d052d6551ff42f8236ddb2cdc03a16e0f9 100644
122--- a/mandelbrot.py
123+++ b/mandelbrot.py
124@@ -7,7 +7,7 @@
125 # Distributed under terms of the BSD-3-Clause license.
126
127
128-import numpy as np
129+import numpy as np # type: ignore
130 import curses
131
132 import colors
133@@ -24,124 +24,129 @@ Y_MID = 0
134
135
136 def get_points(cols, rows):
137- x_min = X_MID - X_SCALE * (1 / (2 ** ZOOM_LEVEL))
138- x_max = X_MID + X_SCALE * (1 / (2 ** ZOOM_LEVEL))
139- y_min = Y_MID - Y_SCALE * (1 / (2 ** ZOOM_LEVEL))
140- y_max = Y_MID + Y_SCALE * (1 / (2 ** ZOOM_LEVEL))
141- x = np.linspace(x_min, x_max, cols)
142- y = np.linspace(y_min, y_max, rows)
143- return x, y
144+ x_min = X_MID - X_SCALE * (1 / (2 ** ZOOM_LEVEL))
145+ x_max = X_MID + X_SCALE * (1 / (2 ** ZOOM_LEVEL))
146+ y_min = Y_MID - Y_SCALE * (1 / (2 ** ZOOM_LEVEL))
147+ y_max = Y_MID + Y_SCALE * (1 / (2 ** ZOOM_LEVEL))
148+ x = np.linspace(x_min, x_max, cols)
149+ y = np.linspace(y_min, y_max, rows)
150+ return x, y
151
152
153 def calculate_point(x, y):
154- global ITERATIONS
155- z = 0
156- p = (x - 0.25) ** 2 + y ** 2
157- if p * (p + (x - 0.25)) < 0.25 * (y ** 2):
158- return -1
159- if (x + 1) ** 2 + y ** 2 <= 0.0625:
160- return -1
161+ global ITERATIONS
162+ z = 0
163+ p = (x - 0.25) ** 2 + y ** 2
164+ if p * (p + (x - 0.25)) < 0.25 * (y ** 2):
165+ return -1
166
167- for i in range(MAX_ITERS):
168- ITERATIONS += 1
169- z = z ** 2 + complex(x, y)
170- if abs(z) >= 2:
171- return i
172+ if (x + 1) ** 2 + y ** 2 <= 0.0625:
173+ return -1
174
175- return -1
176+ for i in range(MAX_ITERS):
177+ ITERATIONS += 1
178+ z = z ** 2 + complex(x, y)
179+ if abs(z) >= 2:
180+ return i
181+
182+ return -1
183
184
185 def calculate_set(cols, rows):
186- global ITERATIONS
187- ITERATIONS = 0
188- x, y = get_points(cols, rows)
189- matrix = np.zeros([rows, cols])
190- for i in range(rows):
191- for j in range(cols):
192- matrix[i, j] = calculate_point(x[j], y[i])
193+ global ITERATIONS
194+ ITERATIONS = 0
195+ x, y = get_points(cols, rows)
196+ matrix = np.zeros([rows, cols])
197+ for i in range(rows):
198+ for j in range(cols):
199+ matrix[i, j] = calculate_point(x[j], y[i])
200
201- return matrix
202+ return matrix
203
204
205 def print_set(screen, cols, rows, matrix, char):
206- screen.clear()
207- for i in range(rows):
208- for j in range(cols):
209- iteration = matrix[i, j]
210- if iteration == -1:
211- screen.addstr(i, j, ' ', curses.color_pair(1))
212- else:
213- color_index = (int(iteration) + 2) % COLOR_COUNT
214- color_index = 2 if color_index < 2 else color_index
215- screen.addstr(i, j, ' ', curses.color_pair(color_index))
216-
217- screen.addstr(rows, 0, f'Max Iterations: {MAX_ITERS}, Zoom: {ZOOM_LEVEL}, Iterations: {ITERATIONS}, Char: {char}', curses.color_pair(COLOR_COUNT))
218- screen.refresh()
219+ screen.clear()
220+ for i in range(rows):
221+ for j in range(cols):
222+ iteration = matrix[i, j]
223+ if iteration == -1: