ITransformable interface
ITransformable is the set of members that classes with a changeable transformation matrix share.
It is implemented by Matrix, Graphics (its world transformation), LinearGradientBrush, PathGradientBrush and TextureBrush. Code that only needs to move, scale, rotate or shear such an object can take an ITransformable and work with any of them. The classes also have these members under their own names; on Matrix they are shorter (Translate for TranslateTransform, and so on).
Every method combines a new transformation with the one the object already has. The order argument is a GpMatrixOrder: with MatrixOrderPrepend, the default, the new transformation is applied to a point before the existing ones, and with MatrixOrderAppend after them. See Matrix for the arithmetic.
Every method returns a GpStatus, which is Ok when the call worked.
An object is used through the interface by assigning it to a variable of the interface type:
Dim user As GdiPlusUser = GdiPlusUser()
Dim bmp As Bitmap = Bitmap(10!, 10!)
Dim g As Graphics = Graphics(bmp)
Dim m As Matrix = Matrix()
Dim t As ITransformable = m
t.TranslateTransform 5, 6
t.ScaleTransform 2, 2
Debug.Print m.OffsetX & " " & m.OffsetY ' 5 6
Set t = g
t.TranslateTransform 7, 8
Dim w As Matrix = Matrix()
t.GetTransform w
Debug.Print w.OffsetX & " " & w.OffsetY ' 7 8
Transform
Syntax: object.Transform = matrix
Replaces the whole transformation. Assigning copies the elements of matrix into the object, so a later change of matrix does not change the object.
Dim user As GdiPlusUser = GdiPlusUser()
Dim m As Matrix = Matrix()
Dim t As ITransformable = m
t.Transform = Matrix(3, 0, 0, 3, 0, 0)
Dim e() As Single = m.Elements
Debug.Print e(1) & " " & e(4) ' 3 3
Note 0.9.45.0
Reading Transform does not work on any of the classes that implement the interface. The getter returns Nothing and records InvalidParameter in LastResult. Read the transformation with GetTransform.
GetTransform
Syntax: object.GetTransform( outMatrix ) As GpStatus
- outMatrix
- required An existing Matrix that receives a copy of the transformation.
ResetTransform
Syntax: object.ResetTransform As GpStatus
Sets the transformation to the identity: no change to any point.
MultiplyTransform
Syntax: object.MultiplyTransform( matrix, [ order ] ) As GpStatus
Combines matrix with the transformation of the object. On a Matrix this is Multiply.
TranslateTransform
Syntax: object.TranslateTransform( dx, dy, [ order ] ) As GpStatus
Syntax: object.TranslateTransform( delta, [ order ] ) As GpStatus
- dx, dy
- required Single distances to move by along each axis.
- delta
- required A GpPointF that holds the two distances.
On a Matrix this is Translate.
ScaleTransform
Syntax: object.ScaleTransform( sx, sy, [ order ] ) As GpStatus
Scales the horizontal axis by sx and the vertical axis by sy. On a Matrix this is Scale.
RotateTransform
Syntax: object.RotateTransform( angle, [ order ] ) As GpStatus
Rotates by angle degrees about the origin. A positive angle turns clockwise where the y axis points down. On a Matrix this is Rotate.
RotateTransformAt
Syntax: object.RotateTransformAt( angle, center, [ order ] ) As GpStatus
Rotates by angle degrees about center, a GpPointF that stays where it is. On a Matrix this is RotateAt.
ShearTransform
Syntax: object.ShearTransform( shearX, shearY, [ order ] ) As GpStatus
Shears the axes. On a Matrix this is Shear.
See Also
- Matrix class
- Graphics class
- GpMatrixOrder enumeration
- IDeviceContext interface – the other interface that Graphics implements