Modifier

Partager via


LinearGradientBrush.ScaleTransform Method

Definition

Scales the local geometric transform by the specified amounts. This method prepends the scaling matrix to the transform.

Overloads

ScaleTransform(Single, Single)

Scales the local geometric transform by the specified amounts. This method prepends the scaling matrix to the transform.

ScaleTransform(Single, Single, MatrixOrder)

Scales the local geometric transform by the specified amounts in the specified order.

ScaleTransform(Single, Single)

Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs

Scales the local geometric transform by the specified amounts. This method prepends the scaling matrix to the transform.

public:
 void ScaleTransform(float sx, float sy);
public void ScaleTransform (float sx, float sy);
member this.ScaleTransform : single * single -> unit
Public Sub ScaleTransform (sx As Single, sy As Single)

Parameters

sx
Single

The amount by which to scale the transform in the x-axis direction.

sy
Single

The amount by which to scale the transform in the y-axis direction.

Examples

For an example, see ScaleTransform.

Applies to

ScaleTransform(Single, Single, MatrixOrder)

Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs

Scales the local geometric transform by the specified amounts in the specified order.

public:
 void ScaleTransform(float sx, float sy, System::Drawing::Drawing2D::MatrixOrder order);
public void ScaleTransform (float sx, float sy, System.Drawing.Drawing2D.MatrixOrder order);
member this.ScaleTransform : single * single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub ScaleTransform (sx As Single, sy As Single, order As MatrixOrder)

Parameters

sx
Single

The amount by which to scale the transform in the x-axis direction.

sy
Single

The amount by which to scale the transform in the y-axis direction.

order
MatrixOrder

A MatrixOrder that specifies whether to append or prepend the scaling matrix.

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.

  • 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 );
   }
private void ScaleTransformExample(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);
             
    // 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);
}
Public Sub ScaleTransformExample(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)

    ' 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)
End Sub

Applies to