User Tools

Site Tools


c:graphics.h:getarccoords

Differences

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

Link to this comparison view

c:graphics.h:getarccoords [2015/05/06 23:06]
c:graphics.h:getarccoords [2024/02/16 01:05] (current)
Line 1: Line 1:
 +===== getarccoords =====
 +
 +
 +====Syntax of getarccoords ==== 
 + <code c>
 +#include <graphics.h>
 +void getarccoords(struct arccoordstype *arccoords);
 +  </code>
 +
 +
 +==== Description of getarccoords ==== 
 +<code c>
 +getarccoords fills in the arccoordstype structure pointed to by arccoords
 +with information about the last call to arc. The arccoordstype structure
 +is defined in graphics.h as follows:
 +struct arccoordstype {
 +   int x, y;
 +   int xstart, ystart, xend, yend;
 +};
 +The members of this structure are used to specify the center point (x,y),
 +the starting position (xstart, ystart), and the ending position (xend,
 +yend) of the arc. These values are useful if you need to make a line meet
 +at the end of an arc.
 +</code>
 +
 +
 +==== Example of getarccoords ====
 +<code c>
 +/* getarccoords example */
 +
 +#include <graphics.h>
 +#include <stdlib.h>
 +#include <stdio.h>
 +#include <conio.h>
 +
 +int main(void)
 +{
 +   /* request autodetection */
 +   int gdriver = DETECT, gmode, errorcode;
 +   struct arccoordstype arcinfo;
 +   int midx, midy;
 +   int stangle = 45, endangle = 270;
 +   char sstr[80], estr[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 */
 +   }
 +
 +   midx = getmaxx() / 2;
 +   midy = getmaxy() / 2;
 +
 +   /* draw arc and get coordinates */
 +   setcolor(getmaxcolor());
 +   arc(midx, midy, stangle, endangle, 100);
 +   getarccoords(&arcinfo);
 +
 +   /* convert arc information into strings */
 +   sprintf(sstr, "*- (%d, %d)", arcinfo.xstart, arcinfo.ystart);
 +
 +   sprintf(estr, "*- (%d, %d)", arcinfo.xend, arcinfo.yend);
 +
 +   /* output the arc information */
 +   outtextxy(arcinfo.xstart, arcinfo.ystart, sstr);
 +   outtextxy(arcinfo.xend, arcinfo.yend, estr);
 +
 +   /* clean up */
 +   getch();
 +   closegraph();
 +   return 0;
 +}
 +</code>
 +
 +
 +==== See also ====
 +[[arc]]
 +[[fillellipse]]
 +[[sector]]
 +
 +
 +===== output of getarccoords 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

Impressum Datenschutz