Skip to main content

Bresenham’s Line Drawing Algorithm Program In C | WaoFamHub

Bresenham’s Line Drawing Algorithm Program In C



INPUT

#include<stdio.h>
#include<graphics.h>

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;
}
else
{
putpixel(x,y,7);
p=p+2*dy;
}
x=x+1;
}
}

int main()
{
int gdriver=DETECT, gmode, error, x0, y0, x1, y1;
initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi");

printf("Enter co-ordinates of first point: ");
scanf("%d%d", &x0, &y0);

printf("Enter co-ordinates of second point: ");
scanf("%d%d", &x1, &y1);
drawline(x0, y0, x1, y1);

getch();
}


OUTPUT



Comments

Popular posts from this blog

Why Software Engineering is Popular? | WaoFamHub

Why Software Engineering is Popular? Here are important reasons behind the popularity of software engineering: Large software – In our real life, it is quite more comfortable to build a wall than a house or building. In the same manner, as the size of the software becomes large, software engineering helps you to build software. Scalability - If the software development process were based on scientific and engineering concepts, it is easier to re-create new software to scale an existing one. Adaptability : Whenever the software process was based on scientific and engineering, it is easy to re-create new software with the help of software engineering. Cost - Hardware industry has shown its skills and huge manufacturing has lower the cost of the computer and electronic hardware. Dynamic Nature - Always growing and adapting nature of the software. It depends on the environment in which the user works. Quality Management : Offers better method of software development to provide quality so...