Graphics.RotateTransform 方法

定義

將指定的旋轉套用至這個 Graphics的轉換矩陣。

多載

RotateTransform(Single, MatrixOrder)

以指定的順序,將指定的旋轉套用至這個 Graphics 的轉換矩陣。

RotateTransform(Single)

將指定的旋轉套用至這個 Graphics的轉換矩陣。

RotateTransform(Single, MatrixOrder)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

以指定的順序,將指定的旋轉套用至這個 Graphics 的轉換矩陣。

C#
public void RotateTransform (float angle, System.Drawing.Drawing2D.MatrixOrder order);

參數

angle
Single

以度為單位的旋轉角度。

order
MatrixOrder

MatrixOrder 列舉的成員,指定旋轉是附加或前面附加至矩陣轉換。

範例

下列程式代碼範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgse,這是 Paint 事件處理程式的參數。 程式代碼會執行下列動作:

  • 依向量轉譯 Windows Form 的世界轉換矩陣 (100, 0)。

  • 以 30 度的角度旋轉世界轉換,將旋轉矩陣附加至具有 Append的世界轉換矩陣。

  • 使用藍色畫筆繪製翻譯的旋轉橢圓形。

C#
private void RotateTransformAngleMatrixOrder(PaintEventArgs e)
{

    // Set world transform of graphics object to translate.
    e.Graphics.TranslateTransform(100.0F, 0.0F);

    // Then to rotate, appending rotation matrix.
    e.Graphics.RotateTransform(30.0F, MatrixOrder.Append);

    // Draw translated, rotated ellipse to screen.
    e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), 0, 0, 200, 80);
}

備註

旋轉作業包含將轉換矩陣乘以矩陣,其元素衍生自 angle 參數。 這個方法會根據 order 參數,在旋轉矩陣前面加上或附加 Graphics 的轉換矩陣。

適用於

.NET 9 及其他版本
產品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

RotateTransform(Single)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

將指定的旋轉套用至這個 Graphics的轉換矩陣。

C#
public void RotateTransform (float angle);

參數

angle
Single

以度為單位的旋轉角度。

範例

下列程式代碼範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgse,這是 Paint 事件處理程式的參數。 程式代碼會執行下列動作:

  • 依向量轉譯 Windows Form 的世界轉換矩陣 (100, 0)。

  • 以 30 度的角度旋轉世界轉換,將旋轉矩陣前面加上世界轉換矩陣。

  • 使用藍色畫筆繪製旋轉的翻譯橢圓形。

C#
private void RotateTransformAngle(PaintEventArgs e)
{

    // Set world transform of graphics object to translate.
    e.Graphics.TranslateTransform(100.0F, 0.0F);

    // Then to rotate, prepending rotation matrix.
    e.Graphics.RotateTransform(30.0F);

    // Draw rotated, translated ellipse to screen.
    e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), 0, 0, 200, 80);
}

備註

旋轉作業包含將轉換矩陣乘以矩陣,其元素衍生自 angle 參數。 這個方法會將旋轉套用至轉換矩陣前面。

適用於

.NET 9 及其他版本
產品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9