From: Lukas Jiriste Date: Thu, 25 Apr 2024 07:45:11 +0000 (+0200) Subject: Fuse the mandelbrot and julia set structures X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=41a9900aa253dc6537a4c5fadfc539c9142e7632;p=42%2Ffract-ol.git Fuse the mandelbrot and julia set structures These had different structures because of the anticipation of differences between input for these fractals. This however makes parsing more difficult. Having a single structure with fields that may not be utilized by every fractal seems to be the more reasonable option. --- diff --git a/fractals.c b/fractals.c index ed428be..0cd8ffe 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:30:49 by ljiriste ### ########.fr */ +/* Updated: 2024/04/25 09:43:26 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -36,7 +36,7 @@ double general_julia(void *zeroth, double resolution, return (fmod(count / 100., 1.)); } -double mandelbrot(t_set_man *settings, double x, double y) +double mandelbrot(t_set *settings, double x, double y) { int count; t_complex c; @@ -59,7 +59,7 @@ double mandelbrot(t_set_man *settings, double x, double y) return (normalize_count(count, complex_norm(z), settings->color_stability)); } -double tricorn(t_set_man *settings, double x, double y) +double tricorn(t_set *settings, double x, double y) { int count; t_complex c; diff --git a/fractals.h b/fractals.h index 66a54cb..9a3a553 100644 --- a/fractals.h +++ b/fractals.h @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/19 10:56:55 by ljiriste #+# #+# */ -/* Updated: 2024/01/19 11:01:53 by ljiriste ### ########.fr */ +/* Updated: 2024/04/25 09:43:50 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,7 @@ double general_julia(void *zeroth, double resolution, void (*tested_f)(void *), int (*is_over_thresh)(void *)); -double mandelbrot(t_set_man *settings, double x, double y); -double tricorn(t_set_man *settings, double x, double y); +double mandelbrot(t_set *settings, double x, double y); +double tricorn(t_set *settings, double x, double y); #endif //FRACTALS_H diff --git a/fractol.h b/fractol.h index 3666c11..cd5e86a 100644 --- a/fractol.h +++ b/fractol.h @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/11 18:51:29 by ljiriste #+# #+# */ -/* Updated: 2024/04/18 11:44:27 by ljiriste ### ########.fr */ +/* Updated: 2024/04/25 09:41:47 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -46,26 +46,12 @@ struct s_view }; typedef struct s_view t_view; -struct s_set_man +struct s_set { int detail; int color_stability; }; -typedef struct s_set_man t_set_man; - -struct s_set_jul -{ - int detail; -}; - -typedef struct s_set_jul t_set_jul; - -union u_set -{ - t_set_man man; - t_set_jul jul; -}; -typedef union u_set t_set; +typedef struct s_set t_set; struct s_session { diff --git a/main.c b/main.c index 6b236f6..a3433ed 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/10/27 14:29:26 by ljiriste #+# #+# */ -/* Updated: 2024/04/25 09:36:26 by ljiriste ### ########.fr */ +/* Updated: 2024/04/25 09:42:33 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -218,8 +218,8 @@ void set_default(t_session *s) s->view.pixel_size.y = 0.01; s->view.color_shift = 0.7; s->view.color_shift_speed = 0.01; - s->set.man.detail = 1000; - s->set.man.color_stability = 100; + s->set.detail = 1000; + s->set.color_stability = 100; s->img.width = 1000; s->img.height = 1000; s->img.undersample_max = 5; @@ -253,7 +253,7 @@ int parse_args(int argc, char **argv, t_session *s) else if (!ft_strcmp(argv[i], "-u") && ft_isint(argv[i + 1])) s->img.undersample_max = ft_atoi(argv[++i]); else if (!ft_strcmp(argv[i], "-d") && ft_isint(argv[i + 1])) - s->set.man.detail = ft_atoi(argv[++i]); + s->set.detail = ft_atoi(argv[++i]); else if (!ft_strcmp(argv[i], "-f") && to_fractal(argv[i + 1]) != NULL) s->view.fractal = to_fractal(argv[i + 1]); else