LinearGradientBrush::ResetTransform Method ()

 

Resets the Transform property to identity.

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

public:
void ResetTransform()

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:

  • Creates a new LinearGradientBrush.

  • Draws an ellipse to the screen using this brush.

  • Calls the MultiplyTransform method to transform the LinearGradientBrush.

  • Draws an ellipse to the screen directly below the first ellipse, using the transformed brush.

  • Resets the transform.

  • Draws a third ellipse to the screen below the first two.

Notice that the lowest ellipse is drawn the same size as the first, and that, due to the call to the ResetTransform method, the gradient has been reduced to match.

private:
   void ResetTransformExample( 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 );

      // Reset the brush transform.
      myLGBrush->ResetTransform();

      // Draw a third ellipse to the screen using the reset brush.
      e->Graphics->FillEllipse( myLGBrush, 20, 250, 200, 100 );
   }

.NET Framework
Available since 1.1
Return to top
Show: