📄 line.c
字号:
/********************************************************************************
* Organization : *
* Author : *
* Module : *
* Unit : *
* Creation Date : 05/14/2007 *
*********************************************************************************
*********************************************************************************
* *
* *
* *
********************************************************************************/
/*=======================================================================================
*****************************************************************************************
Author: mcu - 05/14/2007
Design:
Globals:
none
Paramet:
none
=======================================================================================*/
#define abs(a) (a<0 ? -a : a)
#define ROUND(a) ((int)a+0.5)
//The DDA algorithm
void DrawLine(int xa, int ya, int xb, int yb,int nColor, int layer, int scaling)
{
int dx=xb-xa, dy=yb-ya;
int steps,k;
float xincrement ,yincrement,x=xa,y=ya;
if(abs(dx)>abs(dy))
steps=abs(dx);
else
steps=abs(dy);
xincrement=dx/(float)steps;
yincrement=dy/(float)steps;
DrawPixel(ROUND(x), ROUND(y), nColor, layer,scaling);
for(k=0;k<steps;k++)
{
x+=xincrement;
y+=yincrement;
DrawPixel(ROUND(x), ROUND(y), nColor, layer,scaling);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -