-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfractol.h
126 lines (111 loc) · 3.05 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fractol.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gmiyakaw <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/17 14:53:30 by gmiyakaw #+# #+# */
/* Updated: 2022/12/21 10:53:11 by gmiyakaw ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FRACTOL_H
# define FRACTOL_H
# define HEIGHT 1250
# define LENGTH 1250
# define MAX_ITERATION 25
# define MANDELBROT 1
# define JULIA 2
# include "./libft/libft.h"
# include "./minilibx_opengl_20191021/mlx.h"
# include <stdlib.h>
# include <math.h>
# include <stdio.h>
# include <math.h>
enum {
W = 13,
A = 0,
S = 1,
D = 2,
UP_ARROW = 126,
DOWN_ARROW = 125,
LEFT_ARROW = 123,
RIGHT_ARROW = 124,
LEFT_CTRL = 256,
LEFT_ALT = 261,
LEFT_SHIFT = 257,
ESC = 53,
ON_DESTROY = 17,
ON_MOUSE_DW = 4,
};
typedef struct s_color
{
int r;
int g;
int b;
int t;
} t_color;
typedef struct s_img
{
void *img;
char *addr;
int bpp;
int line_len;
int endian;
} t_img;
typedef struct s_data
{
void *mlx;
void *win;
t_img *img_data;
t_color *color;
double min_r;
double max_r;
double min_i;
double max_i;
unsigned int count;
int color_shift;
int resolution_shift;
int set;
double center_i;
double center_r;
double julia_shiftx;
double julia_shifty;
char **args;
} t_data;
// initialization functions
t_data clean_init(void);
void mlx_setup(t_data *f);
void command_list(t_data *f);
void win_gen(t_data *f);
// Sorting / Parsing functions
void sort_fractal(t_data *f, char *arg);
int generate_fractal(t_data *f);
void set_minmax(t_data *f);
// Mandelbrot functions
int is_mandelbrot(double cr, double ci, t_data *f);
void gen_mandelbrot(t_data *f);
// Julia functions
void gen_julia(t_data *f);
int is_julia(double cr, double ci, t_data *f);
void julia_shift(int x, int y, t_data *f);
// render and color functions
void my_px_put(t_img *img, int x, int y, int color);
int make_color(t_data *f);
int create_trgb(int t, int r, int g, int b);
void shift_color(t_data *f);
void apply_shift(t_data *f);
int get_red(int color_value);
int get_green(int color_value);
int get_blue(int color_value);
// MISC functions
int ft_is_little_endian(void);
// exit functions
void clean_exit(t_data *f);
// event handling functions:
int handle_keys(int keycode, t_data *f);
int handle_mouse(int x, int y, int mousecode, t_data *f);
void mouse_zoom(t_data *f, double zoom, int x, int y);
void move(t_data *f, char direction);
void handle_events(t_data *f);
#endif