LinearGradientBrush::LinearGradientBrush(constPointF&,constPointF&,constColor&,constColor&) method (gdiplusbrush.h)

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

Syntax

void LinearGradientBrush(
  [in, ref] const PointF & point1,
  [in, ref] const PointF & point2,
  [in, ref] const Color &  color1,
  [in, ref] const Color &  color2
);

Parameters

[in, ref] 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.

[in, ref] 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.

[in, ref] color1

Type: const Color

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

[in, ref] color2

Type: const Color

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

Return value

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);

   LinearGradientBrush linGrBrush(
      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

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdiplusbrush.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Color

LinearGradientBrush

Rect