Home Docs
Graphics.h Documentation
Compiler

Basic Shapes

pieslice() in graphics.h

pieslice() draws a wedge from a circle, bounded by two radii and an arc. Use it when you need a filled chart slice or angular region from a center point.

On This Page

Syntax

void pieslice(int x, int y, int stangle, int endangle, int radius);

Draws and fills a pie-shaped slice centered at (x, y) using the specified angle range and radius.

Parameters

  • x, y: center coordinates
  • stangle, endangle: start and end angle in degrees
  • radius: slice radius
pieslice(240, 220, 30, 150, 120);

The filled pattern and color depend on the active settings from setfillstyle() and setcolor().

Full Program

#include <graphics.h>
#include <conio.h>

int main() {
    int gd = DETECT, gm;
    initgraph(&gd, &gm, "");

    setcolor(WHITE);
    setfillstyle(SOLID_FILL, GREEN);
    pieslice(220, 220, 20, 140, 120);

    setfillstyle(SOLID_FILL, RED);
    pieslice(420, 220, 210, 320, 90);

    getch();
    closegraph();
    return 0;
}

Click Run (DOS) to test this quickly.

Common Mistakes

  • Not setting fill style/color before calling pieslice().
  • Using an invalid angle sequence and expecting a different wedge direction.
  • Drawing slices partially outside the screen due to large radius.

Next: sector() for elliptical sectors and arc() for unfilled arcs.