-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyboard2.c
41 lines (37 loc) · 1.49 KB
/
keyboard2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "includes/fractol.h"
void keyboard_move_right(t_fractal *fractal)
{
fractal->factor.re = (fractal->max.re - fractal->min.re) / WIN_WIDTH;
fractal->factor.im = (fractal->max.im - fractal->min.im) / WIN_HEIGHT;
fractal->min.re += OFFSET * fractal->factor.re;
fractal->max.re += OFFSET * fractal->factor.re;
mlx_clear_window(fractal->window.mlx, fractal->window.win);
draw_fractal(fractal);
}
void keyboard_move_left(t_fractal *fractal)
{
fractal->factor.re = (fractal->max.re - fractal->min.re) / WIN_WIDTH;
fractal->factor.im = (fractal->max.im - fractal->min.im) / WIN_HEIGHT;
fractal->min.re -= OFFSET * fractal->factor.re;
fractal->max.re -= OFFSET * fractal->factor.re;
mlx_clear_window(fractal->window.mlx, fractal->window.win);
draw_fractal(fractal);
}
void keyboard_move_up(t_fractal *fractal)
{
fractal->factor.re = (fractal->max.re - fractal->min.re) / WIN_WIDTH;
fractal->factor.im = (fractal->max.im - fractal->min.im) / WIN_HEIGHT;
fractal->min.im += OFFSET * fractal->factor.im;
fractal->max.im += OFFSET * fractal->factor.im;
mlx_clear_window(fractal->window.mlx, fractal->window.win);
draw_fractal(fractal);
}
void keyboard_move_down(t_fractal *fractal)
{
fractal->factor.re = (fractal->max.re - fractal->min.re) / WIN_WIDTH;
fractal->factor.im = (fractal->max.im - fractal->min.im) / WIN_HEIGHT;
fractal->min.im -= OFFSET * fractal->factor.im;
fractal->max.im -= OFFSET * fractal->factor.im;
mlx_clear_window(fractal->window.mlx, fractal->window.win);
draw_fractal(fractal);
}