aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_draw_square.c
blob: a535be414593031bf7cbe9446494157f0284e0a7 (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
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_draw_square.c                                   :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/14 17:28:46 by rbousset          #+#    #+#             */
/*   Updated: 2020/02/14 17:28:46 by rbousset         ###   ########lyon.fr   */
/*                                                                            */
/* ************************************************************************** */

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

void
	ft_draw_square(int a, int b, int rgb, t_cub *clist)
{
	const uint16_t	scale = clist->mlist.scale;
	int				x;
	int				y;

	x = a;
	y = b;
	while (x >= a - scale)
	{
		while (y >= b - scale)
		{
			*(int*)(clist->img.ptr + (x * 4 + (y * clist->img.sizeline))) = rgb;
			y--;
		}
		y = b;
		x--;
	}
}