blob: 7526412ecebea496171c93714b447778af4fde07 (
plain)
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fractol.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/24 09:28:16 by cacharle #+# #+# */
/* Updated: 2020/02/24 13:18:04 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FRACTOL_H
# define FRACTOL_H
# include <unistd.h>
# include <stdlib.h>
# include <stdbool.h>
# include <fcntl.h>
# include <math.h>
# include "mlx.h"
# include "libft.h"
# include "libft_math.h"
# define WINDOW_TITLE "fractol"
# define WINDOW_WIDTH 640
# define WINDOW_HEIGHT 480
# define WINDOW_WIDTH_DOUBLE 640.0
# define WINDOW_HEIGHT_DOUBLE 480.0
# define MLXK_ESC 53
# define MLXK_LEFT 123
# define MLXK_RIGHT 124
# define MLX_LITTLE_ENDIAN 0
# define MLX_BIG_ENDIAN 1
# define PALETTE_SIZE 21
typedef union
{
unsigned int hexcode;
struct
{
uint8_t b;
uint8_t g;
uint8_t r;
uint8_t alpha;
} rgb;
} t_color;
typedef struct
{
int width;
int height;
void *id;
char *data;
int depth;
int size_line;
int endian;
} t_image;
typedef struct
{
double r;
double i;
} t_complex;
typedef int (*t_func_fractal)(t_complex z);
typedef struct
{
bool running;
void *mlx_ptr;
void *window_ptr;
t_image window;
t_complex window_complex[WINDOW_HEIGHT * WINDOW_WIDTH];
t_color palette[PALETTE_SIZE];
t_func_fractal func;
t_complex center;
t_complex plane;
} t_state;
/*
** state.c
*/
int state_init(t_state *state, char *fractal_name);
int state_destroy(t_state *state);
/*
** render.c
*/
int render_update(t_state *state);
void render_update_window_complex(t_state *state);
/*
** event.c
*/
int event_quit(t_state *state);
int event_keydown(int key, t_state *state);
/*
** fractals/
*/
int mandelbrot(t_complex z);
/*
** helper.c
*/
void h_offset_to_complex(t_state *state, t_complex *z, int offset);
#endif
|