繪製陰影矩形
若要繪製陰影矩形,請使用兩個元素和單一GRADIENT_RECT結構定義TRIVERTEX陣列。 下列程式碼範例示範如何使用 GradientFill 函式搭配定義的GRADIENT_FILL_RECT模式繪製陰影矩形。
// Create an array of TRIVERTEX structures that describe
// positional and color values for each vertex. For a rectangle,
// only two vertices need to be defined: upper-left and lower-right.
TRIVERTEX vertex[2] ;
vertex[0].x = 0;
vertex[0].y = 0;
vertex[0].Red = 0x0000;
vertex[0].Green = 0x8000;
vertex[0].Blue = 0x8000;
vertex[0].Alpha = 0x0000;
vertex[1].x = 300;
vertex[1].y = 80;
vertex[1].Red = 0x0000;
vertex[1].Green = 0xd000;
vertex[1].Blue = 0xd000;
vertex[1].Alpha = 0x0000;
// Create a GRADIENT_RECT structure that
// references the TRIVERTEX vertices.
GRADIENT_RECT gRect;
gRect.UpperLeft = 0;
gRect.LowerRight = 1;
// Draw a shaded rectangle.
GradientFill(hdc, vertex, 2, &gRect, 1, GRADIENT_FILL_RECT_H);
下圖顯示上述程式碼範例的繪圖輸出。
相關主題