-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyboard_events.c
94 lines (90 loc) · 2.05 KB
/
keyboard_events.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* keyboard_events.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kprytkov <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/06/06 16:19:41 by kprytkov #+# #+# */
/* Updated: 2018/06/06 16:19:42 by kprytkov ### ########.fr */
/* */
/* ************************************************************************** */
#include "./includes/fractol.h"
static void guess_color(int keycode, t_env *e)
{
if (keycode == 18)
{
e->choose_color = 0;
next_draw(e);
}
if (keycode == 19)
{
e->choose_color = 1;
next_draw(e);
}
if (keycode == 20)
{
e->choose_color = 2;
next_draw(e);
}
if (keycode == 21)
{
e->choose_color = 3;
next_draw(e);
}
}
static int key_move(int keycode, t_env *e)
{
if (keycode == 125)
{
e->min_y += 0.1 * e->zoom;
e->max_y += 0.1 * e->zoom;
next_draw(e);
}
if (keycode == 126)
{
e->min_y -= 0.1 * e->zoom;
e->max_y -= 0.1 * e->zoom;
next_draw(e);
}
if (keycode == 124)
{
e->min_x += 0.1 * e->zoom;
e->max_x += 0.1 * e->zoom;
next_draw(e);
}
if (keycode == 123)
{
e->min_x -= 0.1 * e->zoom;
e->max_x -= 0.1 * e->zoom;
next_draw(e);
}
return (-1);
}
int key_draw(int keycode, t_env *e)
{
if (keycode == 53)
exit(1);
key_move(keycode, e);
if (keycode == 256)
{
e->julia_mode_on = (e->julia_mode_on + 1) % 2;
}
if (keycode == 13)
{
e->infinity += 10;
next_draw(e);
}
if (keycode == 14)
{
e->infinity -= 10;
next_draw(e);
}
if (keycode == 49)
{
init(e);
next_draw(e);
}
guess_color(keycode, e);
return (-1);
}