lineto
- Syntax
-
#include <graphics.h> void lineto(int x, int y);
- Description
- lineto draws a line from the CP (current position) to (x,y), then moves the CP to (x,y).
- Return Value
- None.
- See also
- getlinesettings
- line
- linerel
- setcolor
- setlinestyle
- setwritemode
- line
- Example
-
/* lineto example */ #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> int main(void) { /* request autodetection */ int gdriver = DETECT, gmode, errorcode; char msg[80]; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); } /* move the CP to location (20,30) */ moveto(20, 30); /* create and output a message at (20,30) */ sprintf(msg, " (%d, %d)", getx(), gety()); outtextxy(20,30, msg); /* draw a line to (100,100) */ lineto(100, 100); /* create and output a message at CP */ sprintf(msg, " (%d, %d)", getx(), gety()); outtext(msg); /* clean up */ getch(); closegraph(); return 0; }
Back to index