-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_program.c
More file actions
72 lines (66 loc) · 2.49 KB
/
utils_program.c
File metadata and controls
72 lines (66 loc) · 2.49 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils_program.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: valeriia <valeriia@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/19 12:12:14 by kvalerii #+# #+# */
/* Updated: 2025/01/09 23:20:33 by valeriia ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
#include "libft/libft.h"
#include <mlx.h>
t_scale create_scale(double max_imag, double min_imag,
double max_real, double min_real)
{
t_scale scale;
scale.max_imag = max_imag;
scale.min_imag = min_imag;
scale.max_real = max_real;
scale.min_real = min_real;
return (scale);
}
static void display_info(void)
{
ft_printf("Usage: ./program <parameter> [x y]\n");
ft_printf("\n");
ft_printf("Available parameters:\n");
ft_printf(" Mandelbrot Generate the Mandelbrot set.\n");
ft_printf(" Newton Generate the Mandelbrot set.\n");
ft_printf(" Julia "
"Generate the Julia set with default parameters (0.4, -0.6).\n");
ft_printf(" Julia <x> <y> "
"Generate the Julia set with custom parameters <x> and <y>.\n");
ft_printf("\n");
ft_printf("Example usage:\n");
ft_printf(" ./fractol Mandelbrot Generate Mandelbrot set.\n");
ft_printf(" ./fractol Newton Generate Newton set.\n");
ft_printf(" ./fractol Julia "
"Generate Julia set with default parameters.\n");
ft_printf(" ./fractol Julia 0.355 0.355 "
"Generate Julia set with x = 0.355, y = 0.355.\n");
}
static void send_error_msg(char *msg)
{
if (msg != NULL)
{
ft_putendl_fd(msg, 2);
display_info();
}
}
void free_and_exit(t_my_display *my_display, int exit_code, char *msg)
{
if (my_display && my_display->mlx != NULL)
{
if (my_display->img_data.img_ptr != NULL)
mlx_destroy_image(my_display->mlx, my_display->img_data.img_ptr);
if (my_display->win != NULL)
mlx_destroy_window(my_display->mlx, my_display->win);
mlx_destroy_display(my_display->mlx);
free(my_display->mlx);
}
send_error_msg(msg);
exit(exit_code);
}