PathGradientBrush::SetWrapMode method

The PathGradientBrush::SetWrapMode method sets the wrap mode of this path gradient brush.


Status SetWrapMode(
  IN WrapMode wrapMode



Type: WrapMode

Element of the WrapMode enumeration that specifies how areas painted with the path gradient brush will be tiled. The default value is WrapModeClamp.

Return Value

Type: 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.


The bounding rectangle of a path gradient brush is the smallest rectangle that encloses the brush's boundary path. When you paint the bounding rectangle with the path gradient brush, only the area inside the boundary path gets filled. The area inside the bounding rectangle but outside the boundary path does not get filled.

WrapModeClamp (the default wrap mode) indicates that no painting occurs outside of the brush's bounding rectangle. All of the other wrap modes indicate that areas outside the brush's bounding rectangle will be tiled. Each tile is a copy (possibly flipped) of the filled path inside its bounding rectangle.


The following example creates a PathGradientBrushobject based on a triangular path. The code calls the PathGradientBrush::SetWrapMode method of the PathGradientBrushobject to set the brush's wrap mode to WrapModeTileFlipX. The Graphics::FillRectangle method uses the path gradient brush to tile a large area.

The output of the code is a grid of tiles. As you move from one tile to the next in a given row, the image (filled boundary path inside the bounding rectangle) is flipped horizontally.

VOID Example_SetWrapMode(HDC hdc)
   Graphics graphics(hdc);

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

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

   INT count = 3;

   PathGradientBrush pthGrBrush(points, 3);
   pthGrBrush.SetSurroundColors(colors, &count);

   graphics.FillRectangle(&pthGrBrush, 0, 0, 800, 800); 


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