-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraw.c
36 lines (31 loc) · 1.34 KB
/
draw.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* draw.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: shongou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 23:33:16 by shongou #+# #+# */
/* Updated: 2023/01/04 23:33:18 by shongou ### ########.fr */
/* */
/* ************************************************************************** */
#include "minirt.h"
static void ft_mlx_put_pixel(t_image img, int x, int y, int rgb)
{
char *dst;
dst = img.addr + (y * img.size_line + x * (img.bpp / 8));
*(unsigned int *)dst = rgb;
}
void draw(t_color color, int x, int y, t_image img)
{
int r;
int g;
int b;
int rgb;
rgb = 0;
r = 255 * rounding_num(color.r, 0, 1);
g = 255 * rounding_num(color.g, 0, 1);
b = 255 * rounding_num(color.b, 0, 1);
rgb = (r << 16 | g << 8 | b);
ft_mlx_put_pixel(img, x, y, rgb);
}