diff options
author | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2020-03-07 20:30:07 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2020-03-07 20:30:07 +0100 |
commit | ced2be0469537a5d21043325c9bc54762197ec30 (patch) | |
tree | 0147b95e157bec2b301e82badc1532d40335201b /src/ft_darken_rgb.c | |
parent | The sky is nice (diff) | |
download | 42-cub3d-ced2be0469537a5d21043325c9bc54762197ec30.tar.gz 42-cub3d-ced2be0469537a5d21043325c9bc54762197ec30.tar.bz2 42-cub3d-ced2be0469537a5d21043325c9bc54762197ec30.tar.xz 42-cub3d-ced2be0469537a5d21043325c9bc54762197ec30.tar.zst 42-cub3d-ced2be0469537a5d21043325c9bc54762197ec30.zip |
qwe
Diffstat (limited to '')
-rw-r--r-- | src/ft_darken_rgb.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/ft_darken_rgb.c b/src/ft_darken_rgb.c index 3587d72..fe69fa2 100644 --- a/src/ft_darken_rgb.c +++ b/src/ft_darken_rgb.c @@ -15,20 +15,33 @@ #include <stdio.h> uint32_t - ft_darken_rgb(t_rgb rgb, t_cub *cl) + ft_darken_ceil(t_rgb rgb, t_cub *cl) { t_rgb darker; - float dist; float calc; - if ((dist = cl->rlist.wall_dist) <= 0) - dist = 0.0001; - calc = (dist * 0.2); - calc = (calc >= 255) ? (255) : (calc); - calc = (calc < 1) ? (1) : (calc); darker = rgb; - darker.r /= calc; - darker.g /= calc; - darker.b /= calc; + calc = ((float)(cl->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; + return (ft_rgb_to_hex(darker)); +} + +uint32_t + ft_darken_floor(t_rgb rgb, t_cub *cl) +{ + t_rgb darker; + float calc; + + calc = ((float)(cl->y + (75000.0 / cl->wlist.y_size)) + / (cl->wlist.y_size / 2)) - 1.0; + calc = (calc < 0) ? (0) : (calc); + darker = rgb; + darker.r *= calc; + darker.g *= calc; + darker.b *= calc; return (ft_rgb_to_hex(darker)); } |