LinearGradientBrush::ScaleTransform Method (Single, Single, MatrixOrder)
Scales the local geometric transform by the specified amounts in the specified order.
Assembly: System.Drawing (in System.Drawing.dll)
Parameters
- sx
-
Type:
System::Single
The amount by which to scale the transform in the x-axis direction.
- sy
-
Type:
System::Single
The amount by which to scale the transform in the y-axis direction.
- order
-
Type:
System.Drawing.Drawing2D::MatrixOrder
A MatrixOrder that specifies whether to append or prepend the scaling matrix.
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.
Draw an ellipse to the screen using this brush.
Scales the LinearGradientBrush by a factor of two in the x-axis.
Draws an ellipse to the screen directly below the first ellipse, using the scaled brush.
Notice that the gradient of the lower ellipse is stretched by a factor of two. Also notice that a call to the TranslateTransform method is used to justify the left edge of the gradient fill with the left edge of ellipse.
private: void ScaleTransformExample( 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 ); // Scale the LinearGradientBrush. myLGBrush->ScaleTransform( 2.0f, 1.0f, MatrixOrder::Prepend ); // Rejustify the brush to start at the left edge of the ellipse. myLGBrush->TranslateTransform( -20.0f, 0.0f ); // Draw a second ellipse to the screen using // the transformed brush. e->Graphics->FillEllipse( myLGBrush, 20, 150, 200, 100 ); }
Available since 1.1