-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils2.c
120 lines (114 loc) · 3.7 KB
/
utils2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ahmaymou <ahmaymou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/09 15:11:22 by ahmaymou #+# #+# */
/* Updated: 2023/01/30 20:18:38 by ahmaymou ### ########.fr */
/* */
/* ************************************************************************** */
#include "fract_ol.h"
void change_col(int key, t_mlx_info *info)
{
if (key == 18)
info->p = WHITE;
else if (key == 19)
info->p = LIGHTGREEN;
else if (key == 20)
info->p = ORANGE;
else if (key == 21)
info->p = RED;
else if (key == 23)
info->p = LIGHTBLUE;
else if (key == 22)
info->p = YELLOW;
else if (key == 26)
info->p = KHAKI;
else if (key == 28)
info->p = LIGHTCYAN;
else if (key == 25)
info->p = GRAY;
}
void change_shape(int key, t_mlx_info *info)
{
if (key == 46 || key == 38 || key == 11 || key == 17)
boundry_init(info);
if (key == 46)
ft_strlcpy(info->type, "mandelbrot", 12);
else if (key == 38)
ft_strlcpy(info->type, "julia", 6);
else if (key == 11)
ft_strlcpy(info->type, "burningship", 12);
else if (key == 17)
ft_strlcpy(info->type, "tricorn", 8);
else if (key == 15)
boundry_init(info);
else if (key == 53)
destroy(info);
else if (key == 13)
info->offsety += 0.1;
else if (key == 0)
info->offsetx += 0.1;
else if (key == 1)
info->offsety -= 0.1;
else if (key == 2)
info->offsetx -= 0.1;
}
void boundry_init(t_mlx_info *info)
{
info->offsetx = 0;
info->offsety = 0;
info->xmax = 2;
info->ymax = 2;
info->xmin = -2;
info->ymin = -2;
info->iter_max = MAX_ITER;
}
void init(t_mlx_info *info)
{
info->mlx_ptr = mlx_init();
if (!info->mlx_ptr)
error_init(0, info);
info->window_ptr = mlx_new_window(info->mlx_ptr, WIDTH,
HEIGHT, "fractol 42");
if (!info->window_ptr)
error_init(0, info);
info->data.img = mlx_new_image(info->mlx_ptr, 800, HEIGHT);
if (!info->data.img)
error_init(1, info);
info->data.addr = mlx_get_data_addr(info->data.img,
&info->data.bits_per_pixel,
&info->data.line_length, &info->data.endian);
info->zoom = 1.2;
boundry_init(info);
info->p = WHITE;
info->stop = 0;
draw_info(info);
}
void put_strings2(t_mlx_info *info)
{
mlx_string_put(info->mlx_ptr, info->window_ptr,
830, 370, YELLOW, "LIGHTBLUE : 5");
mlx_string_put(info->mlx_ptr, info->window_ptr,
830, 400, YELLOW, "YELLOW : 6");
mlx_string_put(info->mlx_ptr, info->window_ptr,
830, 430, YELLOW, "KHAKI : 7");
mlx_string_put(info->mlx_ptr, info->window_ptr,
830, 460, YELLOW, "LIGHTCYAN : 8");
mlx_string_put(info->mlx_ptr, info->window_ptr,
830, 490, YELLOW, "GRAY : 9");
mlx_string_put(info->mlx_ptr, info->window_ptr,
830, 505, YELLOW, "------------------------------");
mlx_string_put(info->mlx_ptr, info->window_ptr,
830, 525, YELLOW, "Julia : j");
mlx_string_put(info->mlx_ptr, info->window_ptr,
830, 550, YELLOW, "Mandelbrot : m");
mlx_string_put(info->mlx_ptr, info->window_ptr,
830, 580, YELLOW, "Burninship : b");
mlx_string_put(info->mlx_ptr, info->window_ptr,
830, 610, YELLOW, "Tricorn : t");
mlx_string_put(info->mlx_ptr, info->window_ptr,
830, 640, YELLOW, "freeze Julia : f");
}