Strokes.Transform 方法 (Matrix, Boolean)
将线性变换应用于 Strokes 集合,还可以选择将该变换应用于笔宽度。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink(在 Microsoft.Ink.dll 中)
语法
声明
Public Sub Transform ( _
inkTransform As Matrix, _
applyOnPenWidth As Boolean _
)
用法
Dim instance As Strokes
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
)
参数
- inkTransform
类型:System.Drawing.Drawing2D.Matrix
要用于 Strokes 集合的 System.Drawing.Drawing2D.Matrix 变换。
- applyOnPenWidth
类型:System.Boolean
布尔值,指示是否要将变换应用于 Strokes 集合中 Stroke 对象的 DrawingAttributes 中的墨迹宽度。值
含义
true
变换同时应用于点和笔宽度。
false
变换仅应用于点。
备注
线性变换可表示缩放、旋转、转换以及变换组合。
如果在该变换中对笔宽度进行了适当的缩放,则通过将指定的笔宽度(如果未指定,则默认值为 53)乘以变换行列式的平方根来计算绘制的笔宽度。
示例
在此示例中,附加到 InkOverlay 对象的 Strokes 集合按因子 2 缩放。缩放围绕 Strokes 集合边界框的中心进行。墨迹的宽度也按因子 2 进行缩放。
' Access to the Strokes property returns a copy of the Strokes object.
' This copy must be implicitly (via using statement) or explicitly
' disposed of in order to avoid a memory leak.
Using allStrokes As Strokes = mInkOverlay.Ink.Strokes
Dim inkTransform As Matrix = New Matrix()
Dim bounds As Rectangle = allStrokes.GetBoundingBox()
Dim center As PointF = _
New PointF(0.5F * (bounds.Left + bounds.Right), _
0.5F * (bounds.Top + bounds.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 strokes
allStrokes.Transform(inkTransform, True)
End Using
// Access to the Strokes property returns a copy of the Strokes object.
// This copy must be implicitly (via using statement) or explicitly
// disposed of in order to avoid a memory leak.
using (Strokes allStrokes = mInkOverlay.Ink.Strokes)
{
Matrix inkTransform = new Matrix();
Rectangle bounds = allStrokes.GetBoundingBox();
PointF center = new PointF(0.5f * (bounds.Left + bounds.Right),
0.5f * (bounds.Top + bounds.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 strokes
allStrokes.Transform(inkTransform, true);
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0