LinearGradientBrush.RotateTransform 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將局部幾何變換旋轉至指定範圍。 此方法在轉換前先行旋轉。
多載
| 名稱 | Description |
|---|---|
| RotateTransform(Single) |
將局部幾何變換旋轉至指定範圍。 此方法在轉換前先行旋轉。 |
| RotateTransform(Single, MatrixOrder) |
以指定順序旋轉局部幾何變換,旋轉指定大小。 |
RotateTransform(Single)
將局部幾何變換旋轉至指定範圍。 此方法在轉換前先行旋轉。
public:
void RotateTransform(float angle);
public void RotateTransform(float angle);
member this.RotateTransform : single -> unit
Public Sub RotateTransform (angle As Single)
參數
- angle
- Single
旋轉角度。
範例
如需範例,請參閱 RotateTransform。
適用於
RotateTransform(Single, MatrixOrder)
以指定順序旋轉局部幾何變換,旋轉指定大小。
public:
void RotateTransform(float angle, System::Drawing::Drawing2D::MatrixOrder order);
public void RotateTransform(float angle, System.Drawing.Drawing2D.MatrixOrder order);
member this.RotateTransform : single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub RotateTransform (angle As Single, order As MatrixOrder)
參數
- angle
- Single
旋轉角度。
- order
- MatrixOrder
一個 MatrixOrder 指定要加或加旋轉矩陣的 A。
範例
以下程式碼範例是為 Windows Forms 設計,並需要 PaintEventArgse,一個 OnPaint 事件物件。 程式碼
會產生一個新的 LinearGradientBrush。
用這支刷子在螢幕上畫一個橢圓形。
透過呼叫LinearGradientBrush方法來旋轉45RotateTransform度。
使用旋轉的畫筆,在第一個橢圓下方直接畫出一個橢圓。
注意下橢圓的梯度與上橢圓的 x 軸呈 45 度角。 同時也注意,該方法的呼叫 TranslateTransform 用來將梯度填充的左邊與下橢圓的左邊對齊。
private:
void RotateTransformExample( 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 );
// Rotate the LinearGradientBrush.
myLGBrush->RotateTransform( 45.0f, MatrixOrder::Prepend );
// Rejustify the brush to start at the left edge of the ellipse.
myLGBrush->TranslateTransform( -100.0f, 0.0f );
// Draw a second ellipse to the screen using
// the transformed brush.
e->Graphics->FillEllipse( myLGBrush, 20, 150, 200, 100 );
}
private void RotateTransformExample(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);
// Rotate the LinearGradientBrush.
myLGBrush.RotateTransform(45.0f, MatrixOrder.Prepend);
// Rejustify the brush to start at the left edge of the ellipse.
myLGBrush.TranslateTransform(-100.0f, 0.0f);
// Draw a second ellipse to the screen using
// the transformed brush.
e.Graphics.FillEllipse(myLGBrush, 20, 150, 200, 100);
}
Public Sub RotateTransformExample(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)
' Rotate the LinearGradientBrush.
myLGBrush.RotateTransform(45.0F, MatrixOrder.Prepend)
' Rejustify the brush to start at the left edge of the ellipse.
myLGBrush.TranslateTransform(-100.0F, 0.0F)
' Draw a second ellipse to the screen using the transformed brush.
e.Graphics.FillEllipse(myLGBrush, 20, 150, 200, 100)
End Sub