/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   drawing.c                                          :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: victor </var/spool/mail/victor>            +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2024/09/15 22:12:28 by victor            #+#    #+#             */
/*   Updated: 2025/05/31 15:17:58 by victor           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "../../minirt.h"

void    rt_draw_rect(t_rect rect, t_pixel *pixel, uint id, uint color)
{
    uint    x;
    uint    y;

    y = 0;
    while (y < rect.height && rect.y + y < data.scene.h)
    {
        x = 0;
        while (x < rect.width && rect.x + x < data.scene.w)
        {
            *pixel[(rect.y + y) * data.scene.w + (rect.x + x)].color = uint_to_color(color);
            pixel[(rect.y + y) * data.scene.w + (rect.x + x)].id = id;
            x++;
        }
        y++;
    }
}

void    rt_draw_rect_blend(t_rect rect, t_pixel *pixel, uint id, uint color)
{
    uint    x;
    uint    y;

    y = 0;
    while (y < rect.height && rect.y + y < data.scene.h)
    {
        x = 0;
        while (x < rect.width && rect.x + x < data.scene.w)
        {
            *pixel[(rect.y + y) * data.scene.w + (rect.x + x)].color = \
                    uint_to_color(color_blend(*(int *)pixel[(rect.y + y) \
                            * data.scene.w + (rect.x + x)].color, color));
            pixel[(rect.y + y) * data.scene.w + (rect.x + x)].id = id;
            x++;
        }
        y++;
    }
}
