LinearGradientBrush.ScaleTransform 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將局部幾何變換縮放至指定量。 此方法在變換前加上縮放矩陣。
多載
| 名稱 | Description |
|---|---|
| ScaleTransform(Single, Single) |
將局部幾何變換縮放至指定量。 此方法在變換前加上縮放矩陣。 |
| ScaleTransform(Single, Single, MatrixOrder) |
以指定數量和指定順序縮放局部幾何變換。 |
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 軸方向上縮放的幅度。
- sy
- Single
這是將轉換在 y 軸方向縮放的量。
範例
如需範例,請參閱 ScaleTransform。
適用於
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 軸方向上縮放的幅度。
- sy
- Single
這是將轉換在 y 軸方向縮放的量。
- order
- MatrixOrder
一個 MatrixOrder 指定要加或加疊縮放矩陣的符號。
範例
以下程式碼範例是為 Windows Forms 設計,並需要 PaintEventArgse,一個 OnPaint 事件物件。 此程式碼會執行下列動作:
會產生一個新的 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