## 重载

 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)

``````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)``

#### 参数

sx
Single

X 轴方向上的变换比例因子。The transform scale factor in the x-axis direction.

sy
Single

Y 轴方向上的变换比例因子。The transform scale factor in the y-axis direction.

## ScaleTransform(Single, Single, MatrixOrder)

``````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)``

#### 参数

sx
Single

X 轴方向上的变换比例因子。The transform scale factor in the x-axis direction.

sy
Single

Y 轴方向上的变换比例因子。The transform scale factor in the y-axis direction.

order
MatrixOrder

### 示例

• 创建图形路径并向其添加一个矩形。Creates a graphics path and adds a rectangle to it.

• 从路径点创建一个 PathGradientBrush （在此示例中，点构成一个矩形，但它可以是大多数形状）。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.

• 在应用缩放转换之前，将 PathGradientBrush 绘制到屏幕上。Draws the PathGradientBrush to the screen prior to applying the scale transform.

• 使用缩放转换将其 ScaleTransform 方法应用于画笔。Applies the scale transform to the brush by using its ScaleTransform method.

• 调用 TranslateTransform 方法来移动画笔矩形，使其不会覆盖之前绘制到屏幕的画笔。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.

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

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

// Create a path gradient brush.

// 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);

// Get the path's array of points.
PointF[] myPathPointArray = myPath.PathPoints;

// Create a path gradient brush.

// 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)

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

' Create a path gradient brush.

' 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
``````