-
Notifications
You must be signed in to change notification settings - Fork 0
/
fractol.c
96 lines (89 loc) · 2.97 KB
/
fractol.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fractol.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kprytkov <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/05/27 16:37:40 by kprytkov #+# #+# */
/* Updated: 2018/05/27 16:37:41 by kprytkov ### ########.fr */
/* */
/* ************************************************************************** */
#include "./includes/fractol.h"
static int exit_x(void)
{
exit(1);
return (0);
}
static int arguments_handler(char *str)
{
if (ft_strcmp(str, MANDELBROT) == 0)
return (1);
else if (ft_strcmp(str, JULIA) == 0)
return (2);
else if (ft_strcmp(str, BURNING_SHIP) == 0)
return (3);
else if (ft_strcmp(str, SIERPINSKI_CARPET) == 0)
return (4);
else if (ft_strcmp(str, DOUADY_RABBIT) == 0)
return (5);
else
return (0);
}
static void param_list(void)
{
ft_putstr("List of available parameters:\n");
ft_putstr("1: "MANDELBROT"\n");
ft_putstr("2: "JULIA"\n");
ft_putstr("3: "BURNING_SHIP"\n");
ft_putstr("4: "SIERPINSKI_CARPET"\n");
ft_putstr("5: "DOUADY_RABBIT"\n");
}
static void tips(t_env *e)
{
if (e->choose_fractal == 1 || e->choose_fractal == 3 \
|| e->choose_fractal == 4 || e->choose_fractal == 5)
{
ft_putstr("MANDELBROT'S || BURNING_SHIPS'S ");
ft_putstr("DOUADY_RABBIT'S LEGEND || SIERPINSKI_CARPET'S:\n");
ft_putstr("MOVE: up || down || left || right\n");
ft_putstr("ZOOM: mouse wheel || mouse click (left + && right -)\n");
ft_putstr("CHANGE COLOR : 1 && 2 && 3 && 4\n");
ft_putstr("CHANGE THE COLOR DEPTH: W || E\n");
ft_putstr("RESET: space\n");
}
else if (e->choose_fractal == 2)
{
ft_putstr("JULIA'S LEGEND:\n");
ft_putstr("MOVE: up || down || left || right\n");
ft_putstr("MOVING MODE ON/OFF: left ctrl\n");
ft_putstr("MOVE JULIA: mouse click || mouse cursor\n");
ft_putstr("CHANGE COLOR : 1 && 2 && 3 && 4\n");
ft_putstr("CHANGE THE COLOR DEPTH: W || E\n");
ft_putstr("RESET: space\n");
}
}
int main(int argc, char *argv[])
{
t_env *e;
if (argc == 2 && (arguments_handler(argv[1]) != 0))
{
if (!(e = malloc(sizeof(t_env))))
return (0);
if (init_mlx(e) == 0)
return (0);
e->choose_fractal = arguments_handler(argv[1]);
tips(e);
init(e);
foreach_pixel(e);
next_draw(e);
mlx_hook(e->win_ptr, 2, 5, key_draw, e);
mlx_hook(e->win_ptr, 17, 1L << 17, exit_x, NULL);
mlx_mouse_hook(e->win_ptr, mouse_zoom, e);
mlx_hook(e->win_ptr, MOTION_NOTIFY, MOTION_MASK, mouse_for_julia, e);
mlx_loop(e->mlx_ptr);
}
else
param_list();
return (0);
}