-
Notifications
You must be signed in to change notification settings - Fork 0
/
fractol_init.c
69 lines (64 loc) · 2.36 KB
/
fractol_init.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fractol_init.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kakiba <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/31 19:41:17 by kakiba #+# #+# */
/* Updated: 2023/01/03 19:17:16 by kakiba ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
void set_fract_fanc(t_fractol *fractol)
{
if (fractol->fanc_num == MANDELBROT)
fractol->fract_fanc = drow_mandelbrot;
else if (fractol->fanc_num == JULIA)
{
fractol->julia_c.r = -0.12;
fractol->julia_c.i = 0.74;
fractol->fract_fanc = drow_julia;
}
else
exit_no_leak(fractol, ERROR);
}
void init_mlx(t_fractol *fractol)
{
fractol->mlx_server = NULL;
fractol->mlx_server = mlx_init();
if (fractol->mlx_server == NULL)
exit_no_leak(fractol, ERROR);
fractol->window = NULL;
fractol->window = \
mlx_new_window(fractol->mlx_server, WIDTH, HEIGHT, NAME);
if (fractol->window == NULL)
exit_no_leak(fractol, ERROR);
}
void init_img(t_fractol *fractol)
{
if (!fractol->mlx_server || !fractol->window)
exit_no_leak(fractol, ERROR);
fractol->img_param.img = NULL;
fractol->img_param.img = mlx_new_image(fractol->mlx_server, WIDTH, HEIGHT);
if (fractol->img_param.img == NULL)
exit_no_leak(fractol, ERROR);
fractol->img_param.address = mlx_get_data_addr(\
fractol->img_param.img, \
&(fractol->img_param.bits_per_pixel), \
&(fractol->img_param.line_length), \
&(fractol->img_param.endian) \
);
fractol->img_param.origin.x = WIDTH / 2;
fractol->img_param.origin.y = HEIGHT / 2;
fractol->img_param.zoom = 0.01;
fractol->img_param.max_loop_times = DEF_MAX_LOOP_TIME;
fractol->img_param.cursor.x = 0;
fractol->img_param.cursor.y = 0;
}
void init_mlx_img(t_fractol *fractol)
{
init_mlx(fractol);
init_img(fractol);
set_fract_fanc(fractol);
}