aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_darken_rgb.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ft_darken_rgb.c33
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));
}