-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcolor.c
59 lines (49 loc) · 1.68 KB
/
color.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
48
49
50
51
52
53
54
55
56
57
58
59
/* ************************************************************************** */
/* */
/* :::::::: */
/* color.c :+: :+: */
/* +:+ */
/* By: dnoom <[email protected]> +#+ */
/* +#+ */
/* Created: 2022/04/06 11:25:31 by dnoom #+# #+# */
/* Updated: 2022/04/06 11:25:31 by dnoom ######## odam.nl */
/* */
/* ************************************************************************** */
#include "miniRT.h"
#include "vec/vec.h"
int rgb_to_color(t_vec3i color)
{
return (trgb_to_int(0, color.r, color.g, color.b));
}
t_vec3i color_to_rgb(int color)
{
t_vec3i rgb;
rgb.r = (color & (0xFF << 16)) >> 16;
rgb.g = (color & (0xFF << 8)) >> 8;
rgb.b = color & 0xFF;
return (rgb);
}
t_vec3f color_to_float_vec(t_vec3i color)
{
t_vec3f ret;
ret.x = color_to_float(color.x);
ret.y = color_to_float(color.y);
ret.z = color_to_float(color.z);
return (ret);
}
t_vec3i float_to_color_vec(t_vec3f color)
{
t_vec3i ret;
ret.x = float_to_color(color.x);
ret.y = float_to_color(color.y);
ret.z = float_to_color(color.z);
return (ret);
}
int ray_to_pixel_color(t_vec3f ray_colour)
{
t_vec3i color_int;
int color;
color_int = float_to_color_vec(ray_colour);
color = rgb_to_color(color_int);
return (color);
}