LinearGradientBrush::MultiplyTransform Method (Matrix^, MatrixOrder)

 

Multiplies the Matrix that represents the local geometric transform of this LinearGradientBrush by the specified Matrix in the specified order.

Namespace:   System.Drawing.Drawing2D
Assembly:  System.Drawing (in System.Drawing.dll)

public:
void MultiplyTransform(
	Matrix^ matrix,
	MatrixOrder order
)

Parameters

matrix
Type: System.Drawing.Drawing2D::Matrix^

The Matrix by which to multiply the geometric transform.

order
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 PaintEventArgse, an OnPaint event object. The code performs the following actions:

Notice that the lower ellipse is stretched in the horizontal direction, and that the gradient is stretched to match the new shape.

private:
   void MultiplyTransformExample( PaintEventArgs^ e )
   {
      // Create a LinearGradientBrush.
      Rectangle myRect = Rectangle(20,20,200,100);
      LinearGradientBrush^ myLGBrush = gcnew LinearGradientBrush( myRect,Color::Blue,Color::Red,0.0f,true );

      // Draw an ellipse to the screen using the LinearGradientBrush.
      e->Graphics->FillEllipse( myLGBrush, myRect );

      // Transform the LinearGradientBrush.
      array<Point>^ transformArray = {Point(20,150),Point(400,150),Point(20,200)};
      Matrix^ myMatrix = gcnew Matrix( myRect,transformArray );
      myLGBrush->MultiplyTransform( myMatrix, MatrixOrder::Prepend );

      // Draw a second ellipse to the screen using
      // the transformed brush.
      e->Graphics->FillEllipse( myLGBrush, 20, 150, 380, 50 );
   }

.NET Framework
Available since 1.1
Return to top
Show: