E
Evo
Below is my code,it passed the compile and link under TC2.0 correctly. But the
line it draws is obviously wrong. I think it's somewhere I thought wrong. But I
really can't find it out.
Can someone help me point out the wrong place? Thanks very much!
void bres_line(int x0,int y0,int x1,int y1,int color) {
int dx,dy,h,x,y,numx=1,numy=1,tag=1;
if (x0>x1) numx=-1;
if (y0>y1) numy=-1;
if(numx!=numy) tag=-1;
dx=abs(x0-x1);
dy=abs(y0-y1);
x=x0;y=y0;
h=2*dy*tag-dx;
putpixel(x,y,3);
while((numx<0&&x>x1)||(numx>0&&x<x1)) {
if(h<0)
h=h*numy+2*dy*tag;
else {
h=h*numy+2*(dy*tag-dx);
y+=incy;
}
putpixel(x,y,3);
x+=numx;
}
}
line it draws is obviously wrong. I think it's somewhere I thought wrong. But I
really can't find it out.
Can someone help me point out the wrong place? Thanks very much!
void bres_line(int x0,int y0,int x1,int y1,int color) {
int dx,dy,h,x,y,numx=1,numy=1,tag=1;
if (x0>x1) numx=-1;
if (y0>y1) numy=-1;
if(numx!=numy) tag=-1;
dx=abs(x0-x1);
dy=abs(y0-y1);
x=x0;y=y0;
h=2*dy*tag-dx;
putpixel(x,y,3);
while((numx<0&&x>x1)||(numx>0&&x<x1)) {
if(h<0)
h=h*numy+2*dy*tag;
else {
h=h*numy+2*(dy*tag-dx);
y+=incy;
}
putpixel(x,y,3);
x+=numx;
}
}