aboutsummaryrefslogtreecommitdiff
path: root/parse/parse_color.c
blob: f60270614df1c70846442c72a335d38bbe52b985 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   parse_color.c                                      :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: cacharle <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/01/11 09:52:34 by cacharle          #+#    #+#             */
/*   Updated: 2020/01/11 10:14:29 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "cub3d.h"

t_bool	parse_ceilling_color(t_state *state, char *line)
{
	int	tmp;

	line++;
	if ((tmp = ft_atoi(line)) > 255 || tmp < 0)
		return (FALSE);
	state->ceilling_color.rgb.r = (t_byte)tmp;
	if ((line = ft_strchr(line, ',') + 1) == NULL)
		return (FALSE);
	if ((tmp = ft_atoi(line)) > 255 || tmp < 0)
		return (FALSE);
	state->ceilling_color.rgb.g = (t_byte)tmp;
	if ((line = ft_strchr(line, ',') + 1) == NULL)
		return (FALSE);
	if ((tmp = ft_atoi(line)) > 255 || tmp < 0)
		return (FALSE);
	state->ceilling_color.rgb.b = (t_byte)tmp;
	return (TRUE);
}

t_bool	parse_floor_color(t_state *state, char *line)
{
	int	tmp;

	line++;
	if ((tmp = ft_atoi(line)) > 255 || tmp < 0)
		return (FALSE);
	state->floor_color.rgb.r = (t_byte)tmp;
	if ((line = ft_strchr(line, ',') + 1) == NULL)
		return (FALSE);
	if ((tmp = ft_atoi(line)) > 255 || tmp < 0)
		return (FALSE);
	state->floor_color.rgb.g = (t_byte)tmp;
	if ((line = ft_strchr(line, ',') + 1) == NULL)
		return (FALSE);
	if ((tmp = ft_atoi(line)) > 255 || tmp < 0)
		return (FALSE);
	state->floor_color.rgb.b = (t_byte)tmp;
	return (TRUE);
}