diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-23 18:04:38 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-23 18:04:38 +0100 |
commit | 50759fcc4f3b939ad35254ce220c206056f3f31e (patch) | |
tree | fd28f91d64ccefe142927eeaf9dc85e5719c3666 /src/ft_rgb_to_hex.c | |
parent | Good tweak (diff) | |
download | 42-cub3d-50759fcc4f3b939ad35254ce220c206056f3f31e.tar.gz 42-cub3d-50759fcc4f3b939ad35254ce220c206056f3f31e.tar.bz2 42-cub3d-50759fcc4f3b939ad35254ce220c206056f3f31e.tar.xz 42-cub3d-50759fcc4f3b939ad35254ce220c206056f3f31e.tar.zst 42-cub3d-50759fcc4f3b939ad35254ce220c206056f3f31e.zip |
Fixed
Diffstat (limited to 'src/ft_rgb_to_hex.c')
-rw-r--r-- | src/ft_rgb_to_hex.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ft_rgb_to_hex.c b/src/ft_rgb_to_hex.c index e101dcf..2b72287 100644 --- a/src/ft_rgb_to_hex.c +++ b/src/ft_rgb_to_hex.c @@ -14,10 +14,14 @@ #include <stdint.h> uint32_t - ft_rgb_to_hex(t_rgb rgb) + ft_rgb_to_hex(float dist, t_rgb rgb, t_cub *cl) { uint32_t res; + float calc; + calc = (dist * 0.1 * cl->mlist.darklvl); + calc = (calc >= 255) ? (255) : (calc); + calc = (calc < 1) ? (1) : (calc); rgb.r = (rgb.r > 255) ? (255) : (rgb.r); rgb.g = (rgb.g > 255) ? (255) : (rgb.g); rgb.b = (rgb.b > 255) ? (255) : (rgb.b); @@ -25,6 +29,7 @@ uint32_t rgb.g = (rgb.g < 0) ? (0) : (rgb.g); rgb.b = (rgb.b < 0) ? (0) : (rgb.b); res = 0; - res += ((rgb.r << 16) + (rgb.g << 8) + rgb.b); + res += (((uint8_t)(rgb.r / calc) << 16) + ((uint8_t)(rgb.g / calc) << 8) + + (uint8_t)(rgb.b / calc)); return (res); } |