Back to top OpenSVG (c) Veridict AB, www.veridict.com
Edit this page

Struct Transform

Represents a 2D transformation matrix applied to graphical elements.

Implements
IEquatable<Transform>
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: OpenSvg
Assembly: OpenSvg.dll
Syntax
public readonly struct Transform : IEquatable<Transform>

Fields

| Edit this page View Source

Matrix

Declaration
public readonly Matrix3x2 Matrix
Field Value
Type Description
Matrix3x2

Properties

| Edit this page View Source

Identity

Represents the identity transformation matrix that, when applied, does not change the element.

Declaration
public static Transform Identity { get; }
Property Value
Type Description
Transform
| Edit this page View Source

Scale

Gets the scale components of the transform.

Declaration
public (float scaleX, float scaleY) Scale { get; }
Property Value
Type Description
(float dx, float dy)
| Edit this page View Source

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)
| Edit this page View Source

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 Source

ComposeWith(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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

Equals(Transform)

Determines whether the specified Transform is equal to the current Transform.

Declaration
public bool Equals(Transform other)
Parameters
Type Name Description
Transform other

The Transform to compare with the current Transform.

Returns
Type Description
bool

true if the specified Transform is equal to the current Transform; otherwise, false.

| Edit this page View Source

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
ValueType.Equals(object)
| Edit this page View Source

GetHashCode()

Serves as the default hash function.

Declaration
public override int GetHashCode()
Returns
Type Description
int

A hash code for the current object.

Overrides
ValueType.GetHashCode()
| Edit this page View Source

ToString()

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
ValueType.ToString()
| Edit this page View Source

ToXmlString()

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 Source

operator ==(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 left and right represent the same Transform; otherwise, false.

| Edit this page View Source

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 left and right do not represent the same Transform; otherwise, false.

Implements

IEquatable<T>