c++ program for bresenham's line drawing algorithm vtu code example
Example: bresenham's line algorithm c++
void drawline(int x0, int y0, int x1, int y1)
{
int dx, dy, p, x, y;
dx=x1-x0;
dy=y1-y0;
x=x0;
y=y0;
p=2*dy-dx;
while(x<x1)
{
if(p>=0)
{
putpixel(x,y,7);
y=y+1;
p=p+2*dy-2*dx;
x+=1;
}
else
{
putpixel(x,y,7);
p=p+2*dy;}
x+=1;
}
}