lineto() function in C
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 :
// C Implementation for lineto() #include <graphics.h> // driver code int main() { // gm is Graphics mode which is // a computer display mode that // generates image using pixels. // DETECT is a macro defined in // "graphics.h" header file int gd = DETECT, gm; // initgraph initializes the // graphics system by loading a // graphics driver from disk initgraph(&gd;, &gm;, ""); // lineto fuction lineto(250, 100); getch(); // closegraph function closes the // graphics mode and deallocates // all memory allocated by // graphics system . 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 :
// C Implementation for lineto() #include <graphics.h> // driver code int main() { // gm is Graphics mode which is // a computer display mode that // generates image using pixels. // DETECT is a macro defined in // "graphics.h" header file int gd = DETECT, gm; // initgraph initializes the // graphics system by loading a // graphics driver from disk initgraph(&gd;, &gm;, ""); // change initial position of point // with moveto function moveto(100, 100); // lineto fuction lineto(250, 100); getch(); // closegraph function closes the // graphics mode and deallocates // all memory allocated by // graphics system . closegraph(); return 0; } |
Output :
Recommended Posts:
- arc function in C
- iswctype() function in C/C++
- strtoimax() function in C++
- strtoumax() function in C++
- wctype() function in C/C++
- strrchr() function in C/C++
- strcspn() function in C/C++
- atexit() function in C/C++
- iswxdigit() function in C/C++
- strrev() function in C
- mbsrtowcs() function in C/C++
- wcsncmp() function in C/C++
- wcsrtombs() function in C/C++
- wcsncat() function in C/C++
- wcstod() function in C/C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



