Add undersample_max as variable
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 18 Jan 2024 07:48:51 +0000 (08:48 +0100)
committerLukas Jiriste <ljiriste@student.42prague.com>
Thu, 18 Jan 2024 07:48:51 +0000 (08:48 +0100)
This makes it possible to choose maximum undersample at runtime
(e.g. pass it as argument).

fractol.h
main.c

index b67781204eca560d951715f66e755d5ff408e1d1..5436deaabfbe6a3106eee58602770d6af8bdf9dd 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/01/17 14:43:55 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/01/18 08:41:34 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -28,6 +28,7 @@ struct s_img
        int             height;
        t_mat   calced;
        int             undersample;
+       int             undersample_max;
 };
 typedef struct s_img   t_img;
 
diff --git a/main.c b/main.c
index 26df455fb5afda857e6a06eab6fc01e06fb49f15..06464e817b2c75b706c9a3d9484460de36639b41 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/01/17 14:49:49 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/01/18 08:46:27 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -196,7 +196,7 @@ void        change_zoom(t_session *s, t_vect2 invariant, double d_zoom)
        s->view.window_coord.x += s->view.pixel_size.x * invariant.x * (d_zoom - 1);
        s->view.window_coord.y -= s->view.pixel_size.y * invariant.y * (d_zoom - 1);
        erase_calced(&s->img.calced);
-       s->img.undersample = 2;
+       s->img.undersample = s->img.undersample_max;
        return ;
 }
 
@@ -206,7 +206,7 @@ void        move_view(t_session *s, float move_amount_right, float move_amount_up)
        s->view.window_coord.x += move_amount_right * s->img.height * s->view.pixel_size.x;
        s->view.window_coord.y += move_amount_up * s->img.height * s->view.pixel_size.y;
        erase_calced(&s->img.calced);
-       s->img.undersample = 2;
+       s->img.undersample = s->img.undersample_max;
        return ;
 }
 
@@ -252,15 +252,16 @@ void      init_session(t_session *s)
        ft_mat_init(&s->img.calced, sizeof(bool));
        construct_mat(&s->img.calced, s->img.height, s->img.width);
        init_view(s);
-       s->img.undersample = 2;
+       s->img.undersample = s->img.undersample_max;
 }
 
 void   parse_args(int argc, char **argv, t_session *s)
 {
        if (argc == 0)
                free(argv);
-       s->img.width = 500;
-       s->img.height = 500;
+       s->img.width = 50;
+       s->img.height = 50;
+       s->img.undersample_max = 3;
        return ;
 }