PathGradientBrush::SetBlend method (gdipluspath.h)

Metode PathGradientBrush::SetBlend menetapkan faktor campuran dan posisi campuran sikat gradien jalur ini.

Sintaks

Status SetBlend(
  [in] const REAL *blendFactors,
  [in] const REAL *blendPositions,
  [in] INT        count
);

Parameter

[in] blendFactors

Jenis: REAL*

Penunjuk ke array faktor campuran. Setiap angka dalam array harus dalam rentang 0 hingga 1.

[in] blendPositions

Jenis: REAL*

Penunjuk ke array posisi campuran. Setiap angka dalam array harus dalam rentang 0 hingga 1.

[in] count

Jenis: INT

Bilangan bulat yang menentukan jumlah elemen dalam array blendFactors . Ini sama dengan jumlah elemen dalam array blendPositions .

Menampilkan nilai

Jenis: 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

Objek PathGradientBrush memiliki jalur batas dan titik tengah. Ketika Anda mengisi area dengan sikat gradien jalur, warna berubah secara bertahap saat Anda berpindah dari jalur batas ke titik tengah. Secara default, warna secara linier terkait dengan jarak, tetapi Anda dapat menyesuaikan hubungan antara warna dan jarak dengan memanggil metode PathGradientBrush::SetBlend .

Contoh

Contoh berikut membuat objek PathGradientBrush berdasarkan elips. Kode ini memanggil metode PathGradientBrush::SetBlend dari objek PathGradientBrush untuk menetapkan serangkaian faktor campuran dan posisi campuran untuk kuas. Kemudian kode menggunakan jalur sikat gradien untuk mengisi elips.

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

   // Set blend factors and positions for the path gradient brush.
   REAL fac[] = {
      0.0f, 
      0.4f,     // 40 percent of the way from aqua to blue
      0.8f,     // 80 percent of the way from aqua to blue
      1.0f};

   REAL pos[] = {
      0.0f, 
      0.3f,   // 30 percent of the way from the boundary to the center
      0.7f,   // 70 percent of the way from the boundary to the center
      1.0f};

   pthGrBrush.SetBlend(fac, pos, 4);

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

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

Kuas dan Bentuk Terisi

Warna

Membuat Gradien Jalur

Mengisi Bentuk dengan Gradien Warna

GraphicsPath

PathGradientBrush

PathGradientBrush::GetBlend

PathGradientBrush::GetBlendCount