-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
84 lines (77 loc) · 2.43 KB
/
main.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vsivanat <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/19 20:27:04 by vsivanat #+# #+# */
/* Updated: 2024/04/11 15:48:31 by vsivanat ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
void usage(void)
{
ft_printf("Usage: ./fractol [mandelbrot | julia | burningship]\n");
ft_printf("\t-mandelbrot\n");
ft_printf("\t-julia\n");
ft_printf("\t-julia [ca] [cb]\n");
ft_printf("\t-burningship\n");
exit(-1);
}
void presettings(t_master *master)
{
master->iterations = MAX_ITERATIONS;
if (master->set == MANDELBROT)
{
master->r = MANDELBROT_R;
master->g = MANDELBROT_G;
master->b = MANDELBROT_B;
master->scale = MANDELBROT_SCALE;
loop_img_mandelbrot(master);
}
else if (master->set == JULIA)
{
master->r = JULIA_R;
master->g = JULIA_G;
master->b = JULIA_B;
master->scale = JULIA_SCALE;
loop_img_julia(master);
}
else
{
master->r = BURNINGSHIP_R;
master->g = BURNINGSHIP_G;
master->b = BURNINGSHIP_B;
master->scale = BURNINGSHIP_SCALE;
loop_img_buringship(master);
}
}
void close_window(void *param)
{
t_master *master;
master = (t_master *)param;
mlx_terminate(master->mlx);
exit(0);
}
int main(int argc, char **argv)
{
t_master master;
t_fractol fract;
t_px px;
master.fract = &fract;
master.px = &px;
if (argc < 2 || argc > 4)
usage();
which_fract(argc, argv, &master);
master.mlx = mlx_init(WINDOW_X, WINDOW_Y, master.fract->fract_name, false);
master.img = mlx_new_image(master.mlx, WINDOW_X, WINDOW_Y);
presettings(&master);
mlx_image_to_window(master.mlx, master.img, 0, 0);
mlx_scroll_hook(master.mlx, mouseaction, &master);
mlx_key_hook(master.mlx, key_pres, &master);
mlx_image_to_window(master.mlx, master.img, 0, 0);
mlx_loop(master.mlx);
close_window(&master);
return (0);
}