тоже метод...я использую... void LCD_DrawLine(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2, unsigned char set) { int x,y,count,xs,ys,xm,ym;
x = (int)x1; y = (int)y1; xs = (int)x2 - (int)x1; ys = (int)y2 - (int)y1; if(xs < 0) xm = -1; else if(xs > 0) xm = 1; else xm = 0; if(ys < 0) ym = -1; else if(ys > 0) ym = 1; else ym = 0; if(xs < 0) xs = -xs; if(ys < 0) ys = -ys;
LCD_SetDot ((unsigned char)x,(unsigned char)y, 1);
if(xs > ys) // Ëèíèÿ < 45 ãðàäóñîâ { count = -(xs/2); while(x != x2) { count = count + ys; x = x + xm; if(count > 0) { y = y + ym; count = count - xs; } LCD_SetDot ((unsigned char)x,(unsigned char)y, set); } } else // Ëèíèÿ >= 45 ãðàäóñîâ { count = -(ys/2); while(y != y2) { count = count + xs; y = y + ym; if(count > 0) { x = x + xm; count = count - ys; } LCD_SetDot ((unsigned char)x,(unsigned char)y, set); } } }
Сообщение отредактировал zorromen - Nov 22 2006, 08:54
|