• Have Any Question?
  • contact@eitworld.com

Sector() Function





sector() function is used to draw and fill an elliptical pieslice. sector() is very similar to ellipse() but can fill with any color and / or style set by setfillstyle() function.

Declaration

void sector( int x, int y, int stangle, int endangle, int xradius, int yradius);
  • sector() function contains six parameters x, y, stangle, endangle, xradius and yradius.
  • x and y specifies the x and y coordinates and (x,y) specifies the center of the sector.
  • stangle and endangle specifies start angle and end angle of the sector. To draw an ellipse from sector() function stangle must be 0 and endangle must be 360.
  • xradius specifies x-radius of the sector and yradius specifies y-radius of the sector.
  • For better understanding go through the program:

Program

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

{

int gd=DETECT,gm;

initgraph(&gd,&gm,” “);

sector(320,240,0,180,100,50);

getch();

closegraph();

}

Above program is used to draw a sector of x-radius 100 cm and y-radius 50 cm with start angle 0 and end angle 180 degree at position (320,240). The sector would be filled with the white color because white color is default color. We can also draw filled ellipse with the help of sector() function by putting start angle 0 and end angle 360 degree.

Output

c graphics



Real Time Web Analytics