예제 #1
0
/**
*
* Render a straight line
*
* @param 	x1,y1, starting point coordinates
* @param 	x2,y2, end point coordinates
* @param 	colour, colour of the line
* @param	TftPtr, pointer to the tft instance on which button is rendered
*
******************************************************************************/
void render_line(double x1, double y1, double x2, double y2, u16 colour, TFT *TftPtr){
	double m = (y2-y1)/(x2-x1);
	if (m > 1) {
		if (y1>y2){
			draw_line_y(x2,y2,x1,y1,m,colour, TftPtr);
			return;
		}
		draw_line_y(x1,y1,x2,y2,m,colour, TftPtr);
	}
	else {
		if (x1>x2){
			draw_line_x(x2,y2,x1,y1,m,colour, TftPtr);
			return;
		}
		draw_line_x(x1,y1,x2,y2,m,colour, TftPtr);
	}
}
예제 #2
0
파일: draw_line.c 프로젝트: HARM67/Fdf
void	draw_line(t_app *app, t_line *line, t_obj *o)
{
	t_vec4	tmp;

	tmp = sous_vec4(*line->p[0], *line->p[1]);
	if (ABS(tmp.x) < ABS(tmp.y))
		draw_line_y(app, tmp, line, o);
	else
		draw_line_x(app, tmp, line, o);
}