LinearGradientBrush::RotateTransform method (gdiplusbrush.h)
The LinearGradientBrush::RotateTransform method updates this brush's current transformation matrix with the product of itself and a rotation matrix.
Syntax
Status RotateTransform(
[in] REAL angle,
[in] MatrixOrder order
);
Parameters
[in] angle
Type: REAL
Real number that specifies the angle of rotation in degrees.
[in] order
Type: MatrixOrder
Optional. Element of the MatrixOrder enumeration that specifies the order of the multiplication. MatrixOrderPrepend specifies that the rotation matrix is on the left, and MatrixOrderAppend specifies that the rotation 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 T represents a translation, and matrix R represents a rotation. If matrix M is the product TR, then matrix M represents a composite transformation: first translate, then rotate.
The order of matrix multiplication is important. In general, the matrix product RT is not the same as the matrix product TR. In the example given in the previous paragraph, the composite transformation represented by RT (first rotate, then translate) is not the same as the composite transformation represented by TR (first translate, then rotate).
Examples
The following example creates a linear gradient brush and uses it to fill a rectangle. Next, the code modifies the brush's transformation matrix, applying a composite transformation, and then fills a rectangle with the transformed brush.
VOID Example_RotateTrans(HDC hdc)
{
Graphics myGraphics(hdc);
LinearGradientBrush linGrBrush(
Rect(0, 0, 80, 40),
Color(255, 255, 0, 0), // red
Color(255, 0, 0, 255), // blue
LinearGradientModeHorizontal);
// Fill a large area with the linear gradient brush (no transformation).
myGraphics.FillRectangle(&linGrBrush, 0, 0, 800, 150);
// Apply a composite transformation: first scale, then rotate.
linGrBrush.ScaleTransform(2, 1); // horizontal doubling
linGrBrush.RotateTransform(20, MatrixOrderAppend); // 20-degree rotation
// Fill a large area with the transformed linear gradient brush.
myGraphics.FillRectangle(&linGrBrush, 0, 200, 800, 150);
}
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
Filling Shapes with a Gradient Brush
LinearGradientBrush::MultiplyTransform
LinearGradientBrush::ScaleTransform
LinearGradientBrush::TranslateTransform