-
Notifications
You must be signed in to change notification settings - Fork 0
/
shades.c
43 lines (39 loc) · 1.64 KB
/
shades.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* shades.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maxisimo <maxisimo@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/12/10 17:31:37 by maxisimo #+# #+# */
/* Updated: 2018/12/17 12:32:48 by maxisimo ### ########.fr */
/* */
/* ************************************************************************** */
#include "doom_nukem.h"
void ft_apply_shadow_to_cf(t_color *c, int y)
{
c->r *= (1 - (800. / abs(y)) / 2.);
c->g *= (1 - (800. / abs(y)) / 2.);
c->b *= (1 - (800. / abs(y)) / 2.);
c->r = (c->r < 0) ? 0 : c->r;
c->g = (c->g < 0) ? 0 : c->g;
c->b = (c->b < 0) ? 0 : c->b;
}
void ft_apply_shadow_to_spr(t_color *c, int y)
{
c->r *= (1 - (1. / (20. / y)) / 2.);
c->g *= (1 - (1. / (20. / y)) / 2.);
c->b *= (1 - (1. / (20. / y)) / 2.);
c->r = (c->r < 0) ? 0 : c->r;
c->g = (c->g < 0) ? 0 : c->g;
c->b = (c->b < 0) ? 0 : c->b;
c->r = (c->r >= 255) ? 255 : c->r;
c->g = (c->g >= 255) ? 255 : c->g;
c->b = (c->b >= 255) ? 255 : c->b;
}
void ft_apply_shadow_to_color(t_color *c, double intensity)
{
c->r = c->r * intensity;
c->g = c->g * intensity;
c->b = c->b * intensity;
}