Método GraphicsPathIterator::NextSubpath(INT*,INT*,BOOL*) (gdipluspath.h)

O método GraphicsPathIterator::NextSubpath obtém o índice inicial e o índice final do próximo subcaminho (figura) no caminho associado desse iterador.

Sintaxe

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

Parâmetros

startIndex

Ponteiro para um INT que recebe o índice inicial.

endIndex

Ponteiro para um INT que recebe o índice final.

isClosed

Ponteiro para um BOOL que recebe um valor que indica se a figura obtida está fechada. Se a figura for fechada, o valor recebido será TRUE; caso contrário, o valor recebido será FALSE.

Valor retornado

Esse método retorna o número de pontos de dados na próxima figura. Se não houver mais números no caminho, esse método retornará 0.

Comentários

Na primeira vez que você chamar o método GraphicsPathIterator::NextSubpath de um iterador, ele obtém os índices da primeira figura (subcaminho) do caminho associado desse iterador. Na segunda vez, ele obtém os índices da segunda figura e assim por diante. Sempre que você chama GraphicsPathIterator::NextSubpath, ele retorna o número de pontos de dados na figura cujos índices foram recuperados. Quando não há números restantes, ele retorna 0.

Exemplos

O exemplo a seguir cria um objeto GraphicsPath e adiciona cinco figuras ao caminho. O código passa o endereço desse objeto GraphicsPath para um construtor GraphicsPathIterator para criar um iterador associado ao caminho. O código chama o método GraphicsPathIterator::NextSubpath do iterador três vezes para obter o índice inicial e o índice final da terceira figura do caminho. Em seguida, o código chama o método GraphicsPathIterator::CopyData do iterador para recuperar os pontos de dados da terceira figura.

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;
}

Requisitos

   
Cabeçalho gdipluspath.h

Confira também

Construindo e desenhando demarcadores

GraphicsPath::GetPathData

Graphicspath

Graphicspathiterator

GraphicsPathIterator::CopyData

GraphicsPathIterator::GetSubpathCount

Métodos GraphicsPathIterator::NextMarker

Nextsubpath

Caminhos