aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_darken_rgb.c
blob: 97d0c0e7e553b95f0ea19ce2c35bd28cdb5b40d0 (plain)
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
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_darken_rgb.c                                    :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/03/05 16:04:28 by rbousset          #+#    #+#             */
/*   Updated: 2020/03/05 16:04:29 by rbousset         ###   ########lyon.fr   */
/*                                                                            */
/* ************************************************************************** */

#include <cub3d.h>
#include <stdint.h>
#include <stdio.h>

uint32_t
	ft_darken_rgb(t_rgb rgb, int32_t y, t_cub *cl)
{
	t_rgb		darker;
	uint8_t		calc;

	calc = (((cl->wlist.y_size / 2) + y)),
	calc = (calc >= 255) ? (255) : (calc);
	calc = (calc < 1) ? (1) : (calc);
	darker = rgb;
	darker.r /= calc;
	darker.g /= calc;
	darker.b /= calc;
	return (ft_rgb_to_hex(darker));
}