-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent.c
132 lines (126 loc) · 2.67 KB
/
event.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* event.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sel-hamr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/23 17:37:25 by sel-hamr #+# #+# */
/* Updated: 2019/12/25 10:13:30 by sel-hamr ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
int mouse_press(int button, int x, int y, t_t *t)
{
if (button == 5 && t->stop == 1)
zoom(t, (double)x, (double)y, 1.1);
else if (button == 4 && t->stop == 1)
zoom(t, (double)x, (double)y, 0.9);
check_ar(t);
return (1);
}
void key_press2(int keycode, t_t *t)
{
if (keycode == 124)
{
t->start_x = t->start_x - 0.037;
t->end_x = t->end_x - 0.037;
check_ar(t);
}
else if (keycode == 125)
{
t->start_y = t->start_y - 0.037;
t->end_y = t->end_y - 0.037;
check_ar(t);
}
else if (keycode == 126)
{
t->start_y = t->start_y + 0.037;
t->end_y = t->end_y + 0.037;
check_ar(t);
}
else if (keycode == 24)
{
t->max += 10;
check_ar(t);
}
else
key_press3(keycode, t);
}
int key_press(int keycode, t_t *t)
{
if (keycode == 53)
{
destroy_exit(t);
exit(0);
}
else if (keycode == 69 && t->stop == 1)
{
simple_zoome1(t);
check_ar(t);
}
else if (keycode == 78 && t->stop == 1)
{
simple_zoome2(t);
check_ar(t);
}
else if (keycode == 27)
{
if (t->max >= 10)
t->max -= 10;
check_ar(t);
}
else
key_press2(keycode, t);
return (1);
}
void key_press3(int keycode, t_t *t)
{
if (keycode == 83)
{
t->name = "julia";
init(t, t->name);
check_ar(t);
}
else if (keycode == 49)
{
if (t->stop == 0)
t->stop = 1;
else
t->stop = 0;
check_ar(t);
}
else if (keycode == 36)
{
t->color = rand();
check_ar(t);
}
else
key_press4(keycode, t);
}
void key_press4(int keycode, t_t *t)
{
if (keycode == 84)
{
t->name = "Burningship";
init(t, t->name);
check_ar(t);
}
else if (keycode == 85)
{
t->name = "Mandelbrot";
init(t, t->name);
check_ar(t);
}
else if (keycode == 82)
{
init(t, t->name);
check_ar(t);
}
else if (keycode == 123)
{
t->start_x = t->start_x + 0.037;
t->end_x = t->end_x + 0.037;
check_ar(t);
}
}