Draw lines to specified points.
#include <graph.h>
short __far _lineto( short x, short y );
short __far _lineto_w( double wx, double wy );
x, y | End point | |
wx, wy | End point |
The functions in the _lineto family draw a line from the current graphics position up to and including the destination point. The destination point for the _lineto function is given by the view-coordinate point (x, y). The destination point for the _lineto_w function is given by the window-coordinate point (wx, wy).
The line is drawn using the current color, logical write mode, and line style. If no error occurs, _lineto sets the current graphics position to the view-coordinate point (x, y); _lineto_w sets the current position to the window-coordinate point (wx, wy).
If you use _floodfill to fill in a closed figure drawn with _lineto calls, the figure must be drawn with a solid line-style pattern.
The _lineto and _lineto_w routines return a nonzero value if anything is drawn; otherwise, they return 0.
Standards:None
16-Bit:DOS
32-Bit:None
_getcurrentposition functions, _moveto functions, _setlinestyle
/* MOVETO.C: This program draws line segments of different colors. */
#include <graph.h>
#include <stdlib.h>
#include <conio.h>
void main( void )
{
short x, y, xinc, yinc, color = 1;
struct _videoconfig v;
/* Find a valid graphics mode. */
if( !_setvideomode( _MAXCOLORMODE ) )
exit( 1 );
_getvideoconfig( &v );
xinc = v.numxpixels / 50;
yinc = v.numypixels / 50;
for( x = 0, y = v.numypixels - 1; x < v.numxpixels; x += xinc, y -= yinc )
{
_setcolor( color++ % 16 );
_moveto( x, 0 );
_lineto( 0, y );
}
_getch();
_setvideomode( _DEFAULTMODE );
exit( 0 );
}