Exemple #1
0
void			draw(t_env *data, t_pos *start, t_pos *destination)
{
	int dx;
	int dy;

	dx = destination->x - start->x;
	dy = destination->y - start->y;
	mlx_pixel_put(data->mlx, data->win, start->x, start->y, data->color);
	if (abs(dx) > abs(dy))
		draw_dx(data, start, dx, dy);
	else
		draw_dy(data, start, dx, dy);
}
Exemple #2
0
void			draw_line_sdl(SDL_Surface *s, t_pixsdl start, t_pixsdl end)
{
    int dir[4];

    dir[0] = abs(end.x - start.x);
    dir[1] = abs(end.y - start.y);
    dir[2] = (dir[0] > 0) ? 1 : -1;
    dir[3] = (dir[1] > 0) ? 1 : -1;
    draw_pix_sdl(s, &start);
    if (dir[0] > dir[1])
        draw_dx(s, &start, dir);
    else
        draw_dy(s, &start, dir);
}