-
Notifications
You must be signed in to change notification settings - Fork 0
/
hook.c
71 lines (65 loc) · 1.94 KB
/
hook.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* hook.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ddehtyar <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/06/20 18:57:31 by ddehtyar #+# #+# */
/* Updated: 2018/07/19 19:22:25 by ddehtyar ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
int deal_key_hook(int key, t_fractol *den)
{
if (key == 123)
den->x1 -= 0.3 / den->zoom;
if (key == 124)
den->x1 += 0.3 / den->zoom;
if (key == 125)
den->y1 += 0.3 / den->zoom;
if (key == 126)
den->y1 -= 0.3 / den->zoom;
if (key == 24)
den->maxi += 20;
if (key == 27)
den->maxi -= 20;
if (key == 49)
den->lock = den->lock == 1 ? 0 : 1;
if (key == 14)
den->var_color += den->var_color == 4 ? -3 : 1;
ft_chenge_frac(den);
if (key == 15 || key == 48)
{
if (key == 48)
den->name += den->name == 8 ? -7 : 1;
clear_image(den);
find_fractol(den);
}
return (0);
}
int deal_key(int key)
{
if (key == 53)
exit(1);
return (0);
}
int mouse_hints(int x, int y, t_fractol *den)
{
if ((x > 0 && x < WIDTH) && (y > 0 && y < WIDTH) && den->lock == 1)
{
den->cre = -0.7 + x / 1000.0;
den->cim = 0.27015 + y / 1000.0;
}
ft_chenge_frac(den);
return (0);
}
void clear_image(t_fractol *den)
{
ft_memset(den->img_data_addr, 0, ((WIDTH * WIDTH) * 4));
}
void ft_chenge_frac(t_fractol *den)
{
clear_image(den);
make_threads(den);
}