Stroke.Transform 方法 (Matrix, Boolean)

将线性变换应用于 Stroke 对象,还可以选择将该变换应用于笔宽度。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public Sub Transform ( _
    inkTransform As Matrix, _
    applyOnPenWidth As Boolean _
)
用法
Dim instance As Stroke
Dim inkTransform As Matrix
Dim applyOnPenWidth As Boolean

instance.Transform(inkTransform, applyOnPenWidth)
public void Transform(
    Matrix inkTransform,
    bool applyOnPenWidth
)
public:
void Transform(
    Matrix^ inkTransform, 
    bool applyOnPenWidth
)
public void Transform(
    Matrix inkTransform,
    boolean applyOnPenWidth
)
public function Transform(
    inkTransform : Matrix, 
    applyOnPenWidth : boolean
)

参数

  • applyOnPenWidth
    类型:System.Boolean
    布尔值,指示是否要将变换应用于 Stroke 对象的 DrawingAttributes 中的墨迹宽度。

    含义

    true

    变换同时应用于点和笔宽度。

    false

    变换仅应用于点。

备注

线性变换可表示缩放、旋转、转换以及变换组合。

如果在该变换中对笔宽度进行了适当的缩放,则通过将指定的笔宽度(如果未指定,则默认值为 53)乘以变换行列式的平方根来计算绘制的笔宽度。

示例

此 C# 示例以笔画的边界框为中心按因子 2 对 Stroke 对象 theStroke 进行缩放。墨迹的宽度也按因子 2 进行缩放。

using System.Drawing.Drawing2D;
//...
Matrix inkTransform = new Matrix();
Rectangle inkBounds = theStroke.GetBoundingBox();
PointF center = new PointF(0.5f * (inkBounds.Left + inkBounds.Right),
                           0.5f * (inkBounds.Top + inkBounds.Bottom));
// Translate to center of bounding box
inkTransform.Translate(center.X, center.Y);
// Scale by factor of 2
inkTransform.Scale(2.0F, 2.0F);
// Translate back
inkTransform.Translate(-center.X, -center.Y);
// Transform stroke
theStroke.Transform(inkTransform, true);

此 Microsoft Visual Basic .NET 示例以笔画的边界框为中心按因子 2 对 Stroke 对象 theStroke 进行缩放。墨迹的宽度也按因子 2 进行缩放。

Imports System.Drawing.Drawing2D
'...
Dim inkTransform As New Matrix()
Dim inkBounds As Rectangle = theStroke.GetBoundingBox()
Dim center As New PointF(0.5F * (inkBounds.Left + inkBounds.Right), _
                         0.5F * (inkBounds.Top + inkBounds.Bottom))
'Translate to center of bounding box
inkTransform.Translate(center.X, center.Y)
'Scale by a factor of 2
inkTransform.Scale(2.0F, 2.0F)
'Translate back
inkTransform.Translate(-center.X, -center.Y)
'Transform stroke
theStroke.Transform(inkTransform, True)

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

Stroke 类

Stroke 成员

Transform 重载

Microsoft.Ink 命名空间

Transform

Stroke.Move

Stroke.Rotate

Strokes.Transform