PathGradientBrush::Metode GetBlend (gdipluspath.h)
Metode PathGradientBrush::GetBlend mendapatkan faktor campuran dan posisi campuran yang sesuai yang saat ini diatur untuk sikat gradien jalur ini.
Sintaks
Status GetBlend(
[out] REAL *blendFactors,
[out] REAL *blendPositions,
[in] INT count
);
Parameter
[out] blendFactors
Jenis: REAL*
Penunjuk ke array yang menerima faktor campuran.
[out] blendPositions
Jenis: REAL*
Penunjuk ke array yang menerima posisi campuran.
[in] count
Jenis: INT
Bilangan bulat yang menentukan jumlah faktor campuran yang akan diambil. Sebelum memanggil metode PathGradientBrush::GetBlend dari objek PathGradientBrush , panggil metode PathGradientBrush::GetBlendCount dari objek PathGradientBrush yang sama untuk menentukan jumlah faktor campuran saat ini. Jumlah posisi campuran yang diambil sama dengan jumlah faktor campuran yang diambil.
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 menunjukkan beberapa metode kelas PathGradientBrush termasuk PathGradientBrush::SetBlend, PathGradientBrush::GetBlendCount, dan PathGradientBrush::GetBlend. Kode membuat objek PathGradientBrush dan memanggil metode PathGradientBrush::SetBlend untuk membuat serangkaian faktor campuran dan posisi campuran untuk kuas. Kemudian kode memanggil metode PathGradientBrush::GetBlendCount untuk mengambil jumlah faktor campuran. Setelah jumlah faktor campuran diambil, kode mengalokasikan dua buffer: satu untuk menerima array faktor campuran dan satu untuk menerima array posisi campuran. Kemudian kode memanggil metode PathGradientBrush::GetBlend untuk mengambil faktor campuran dan posisi campuran.
VOID Example_GetBlend(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);
// Obtain information about the path gradient brush.
INT blendCount = pthGrBrush.GetBlendCount();
REAL* factors = new REAL[blendCount];
REAL* positions = new REAL[blendCount];
pthGrBrush.GetBlend(factors, positions, blendCount);
for(INT j = 0; j < blendCount; ++j)
{
// Inspect or use the value in factors[j].
// Inspect or use the value in positions[j].
}
delete [] factors;
delete [] positions;
}
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
Mengisi Bentuk dengan Gradien Warna
PathGradientBrush::GetBlendCount
PathGradientBrush::SetCenterColor
PathGradientBrush::SetCenterPoint Methods
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk