Help Center

GdipSetPathGradientTransformfunction

Sets the transformation matrix of this path gradient brush.

Graphicsfunctiondocumented

Syntax

FUNCTION GdipSetPathGradientTransform (BYVAL brush AS GpPathGradient PTR, BYVAL matrix AS GpMatrix PTR) AS GpStatus

Parameters

NameDescription
brush[in] Pointer to the PathGradientBrush object.
matrix[in] Pointer to a variable that specifies the transformation matrix.

Description

Sets the transformation matrix of this path gradient brush.

Remarks

A PathGradientBrush object has a GraphicsPath object that serves as the boundary path for the brush. When you paint with a path gradient brush, only the area inside the boundary path is filled. If the brush's transformation matrix is set to represent any transformation other than the identity, then the boundary path is transformed according to that matrix during rendering, and only the area inside the transformed path is filled.

Example

' ======================================================================================== ' The following example creates a PathGradientBrush object based on a triangular path. The ' GdipFillRectangle function uses the path gradient brush to paint a rectangle that ' contains the triangular path. Next, the code creates a Matrix object that represents a ' composite transformation (rotate, then translate) and passes the address of that Matrix ' object to the GdipSetPathGradientTransform function. The code calls GdipFillRectangle a ' second time to paint the same rectangle using the transformed path gradient brush. ' ======================================================================================== SUB Example_SetPathGradientTransform (BYVAL hdc AS HDC)

DIM hStatus AS LONG

' // Create a graphics object from the device context DIM graphics AS GpGraphics PTR hStatus = GdipCreateFromHDC(hdc, @graphics)

' // Get the DPI scaling ratios DIM dpiX AS SINGLE hStatus = GdipGetDpiX(graphics, @dpiX) DIM rxRatio AS SINGLE = dpiX / 96 DIM dpiY AS SINGLE hStatus = GdipGetDpiY(graphics, @dpiY) DIM ryRatio AS SINGLE = dpiY / 96 ' // Set the scale transform hStatus = GdipScaleWorldTransform(graphics, rxRatio, ryRatio, MatrixOrderPrepend)

' // Creates a gradient brush based on an array of points DIM pts(0 TO 2) AS GpPointF = {(0, 0), (100, 0), (100, 100)} DIM brush AS GpPathGradient PTR hStatus = GdipCreatePathGradient(@pts(0), 3, WrapModeClamp, @brush)

' // Sets the surround colors

DIM count AS LONG = 3 DIM colors(0 TO 2) AS ARGB = {ARGB_RED, ARGB_LIGHTGREEN, ARGB_BLACK} hStatus = GdipSetPathGradientSurroundColorsWithCount(brush, @colors(0), @count)

' // Fill an area with the path gradient brush (no transformation). hStatus = GdipFillRectangle(graphics, brush, 0, 0, 200, 200)

' // Set the transformation for the brush (rotate, then translate). DIM matrix AS GpMatrix PTR hStatus = GdipCreateMatrix2(0, 1, -1, 0, 150, 60, @matrix) hStatus = GdipSetPathGradientTransform(brush, matrix)

' // Fill the same area with the transformed path gradient brush. hStatus = GdipFillRectangle(graphics, brush, 0, 0, 200, 200)

' // Cleanup IF matrix THEN GdipDeleteMatrix(matrix) IF brush THEN GdipDeleteBrush(brush) IF graphics THEN GdipDeleteGraphics(graphics)

END SUB ' ========================================================================================

Reference

  • Defined in AfxNova/AfxGdiPlus.bi:2266
  • Documented in Graphics/GdiPlus Flat Api/GdiPlusPathGradientBrush.md
  • Topic: GdiPlusPathGradientBrush