void LCD_Line(u16 x1, u16 y1, u16 x2, u16 y2)
{
u16 x, y, t;
Set_direction(0);
if( (x1 == x2) && (y1 == y2) )
LCD_Point(x1, y1);
else if( abs(y2 - y1) > abs(x2 - x1) ) /*斜率大于1*/
{
if(y1 > y2)
{
t = y1;
y1 = y2;
y2 = t;
t = x1;
x1 = x2;
x2 = t;
}
for(y=y1; y<y2; y++) /*以y轴为基准*/
{
x = (u32)(y-y1)*(x2-x1) / (y2-y1) + x1;
LCD_Point(x, y);
}
}
else /*斜率小于等于1*/
{
if(x1 > x2)
{
t = y1;
y1 = y2;
y2 = t;
t = x1;
x1 = x2;
x2 = t;
}
for(x=x1; x<x2; x++) /*以x轴为基准*/
{
y = (u32)(x-x1)*(y2-y1) / (x2-x1) + y1; ????????????????????
LCD_Point(x, y);
}
}
} 以X轴为基准y = (u32)(x-x1)*(y2-y1) / (x2-x1) + y1 是不是应该为y = (u32)(x+x1)*(y2-y1) / (x2-x1) + y1; |