From: Lukas Jiriste Date: Thu, 25 Apr 2024 09:15:59 +0000 (+0200) Subject: Fix halo by tuning the fractal parameters X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=953d0660bbc6e9acb08e7e995a3ecc6adb5f1150;p=42%2Ffract-ol.git Fix halo by tuning the fractal parameters I don't really know why the halo still lived but changing the the number from which to count seems to resolve it. --- diff --git a/event_handling.c b/event_handling.c index 4b9d22e..95e72b8 100644 --- a/event_handling.c +++ b/event_handling.c @@ -6,10 +6,11 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/12/05 19:35:01 by ljiriste #+# #+# */ -/* Updated: 2024/04/18 11:47:43 by ljiriste ### ########.fr */ +/* Updated: 2024/04/25 10:35:46 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ +#include #include #include #include @@ -70,7 +71,9 @@ int no_event_handle(t_session *s) calculate_base(s); } draw_fractal(s); - s->view.color_shift += s->view.color_shift_speed; + s->view.color_shift = fmod(s->view.color_shift + s->view.color_shift_speed, 1.); + if (s->view.color_shift < 0) + s->view.color_shift += 1; } return (0); } diff --git a/fractals.c b/fractals.c index 0cd8ffe..069fc4c 100644 --- a/fractals.c +++ b/fractals.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/12/05 19:57:50 by ljiriste #+# #+# */ -/* Updated: 2024/04/25 09:43:26 by ljiriste ### ########.fr */ +/* Updated: 2024/04/25 11:13:38 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,6 +15,8 @@ #include "fractol.h" #include +#define THRESHOLD 256 + double normalize_count(int count, double norm, double color_stability) { return (fmod((double)(count + 1 - log(log(norm) / log(2)) / log(2)) / color_stability, 1.)); @@ -44,12 +46,12 @@ double mandelbrot(t_set *settings, double x, double y) c.r = x; c.i = y; - count = 1; + count = 4; z.r = x; z.i = y; - if (complex_norm(c) > 4) - return (normalize_count(1, 4, settings->color_stability)); - while (complex_norm(z) < 256 && count < settings->detail) + if (complex_norm(c) > THRESHOLD) + return (normalize_count(count, THRESHOLD, settings->color_stability)); + while (complex_norm(z) <= THRESHOLD && count < settings->detail) { z = complex_add(complex_mul(z, z), c); ++count; @@ -67,12 +69,12 @@ double tricorn(t_set *settings, double x, double y) c.r = x; c.i = y; - count = 0; + count = 4; z.r = 0; z.i = 0; - if (complex_norm(c) > 4) - return (normalize_count(1, 4, settings->color_stability)); - while (complex_norm(z) < 256 && count < settings->detail) + if (complex_norm(c) > THRESHOLD) + return (normalize_count(count + 1, THRESHOLD, settings->color_stability)); + while (complex_norm(z) <= THRESHOLD && count < settings->detail) { z = complex_add(complex_mul(complex_conj(z), complex_conj(z)), c); ++count;