|
hello
im trying to implement the algorithm
of drawline() in screen class
i did exactly as the slides say
but when i try to run the program nothing is printed on the screen
ther is no error
function void drawLine(int x1, int y1, int x2, int y2) {
var int a,b,diff,dx,dy;
let a=0;
let b=0;
let diff=0;
let dx=x2-x1;
let dy=y2-y1;
while(~(a>dx) & ~(b>dy)){
if(diff<0){
let a=a+1;
let diff=diff+dy;
}
else{
let b=b+1;
let diff=diff-dx;
}
do Screen.drawPixel(x1 + a, y1 + b);
}
return;
}
|