-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_utils.c
47 lines (41 loc) · 1.51 KB
/
map_utils.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* map_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rblondia <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/01 18:20:25 by rblondia #+# #+# */
/* Updated: 2021/12/17 16:21:41 by rblondia ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../includes/fdf.h"
int get_index(int x, int y, int width)
{
return (y * width + x);
}
t_v3f new_3d_point(int x, int y, t_map *map)
{
t_v3f point;
int index;
index = get_index(x, y, map->width);
point.x = x;
point.y = y;
point.z = map->cords[index]->z;
return (point);
}
int get_default_color(int z, t_map *map)
{
double percentage;
percentage = percent(map->z_min, map->z_max, z);
if (percentage < 0.2)
return (COLOR_DISCO);
else if (percentage < 0.4)
return (COLOR_BRICK_RED);
else if (percentage < 0.6)
return (COLOR_FLAMINGO);
else if (percentage < 0.8)
return (COLOR_JAFFA);
else
return (COLOR_SAFFRON);
}