Bewerken

Share via


PathGradientBrush.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:
PathGradientBrush.cs
Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs
Source:
PathGradientBrush.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 transform scale factor in the x-axis direction.

sy
Single

The transform scale factor in the y-axis direction.

Examples

For an example, see ScaleTransform.

Applies to

ScaleTransform(Single, Single, MatrixOrder)

Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs
Source:
PathGradientBrush.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 transform scale factor in the x-axis direction.

sy
Single

The transform scale factor 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

  • Creates a graphics path and adds a rectangle to it.

  • Creates a PathGradientBrush from the path points (in this example, the points form a rectangle, but it could be most any shape).

  • Sets the center color to red and the surrounding color to blue.

  • Draws the PathGradientBrush to the screen prior to applying the scale transform.

  • Applies the scale transform to the brush by using its ScaleTransform method.

  • Calls the TranslateTransform method to move the brush rectangle such that it does not overlay the one drawn to the screen earlier.

  • Draws the translated brush rectangle to the screen.

Notice that the bottom rectangle is twice as long in the x-axis as is the one drawn prior to the translation.

public:
   void ScaleTransformExample( PaintEventArgs^ e )
   {
      // Create a graphics path and add a rectangle.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      Rectangle rect = Rectangle(100,20,100,50);
      myPath->AddRectangle( rect );

      // Get the path's array of points.
      array<PointF>^myPathPointArray = myPath->PathPoints;

      // Create a path gradient brush.
      PathGradientBrush^ myPGBrush = gcnew PathGradientBrush( myPathPointArray );

      // Set the color span.
      myPGBrush->CenterColor = Color::Red;
      array<Color>^ mySurroundColor = {Color::Blue};
      myPGBrush->SurroundColors = mySurroundColor;

      // Draw the brush to the screen prior to transformation.
      e->Graphics->FillRectangle( myPGBrush, 10, 10, 200, 200 );

      // Scale by a factor of 2 in the x-axis by applying the scale
      // transform to the brush.
      myPGBrush->ScaleTransform( 2, 1, MatrixOrder::Append );

      // Move the brush down by 100 by Applying the translate
      // transform to the brush.
      myPGBrush->TranslateTransform(  -100, 100, MatrixOrder::Append );

      // Draw the brush to the screen again after applying the
      // transforms.
      e->Graphics->FillRectangle( myPGBrush, 10, 10, 300, 300 );
   }
public void ScaleTransformExample(PaintEventArgs e)
{
             
    // Create a graphics path and add a rectangle.
    GraphicsPath myPath = new GraphicsPath();
    Rectangle rect = new Rectangle(100, 20, 100, 50);
    myPath.AddRectangle(rect);
             
    // Get the path's array of points.
    PointF[] myPathPointArray = myPath.PathPoints;
             
    // Create a path gradient brush.
    PathGradientBrush myPGBrush = new
        PathGradientBrush(myPathPointArray);
             
    // Set the color span.
    myPGBrush.CenterColor = Color.Red;
    Color[] mySurroundColor = {Color.Blue};
    myPGBrush.SurroundColors = mySurroundColor;
             
    // Draw the brush to the screen prior to transformation.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200);
             
    // Scale by a factor of 2 in the x-axis by applying the scale
    // transform to the brush.
    myPGBrush.ScaleTransform(2, 1, MatrixOrder.Append);
             
    // Move the brush down by 100 by Applying the translate
    // transform to the brush.
    myPGBrush.TranslateTransform(-100, 100, MatrixOrder.Append);
             
    // Draw the brush to the screen again after applying the
    // transforms.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300);
}
Public Sub ScaleTransformExample(ByVal e As PaintEventArgs)

    ' Create a graphics path and add a rectangle.
    Dim myPath As New GraphicsPath
    Dim rect As New Rectangle(100, 20, 100, 50)
    myPath.AddRectangle(rect)

    ' Get the path's array of points.
    Dim myPathPointArray As PointF() = myPath.PathPoints

    ' Create a path gradient brush.
    Dim myPGBrush As New PathGradientBrush(myPathPointArray)

    ' Set the color span.
    myPGBrush.CenterColor = Color.Red
    Dim mySurroundColor As Color() = {Color.Blue}
    myPGBrush.SurroundColors = mySurroundColor

    ' Draw the brush to the screen prior to transformation.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200)

    ' Scale by a factor of 2 in the x-axis by applying the scale
    ' transform to the brush.
    myPGBrush.ScaleTransform(2, 1, MatrixOrder.Append)

    ' Move the brush down by 100 by Applying the translate
    ' transform to the brush.
    myPGBrush.TranslateTransform(-100, 100, MatrixOrder.Append)

    ' Draw the brush to the screen again after applying the
    ' transforms.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300)
End Sub

Applies to