-
Notifications
You must be signed in to change notification settings - Fork 0
/
fdf_gradient_colors.c
48 lines (41 loc) · 1.63 KB
/
fdf_gradient_colors.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fdf_gradient_colors.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yettabaa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/29 22:19:34 by yettabaa #+# #+# */
/* Updated: 2023/01/31 04:50:01 by yettabaa ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
static int get_b(int trgb)
{
return (trgb & 0xFF);
}
static int get_g(int trgb)
{
return ((trgb >> 8) & 0xFF);
}
static int get_r(int trgb)
{
return ((trgb >> 16) & 0xFF);
}
static int get_t(int trgb)
{
return ((trgb >> 24) & 0xFF);
}
int ft_gradient(int start_color, int end_color, double percent)
{
int grad[4];
grad[0] = (int)round((1 - percent) * get_b(start_color) + percent
* get_b(end_color));
grad[1] = (int)round((1 - percent) * get_g(start_color) + percent
* get_g(end_color));
grad[2] = (int)round((1 - percent) * get_r(start_color) + percent
* get_r(end_color));
grad[3] = (int)round((1 - percent) * get_t(start_color) + percent
* get_t(end_color));
return (grad[3] << 24 | grad[2] << 16 | grad[1] << 8 | grad[0]);
}