Stroke.Transform(Matrix, Boolean) 方法

定義

根據指定的 Matrix 物件執行轉換。

public:
 virtual void Transform(System::Windows::Media::Matrix transformMatrix, bool applyToStylusTip);
public virtual void Transform (System.Windows.Media.Matrix transformMatrix, bool applyToStylusTip);
abstract member Transform : System.Windows.Media.Matrix * bool -> unit
override this.Transform : System.Windows.Media.Matrix * bool -> unit
Public Overridable Sub Transform (transformMatrix As Matrix, applyToStylusTip As Boolean)

參數

transformMatrix
Matrix

定義轉換的 Matrix 物件。

applyToStylusTip
Boolean

如果要套用轉換至手寫筆筆尖,則為 true,否則為 false

範例

下列範例示範如何轉換 Stroke 物件。

protected DrawingVisual DrawDCOnly(Stroke myStroke)
{
    // Create new Visual context to draw on
    DrawingVisual myVisual = new DrawingVisual();
    DrawingContext myContext = myVisual.RenderOpen();

    // myMatrix is scaled by:
    // myMatrix.Scale(0.5, 0.5)
    myStroke.Transform(myMatrix, false);

    // Draw the stroke on the Visual context using DrawingContext
    myStroke.Draw(myContext);

    // Close the context
    myContext.Close();

    return myVisual;
}
Function DrawDCOnly(ByVal myStroke As Stroke) As DrawingVisual

    ' Create new Visual context to draw on
    Dim myVisual As DrawingVisual = New DrawingVisual()
    Dim myContext As DrawingContext = myVisual.RenderOpen()

    ' myMatrix is scaled by:
    ' myMatrix.Scale(0.5, 0.5)
    myStroke.Transform(myMatrix, False)

    ' Draw the stroke on the Visual context using DrawingContext
    myStroke.Draw(myContext)

    ' Close the context
    myContext.Close()

    Return myVisual

End Function

備註

Matrix物件代表 3x3 矩陣,用於二維空間中的轉換。 Stroke 物件的每個點都會由提供的矩陣轉換。 例如,如果原始 Point.X 值為 100,則原始 Point.Y 值為 55,而轉換 Matrix.Scale (0.5, 0.5) ,則新的 Point.X 值為 50,而新的 Point.Y 值為 27.5。

適用於