float x1 = 100,y1 = 100;
float x2 = 100,y2 = 10;
float temp;
if(x1>x2){
temp = x1;
x1 = x2;
x2 = temp;
}
if (y1>y2)
{
temp = y1;
y1 = y2;
y2 = temp;
}
float x = x1,y=y1;
float dx = x2 - x1;
float dy = y2 - y1;
float k = dy/dx;
if(abs(k)<=1 && dx != 0){
for(x=x1;x<=x2;x++){
pDC->SetPixel(x,int(y+0.5),0);
y = y + k;
}
}else{
if(dx != 0 ){
for(y=y1;y<=y2;y++)
{
pDC->SetPixel(int(x+0.5),y,0);
x = x + 1/k;
}
}
else
{
for(y=y1;y<=y2;y++)
{
pDC->SetPixel(int(x+0.5),y,0);
}
}
float x2 = 100,y2 = 10;
float temp;
if(x1>x2){
temp = x1;
x1 = x2;
x2 = temp;
}
if (y1>y2)
{
temp = y1;
y1 = y2;
y2 = temp;
}
float x = x1,y=y1;
float dx = x2 - x1;
float dy = y2 - y1;
float k = dy/dx;
if(abs(k)<=1 && dx != 0){
for(x=x1;x<=x2;x++){
pDC->SetPixel(x,int(y+0.5),0);
y = y + k;
}
}else{
if(dx != 0 ){
for(y=y1;y<=y2;y++)
{
pDC->SetPixel(int(x+0.5),y,0);
x = x + 1/k;
}
}
else
{
for(y=y1;y<=y2;y++)
{
pDC->SetPixel(int(x+0.5),y,0);
}
}