Fuse the mandelbrot and julia set structures
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 25 Apr 2024 07:45:11 +0000 (09:45 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Thu, 25 Apr 2024 07:45:11 +0000 (09:45 +0200)
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.

fractals.c
fractals.h
fractol.h
main.c

index ed428be829331123c59bc9936161c2068cf7ca9f..0cd8ffed7ee0eb655e86cc640ac2789f87a93307 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   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;
index 66a54cbe5159872f2fef4dfa00bcf9a9530bf1cb..9a3a5539199d37c3ae7b73e17b2717c3787eddb7 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   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
index 3666c111587f2eb5cd81a671e70d3d420c0368f0..cd5e86a04254d825bb2d9f5b1b03cd9a5db394b9 100644 (file)
--- a/fractol.h
+++ b/fractol.h
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   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 6b236f6ba8d1ebb457b6f7a4952586d2dfe9b51c..a3433edf8d9f7492e7a415acd8782188b14ba926 100644 (file)
--- a/main.c
+++ b/main.c
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   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