|
void LCD_DrawLine(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2,unsigned int color)
{
unsigned int x, y, t;
if((x1 == x2) && (y1 == y2))
LCD_DrawPoint(x1, y1,color);
else if( (abs(y2 - y1))> (abs(x2 - x1)))
{
if(y1 > y2)
{
t = y1;
y1 = y2;
y2 = t;
t = x1;
x1 = x2;
x2 = t;
}
for(y = y1; y <= y2; y ++)
{
x = (y - y1) * (x2 - x1) / (y2 - y1) + x1;//为什么这里会有不少x丢失
LCD_DrawPoint(x, y,color);
}
}
else
{
if(x1 > x2)
{
t = y1;
y1 = y2;
y2 = t;
t = x1;
x1 = x2;
x2 = t;
}
for(x = x1; x <= x2; x ++)
{
y = (x - x1) * (y2 - y1) / (x2 - x1) + y1;
LCD_DrawPoint(x, y,color);
}
}
}
|
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|