aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_darken_rgb.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-08 00:26:09 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-08 00:26:09 +0100
commit1842a21f7187f32982f9f19623affbc48b4f4573 (patch)
tree37ac21c1fa4bdb5cac2e407015c3c2e23578c6c8 /src/ft_darken_rgb.c
parentdefines are bav (diff)
download42-cub3d-1842a21f7187f32982f9f19623affbc48b4f4573.tar.gz
42-cub3d-1842a21f7187f32982f9f19623affbc48b4f4573.tar.bz2
42-cub3d-1842a21f7187f32982f9f19623affbc48b4f4573.tar.xz
42-cub3d-1842a21f7187f32982f9f19623affbc48b4f4573.tar.zst
42-cub3d-1842a21f7187f32982f9f19623affbc48b4f4573.zip
I gotta figure out
Diffstat (limited to 'src/ft_darken_rgb.c')
-rw-r--r--src/ft_darken_rgb.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/ft_darken_rgb.c b/src/ft_darken_rgb.c
index 564dfbd..7f5e12a 100644
--- a/src/ft_darken_rgb.c
+++ b/src/ft_darken_rgb.c
@@ -12,21 +12,23 @@
#include <cub3d.h>
#include <stdint.h>
-#include <stdio.h>
uint32_t
ft_darken_ceil(t_rgb rgb, int32_t y, t_cub *cl)
{
t_rgb darker;
+ float dist;
float calc;
darker = rgb;
- calc = ((float)(y - (75000.0 / cl->wlist.y_size))
- / (cl->wlist.y_size / 2));
- calc = (calc < 0) ? (0) : (calc);
- darker.r *= 1 - calc;
- darker.g *= 1 - calc;
- darker.b *= 1 - calc;
+ (void)y;
+ dist = (cl->rlist.ceil_dist > 0) ? (cl->rlist.ceil_dist) : (0.0001);
+ calc = dist * 0.4;
+ calc = (calc >= 255) ? (255) : (calc);
+ calc = (calc < 1) ? (1) : (calc);
+ darker.r /= calc;
+ darker.g /= calc;
+ darker.b /= calc;
return (ft_rgb_to_hex(darker));
}