Struct Transform
Represents a 2D transformation matrix applied to graphical elements.
Implements
Inherited Members
Namespace: OpenSvg
Assembly: OpenSvg.dll
Syntax
public readonly struct Transform : IEquatable<Transform>
Fields
| Edit this page View SourceMatrix
Declaration
public readonly Matrix3x2 Matrix
Field Value
Type | Description |
---|---|
Matrix3x2 |
Properties
| Edit this page View SourceIdentity
Represents the identity transformation matrix that, when applied, does not change the element.
Declaration
public static Transform Identity { get; }
Property Value
Type | Description |
---|---|
Transform |
Scale
Gets the scale components of the transform.
Declaration
public (float scaleX, float scaleY) Scale { get; }
Property Value
Type | Description |
---|---|
(float dx, float dy) |
Skew
Gets the skew components of the transform in degrees.
Declaration
public (float skewXDegrees, float skewYDegrees) Skew { get; }
Property Value
Type | Description |
---|---|
(float dx, float dy) |
Translation
Gets the translation components of the transform.
Declaration
public (float dx, float dy) Translation { get; }
Property Value
Type | Description |
---|---|
(float dx, float dy) |
Methods
| Edit this page View SourceComposeWith(Transform)
Composes this transform with another, resulting in a transform that is the equivalent of applying each in sequence.
Declaration
public Transform ComposeWith(Transform other)
Parameters
Type | Name | Description |
---|---|---|
Transform | other | The other transform to compose with. |
Returns
Type | Description |
---|---|
Transform | A new transform that applies both transforms in sequence. |
CreateMatrix(float, float, float, float, float, float)
Creates a general 2D transformation matrix.
Declaration
public static Transform CreateMatrix(float m11 = 1, float m12 = 0, float m21 = 0, float m22 = 1, float dx = 0, float dy = 0)
Parameters
Type | Name | Description |
---|---|---|
float | m11 | Value at row 1, column 1 in the matrix. |
float | m12 | Value at row 1, column 2 in the matrix. |
float | m21 | Value at row 2, column 1 in the matrix. |
float | m22 | Value at row 2, column 2 in the matrix. |
float | dx | The distance to translate along the x-axis. |
float | dy | The distance to translate along the y-axis. |
Returns
Type | Description |
---|---|
Transform | A general 2D transformation matrix. |
CreateRotation(float, float, float)
Creates a rotation transform that rotates an element around a given point.
Declaration
public static Transform CreateRotation(float angleDegrees = 0, float pivotX = 0, float pivotY = 0)
Parameters
Type | Name | Description |
---|---|---|
float | angleDegrees | The angle of rotation in degrees. |
float | pivotX | The x-coordinate of the pivot point. |
float | pivotY | The y-coordinate of the pivot point. |
Returns
Type | Description |
---|---|
Transform | A rotation transform. |
CreateScale(float, float)
Creates a scale transform that resizes an element.
Declaration
public static Transform CreateScale(float scaleX = 1, float scaleY = 1)
Parameters
Type | Name | Description |
---|---|---|
float | scaleX | The scaling factor along the x-axis. |
float | scaleY | The scaling factor along the y-axis. |
Returns
Type | Description |
---|---|
Transform | A scaling transform. |
CreateSkew(float, float)
Creates a skew transform that slants the x and y coordinates of an element.
Declaration
public static Transform CreateSkew(float skewXDegrees = 0, float skewYDegrees = 0)
Parameters
Type | Name | Description |
---|---|---|
float | skewXDegrees | The skew angle for the x-axis in degrees. |
float | skewYDegrees | The skew angle for the y-axis in degrees. |
Returns
Type | Description |
---|---|
Transform | A skew transform. |
CreateTranslation(float, float)
Creates a translation transform that moves an element along the x and y-axis.
Declaration
public static Transform CreateTranslation(float dx = 0, float dy = 0)
Parameters
Type | Name | Description |
---|---|---|
float | dx | The distance to move along the x-axis. |
float | dy | The distance to move along the y-axis. |
Returns
Type | Description |
---|---|
Transform | A translation transform. |
Equals(Transform)
Declaration
public bool Equals(Transform other)
Parameters
Type | Name | Description |
---|---|---|
Transform | other |
Returns
Type | Description |
---|---|
bool | true if the specified Transform is equal to the current Transform; otherwise, false. |
Equals(object?)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false. |
Overrides
| Edit this page View SourceGetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for the current object. |
Overrides
| Edit this page View SourceToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that represents the current object. |
Overrides
| Edit this page View SourceToXmlString()
Gets the XML string representation of this Transform.
Declaration
public string ToXmlString()
Returns
Type | Description |
---|---|
string | The XML string representation of this Transform. |
Operators
| Edit this page View Sourceoperator ==(Transform, Transform)
Determines whether two specified instances of Transform are equal.
Declaration
public static bool operator ==(Transform left, Transform right)
Parameters
Type | Name | Description |
---|---|---|
Transform | left | The first Transform to compare. |
Transform | right | The second Transform to compare. |
Returns
Type | Description |
---|---|
bool | true if |
operator !=(Transform, Transform)
Determines whether two specified instances of Transform are not equal.
Declaration
public static bool operator !=(Transform left, Transform right)
Parameters
Type | Name | Description |
---|---|---|
Transform | left | The first Transform to compare. |
Transform | right | The second Transform to compare. |
Returns
Type | Description |
---|---|
bool | true if |