LinearGradientBrush.ResetTransform Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Resets the Transform property to identity.
public:
void ResetTransform();
public void ResetTransform ();
member this.ResetTransform : unit -> unit
Public Sub ResetTransform ()
Examples
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 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 );
}
private void ResetTransformExample(PaintEventArgs e)
{
// Create a LinearGradientBrush.
Rectangle myRect = new Rectangle(20, 20, 200, 100);
LinearGradientBrush myLGBrush = new 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.
Point[] transformArray = { new Point(20, 150),
new Point(400,150), new Point(20, 200) };
Matrix myMatrix = new 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);
}
Public Sub ResetTransformExample(ByVal e As PaintEventArgs)
' Create a LinearGradientBrush.
Dim myRect As New Rectangle(20, 20, 200, 100)
Dim myLGBrush As New 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.
Dim transformArray As Point() = {New Point(20, 150), _
New Point(400, 150), New Point(20, 200)}
Dim myMatrix As New 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)
End Sub
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기