circle


Syntax

#include <graphics.h>

void circle(int x, int y, int radius);

Description
circle draws a circle in the current drawing color with its center at (x,y) and the radius given by radius.

The linestyle parameter does not affect arcs, circles, ellipses, or pie slices. Only the thickness parameter is used.

If your circles are not perfectly round, adjust the aspect ratio.

Return Value
None.

See also
arc
ellipse
fillellipse
getaspectratio
sector
setaspectratio

Example

/* circle example */ 



#include <graphics.h>

#include <stdlib.h>

#include <stdio.h>

#include <conio.h>



int main(void)

{

   /* request autodetection */

   int gdriver = DETECT, gmode, errorcode;

   int midx, midy, radius = 100;



   /* 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;

   setcolor(getmaxcolor());



   /* draw the circle */

   circle(midx, midy, radius);

   /* clean up */

   getch();

   closegraph();

   return 0;

}


Back to index