共用方式為


PathGradientBrush.ScaleTransform 方法

定義

依指定的量調整局部幾何轉換。 這個方法會將縮放矩陣前面加上轉換。

多載

ScaleTransform(Single, Single)

依指定的量調整局部幾何轉換。 這個方法會將縮放矩陣前面加上轉換。

ScaleTransform(Single, Single, MatrixOrder)

依指定順序的指定數量來縮放局部幾何轉換。

ScaleTransform(Single, Single)

來源:
PathGradientBrush.cs
來源:
PathGradientBrush.cs
來源:
PathGradientBrush.cs
來源:
PathGradientBrush.cs
來源:
PathGradientBrush.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)

來源:
PathGradientBrush.cs
來源:
PathGradientBrush.cs
來源:
PathGradientBrush.cs
來源:
PathGradientBrush.cs
來源:
PathGradientBrush.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 Forms 搭配使用,而且需要 PaintEventArgseOnPaint 事件物件。 程序代碼

  • 建立圖形路徑,並將矩形加入其中。

  • 從路徑點建立 PathGradientBrush(在此範例中,這些點會形成矩形,但可能是大部分的圖形)。

  • 將中央色彩設定為紅色,並將周圍色彩設定為藍色。

  • 在套用縮放轉換之前,先將 PathGradientBrush 繪製到畫面。

  • 使用其 ScaleTransform 方法,將縮放轉換套用至筆刷。

  • 呼叫 TranslateTransform 方法來移動筆刷矩形,使其不會重疊先前繪製到螢幕的筆刷矩形。

  • 將翻譯的筆刷矩形繪製到螢幕。

請注意,在 x 軸中,底部矩形的長度是平移前繪製的兩倍。

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

適用於