Beispiel #1
0
static int	ft_drawtile(int i, int j, t_game *g)
{
        int		y;
        int		x;
        int		start_x;
        int		start_y;
        int		c;

        start_y = i * (g->tiley + 1);
        start_x = j * (g->tilex + 1);
        y = -1;
        while (++y < (g->tiley + 2))
        {
                x = -1;
                while (++x < (g->tilex + 2))
                {
                        if (!(y % (g->tiley + 1)) || !(x % (g->tilex + 1)))
                                c = ft_getcolor(-1);
                        else
                                c = ft_getcolor(g->tab[i * g->square + j]);
                        attron(COLOR_PAIR(c));
                        mvprintw(start_y + y, start_x + x, " ");
                        attroff(COLOR_PAIR(c));
                }
        }
        return (0);
}
void			ft_draw_raytracer(t_data *d, int x, int y)
{
	t_vect		inter;
	int			nb_obj;
	int			index[2];

	index[0] = 0;
	while (index[0] < d->img.size[0])
	{
		index[1] = 0;
		while (index[1] < d->img.size[1])
		{
			d->c.c = 0;
			nb_obj = ft_ray_tracing(d, index, &inter);
			if (nb_obj > -1)
				ft_getcolor(d, &inter, nb_obj);
			ft_put_pixel_to_image(d, index[0] + x, index[1] + y, d->c.c);
			index[1]++;
		}
		index[0]++;
	}
	write(2, BLUE, 7);
	write(2, "Draw: done\n", 11);
	write(2, END, 4);
}
Beispiel #3
0
void	ft_drawhorizontal(t_env *e, t_point p, t_point p1)
{
	while (p.x < p1.x)
	{
		ft_imgpixelput(e, p.x, p.y, ft_getcolor(e, p));
		p.x++;
	}
}
Beispiel #4
0
static int	ft_drawvalue(int i, int j, t_game *g)
{
        int		sx;
        int		sy;
        int		v;

        v = g->tab[i * g->square + j];
        sy = i * (g->tiley + 1) + 1 + g->tiley / 2;
        sx = j * (g->tilex + 1) + 1 + (g->tilex - ft_nbrlen(v)) / 2;
        if (v)
        {
                attron(COLOR_PAIR(ft_getcolor(v)) | A_BOLD);
                mvprintw(sy, sx, "%d", v);
                attroff(COLOR_PAIR(ft_getcolor(v)) | A_BOLD);
        }
        return (1);
}
Beispiel #5
0
int		ft_hsvtorgb(double hue, double saturation, double value)
{
	t_color		c;

	c.hi = ((int)floor(hue / 60)) % 6;
	c.f = hue / 60 - floor(hue / 60);
	value = value * 255;
	c.v = (int)value;
	c.p = (int)value * (1 - saturation);
	c.q = (int)value * (1 - c.f * saturation);
	c.t = (int)value * (1 - (1 - c.f) * saturation);
	if (c.hi == 0)
		return (ft_getcolor(c.v, c.t, c.p));
	else if (c.hi == 1)
		return (ft_getcolor(c.q, c.v, c.p));
	else if (c.hi == 2)
		return (ft_getcolor(c.p, c.v, c.t));
	else if (c.hi == 3)
		return (ft_getcolor(c.p, c.q, c.v));
	else if (c.hi == 4)
		return (ft_getcolor(c.t, c.p, c.v));
	else
		return (ft_getcolor(c.v, c.p, c.q));
}