Pie

2.x

  BOOL Pie(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect, nxStartArc, nyStartArc, nxEndArc, nyEndArc)    
  HDC hdc; /* handle of device context */
  int nLeftRect; /* x-coordinate upper-left corner bounding rectangle */
  int nTopRect; /* y-coordinate upper-left corner bounding rectangle */
  int nRightRect; /* x-coordinate lower-right corner bounding rectangle */
  int nBottomRect; /* y-coordinate lower-right corner bounding rectangle */
  int nxStartArc; /* x-coordinate arc starting point */
  int nyStartArc; /* y-coordinate arc starting point */
  int nxEndArc; /* x-coordinate arc ending point */
  int nyEndArc; /* y-coordinate arc ending point */

The Pie function draws a pie-shaped wedge by drawing an elliptical arc whose center and two endpoints are joined by lines.

Parameters

hdc

Identifies the device context.

nLeftRect

Specifies the logical x-coordinate of the upper-left corner of the bounding rectangle.

nTopRect

Specifies the logical y-coordinate of the upper-left corner of the bounding rectangle.

nRightRect

Specifies the logical x-coordinate of the lower-right corner of the bounding rectangle.

nBottomRect

Specifies the logical y-coordinate of the lower-right corner of the bounding rectangle.

nxStartArc

Specifies the logical x-coordinate of the arc's starting point. This point does not have to lie exactly on the arc.

nyStartArc

Specifies the logical y-coordinate of the arc's starting point. This point does not have to lie exactly on the arc.

nxEndArc

Specifies the logical x-coordinate of the arc's endpoint. This point does not have to lie exactly on the arc.

nyEndArc

Specifies the logical y-coordinate of the arc's endpoint. This point does not have to lie exactly on the arc.

Return Value

The return value is nonzero if the function is successful. Otherwise, it is zero.

Comments

The center of the arc drawn by the Pie function is the center of the bounding rectangle specified by the nLeftRect, nTopRect, nRightRect, and nBottomRect parameters. The starting and ending points of the arc are specified by the nxStartArc, nyStartArc, nxEndArc, and nyEndArc parameters. The function draws the arc by using the selected pen, moving in a counterclockwise direction. It then draws two additional lines from each endpoint to the arc's center. Finally, it fills the pie-shaped area by using the current brush.

If nxStartArc equals nxEndArc and nyStartArc equals nyEndArc, the result is an
ellipse with a single line from the center of the ellipse to the point (nxStartArc,
nyStartArc
) or (nxEndArc,nyEndArc).

The figure drawn by this function extends up to but does not include the right and bottom coordinates. This means that the height of the figure is nBottomRect nTopRect and the width of the figure is nRightRectnLeftRect.

Both the width and the height of a rectangle must be greater than 2 units and less than 32,767 units.

Example

The following example uses a RECT structure to store the points that define the bounding rectangle and uses POINT structures to store the coordinates that specify the beginning and end of the wedge:

HDC hdc;

RECT rc = { 10, 10, 180, 140 };
POINT ptStart = {  12,  12 };
POINT ptEnd = { 128, 135 };

Pie(hdc, rc.left, rc.top, rc.right, rc.bottom,
    ptStart.x, ptStart.y, ptEnd.x, ptEnd.y);

See Also

Chord