lineto function in graphics

lineto function is used to draw line from current position to the point(x,y). lineto function takes two arguments, both are integer datatype. The both argument indicate the ending position of line on x and y coordinate.

General syntax of lineto function is:
                                             lineto( int endx-pos, int endy-pos );

                                                 We can get current position by using getx and gety function. And we can set the current position of cursor by using moveto function. And we can also set the line style by using setlinestyle function.
                                                 line function takes four argument to draw line. All are integer datatype. First two argument is for set the starting position of x and y coordinate of line and another two argument is for  set the ending position of x and y coordinate of line. But in lineto function the starting position of line is current position of cursor.


C Graphics program to demonstrate the lineto function


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

int main( )
{
    int gd=DETECT, gm;
    initgraph(&gd,&gm,"C:\\tc\\bgi");
    setlinestyle(2,2,3);
    moveto(100,200);
    lineto(400,200);
    getch();
    closegraph();
    return 0;
}


lineto function of c graphics

Download


0 comments:

Post a Comment