## Thick line using built in function

Program Description

Draws a thick line using inbuilt line() function. Takes the line co-ordinates from the user to plot the desired line

Program
```/*********************************************
*  	code.cheraus.com
*
* Thick line using built in function.
*
*********************************************/

#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
#include<graphics.h>

//function prototype
void thick_line(int x1,int x2,int y1,int y2);

int main()
{

int x1,x2,y1,y2,gd,gm;

clrscr();

cout<<"\nEnter the First point (x1,y1) :";
cin>>x1>>y1;

cout<<"\nEnter the Second point (x2,y2) :";
cin>>x2>>y2;

detectgraph(&gd,&gm);
initgraph(&gd,&gm,"C:\\turboc3\\bgi");

setcolor(10);

//drawing the co-ordinate axes
line(0,240,640,240);
line(320,0,320,480);

setcolor(5);

//converting the screen co-ordinates to more user friendly co-ordinates
// with respect to the centre of the screen.
x1 = 320 + x1;
x2 = 320 + x2;

y1 = 240 - y1;
y2 = 240 - y2;

//function call for thick line.
thick_line(x1,x2,y1,y2);

getch();
return 0;

}

/*
Function Definition for thick line

Function: thick_line() Draws the thick line using inbuilt function.
Input: Takes four input
1) x co-ordinate for 1st point
2) y co-ordinate for 1st point
3) x co-ordinate for 2nd point
4) y co-ordinate for 2nd point

Return : This function does not return anything.

*/

void thick_line(int x1,int x2,int y1,int y2)
{
int t,t1,i;

cout<<"\nEnter the Thickness : ";
cin>>t;

line(x1,y1,x2,y2);

if((y2-y1)/(x2-x1)<1)

{

t1 = (t-1)*sqrt((pow((x2-x1),2))+(pow((y2-y1),2)))/(2*abs(x2-x1));

for(i=0;i<t1;i++)
{

line(x1,y1-i,x2,y2-i);

line(x1,y1+i,x2,y2+i);

}

}

else

{

t1 = (t-1)*sqrt((pow((x2-x1),2))+(pow((y2-y1),2)))/(2*abs(y2-y1));

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

{

line(x1-i,y1,x2-i,y2);

line(x1+i,y1,x2+i,y2);

}

}

}
```

Output
Output Image of Getting Co-ordinate

Image Of Getting Thickness

Final Output