0% found this document useful (0 votes)
22 views3 pages

#Include #Include

This code takes in x and y coordinate points from the user and draws a line between them using the Bresenham's line algorithm. It initializes the graphics mode, calculates the change in x and y per step, and uses a for loop to incrementally draw pixels between the points, calling a function to round the x and y values before drawing each pixel.

Uploaded by

Rudra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

#Include #Include

This code takes in x and y coordinate points from the user and draws a line between them using the Bresenham's line algorithm. It initializes the graphics mode, calculates the change in x and y per step, and uses a for loop to incrementally draw pixels between the points, calling a function to round the x and y values before drawing each pixel.

Uploaded by

Rudra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include<stdio.

h>

#include<conio.h>
#include<graphics.h>

#include<math.h>

void check(x)

x=x+0.5;

void main()

int a=DETECT,b,x0,y0,x1,y1,i,steps;

float xin,yin;

float dx,dy;

float xf,yf;

printf("Enter the value of x0 cordinate:");

scanf("%d",&x0);

printf("Enter the value of y0 cordinate:");

scanf("%d",&y0);

printf("Enter the value of x1 cordinate:");

scanf("%d",&x1);

printf("Enter the value of y1 cordinate:");

scanf("%d",&y1);

initgraph(&a,&b,"C:\\TURBOC3\\BGI");

dx=x1-x0;

dy=y1-y0;

if(abs(dx)>abs(dy))

steps=abs(dx);

}
else

steps=abs(dy);

xin=dx/(float)steps;

yin=dy/(float)steps;

xf = x0;

yf = y0;

clrscr();

putpixel(xf,yf,YELLOW);

for(i=0;i<steps;i++)

xf=xf+xin;

yf=yf+yin;

check(xf);

check(yf);

putpixel(xf,yf,YELLOW);

getch();

You might also like