lineto() function in C
Last Updated :
04 Dec, 2019
The header file graphics.h contains lineto() function which draws a line from current position to the point(x,y).
Note : Use getx() and gety() to get the current position.
Syntax :
lineto(int x, int y);
where,
(x, y) are the coordinates upto which the
line will be drawn from previous point.
CASE 1 : When the initial position of point is (0,0)
Below is the implementation of lineto() function with initial position at origin :
#include <graphics.h>
int main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "" );
lineto(250, 100);
getch();
closegraph();
return 0;
}
|
Output :
CASE 2 : When the initial position of point is not (0, 0)
Below is the implementation of lineto() function with initial position other than origin :
#include <graphics.h>
int main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "" );
moveto(100, 100);
lineto(250, 100);
getch();
closegraph();
return 0;
}
|
Output :
Share your thoughts in the comments
Please Login to comment...