次の方法で共有


CDC::Pie

楕円の円弧と、その 2 つの端点と中心を結ぶ直線で作られる扇形を描画します。

BOOL Pie(
   int x1,
   int y1,
   int x2,
   int y2,
   int x3,
   int y3,
   int x4,
   int y4 
);
BOOL Pie(
   LPCRECT lpRect,
   POINT ptStart,
   POINT ptEnd 
);

パラメーター

  • x1
    外接する四角形の左上隅の x 座標を指定します (論理単位)。

  • y1
    外接する四角形の左上隅の y 座標を指定します (論理単位)。

  • x2
    外接する四角形の右下隅の x 座標を指定します (論理単位)。

  • y2
    外接する四角形の右下隅の y 座標を指定します (論理単位)。

  • x3
    円弧の始点の x 座標を指定します (論理単位)。 この点は、正確に円弧の線上になくてもかまいません。

  • y3
    円弧の始点の y 座標を指定します (論理単位)。 この点は、正確に円弧の線上になくてもかまいません。

  • x4
    円弧の端点の x 座標を指定します (論理単位)。 この点は、正確に円弧の線上になくてもかまいません。

  • y4
    円弧の端点の y 座標を指定します (論理単位)。 この点は、正確に円弧の線上になくてもかまいません。

  • lpRect
    外接する四角形を指定します。 このパラメーターには、CRect オブジェクトまたは RECT 構造体へのポインターを渡すこともできます。

  • ptStart
    円弧の始点を指定します。 この点は、正確に円弧の線上になくてもかまいません。 このパラメーターには、POINT 構造体または CPoint オブジェクトを渡すことができます。

  • ptEnd
    円弧の端点を指定します。 この点は、正確に円弧の線上になくてもかまいません。 このパラメーターには、POINT 構造体または CPoint オブジェクトを渡すことができます。

戻り値

正常終了した場合は 0 以外を返します。それ以外の場合は 0 を返します。

解説

円弧の中心は、x1、y1、x2、y2 (または lpRect) で指定される外接する四角形の中心です。 円弧の始点と終点は x3、y3、x4、y4 (または ptStart と ptEnd) で指定されます。

円弧は選択されたペンにより反時計回りに描画されます。 2 本の直線は円弧のそれぞれの端点から円弧の中心まで描画されます。 扇形の領域は選択されたブラシで塗りつぶされます。 x3 が x4 と等しくまた y3 が y4 と等しいときは、楕円の中心から点 (x3, y3) または (x4, y4) に 1 本の直線が描画されます。

この関数で描画される図形は、右下隅の座標まで拡張されます。右下隅の座標は含みません。 つまり、図形の高さは y2 - y1、図形の幅は x2 - x1 になります。 外接する四角形の幅と高さは 2 単位より大きく、32,767 単位より小さくする必要があります。

使用例

void CDCView::DrawPie(CDC* pDC)
{
   // Fill the client area with a simple pie chart. A
   // big blue slice covers 75% of the pie, from
   // 6 o'clock to 3 o'clock. This portion is filled
   // with blue and has a blue edge. The remaining 25%
   // is filled with a red, diagonal hatch and has
   // a red edge.

   // Get the client area.
   CRect rectClient;
   GetClientRect(rectClient);

   // Make a couple of pens and similar brushes.
   CPen penBlue, penRed;
   CBrush brushBlue, brushRed;
   CBrush* pOldBrush;
   CPen* pOldPen;

   brushBlue.CreateSolidBrush(RGB(0, 0, 255));
   brushRed.CreateHatchBrush(HS_FDIAGONAL, RGB(255, 0, 0));
   penBlue.CreatePen(PS_SOLID | PS_COSMETIC, 1, RGB(0, 0, 255));
   penRed.CreatePen(PS_SOLID | PS_COSMETIC, 1, RGB(255, 0, 0));

   // Draw from 3 o'clock to 6 o'clock, counterclockwise,
   // in a blue pen with a solid blue fill.

   pOldPen = pDC->SelectObject(&penBlue);
   pOldBrush = pDC->SelectObject(&brushBlue);

   pDC->Pie(rectClient,
      CPoint(rectClient.right, rectClient.CenterPoint().y),
      CPoint(rectClient.CenterPoint().x, rectClient.right));

   // Draw the remaining quarter slice from 6 o'clock
   // to 3 o'clock, counterclockwise, in a red pen with
   // the hatched brush.
   pDC->SelectObject(&penRed);
   pDC->SelectObject(&brushRed);

   // Same parameters, but reverse start and end points.
   pDC->Pie(rectClient,
      CPoint(rectClient.CenterPoint().x, rectClient.right),
      CPoint(rectClient.right, rectClient.CenterPoint().y));

   // Restore the previous pen.
   pDC->SelectObject(pOldPen);
}

必要条件

**ヘッダー:**afxwin.h

参照

参照

CDC クラス

階層図

CDC::Chord

Pie

RECT 構造体

POINT 構造体

CRect クラス

CPoint クラス

その他の技術情報

CDC のメンバー