PathGradientBrush.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 事件物件。 此程式碼會執行下列動作:
建立圖形路徑並加入一個矩形。
從路徑點(在此例中,點形成矩形,但幾乎可以是任何形狀)建立 a PathGradientBrush 。
將中心顏色設為紅色,周圍顏色設為藍色。
在套用旋轉轉換前,先將 畫 PathGradientBrush 到 螢幕上。
用它 RotateTransform 的方法把旋轉轉換套用到畫筆上。
將旋轉的畫筆(矩形)畫到螢幕上。
注意底部矩形相較於平移前繪製的矩形旋轉了45度。
public:
void RotateTransformExample( PaintEventArgs^ e )
{
// Create a graphics path and add an ellipse.
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 );
// Apply the rotate transform to the brush.
myPGBrush->RotateTransform( 45, MatrixOrder::Append );
// Draw the brush to the screen again after applying the
// transform.
e->Graphics->FillRectangle( myPGBrush, 10, 10, 200, 300 );
}
public void RotateTransformExample(PaintEventArgs e)
{
// Create a graphics path and add an ellipse.
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);
// Apply the rotate transform to the brush.
myPGBrush.RotateTransform(45, MatrixOrder.Append);
// Draw the brush to the screen again after applying the
// transform.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 300);
}
Public Sub RotateTransformExample(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)
' Apply the rotate transform to the brush.
myPGBrush.RotateTransform(45, MatrixOrder.Append)
' Draw the brush to the screen again after applying the
' transform.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 300)
End Sub