GraphicsPathIterator::Metode rewind (gdipluspath.h)

Metode GraphicsPathIterator::Rewind memutar balik iterator ini ke awal jalur terkait.

Sintaks

void Rewind();

Mengembalikan nilai

Tidak ada

Keterangan

Pertama kali Anda memanggil metode NextSubpath dari iterator, metode tersebut mendapatkan gambar pertama (subpath) dari jalur terkait iterator tersebut. Kedua kalinya, ia mendapatkan angka kedua, dan sebagainya. Saat Anda memanggil GraphicsPathIterator::Rewind, urutan dimulai kembali; artinya, setelah Anda memanggil GraphicsPathIterator::Rewind, panggilan berikutnya ke GraphicsPathIterator::NextSubpath mendapatkan gambar pertama di jalur. Metode GraphicsPathIterator::NextMarker dan GraphicsPathIterator::NextPathType bersifat serupa.

Contoh

Contoh berikut membuat objek GraphicsPath dan menambahkan lima gambar ke jalur. Kode meneruskan alamat objek GraphicsPath tersebut ke konstruktor GraphicsPathIterator untuk membuat iterator yang terkait dengan jalur. Kode memanggil metode GraphicsPathIterator::NextSubpath iterator dua kali untuk mengambil gambar kedua di jalur. Metode DrawPath menggambar jalur tersebut dengan warna biru. Selanjutnya, kode memanggil metode GraphicsPathIterator::Rewind lalu memanggil GraphicsPathIterator::NextSubpath sekali untuk mendapatkan gambar pertama di jalur. Metode DrawPath menggambar gambar tersebut dengan warna merah.


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

Persyaratan

   
Klien minimum yang didukung Windows XP, Windows 2000 Professional [hanya aplikasi desktop]
Server minimum yang didukung Windows 2000 Server [hanya aplikasi desktop]
Target Platform Windows
Header gdipluspath.h (termasuk Gdiplus.h)
Pustaka Gdiplus.lib
DLL Gdiplus.dll

Lihat juga

Membuat dan Menggambar Jalur

GraphicsPath

GraphicsPathIterator

GraphicsPathIterator::Metode NextMarker

GraphicsPathIterator::NextPathType

GraphicsPathIterator::NextSubpath Methods

Jalan