Borland C++ reference

line

raw OCR

Draws a line between two specified points.

Defined in header <graphics.h>

Syntax

#include <graphics.h>
void  far line(int xl, int yl, int x2, int y2);

Portability

DOSUNIXWindowsANSI CC++ only
■

Remarks

line draws a line in the current color, using the current line style and thickness between the two points specified, {xl,yl) and (x2,y2), without updating the current position (CP).

Return value

None.

See also

Example

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)

   /* request autodetection */
   int gdriver = DETECT, gmode, errorcode;
   int xmax, ymax;

   /* initialize graphics and local variables  */
   initgraph(&gdriver, &gmode,  "");
/* read result of initialization  */
errorcode = graphresult O*-

if  (errorcode != grOk) { /* an error occurred */
   printf("Graphics error:  %s\n", grapherrormsg(errorcode)
   printf ("Press any key to halt:");
   getchO ;
   exit(l);
}
setcolor(getmaxcolor() ) ;
xmax = getmaxx ();
ymax = getmaxy ();
/* draw a diagonal  line */
line(0, 0, xmax, ymax) ;

/* clean up */
getchO ;
closegraphO  ;
return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.