PathGradientBrush::SetFocusScales method (gdipluspath.h)

The PathGradientBrush::SetFocusScales method sets the focus scales of this path gradient brush.

Syntax

Status SetFocusScales(
  [in] REAL xScale,
  [in] REAL yScale
);

Parameters

[in] xScale

Type: REAL

Real number that specifies the x focus scale.

[in] yScale

Type: REAL

Real number that specifies the y focus scale.

Return value

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

Remarks

By default, the center color of a path gradient is at the center point. By calling PathGradientBrush::SetFocusScales, you can specify that the center color should appear along a path that surrounds the center point. That path is the boundary path scaled by a factor of xScale in the x direction and by a factor of yScale in the y direction. The area inside the scaled path is filled with the center color.

Examples

The following example creates a PathGradientBrush object based on a triangular path. The code calls the PathGradientBrush::SetFocusScales method of the PathGradientBrush object to set the brush's focus scales to (0.2, 0.2). Then the code uses the path gradient brush to paint a rectangle that includes the triangular path.

VOID Example_SetFocusScales(HDC hdc)
{
   Graphics graphics(hdc);

   Point points[] = {Point(100, 0), Point(200, 200), Point(0, 200)};

   // No GraphicsPath object is created. The PathGradientBrush
   // object is constructed directly from the array of points.
   PathGradientBrush pthGrBrush(points, 3);

   Color colors[] = {
      Color(255, 255, 0, 0),    // red
      Color(255, 0, 0, 255)};   // blue

   REAL relativePositions[] = {
      0.0f,    // red at the boundary of the outer triangle
      1.0f};   // blue at the boundary of the inner triangle

   pthGrBrush.SetInterpolationColors(colors, relativePositions, 2);

   // The inner triangle is formed by scaling the outer triangle
   // about its centroid. The scaling factor is 0.2 in both
   // the x and y directions.
   pthGrBrush.SetFocusScales(0.2f, 0.2f);

   // Fill a rectangle that is larger than the triangle
   // specified in the Point array. The portion of the
   // rectangle outside the triangle will not be painted.
   graphics.FillRectangle(&pthGrBrush, 0, 0, 200, 200); 
}

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 gdipluspath.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Brushes and Filled Shapes

Creating a Path Gradient

Filling a Shape with a Color Gradient

PathGradientBrush

PathGradientBrush::GetFocusScales

PathGradientBrush::SetInterpolationColors