GraphicsPathIterator::NextSubpath(INT*,INT*,BOOL*) 메서드(gdipluspath.h)

GraphicsPathIterator::NextSubpath 메서드는 이 반복기의 연결된 경로에서 다음 하위 경로(그림)의 시작 인덱스와 끝 인덱스를 가져옵니다.

구문

INT NextSubpath(
  INT  *startIndex,
  INT  *endIndex,
  BOOL *isClosed
);

매개 변수

startIndex

시작 인덱스를 수신하는 INT 에 대한 포인터입니다.

endIndex

끝 인덱스를 수신하는 INT 에 대한 포인터입니다.

isClosed

가져온 그림이 닫혀 있는지 여부를 나타내는 값을 받는 BOOL 에 대한 포인터입니다. 그림이 닫힌 경우 수신된 값은 TRUE이고, 그렇지 않으면 받은 값이 FALSE입니다.

반환 값

이 메서드는 다음 그림의 데이터 포인트 수를 반환합니다. 경로에 더 이상 그림이 없으면 이 메서드는 0을 반환합니다.

설명

반복 기의 GraphicsPathIterator::NextSubpath 메서드를 처음 호출하면 해당 반복기의 연결된 경로의 첫 번째 그림(하위 경로)에 대한 인덱스를 가져옵니다. 두 번째로 두 번째 그림에 대한 인덱스를 가져옵니다. GraphicsPathIterator::NextSubpath를 호출할 때마다 인덱스가 검색된 그림의 데이터 요소 수를 반환합니다. 남은 수치가 없으면 0을 반환합니다.

예제

다음 예제에서는 GraphicsPath 개체를 만들고 경로에 5개의 그림을 추가합니다. 코드는 해당 GraphicsPath 개체의 주소를 GraphicsPathIterator 생성자에 전달하여 경로와 연결된 반복기를 만듭니다. 이 코드는 반복기의 GraphicsPathIterator::NextSubpath 메서드를 세 번 호출하여 경로의 세 번째 그림의 시작 인덱스와 끝 인덱스를 가져옵니다. 그런 다음 코드는 반복기의 GraphicsPathIterator::CopyData 메서드를 호출하여 세 번째 그림의 데이터 요소를 검색합니다.

VOID NextSubpathExample2(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a graphics path with five figures (subpaths).
   GraphicsPath path;

   path.AddRectangle(Rect(20, 20, 60, 30));   // Subpath count is 1.

   path.AddLine(100, 20, 160, 50);            // Subpath count is 2.
   path.AddArc(180, 20, 60, 30, 0.0f, 180.0f);

   path.AddRectangle(Rect(260, 20, 60, 30));  // Subpath count is 3.

   path.AddLine(340, 20, 400, 50);            // Subpath count is 4.
   path.AddArc(340, 20, 60, 30, 0.0f, 180.0f);
   path.CloseFigure();
  
   path.AddRectangle(Rect(420, 20, 60, 30));  // Subpath count is 5.

   // Create an iterator, and associate it with the path.
   GraphicsPathIterator iterator(&path);

   // Call NextSubpath three times to get the starting and ending
   // indices for the third figure.
   INT start;
   INT end;
   BOOL isClosed;
   INT count;
   count = iterator.NextSubpath(&start, &end, &isClosed);
   count = iterator.NextSubpath(&start, &end, &isClosed);
   count = iterator.NextSubpath(&start, &end, &isClosed);

   // Get the third figure's data points.
   PointF* points = new PointF[count];
   BYTE* types = new BYTE[count];
   iterator.CopyData(points, types, start, end);

   // Draw the third figure's data points.
   SolidBrush brush(Color(255, 255, 0, 0));
   for(INT j = 0; j < count; ++j)
      graphics.FillEllipse(
         &brush,
         points[j].X - 3.0f,
         points[j].Y - 3.0f,
         6.0f,
         6.0f);

   delete points;
   delete types;
}

요구 사항

   
머리글 gdipluspath.h

참고 항목

경로 구성 및 그리기

GraphicsPath::GetPathData

Graphicspath

GraphicsPathIterator

GraphicsPathIterator::CopyData

GraphicsPathIterator::GetSubpathCount

GraphicsPathIterator::NextMarker 메서드

NextSubpath

경로