PathGradientBrush::TranslateTransform method (gdipluspath.h)

The PathGradientBrush::TranslateTransform method updates this brush's current transformation matrix with the product of itself and a translation matrix.

Syntax

Status TranslateTransform(
  [in] REAL        dx,
  [in] REAL        dy,
  [in] MatrixOrder order
);

Parameters

[in] dx

Type: REAL

Real number that specifies the horizontal component of the translation.

[in] dy

Type: REAL

Real number that specifies the vertical component of the translation.

[in] order

Type: MatrixOrder

Optional. Element of the MatrixOrder enumeration that specifies the order of the multiplication. MatrixOrderPrepend specifies that the translation matrix is on the left, and MatrixOrderAppend specifies that the translation matrix is on the right. The default value is MatrixOrderPrepend.

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

A single 3 ×3 matrix can store any sequence of affine transformations. If you have several 3 ×3 matrices, each of which represents an affine transformation, the product of those matrices is a single 3 ×3 matrix that represents the entire sequence of transformations. The transformation represented by that product is called a composite transformation. For example, suppose matrix S represents a scaling and matrix T represents a translation. If matrix M is the product ST, then matrix M represents a composite transformation: first scale, then translate.

Examples

The following example creates a PathGradientBrush object based on a triangular path. The calls to the PathGradientBrush::ScaleTransform and PathGradientBrush::TranslateTransform methods of the PathGradientBrush object set the elements of the brush's transformation matrix so that it represents a composite transformation: first scale, then translate. The code uses the path gradient brush twice to paint a rectangle: once before the transformation is set and once after the transformation is set.

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

   Point pts[] = {Point(0, 0), Point(50, 0), Point(50, 50)};
   PathGradientBrush pthGrBrush(pts, 3);

   // Fill an area with the path gradient brush (no transformation).
   graphics.FillRectangle(&pthGrBrush, 0, 0, 500, 500);

   pthGrBrush.ScaleTransform(3.0f, 1.0f);
   pthGrBrush.TranslateTransform(100.0f, 50.0f, MatrixOrderAppend);

   // Fill the same area with the transformed path gradient brush.
   graphics.FillRectangle(&pthGrBrush, 0, 0, 500, 500);  
}

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

Matrix

Matrix Representation of Transformations

MatrixOrder

PathGradientBrush

PathGradientBrush::GetTransform

PathGradientBrush::MultiplyTransform

PathGradientBrush::ResetTransform

PathGradientBrush::RotateTransform

PathGradientBrush::ScaleTransform

PathGradientBrush::SetTransform

Transformations