網掛けされた四角形の描画

網かけの四角形を描画するには、2 つの要素と 1 つの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);

次の図は、前のコード例の描画出力を示しています。

左側の濃色から右側の明るいグラデーションの塗りつぶしを含む四角形を示す図

ビットマップの概要

ビットマップ関数

網かけの三角形を描画する

EMRGRADIENTFILL

GRADIENT_RECT

GradientFill

TRIVERTEX