GraphicsPathIterator::Rewind メソッド (gdipluspath.h)

GraphicsPathIterator::Rewind メソッドは、この反復子を関連付けられたパスの先頭に巻き戻します。

構文

void Rewind();

戻り値

なし

解説

反復子の NextSubpath メソッドを初めて呼び出すと、その反復子の関連付けられたパスの最初の図 (サブパス) が取得されます。 2 回目は、2 番目の図を取得します。などです。 GraphicsPathIterator::Rewind を呼び出すと、シーケンスはやり直されます。つまり、GraphicsPathIterator::Rewind を呼び出すと、次に GraphicsPathIterator::NextSubpath を呼び出すと、パスの最初の図が取得されます。 GraphicsPathIterator::NextMarker メソッドと GraphicsPathIterator::NextPathType メソッドも同様に動作します。

次の例では 、GraphicsPath オブジェクトを作成し、パスに 5 つの図形を追加します。 このコードは、 その GraphicsPath オブジェクトのアドレスを GraphicsPathIterator コンストラクターに渡して、パスに関連付けられた反復子を作成します。 このコードでは、反復子の GraphicsPathIterator::NextSubpath メソッドを 2 回呼び出して、パス内の 2 番目の図を取得します。 DrawPath メソッドは、そのパスを青で描画します。 次に、 GraphicsPathIterator::Rewind メソッドを呼び出し、 GraphicsPathIterator::NextSubpath を 1 回呼び出して、パスの最初の図を取得します。 DrawPath メソッドは、その図形を赤で描画します。


VOID RewindExample(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);

   // Get the second subpath by calling NextSubpath twice.
   GraphicsPath subpath;
   BOOL isClosed;
   INT count;
   count = iterator.NextSubpath(&subpath, &isClosed);
   count = iterator.NextSubpath(&subpath, &isClosed);

   // Draw the second figure in blue.
   Pen bluePen(Color(255, 0, 0, 255));
   graphics.DrawPath(&bluePen, &subpath);

   // Rewind the iterator, and get the first figure in the path.
   iterator.Rewind();
   count = iterator.NextSubpath(&subpath, &isClosed);

   // Draw the first figure in red.
   Pen redPen(Color(255, 255, 0, 0));
   graphics.DrawPath(&redPen, &subpath);
}

要件

   
サポートされている最小のクライアント Windows XP、Windows 2000 Professional [デスクトップ アプリのみ]
サポートされている最小のサーバー Windows 2000 Server [デスクトップ アプリのみ]
対象プラットフォーム Windows
ヘッダー gdipluspath.h (Gdiplus.h を含む)
Library Gdiplus.lib
[DLL] Gdiplus.dll

関連項目

パスの作成および描画

Graphicspath

GraphicsPathIterator

GraphicsPathIterator::NextMarker メソッド

GraphicsPathIterator::NextPathType

GraphicsPathIterator::NextSubpath メソッド

パス