function bresenhamStep(x1,x2,y1,y2)
dX=x2-x1;
dY=y2-y1;
deltaX=abs(dX*2);
deltaY=abs(dY*2);
grad = dY/dX;
plot(x1,y1,'ro');
plot(x2,y2,'ro');
plot([x1,x2],[y1,y2],'b-');
drawnow();
if(deltaX>deltaY&&dX>0&&grad>0)
D = deltaY - deltaX / 2;
nextX=x1;
nextY=y1;
while (nextX ~= x2)
if (D >= 0)
nextY = nextY + 1;
D = D - deltaX;
end
nextX = nextX + 1;
D = D + deltaY;
plot(nextX, nextY,'r*');
drawnow();
pause(0.01);
end
end
if(deltaX>deltaY&&dX<0&&grad>0)
D = -deltaY + deltaX / 2;
nextX=x1;
nextY=y1;
while (nextX ~= x2)
if (D < 0)
nextY = nextY - 1;
D = D + deltaX;
end
nextX = nextX - 1;
D = D - deltaY;
plot(nextX, nextY,'r*');
drawnow();
pause(0.01);
end
end
if(deltaX<deltaY&&dX>0&&grad>0)
D = deltaX - deltaY / 2;
nextX=x1;
nextY=y1;
while (nextY ~= y2)
if (D >= 0)
nextX = nextX + 1;
D = D - deltaY;
end
nextY = nextY + 1;
D = D + deltaX;
plot(nextX, nextY,'r*');
drawnow();
pause(0.01);
end
end
if(deltaX<deltaY&&dX<0&&grad>0)
D = -deltaX + deltaY / 2;
nextX=x1;
nextY=y1;
while (nextY ~= y2)
if (D < 0)
nextX = nextX - 1;
D = D + deltaY;
end
nextY = nextY - 1;
D = D - deltaX;
plot(nextX, nextY,'r*');
drawnow();
pause(0.01);
end
end
if(deltaX>deltaY&&dX>0&&grad<0)
D = (-deltaY) + deltaX / 2;
nextX=x1;
nextY=y1;
while (nextX ~= x2)
if (D < 0)
nextY = nextY - 1;
D = D + deltaX;
end
nextX = nextX + 1;
D = D + (-deltaY);
plot(nextX, nextY,'r*');
drawnow();
pause(0.01);
end
end
if(deltaX>deltaY&&dX<0&&grad<0)
D = -(-deltaY) - deltaX / 2;
nextX=x1;
nextY=y1;
while (nextX ~= x2)
if (D >= 0)
nextY = nextY + 1;
D = D - deltaX;
end
nextX = nextX - 1;
D = D - (-deltaY);
plot(nextX, nextY,'r*');
drawnow();
pause(0.01);
end
end
if(deltaX<deltaY&&dX>0&&grad<0)
D = (-deltaX) + deltaY / 2;
nextX=x1;
nextY=y1;
while (nextY ~= y2)
if (D < 0)
nextX = nextX + 1;
D = D + deltaY;
end
nextY = nextY - 1;
D = D + (-deltaX);
plot(nextX, nextY,'r*');
drawnow();
pause(0.01);
end
end
if(deltaX<deltaY&&dX<0&&grad<0)
D = -(-deltaX) - deltaY / 2;
nextX=x1;
nextY=y1;
while (nextY ~= y2)
if (D >= 0)
nextX = nextX - 1;
D = D - deltaY;
end
nextY = nextY + 1;
D = D - (-deltaX);
plot(nextX, nextY,'r*');
drawnow();
pause(0.01);
end
end
end