Creates a LinearGradientBrush::LinearGradientBrush object from a set of boundary points and boundary colors.

Syntax

``````void LinearGradientBrush(
const PointF & point1,
const PointF & point2,
const Color &  color1,
const Color &  color2
);
``````

Parameters

`point1`

Type: const PointF

Reference to a Point object that specifies the starting point of the gradient. The starting boundary line passes through the starting point.

`point2`

Type: const PointF

Reference to a Point object that specifies the ending point of the gradient. The ending boundary line passes through the ending point.

`color1`

Type: const Color

Reference to a Color object that specifies the color at the starting boundary line of this linear gradient brush.

`color2`

Type: const Color

Reference to a Color object that specifies the color at the ending boundary line of this linear gradient brush.

None

Remarks

The "directional line," an imaginary straight line, is defined by the starting point, point1, and the ending point, point2. The starting boundary of the gradient is a straight line that is perpendicular to the directional line and that passes through the starting point. The ending boundary of the gradient is a straight line that is parallel to the starting boundary line and that passes through the ending point. The gradient color is constant along lines that are parallel to the boundary lines. The gradient gradually changes from the starting color to the ending color along the directional line.

Examples

The following example creates a linear gradient brush from a set of boundary points and boundary colors. The code then uses the brush to paint the interior of a rectangle.

``````VOID Example_Construct02(HDC hdc)
{
Graphics myGraphics(hdc);

PointF(0.8f, 1.6f),
PointF(3.0f, 2.4f),
Color(255, 255, 0, 0),   // red
Color(255, 0, 0, 255));  // blue

myGraphics.SetPageUnit(UnitInch);
myGraphics.FillRectangle(&linGrBrush, 0, 0, 4, 3);
}
``````

Requirements

Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows