Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

PathGradientBrush.MultiplyTransform Method (Matrix, MatrixOrder)

Updates the brush's transformation matrix with the product of the brush's transformation matrix multiplied by another matrix.

Namespace:  System.Drawing.Drawing2D
Assembly:  System.Drawing (in System.Drawing.dll)
public void MultiplyTransform(
	Matrix matrix,
	MatrixOrder order


Type: System.Drawing.Drawing2D.Matrix

The Matrix that will be multiplied by the brush's current transformation matrix.

Type: System.Drawing.Drawing2D.MatrixOrder

A MatrixOrder that specifies in which order to multiply the two matrices.

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, an OnPaint event object. The code performs the following actions:

  • Creates a graphics path and adds a rectangle to it.

  • Creates a PathGradientBrush from the path points (in this example, the points form a rectangle, but it could be most any shape).

  • Sets the center color to red and the surrounding color to blue.

  • Draws the PathGradientBrush to the screen prior to applying the multiply transform.

  • Creates s matrix that rotates the brush 90 degrees and translates it by 100 in both axes.

  • Applies this matrix to the brush by using the MultiplyTransform method.

  • Draws the brush to the screen.

public void MultiplyTransformExample(PaintEventArgs e)

    // Create a graphics path and add an rectangle.
    GraphicsPath myPath = new GraphicsPath();
    Rectangle rect = new Rectangle(20, 20, 100, 50);

    // Get the path's array of points.
    PointF[] myPathPointArray = myPath.PathPoints;

    // Create a path gradient brush.
    PathGradientBrush myPGBrush = new

    // Set the color span.
    myPGBrush.CenterColor = Color.Red;
    Color[] mySurroundColor = {Color.Blue};
    myPGBrush.SurroundColors = mySurroundColor;

    // Draw the brush to the screen prior to transformation.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200);

    // Create a new matrix that rotates by 90 degrees, and 
    // translates by 100 in each direction.
    Matrix myMatrix = new Matrix(0, 1, -1, 0, 100, 100);

    // Apply the transform to the brush.
    myPGBrush.MultiplyTransform(myMatrix, MatrixOrder.Append);

    // Draw the brush to the screen again after applying the 
    // transform.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 300);

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.