Strokes.Transform Method (Matrix, Boolean)
Applies a linear transformation to a Strokes collection, with the option of applying the transformation to the pen width.
Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in microsoft.ink.dll)
Syntax
'Declaration
Public Sub Transform ( _
inkTransform As Matrix, _
applyOnPenWidth As Boolean _
)
'Usage
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
)
Not applicable.
Parameters
- inkTransform
The System.Drawing.Drawing2D.Matrix transform to use on the Strokes collection.
applyOnPenWidth
The Boolean value that indicates whether to apply the transform to the width of the ink in the DrawingAttributes of the Stroke objects in the Strokes collection.Value
Meaning
true
The transformation applies to both the points and pen width.
false
The transformation applies only to the points.
Remarks
The linear transform can represent scaling, rotation, translation, and combinations of transformations.
If the pen width is scaled appropriately for the transform, the drawn pen width is calculated by multiplying the specified pen width (or default of 53, if unspecified) by the square root of the determinant of the transform.
Example
This C# example scales the Strokes collection attached to an InkOverlay object, theInkOverlay
, by a factor of two around the center of the Strokes collection's bounding box. The width of the ink is also scaled by a factor of two.
using System.Drawing.Drawing2D;
//...
Matrix inkTransform = new Matrix();
Rectangle inkBounds = theInkOverlay.Ink.Strokes.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 strokes
theInkOverlay.Ink.Strokes.Transform(inkTransform, true);
This Microsoft Visual Basic.NET example scales the Strokes collection attached to an InkOverlay object, theInkOverlay
, by a factor of two around the center of the Strokes collection's bounding box. The width of the ink is also scaled by a factor of two.
Imports System.Drawing.Drawing2D
'...
Dim inkTransform As New Matrix()
Dim inkBounds As Rectangle = theInkOverlay.Ink.Strokes.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 strokes
theInkOverlay.Ink.Strokes.Transform(inkTransform, True)
Platforms
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
Version Information
.NET Framework
Supported in: 3.0
See Also
Reference
Strokes Class
Strokes Members
Microsoft.Ink Namespace
Strokes.Scale
Strokes.Move
Strokes.Rotate
Microsoft.Ink.Stroke.Transform