LinearGradientBrush::ResetTransform Method ()
.NET Framework (current version)
Resets the Transform property to identity.
Assembly: System.Drawing (in System.Drawing.dll)
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
Available since 1.1
Show: