Metode PathGradientBrush::GetCenterPoint(PointF*) (gdipluspath.h)

Metode PathGradientBrush::GetCenterPoint mendapatkan titik tengah dari sikat gradien jalur ini.

Sintaks

Status GetCenterPoint(
  PointF *point
);

Parameter

point

Penunjuk ke objek PointF yang menerima titik tengah.

Mengembalikan nilai

Type:Status

Jika metode berhasil, metode mengembalikan Ok, yang merupakan elemen dari enumerasi Status .

Jika metode gagal, metode mengembalikan salah satu elemen lain dari enumerasi Status .

Keterangan

Secara default, titik tengah objek PathGradientBrush berada di sentroid jalur batas kuas, tetapi Anda dapat mengatur titik tengah ke lokasi mana pun, di dalam atau di luar jalur, dengan memanggil metode SetCenterPoint dari objek PathGradientBrush .

Contoh

Contoh berikut menunjukkan beberapa metode kelas PathGradientBrush termasuk PathGradientBrush::GetCenterPoint dan PathGradientBrush::SetCenterColor. Kode membuat objek PathGradientBrush dan kemudian mengatur warna tengah dan warna batas kuas. Kode memanggil metode PathGradientBrush::GetCenterPoint untuk menentukan titik tengah gradien jalur dan kemudian menarik garis dari asal ke titik tengah tersebut.

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

   // Create a path that consists of a single ellipse.
   GraphicsPath path;
   path.AddEllipse(0, 0, 200, 100);

   // Use the path to construct a brush.
   PathGradientBrush pthGrBrush(&path);

   // Set the color at the center of the path to blue.
   pthGrBrush.SetCenterColor(Color(255, 0, 0, 255));

   // Set the color along the entire boundary of the path to aqua.
   Color colors[] = {Color(255, 0, 255, 255)};
   INT count = 1;
   pthGrBrush.SetSurroundColors(colors, &count);

   // Fill the ellipse with the path gradient brush.
   graphics.FillEllipse(&pthGrBrush, 0, 0, 200, 100);

   // Obtain information about the path gradient brush.
   PointF centerPoint;
   pthGrBrush.GetCenterPoint(&centerPoint);

   // Draw a line from the origin to the center of the ellipse.
   Pen pen(Color(255, 0, 255, 0));
   graphics.DrawLine(&pen, PointF(0, 0), centerPoint);  
}

Persyaratan

   
Header gdipluspath.h

Lihat juga

Kuas dan Bentuk Terisi

Warna

Membuat Gradien Jalur

Mengisi Bentuk dengan Gradien Warna

PathGradientBrush

PathGradientBrush::GetCenterColor

PathGradientBrush::SetCenterColor

PathGradientBrush::SetCenterPoint Methods