CDC::Arc

绘制椭圆弧。

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

参数

  • x1
    指定边框的左上角的x坐标(以逻辑单位)。

  • y1
    指定边框的左上角的y坐标(以逻辑单位)。

  • x2
    指定边框右下角的x坐标(以逻辑单位)。

  • y2
    指定边框的右下角的y坐标(以逻辑单位)。

  • x3
    指定定义弧形的起点点的x坐标(以逻辑单位)。 该弧点不必完全位于。

  • y3
    指定定义弧形的起点点的y坐标(以逻辑单位)。 该弧点不必完全位于。

  • x4
    指定定义弧形的终点点的x坐标(以逻辑单位)。 该弧点不必完全位于。

  • y4
    指定定义弧形的终点点的y坐标(以逻辑单位)。 该弧点不必完全位于。

  • lpRect
    指定边框(以逻辑单位)。 可以通过 LPRECT 或一 CRect 对象此参数的。

  • ptStart
    指定该x,并定义弧形的点y坐标起点(在逻辑单位)。 该弧点不必完全位于。 可以通过 POINT 结构或 CPoint 对象此参数的。

  • ptEnd
    指定该x,并定义弧形的点y坐标终结点(以逻辑单位)。 该弧点不必完全位于。 您可以通过一 POINT 结构或一 CPoint 对象此参数的。

返回值

非零,如果函数运行成功;否则为0。

备注

弧线绘制通过使用函数是指定的边框定义的椭圆的段。

实际的弧线是从边框的中心绘制的射线通过指定的起点相交椭圆的点。 实际终结点弧线是从边框的中心绘制的射线通过指定的终点相交椭圆的点。 弧线在左转绘制。 因为弧线不是一个闭合图形,它不会加载。 矩形的宽度和高度小于2个单位和少于32,767个单位必须大。

示例

void CDCView::DrawArc(CDC* pDC)
{
   // Fill the client area with a thin circle. The circle's
   // interior is not filled. The circle's perimeter is
   // blue from 6 o'clock to 3 o'clock and red from 3
   // o'clock to 6 o'clock.

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

   // Make a couple of pens.
   CPen penBlue;
   CPen penRed;
   CPen* pOldPen;

   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.

   pOldPen = pDC->SelectObject(&penBlue);

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

   // Draw from 6 o'clock to 3 o'clock, counterclockwise,
   // in a red pen.
   pDC->SelectObject(&penRed);

   // Keep the same parameters, but reverse start
   // and end points.
   pDC->Arc(rectClient,
      CPoint(rectClient.CenterPoint().x, rectClient.right),
      CPoint(rectClient.right, rectClient.CenterPoint().y));

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

要求

Header: afxwin.h

请参见

参考

CDC 类

层次结构图

CDC::Chord

Arc

POINT 结构

RECT 结构