LinearGradientBrush.ScaleTransform 方法

定义

按指定量缩放局部几何转换。 此方法将缩放矩阵追加到转换之前。

重载

ScaleTransform(Single, Single)

按指定量缩放局部几何转换。 此方法将缩放矩阵追加到转换之前。

ScaleTransform(Single, Single, MatrixOrder)

按指定顺序按指定量缩放局部几何转换。

ScaleTransform(Single, Single)

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

按指定量缩放局部几何转换。 此方法将缩放矩阵追加到转换之前。

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 轴方向缩放转换的量。

sy
Single

在 y 轴方向缩放转换的量。

示例

有关示例,请参阅 ScaleTransform

适用于

ScaleTransform(Single, Single, MatrixOrder)

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

按指定顺序按指定量缩放局部几何转换。

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 轴方向缩放转换的量。

sy
Single

在 y 轴方向缩放转换的量。

order
MatrixOrder

一个 MatrixOrder,指定是追加还是追加缩放矩阵。

示例

下面的代码示例旨在与 Windows 窗体一起使用,它需要 PaintEventArgseOnPaint 事件对象。 该代码执行以下操作:

  • 创建新的 LinearGradientBrush

  • 使用此画笔将省略号绘制到屏幕。

  • 按 x 轴中的两个因子缩放 LinearGradientBrush

  • 使用缩放画笔将椭圆绘制到屏幕正下方的第一个椭圆。

请注意,下椭圆的渐变由两个因子拉伸。 另请注意,调用 TranslateTransform 方法用于使渐变填充的左边缘与椭圆左边缘对齐。

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

适用于