Compartir a través de


Stroke.Transform Method

Stroke.Transform Method

Applies a linear transformation to a Stroke object.

Definition

Visual Basic .NET Public Sub Transform( _
ByVal inkTransform As Matrix, _
ByVal applyOnPenWidth As Boolean _
)
C# public void Transform(
Matrix inkTransform,
bool applyOnPenWidth
);
Managed C++ public: void Transform(
Matrix *inkTransform,
bool *applyOnPenWidth
);

Parameters

> > >
inkTransform System.Drawing.Drawing2D.Matrix. The System.Drawing.Drawing2D.Matrix Leave Site transform to use on the Stroke object.
applyOnPenWidth System.Boolean. The Boolean value that indicates whether to apply the transform to the width of the ink in the DrawingAttributes of the Stroke object.

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.

Examples

[C#]

This C# example scales a Stroke object, theStroke, by a factor of two around the center of the stroke's bounding box. The width of the ink ia also scaled by a factor of two.

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);
                

[VB.NET]

This Microsoft® Visual Basic® .NET example scales a Stroke object, theStroke, by a factor of two around the center of the stroke's bounding box. The width of the ink ia also scaled by a factor of two.

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)
                

See Also