语言

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。

适用于