/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/11 18:51:29 by ljiriste #+# #+# */
-/* Updated: 2024/01/18 10:11:39 by ljiriste ### ########.fr */
+/* Updated: 2024/01/18 17:12:40 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
};
typedef struct s_view t_view;
+struct s_set_man
+{
+ int detail;
+ int threshold;
+ 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;
+
struct s_session
{
void *mlx;
void *win;
t_img img;
t_view view;
+ t_set set;
};
typedef struct s_session t_session;
/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/27 14:29:26 by ljiriste #+# #+# */
-/* Updated: 2024/01/18 10:44:15 by ljiriste ### ########.fr */
+/* Updated: 2024/01/18 17:14:33 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
return ;
}
-double mandelbrot(double x, double y)
+double mandelbrot(t_set_man *settings, double x, double y)
{
- const double threshold = 1000;
- const double detail = 10;
int count;
t_complex c;
t_complex z;
z.r = 0;
z.i = 0;
if (complex_norm(c) > 4)
- return (0.01);
- while (complex_norm(z) < threshold && count < 100 * detail)
+ return (0);
+ while (complex_norm(z) < settings->threshold && count < settings->detail)
{
z = complex_add(complex_mul(z, z), c);
++count;
}
- if (count == 100 * detail)
+ if (count == settings->detail)
return (-1);
- return (fmod((count + 1 - log(log(complex_norm(z)) / log(2)) / log(2)) / 100., 1.));
+ return (fmod((double)(count + 1 - log(log(complex_norm(z)) / log(2)) / log(2)) / settings->color_stability, 1.));
}
t_color get_img_pixel_color(t_img *img, int x, int y)
if (!*(bool *)ft_mat_access(&s->img.calced, x, y))
{
- palette_param = s->view.fractal(
+ palette_param = s->view.fractal(&s->set,
s->view.window_coord.x + s->view.pixel_size.x * x,
s->view.window_coord.y - s->view.pixel_size.y * y);
return (s->view.palette(palette_param));
{
if (argc == 0)
free(argv);
+ s->set.man.detail = 1000;
+ s->set.man.threshold = 1000;
+ s->set.man.color_stability = 100;
s->img.width = 1000;
s->img.height = 1000;
s->img.undersample_max = 5;