Moveto function in C/C++ graphics
Moveto function in C/C++ graphics
Moveto moves the current position(cp) to (x,y).
Syntax :
moveto(int x,int y);
Means if you want to move a point from the current position to a new position then you
can use this function.
Example :
#include <graphics.h>
#include <conio.h>
void main()
{
int d,m;
d = DETECT;
char msg[80];
initgraph(&d, &m, "d:\\tc\\bgi");
//move the C.P. to location (50, 80)
moveto(50, 80);
// plot a pixel
putpixel(getx(), gety(), getmaxcolor());
//output a message at (50, 80)
sprintf(msg, " (%d, %d)", getx(), gety());
outtextxy(50, 80, msg);
/* move to (200, 100) */
moveto(200, 100);
// plot a pixel
putpixel(getx(), gety(), getmaxcolor());
/* create and output a message at C.P. */
sprintf(msg, " (%d, %d)", getx(), gety());
outtext(msg);
getch();
closegraph();
}
Output :
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment