User Tools

Site Tools


c:graphics.h:moverel

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:graphics.h:moverel [2024/02/16 01:05] (current)
Line 1: Line 1:
 +===== moverel =====
 +
 +
 +====Syntax of moverel ==== 
 + <code c>
 +#include <graphics.h>
 +void moverel(int dx, int dy);
 +  </code>
 +
 +
 +==== Description of moverel ==== 
 +<code c>
 +moverel moves the current position (CP) dx pixels in the x direction and
 +dy pixels in the y direction.
 +</code>
 +
 +
 +==== Example of moverel ====
 +<code c>
 +/* moverel 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) {  /* an error occurred */
 +printf("Graphics error: %s\n", grapherrormsg(errorcode));
 +
 +printf("Press any key to halt:");
 +getch();
 +exit(1);   /* terminate with an error code */
 +   }
 +
 +   /* move the CP to location (20,30) */
 +   moveto(20,30);
 +
 +   /* plot a pixel at the CP */
 +   putpixel(getx(), gety(), getmaxcolor());
 +
 +   /* create and output a message at (20,30) */
 +   sprintf(msg, " (%d, %d)", getx(), gety());
 +   outtextxy(20,30, msg);
 +
 +   /* move to a point a relative distance away from the current CP */
 +   moverel(100, 100);
 +
 +
 +   /* plot a pixel at the CP */
 +   putpixel(getx(), gety(), getmaxcolor());
 +
 +   /* create and output a message at CP */
 +   sprintf(msg, " (%d, %d)", getx(), gety());
 +   outtext(msg);
 +
 +   /* clean up */
 +   getch();
 +   closegraph();
 +   return 0;
 +}
 +</code>
 +
 +
 +==== See also ====
 +[[moveto]]
 +
 +
 +===== output of moverel example ===== 
 +
 +    no output of example at the moment
 +    do not hesitate and add it...  
 +
 +
  

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/graphics.h/moverel.txt · Last modified: 2024/02/16 01:05 (external edit)

Impressum Datenschutz