Esempio n. 1
0
void	ft_draw_map(t_env *e)
{
	t_point		pt1;
	t_point		pt2;
	int			i;
	int			j;

	i = 0;
	while (i < e->nb_line && !(j = 0))
	{
		while (j < e->size[i])
		{
			pt1 = ft_get_point(e, e->points[i][j], &ft_iso);
			if (j < e->size[i] - 1)
			{
				pt2 = ft_get_point(e, e->points[i][j + 1], &ft_iso);
				ft_draw_line(e, pt1, pt2);
			}
			if (i < (e->nb_line - 1) && j < e->size[i + 1])
			{
				pt2 = ft_get_point(e, e->points[i + 1][j], &ft_iso);
				ft_draw_line(e, pt1, pt2);
			}
			j++;
		}
		i++;
	}
}
Esempio n. 2
0
File: image.c Progetto: sganon/FdF
void	ft_draw_image(t_env *e)
{
	int		y;
	int		x;
	t_point	p1;
	t_point	p2;
	int		xx;

	y = -1;
	while (++y < e->y - 1)
	{
		x = -1;
		xx = e->pos_x - (y * e->size / 2);
		while (++x < e->x - 1)
		{
			get_color(y, x, e);
			p1.y = e->pos_y + (y * e->size - (e->map[y][x] * PIKE));
			p1.x = xx + x * e->size;
			p2.y = e->pos_y + ((y + 1) * e->size - (e->map[y + 1][x] * PIKE));
			p2.x = e->pos_x - ((y + 1) * e->size / 2) + x * e->size;
			ft_draw_line(p1, p2, e);
			p2.y = e->pos_y + (y * e->size - (e->map[y][x + 1] * PIKE));
			p2.x = xx + (x + 1) * e->size;
			ft_draw_line(p1, p2, e);
		}
	}
	ft_draw_border(e);
}
Esempio n. 3
0
void	ft_draw_rect(t_env *e, t_point *p1, t_point *p2)
{
	t_point		p3;
	t_point		p4;

	p3.x = p1->x;
	p3.y = p2->y;
	p4.x = p2->x;
	p4.y = p1->y;
	ft_draw_line(e, *p1, p3);
	ft_draw_line(e, p3, *p2);
	ft_draw_line(e, *p2, p4);
	ft_draw_line(e, p4, *p1);
}
Esempio n. 4
0
static	void	ft_fdf_draw_ver(t_array *a, t_mlx *mlx)
{
	int		i;
	int		j;
	t_line	line;
	t_pt	p1;
	t_pt	p2;

	i = -1;
	while (++i < (a->max_size_x))
	{
		j = -1;
		while (++j < (a->y - 1))
		{
			if (i < a->nb_x_line[j] && i < a->nb_x_line[j + 1])
			{
				p1.x = a->end_tab[j][i].x;
				p1.y = a->end_tab[j][i].y;
				p2.x = a->end_tab[j + 1][i].x;
				p2.y = a->end_tab[j + 1][i].y;
				line = ft_make_line(p1.x, p1.y, p2.x, p2.y);
				ft_draw_line(line, mlx, 0xffffff);
			}
		}
	}
	ft_draw_pixel(mlx, 0xffffff, p2);
}
Esempio n. 5
0
static void		ft_print_ls_(t_env *e, t_val pos, int x, int y)
{
	pos.x0 = x - y;
	pos.y0 = (x + y) - (int)(e->map[y].tab[x] * e->z);
	pos.z = e->map[y].tab[x];
	if ((x + 1) < e->map[y].length)
	{
		pos.x1 = (x + 1) - y;
		pos.y1 = ((x + 1) + y) - (int)(e->map[y].tab[x + 1] * e->z);
		ft_draw_line(e, pos, (int *)ft_memalloc(sizeof(int) * 10));
	}
	if ((e->map[y + 1].tab != NULL) && (x < e->map[y + 1].length))
	{
		pos.x1 = x - (y + 1);
		pos.y1 = (x + (y + 1)) - (int)(e->map[y + 1].tab[x] * e->z);
		ft_draw_line(e, pos, (int *)ft_memalloc(sizeof(int) * 10));
	}
}
Esempio n. 6
0
int		ft_tldraw(t_fdf *fdf)
{
	int	i;
	int	j;

	i = 0;
	while (i < fdf->tabsize)
	{
		j = 0;
		while (j < fdf->dotsize[i])
		{
			if (j < fdf->dotsize[i] - 1)
				ft_draw_line(fdf, fdf->dot[i][j], fdf->dot[i][j + 1]);
			if (i < fdf->tabsize - 1 && j < fdf->dotsize[i + 1])
				ft_draw_line(fdf, fdf->dot[i][j], fdf->dot[i + 1][j]);
			j++;
		}
		i++;
	}
	return (0);
}
Esempio n. 7
0
int		ft_trdraw(t_fdf *fdf)
{
	int	i;
	int	j;

	i = 0;
	while (i < fdf->tabsize)
	{
		j = fdf->dotsize[i] - 1;
		while (j >= 0)
		{
			if (j > 0)
				ft_draw_line(fdf, fdf->dot[i][j], fdf->dot[i][j - 1]);
			if (i < fdf->tabsize - 1 && j < fdf->dotsize[i + 1])
				ft_draw_line(fdf, fdf->dot[i][j], fdf->dot[i + 1][j]);
			j--;
		}
		i++;
	}
	return (0);
}
Esempio n. 8
0
int		ft_bldraw(t_fdf *fdf)
{
	int	i;
	int	j;

	i = fdf->tabsize - 1;
	while (i >= 0)
	{
		j = 0;
		while (j < fdf->dotsize[i])
		{
			if (j < fdf->dotsize[i] - 1)
				ft_draw_line(fdf, fdf->dot[i][j], fdf->dot[i][j + 1]);
			if (i > 0 && j < fdf->dotsize[i - 1])
				ft_draw_line(fdf, fdf->dot[i][j], fdf->dot[i - 1][j]);
			j++;
		}
		i--;
	}
	return (0);
}
Esempio n. 9
0
int ft_draw_box(FBSurface *s, FTRect *rect, FTDrawGC *gc, int fill)
{
    FTPoint a, b, c, d;

    if (fill)
    {
        a.x = rect->x;
        a.y = rect->y;

        b.x = rect->x + rect->width - 1;
        b.y = rect->y;

        for (; a.y < rect->y + rect->height; a.y++, b.y++)
        {
            ft_draw_line(s, &a, &b, gc);
        }
    }
    else
    {
        a.x = rect->x;
        a.y = rect->y;

        b.x = rect->x + rect->width - 1;
        b.y = rect->y;

        c.x = rect->x + rect->width  - 1;
        c.y = rect->y + rect->height - 1;

        d.x = rect->x;
        d.y = rect->y + rect->height - 1;

        ft_draw_line(s, &a, &b, gc);
        ft_draw_line(s, &b, &c, gc);
        ft_draw_line(s, &c, &d, gc);
        ft_draw_line(s, &d, &a, gc);
    }

    return FT_SUCCESS;
}
Esempio n. 10
0
static void	cond_two(t_mlx *ptr, t_line *lines, int i, int j)
{
	int	p1[3];
	int	p2[3];

	p1[0] = lines[i].x[j];
	p1[1] = lines[i].y[j];
	p1[2] = lines[i].z_origin[j];
	p2[0] = lines[i + 1].x[j];
	p2[1] = lines[i + 1].y[j];
	p2[2] = lines[i + 1].z_origin[j];
	ft_draw_line(p1, p2, ptr);
}
Esempio n. 11
0
File: draw.c Progetto: joplevy/fdf
void	ft_draw(t_point **tab, t_coord max)
{
	void	*mlx;
	void	*win;
	int		y;
	int		x;

	mlx = mlx_init();
	win = mlx_new_window(mlx, 1600, 800, "fdf");
	y = -1;
	while (++y <= max.y)
	{
		x = -1;
		while (++x <= max.x)
		{
			if (x < max.x)
				ft_draw_line(mlx, win, tab[y][x], tab[y][x + 1]);
			if (y > 0)
				ft_draw_line(mlx, win, tab[y][x], tab[y - 1][x]);
		}
	}
	mlx_key_hook(win, my_key_func, 0);
	mlx_loop(mlx);
}
Esempio n. 12
0
File: fdf.c Progetto: pielo/fdf
int		main(int argc, char **argv)
{
	t_env	e;
	c_list	**coord;

	if (argc == 2)
	{
		e.mlx = mlx_init();
		if (!e.mlx)
			return (1);
		e.win = mlx_new_window(e.mlx, 1280, 768, "42");
		mlx_key_hook(e.win, key_hook, &e);
		coord = ft_init(argv[1]);
		ft_draw_line(&e, coord);
		mlx_loop(e.mlx);
	}
	else
		ft_putstr("Mettre un nom de fichier\n");
	return (0);
}
Esempio n. 13
0
static	void	ft_fdf_draw_hor(t_array *a, t_mlx *mlx)
{
	int		i;
	int		j;
	t_line	line;
	t_pt	p1;
	t_pt	p2;

	j = -1;
	while (++j < (a->y))
	{
		i = -1;
		while (++i < (a->nb_x_line[j] - 1))
		{
			p1.x = a->end_tab[j][i].x;
			p1.y = a->end_tab[j][i].y;
			p2.x = a->end_tab[j][i + 1].x;
			p2.y = a->end_tab[j][i + 1].y;
			line = ft_make_line(p1.x, p1.y, p2.x, p2.y);
			ft_draw_line(line, mlx, 0xffffff);
		}
	}
	ft_draw_pixel(mlx, 0xffffff, p2);
}