-
Notifications
You must be signed in to change notification settings - Fork 0
/
fractol.h
113 lines (100 loc) · 2.99 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fractol.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rd-agost <rd-agost@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/28 12:01:22 by rd-agost #+# #+# */
/* Updated: 2024/08/07 21:18:55 by rd-agost ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FRACTOL_H
# define FRACTOL_H
# include <stdio.h>
# include <stdlib.h>
# include <unistd.h>
# include <X11/X.h>
# include <X11/Xlib.h>
# include <X11/keysym.h>
# include <math.h>
# include "minilibx-linux/mlx.h"
# define ERROR_MSG "Input errato, scegli un frattale"
# define HEIGHT 700
# define WIDTH 700
# define BLACK 0x000000
# define WHITE 0xFFFFFF
# define RED 0xFF0000
# define BLUE 0x0000FF
# define MAGENTA 0xFF00FF
# define LIME_SHOCK 0xCCFF00
# define NEON_ORANGE 0xFF6600
# define PSYCHEDELIC_PURPLE 0x660066
# define AQUA_DREAM 0x33CCCC
# define HOT_PINK 0xFF66B2
# define ELECTRIC_BLUE 0x0066FF
# define LAVA_RED 0xFF3300
/*
PIXEL BUFFER AKA IMAGE
- values fom mlx_get_data_addr()
- ptr to image struct
- ptr that will be used to change pixels in our img
(points to the actual pixels)
- bits per pixel
*/
typedef struct s_img
{
void *img_ptr;
char *pixels_ptr;
int bits_pp;
int endian;
int line_len;
} t_img;
/*
FRACTAL ESSENTIALS
- ptr coming from mlx_init()
- ptr coming from mlx_new_window()
- image perche' px by px anche no
- hooks values
*/
typedef struct s_fractal
{
char *name;
void *mlx_connection;
void *mlx_window;
t_img img;
double escape_value;
int iterations;
double shift_x;
double shift_y;
double zoom;
double julia_x;
double julia_y;
} t_fractal;
/*
COMPLEX NUM
*/
typedef struct s_complex
{
double x;
double y;
} t_complex;
// utils_one.c
int ft_strncmp(char *s1, char *s2, size_t n);
void putstr_fd(char *s, int fd);
int ft_strlen(char *s);
double ft_atodbl(char *s);
//utils_two.c
double scale(double un_n, double n_mn, double n_mx, double o_mx);
t_complex ft_vector_sum(t_complex z1, t_complex z2);
t_complex ft_square_complex(t_complex z);
//init.c
void ft_fractal_init(t_fractal *fractal);
//rendering.c
void ft_render(t_fractal *fractal);
//event_listeners.c
int ft_key_handler(int keysym, t_fractal *fractal);
int ft_close_handler(t_fractal *fractal);
int ft_mouse_handler(int button, int x, int y, t_fractal *fractal);
int ft_julia_track(int x, int y, t_fractal *fractal);
#endif