-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.h
380 lines (371 loc) · 12.3 KB
/
utils.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jferrer- <jferrer-@student.42barc...> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/19 17:56:15 by jferrer- #+# #+# */
/* Updated: 2022/03/07 20:06:48 by jferrer- ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef UTILS_H
# define UTILS_H
# include <math.h>
# include <stdio.h>
# include <unistd.h>
# include <stdlib.h>
//# include "minilibx_opengl_20191021/mlx.h"
//# include "minilibx_opengl_20191021/mlx_xpm.c"
//gcc -L minilibx_opengl_20191021 -lmlx -framework OpenGL
// -framework AppKit calculate.c utils.c -o exec
typedef struct s_data
{
void *img;
char *addr;
int bits_per_pixel;
int line_length;
int endian;
} t_data;
typedef struct s_vars
{
void *mlx;
void *win;
double x;
double y;
double scale;
double init_z;
double init_zi;
} t_vars;
typedef struct s_mem
{
void *values;
void *rows;
void *vars;
} t_mem;
/*
struct s_col_name mlx_col_name[] =
{
{"snow", 0xfffafa}, {"ghost white", 0xf8f8ff}, {"ghostwhite", 0xf8f8ff},
{"white smoke", 0xf5f5f5}, {"whitesmoke", 0xf5f5f5},
{"gainsboro", 0xdcdcdc}, {"floral white", 0xfffaf0},
{"floralwhite", 0xfffaf0}, {"old lace", 0xfdf5e6},
{"oldlace", 0xfdf5e6}, {"linen", 0xfaf0e6},
{"antique white", 0xfaebd7}, {"antiquewhite", 0xfaebd7},
{"papaya whip", 0xffefd5}, {"papayawhip", 0xffefd5},
{"blanched almond", 0xffebcd}, {"blanchedalmond", 0xffebcd},
{"bisque", 0xffe4c4}, {"peach puff", 0xffdab9},
{"peachpuff", 0xffdab9}, {"navajo white", 0xffdead},
{"navajowhite", 0xffdead}, {"moccasin", 0xffe4b5},
{"cornsilk", 0xfff8dc}, {"ivory", 0xfffff0},
{"lemon chiffon", 0xfffacd}, {"lemonchiffon", 0xfffacd},
{"seashell", 0xfff5ee}, {"honeydew", 0xf0fff0},
{"mint cream", 0xf5fffa}, {"mintcream", 0xf5fffa},
{"azure", 0xf0ffff}, {"alice blue", 0xf0f8ff},
{"aliceblue", 0xf0f8ff}, {"lavender", 0xe6e6fa},
{"lavender blush", 0xfff0f5}, {"lavenderblush", 0xfff0f5},
{"misty rose", 0xffe4e1}, {"mistyrose", 0xffe4e1},
{"white", 0xffffff}, {"black", 0x0},
{"dark slate", 0x2f4f4f}, {"darkslategray", 0x2f4f4f},
{"dark slate", 0x2f4f4f}, {"darkslategrey", 0x2f4f4f},
{"dim gray", 0x696969}, {"dimgray", 0x696969},
{"dim grey", 0x696969}, {"dimgrey", 0x696969},
{"slate gray", 0x708090}, {"slategray", 0x708090},
{"slate grey", 0x708090}, {"slategrey", 0x708090},
{"light slate", 0x778899}, {"lightslategray", 0x778899},
{"light slate", 0x778899}, {"lightslategrey", 0x778899},
{"gray", 0xbebebe}, {"grey", 0xbebebe},
{"light grey", 0xd3d3d3}, {"lightgrey", 0xd3d3d3},
{"light gray", 0xd3d3d3}, {"lightgray", 0xd3d3d3},
{"midnight blue", 0x191970}, {"midnightblue", 0x191970},
{"navy", 0x80}, {"navy blue", 0x80}, {"navyblue", 0x80},
{"cornflower blue", 0x6495ed}, {"cornflowerblue", 0x6495ed},
{"dark slate", 0x483d8b}, {"darkslateblue", 0x483d8b},
{"slate blue", 0x6a5acd}, {"slateblue", 0x6a5acd},
{"medium slate", 0x7b68ee}, {"mediumslateblue", 0x7b68ee},
{"light slate", 0x8470ff}, {"lightslateblue", 0x8470ff},
{"medium blue", 0xcd}, {"mediumblue", 0xcd},
{"royal blue", 0x4169e1}, {"royalblue", 0x4169e1},
{"blue", 0xff}, {"dodger blue", 0x1e90ff},
{"dodgerblue", 0x1e90ff}, {"deep sky", 0xbfff},
{"deepskyblue", 0xbfff}, {"sky blue", 0x87ceeb},
{"skyblue", 0x87ceeb}, {"light sky", 0x87cefa},
{"lightskyblue", 0x87cefa}, {"steel blue", 0x4682b4},
{"steelblue", 0x4682b4}, {"light steel", 0xb0c4de},
{"lightsteelblue", 0xb0c4de}, {"light blue", 0xadd8e6},
{"lightblue", 0xadd8e6}, {"powder blue", 0xb0e0e6},
{"powderblue", 0xb0e0e6}, {"pale turquoise", 0xafeeee},
{"paleturquoise", 0xafeeee}, {"dark turquoise", 0xced1},
{"darkturquoise", 0xced1}, {"medium turquoise", 0x48d1cc},
{"mediumturquoise", 0x48d1cc}, {"turquoise", 0x40e0d0},
{"cyan", 0xffff}, {"light cyan", 0xe0ffff},
{"lightcyan", 0xe0ffff}, {"cadet blue", 0x5f9ea0},
{"cadetblue", 0x5f9ea0}, {"medium aquamarine", 0x66cdaa},
{"mediumaquamarine", 0x66cdaa}, {"aquamarine", 0x7fffd4},
{"dark green", 0x6400}, {"darkgreen", 0x6400},
{"dark olive", 0x556b2f}, {"darkolivegreen", 0x556b2f},
{"dark sea", 0x8fbc8f}, {"darkseagreen", 0x8fbc8f},
{"sea green", 0x2e8b57}, {"seagreen", 0x2e8b57},
{"medium sea", 0x3cb371}, {"mediumseagreen", 0x3cb371},
{"light sea", 0x20b2aa}, {"lightseagreen", 0x20b2aa},
{"pale green", 0x98fb98}, {"palegreen", 0x98fb98},
{"spring green", 0xff7f}, {"springgreen", 0xff7f},
{"lawn green", 0x7cfc00}, {"lawngreen", 0x7cfc00},
{"green", 0xff00}, {"chartreuse", 0x7fff00},
{"medium spring", 0xfa9a}, {"mediumspringgreen", 0xfa9a},
{"green yellow", 0xadff2f}, {"greenyellow", 0xadff2f},
{"lime green", 0x32cd32}, {"limegreen", 0x32cd32},
{"yellow green", 0x9acd32}, {"yellowgreen", 0x9acd32},
{"forest green", 0x228b22}, {"forestgreen", 0x228b22},
{"olive drab", 0x6b8e23}, {"olivedrab", 0x6b8e23},
{"dark khaki", 0xbdb76b}, {"darkkhaki", 0xbdb76b},
{"khaki", 0xf0e68c}, {"pale goldenrod", 0xeee8aa},
{"palegoldenrod", 0xeee8aa}, {"light goldenrod", 0xfafad2},
{"lightgoldenrodyellow", 0xfafad2}, {"light yellow", 0xffffe0},
{"lightyellow", 0xffffe0}, {"yellow", 0xffff00},
{"gold", 0xffd700}, {"light goldenrod", 0xeedd82},
{"lightgoldenrod", 0xeedd82}, {"goldenrod", 0xdaa520},
{"dark goldenrod", 0xb8860b}, {"darkgoldenrod", 0xb8860b},
{"rosy brown", 0xbc8f8f}, {"rosybrown", 0xbc8f8f},
{"indian red", 0xcd5c5c}, {"indianred", 0xcd5c5c},
{"saddle brown", 0x8b4513}, {"saddlebrown", 0x8b4513},
{"sienna", 0xa0522d}, {"peru", 0xcd853f},
{"burlywood", 0xdeb887}, {"beige", 0xf5f5dc},
{"wheat", 0xf5deb3}, {"sandy brown", 0xf4a460},
{"sandybrown", 0xf4a460}, {"tan", 0xd2b48c},
{"chocolate", 0xd2691e}, {"firebrick", 0xb22222},
{"brown", 0xa52a2a}, {"dark salmon", 0xe9967a},
{"darksalmon", 0xe9967a}, {"salmon", 0xfa8072},
{"light salmon", 0xffa07a}, {"lightsalmon", 0xffa07a},
{"orange", 0xffa500}, {"dark orange", 0xff8c00},
{"darkorange", 0xff8c00}, {"coral", 0xff7f50},
{"light coral", 0xf08080}, {"lightcoral", 0xf08080},
{"tomato", 0xff6347}, {"orange red", 0xff4500},
{"orangered", 0xff4500}, {"red", 0xff0000},
{"hot pink", 0xff69b4}, {"hotpink", 0xff69b4},
{"deep pink", 0xff1493}, {"deeppink", 0xff1493},
{"pink", 0xffc0cb}, {"light pink", 0xffb6c1},
{"lightpink", 0xffb6c1}, {"pale violet", 0xdb7093},
{"palevioletred", 0xdb7093}, {"maroon", 0xb03060},
{"medium violet", 0xc71585}, {"mediumvioletred", 0xc71585},
{"violet red", 0xd02090}, {"violetred", 0xd02090},
{"magenta", 0xff00ff}, {"violet", 0xee82ee},
{"plum", 0xdda0dd}, {"orchid", 0xda70d6},
{"medium orchid", 0xba55d3},
{"mediumorchid", 0xba55d3},
{"dark orchid", 0x9932cc},
{"darkorchid", 0x9932cc},
{"dark violet", 0x9400d3},
{"darkviolet", 0x9400d3},
{"blue violet", 0x8a2be2},
{"blueviolet", 0x8a2be2},
{"purple", 0xa020f0},
{"medium purple", 0x9370db},
{"mediumpurple", 0x9370db},
{"thistle", 0xd8bfd8},
{"snow1", 0xfffafa},
{"snow2", 0xeee9e9},
{"seashell1", 0xfff5ee},
{"seashell2", 0xeee5de},
{"antiquewhite1", 0xffefdb},
{"antiquewhite2", 0xeedfcc},
{"bisque1", 0xffe4c4},
{"bisque2", 0xeed5b7},
{"peachpuff1", 0xffdab9},
{"peachpuff2", 0xeecbad},
{"navajowhite1", 0xffdead},
{"navajowhite2", 0xeecfa1},
{"lemonchiffon1", 0xfffacd},
{"lemonchiffon2", 0xeee9bf},
{"cornsilk1", 0xfff8dc},
{"cornsilk2", 0xeee8cd},
{"ivory1", 0xfffff0},
{"ivory2", 0xeeeee0},
{"honeydew1", 0xf0fff0},
{"honeydew2", 0xe0eee0},
{"lavenderblush1", 0xfff0f5},
{"lavenderblush2", 0xeee0e5},
{"mistyrose1", 0xffe4e1},
{"mistyrose2", 0xeed5d2},
{"azure1", 0xf0ffff},
{"azure2", 0xe0eeee},
{"slateblue1", 0x836fff},
{"slateblue2", 0x7a67ee},
{"royalblue1", 0x4876ff},
{"royalblue2", 0x436eee},
{"blue1", 0xff},
{"blue2", 0xee},
{"dodgerblue1", 0x1e90ff},
{"dodgerblue2", 0x1c86ee},
{"steelblue1", 0x63b8ff},
{"steelblue2", 0x5cacee},
{"deepskyblue1", 0xbfff},
{"deepskyblue2", 0xb2ee},
{"skyblue1", 0x87ceff},
{"skyblue2", 0x7ec0ee},
{"lightskyblue1", 0xb0e2ff},
{"lightskyblue2", 0xa4d3ee},
{"slategray1", 0xc6e2ff},
{"slategray2", 0xb9d3ee},
{"lightsteelblue1", 0xcae1ff},
{"lightsteelblue2", 0xbcd2ee},
{"lightblue1", 0xbfefff},
{"lightblue2", 0xb2dfee},
{"lightcyan1", 0xe0ffff},
{"lightcyan2", 0xd1eeee},
{"paleturquoise1", 0xbbffff},
{"paleturquoise2", 0xaeeeee},
{"cadetblue1", 0x98f5ff},
{"cadetblue2", 0x8ee5ee},
{"turquoise1", 0xf5ff},
{"turquoise2", 0xe5ee},
{"cyan1", 0xffff},
{"cyan2", 0xeeee},
{"darkslategray1", 0x97ffff},
{"darkslategray2", 0x8deeee},
{"aquamarine1", 0x7fffd4},
{"aquamarine2", 0x76eec6},
{"darkseagreen1", 0xc1ffc1},
{"darkseagreen2", 0xb4eeb4},
{"seagreen1", 0x54ff9f},
{"seagreen2", 0x4eee94},
{"palegreen1", 0x9aff9a},
{"palegreen2", 0x90ee90},
{"springgreen1", 0xff7f},
{"springgreen2", 0xee76},
{"green1", 0xff00},
{"green2", 0xee00},
{"chartreuse1", 0x7fff00},
{"chartreuse2", 0x76ee00},
{"olivedrab1", 0xc0ff3e},
{"olivedrab2", 0xb3ee3a},
{"darkolivegreen1", 0xcaff70},
{"darkolivegreen2", 0xbcee68},
{"khaki1", 0xfff68f},
{"khaki2", 0xeee685},
{"lightgoldenrod1", 0xffec8b},
{"lightgoldenrod2", 0xeedc82},
{"lightyellow1", 0xffffe0},
{"lightyellow2", 0xeeeed1},
{"yellow1", 0xffff00},
{"yellow2", 0xeeee00},
{"gold1", 0xffd700},
{"gold2", 0xeec900},
{"goldenrod1", 0xffc125},
{"goldenrod2", 0xeeb422},
{"darkgoldenrod1", 0xffb90f},
{"darkgoldenrod2", 0xeead0e},
{"rosybrown1", 0xffc1c1},
{"rosybrown2", 0xeeb4b4},
{"indianred1", 0xff6a6a},
{"indianred2", 0xee6363},
{"sienna1", 0xff8247},
{"sienna2", 0xee7942},
{"burlywood1", 0xffd39b},
{"burlywood2", 0xeec591},
{"wheat1", 0xffe7ba},
{"wheat2", 0xeed8ae},
{"tan1", 0xffa54f},
{"tan2", 0xee9a49},
{"chocolate1", 0xff7f24},
{"chocolate2", 0xee7621},
{"firebrick1", 0xff3030},
{"firebrick2", 0xee2c2c},
{"brown1", 0xff4040},
{"brown2", 0xee3b3b},
{"salmon1", 0xff8c69},
{"salmon2", 0xee8262},
{"lightsalmon1", 0xffa07a},
{"lightsalmon2", 0xee9572},
{"orange1", 0xffa500},
{"orange2", 0xee9a00},
{"darkorange1", 0xff7f00},
{"darkorange2", 0xee7600},
{"coral1", 0xff7256},
{"coral2", 0xee6a50},
{"tomato1", 0xff6347},
{"tomato2", 0xee5c42},
{"orangered1", 0xff4500},
{"orangered2", 0xee4000},
{"red1", 0xff0000},
{"red2", 0xee0000},
{"deeppink1", 0xff1493},
{"deeppink2", 0xee1289},
{"hotpink1", 0xff6eb4},
{"hotpink2", 0xee6aa7},
{"pink1", 0xffb5c5},
{"pink2", 0xeea9b8},
{"lightpink1", 0xffaeb9},
{"lightpink2", 0xeea2ad},
{"palevioletred1", 0xff82ab},
{"palevioletred2", 0xee799f},
{"maroon1", 0xff34b3},
{"maroon2", 0xee30a7},
{"violetred1", 0xff3e96},
{"violetred2", 0xee3a8c},
{"magenta1", 0xff00ff},
{"magenta2", 0xee00ee},
{"orchid1", 0xff83fa},
{"orchid2", 0xee7ae9},
{"plum1", 0xffbbff},
{"plum2", 0xeeaeee},
{"mediumorchid1", 0xe066ff},
{"mediumorchid2", 0xd15fee},
{"darkorchid1", 0xbf3eff},
{"darkorchid2", 0xb23aee},
{"purple1", 0x9b30ff},
{"purple2", 0x912cee},
{"mediumpurple1", 0xab82ff},
{"mediumpurple2", 0x9f79ee},
{"thistle1", 0xffe1ff},
{"thistle2", 0xeed2ee},
{"gray0", 0x0},
{"grey0", 0x0},
{"gray1", 0x30303},
{"grey1", 0x30303},
{"gray2", 0x50505},
{"grey2", 0x50505},
{"gray3", 0x80808},
{"grey3", 0x80808},
{"gray4", 0xa0a0a},
{"grey4", 0xa0a0a},
{"gray5", 0xd0d0d},
{"grey5", 0xd0d0d},
{"gray6", 0xf0f0f},
{"grey6", 0xf0f0f},
{"gray7", 0x121212},
{"grey7", 0x121212},
{"gray8", 0x141414},
{"grey8", 0x141414},
{ "gray9", 0x171717},
{"grey99", 0xfcfcfc},
{"gray100", 0xffffff},
{"grey100", 0xffffff},
{"dark grey", 0xa9a9a9},
{"darkgrey", 0xa9a9a9},
{"dark gray", 0xa9a9a9},
{"darkgray", 0xa9a9a9},
{"dark blue", 0x8b},
{"darkblue", 0x8b},
{"dark cyan", 0x8b8b},
{"darkcyan", 0x8b8b},
{"dark magenta", 0x8b008b},
{"darkmagenta", 0x8b008b},
{"dark red", 0x8b0000},
{"darkred", 0x8b0000},
{"light green", 0x90ee90},
{"lightgreen", 0x90ee90}, {"none", -1}, {0, 0}
};
*/
void printfrac(void *p, void *window, double **coords);
double **init_mandelbrot(t_vars *vars, t_mem *mem);
double **init_julia(t_vars *vars, t_mem *mem);
int ft_strncmp(const char *s1, const char *s2, size_t n);
size_t ft_strlen(const char *str);
double double_atoi(const char *str);
int mouse_hook_m(int key, int x, int y, t_vars *vars);
int mouse_hook_j(int key, int x, int y, t_vars *vars);
int escape(int key, t_mem *mem);
void init_data(t_vars *vars, double z, double zi);
double **create_array(int i, t_mem *mem);
#endif