c++ win32 中的这个中点算法不起作用。它什么也不画或只画水平线。我犯了什么错误?
void midPoint(HDC hdc)
{
double dx = end.getXPoint()-start.getXPoint();
double dy = end.getYPoint()-start.getYPoint();
double x = start.getXPoint();
double y = start.getYPoint();
SetPixel(hdc,x,y,color);
double d = dx - (dy/2);
double d1 = dx;
double d2 = abs(dx-dy);
while(x < end.getXPoint())
{
d = abs(((( y+0.5)-start.getYPoint())*dx) - (((x+1)-start.getXPoint())*dy));
if(d < 0)
{
x = x+1;
y = y+1;
}
else
{
x = x+1;
}
SetPixel(hdc,x,y,color);
}
}