From c7e66e6c51b7c734cf4a656aac33b4112960284a Mon Sep 17 00:00:00 2001 From: John Lorentzson Date: Wed, 30 Jul 2025 23:51:27 +0200 Subject: [PATCH] Add Hugo's unfinished mandelbrot fractal demo --- editor/mandelbrot.c6l | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 editor/mandelbrot.c6l diff --git a/editor/mandelbrot.c6l b/editor/mandelbrot.c6l new file mode 100644 index 0000000..b46e4b7 --- /dev/null +++ b/editor/mandelbrot.c6l @@ -0,0 +1,34 @@ +;; Constants. +width = 30 +height = 30 +size_pow_two = 16 +size = 4 +max_iteration = 100 ; How god the algorithm is + +for x_pos do width times + for y_pos do height times + + is_inside_mandelbrot = 1 + x = 0 ; x_math + y = 0 ; y_math + + for i do max_iteration times + ;; because the set is so small we need to scale evrything up with scale. + + ;; if x^2 + y^2 > 2^2 * size^2 then outside set. + if x * x + y * y > 4 * size_pow_two then + is_inside_mandelbrot = 0 + else + ;; z = z^2 + c + ;; z = x + yi + ;; c = x_pos + i*y_pos + ;; z^2 = (x + yi)(x + yi) = x^2 -y^2 + 2yxi + ;; therefore: x = x^2 - y^2 + x_pos, y = 2xy + y_pos + x = x*x - y *y + x_pos * size + y = 2 * x * y +y_pos * size + end + end + if is_inside_mandelbrot == 1 then + draw_pixel(x_pos,y_pos) + end +end