计算机图形学——直线扫描转换基本增量法
void dda(HDC hdc)
{
float dx,dy;
int k;
float x;
float y;
HPEN pen=NULL;
pen = CreatePen(PS_SOLID,5,RGB(255,0,0));
SelectObject(hdc,pen);
k=_abs(x2-x1);
if(_abs(y2-y1)>k)
k=_abs(y2-y1);
dx=(x2-x1)/k;
dy=(y2-y1)/k;
x=x1;
y=y1;
for(int i=0;i<=k;i++)
{
MoveToEx(hdc, (int)(x+0.5f)*20,(int)(y+0.5f)*20, NULL);
LineTo(hdc,(int)(x+0.5f)*20,(int)(y+0.5f)*20);
x=x+dx;
y=y+dy;
}
}