-
Notifications
You must be signed in to change notification settings - Fork 0
/
fractol.h
111 lines (97 loc) · 3.2 KB
/
fractol.h
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fractol.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jqueijo- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/19 12:58:23 by jqueijo- #+# #+# */
/* Updated: 2024/05/17 12:56:19 by jqueijo- ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FRACTOL_H
# define FRACTOL_H
# include "minilibx-linux/mlx.h"
# include <stdint.h> // Define integer types, limits, macros
# include <stdlib.h> // Memory allocation
# include <stdio.h> // Standard input and output, perror function / Debugging
# include <math.h> // math functions
# include <unistd.h> // System calls
# include <X11/keysym.h> // Predefined key symbols corresponding to keycodes
# include <X11/X.h> // Constant definitions for Xlib functions
# define ERROR_MESSAGE "Please enter:\n\n\
'./fractol mandelbrot' for Mandelbrot set\n\
'./fractol julia' for pre-determined Julia set\n\
'./fractol julia <re_value> <im_value>' for a custom Julia set\n\n\
Press p and m to change the number of iterations (plus and minus)\n\
Use the mouse wheel to zoom in and out\n\
Use the arrow keys to move the image\n\
Press c to change the color range\n"
# define WIDTH 800
# define HEIGHT 800
# define MAX_ITER 512
# define BLACK 0x000000
# define WHITE 0xFFFFFF
# define PURPLE 0x800080
# define TEAL 0x008080
# define MAGENTA 0xFF00FF
# define LIME 0x00FF00
# define CYAN 0x00FFFF
# define YELLOW 0xFFFF00
# define ORANGE 0xFFA500
# define HOT_PINK 0xFF69B4
# define AQUAMARINE 0x7FFFD4
# define INDIGO 0x4B0082
typedef struct s_img
{
void *img_ptr;
char *addr;
int bpp;
int line_len;
int endian;
} t_img;
typedef struct s_fractal
{
char *name;
void *mlx_ptr;
void *win_ptr;
t_img img;
int iter_definition;
int escape_value;
double shift_x;
double shift_y;
double zoom;
double julia_x;
double julia_yi;
double fractal_type;
double cmin;
double cmax;
int color_range;
int first;
int color;
} t_fractal;
typedef struct s_complex
{
double x;
double yi;
double csquare;
} t_complex;
/* string_utils.c */
int ft_strcmp(const char *str, const char *str2);
void ft_putstr_fd(char *s, int fd);
double ft_atodbl(char *s);
/* math_utils.c */
double rescale(double num, int flag);
double rescale_color(double num, t_fractal *fractal);
t_complex sum_complex(t_complex z1, t_complex z2);
t_complex square_complex(t_complex z);
int fill_mandel(t_complex *z);
/* init.c */
void fractal_init(t_fractal *fractal);
/* render.c */
void fractal_render(t_fractal *fractal);
/* events.c */
int handle_keypress(int keysym, t_fractal *fractal);
int handle_close(t_fractal *fractal);
int handle_mouse(int button, t_fractal *fractal);
#endif