C++ pieslice() - Draw and Fills Circle or Piece of Circle

- July 12, 2018
pieslice function cpp

In C++, the pieslice() function is used to draw and fills a slice of pie starting from a specified angle and up to another specified angle, along the fixed centered point (x, y) with specified radius.

Syntax of pislice() Function

The general syntax of this function looks like this:

pieslice(x, y, s_angle, e_angle, radius);
x and y represent centered point of the pie slice. These are x-coordinate and y-coordinate of the center of pie slice on the screen.
s_angle It represents the starting angle of the arc in degree.
e_angle It represents the ending angle of the arc in degree.
radius It represents radius of the pie.

Each of the above mentioned parameter can be a constant or variable of "int" data type.

This function can also be used to draw a circle and line. If you want to draw a circle, give the starting angle 0° and ending angle 360°.

In the same way, a line can be draw with this function by giving same values to starting and ending angles.

Example of pieslice() Function

The following C++ program draws a circle using this function.

using namespace std;
      int d, m, n;
      d = DETECT;
      initgraph (&d, &m, " ");
      pieslice(300, 200, 0, 360, 90);

Leave your reply.


Start typing and press Enter to search