/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/05 19:35:01 by ljiriste #+# #+# */
-/* Updated: 2024/01/16 14:24:40 by ljiriste ### ########.fr */
+/* Updated: 2024/01/17 10:31:31 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
#include "vect2.h"
-#define MOVE_AMOUNT 0.1
+#define MOVE_AMOUNT 0.03
+#define ZOOM_OUT 0.5
+#define ZOOM_IN 2
int handle_key_press(int keycode, t_session *s)
{
move_view(0, -MOVE_AMOUNT, s);
else if (keycode == XK_Right || keycode == XK_d)
move_view(MOVE_AMOUNT, 0, s);
- if (keycode != XK_Escape && s->view.draw_whole)
+ else if (keycode == XK_KP_Add)
+ change_zoom(&s->view, (t_vect2){.x = s->img.width / 2, .y = s->img.height / 2}, ZOOM_IN);
+ else if (keycode == XK_KP_Subtract)
+ change_zoom(&s->view, (t_vect2){.x = s->img.width / 2, .y = s->img.height / 2}, ZOOM_OUT);
+ if (keycode != XK_Escape)
draw_fractal(s);
return (0);
}
int handle_mouse_press(int button, int x, int y, t_session *s)
{
- double delta_zoom;
-
if (button == Button4)
- delta_zoom = 0.5;
+ change_zoom(&s->view, (t_vect2){.x = x, .y = y}, ZOOM_OUT);
else if (button == Button5)
- delta_zoom = 2;
+ change_zoom(&s->view, (t_vect2){.x = x, .y = y}, ZOOM_IN);
if (button == Button4 || button == Button5)
- {
- change_zoom(&s->view, (t_vect2){.x = x, .y = y}, delta_zoom);
draw_fractal(s);
- }
return (0);
}