Skip to content

Class TransformOrigin

Definition

Namespace: StardewUI.Graphics
Assembly: StardewUI.dll

Describes the origin point to use for a local Transform.

public record TransformOrigin : IEquatable<StardewUI.Graphics.TransformOrigin>

Inheritance
Object ⇦ TransformOrigin

Implements
IEquatable<TransformOrigin>

Remarks

Origin data needs to track two vectors; the relative or percentage position with X and Y between 0 and 1 (e.g. the center of the layout would be (0.5, 0.5)) as well as the absolute or pixel position.

The relative position is used for individual drawing operations; when drawing a single sprite or text string, the XNA drawing APIs use this exact origin vector. The absolute position, on the other hand, is required for transform propagation in the GlobalTransform, i.e. if the custom-origin transform is applied to a layout view, because it must be converted into a translation matrix.

Members

Constructors

Name Description
TransformOrigin(Vector2, Vector2) Describes the origin point to use for a local Transform.

Fields

Name Description
Default Default origin, with both Relative and Absolute set to Zero.

Properties

Name Description
Absolute The pixel position of the exact origin point, relative to the transformed view's top-left corner.
EqualityContract
Relative The relative position with X and Y values between 0 and 1, where (0, 0) is the top-left, (0.5, 0.5) is the middle, and (1, 1) is the bottom right.

Details

Constructors

TransformOrigin(Vector2, Vector2)

Describes the origin point to use for a local Transform.

public TransformOrigin(Microsoft.Xna.Framework.Vector2 Relative, Microsoft.Xna.Framework.Vector2 Absolute);
Parameters

Relative   Vector2
The relative position with X and Y values between 0 and 1, where (0, 0) is the top-left, (0.5, 0.5) is the middle, and (1, 1) is the bottom right.

Absolute   Vector2
The pixel position of the exact origin point, relative to the transformed view's top-left corner.

Remarks

Origin data needs to track two vectors; the relative or percentage position with X and Y between 0 and 1 (e.g. the center of the layout would be (0.5, 0.5)) as well as the absolute or pixel position.

The relative position is used for individual drawing operations; when drawing a single sprite or text string, the XNA drawing APIs use this exact origin vector. The absolute position, on the other hand, is required for transform propagation in the GlobalTransform, i.e. if the custom-origin transform is applied to a layout view, because it must be converted into a translation matrix.


Fields

Default

Default origin, with both Relative and Absolute set to Zero.

public static readonly StardewUI.Graphics.TransformOrigin Default;
Field Value

TransformOrigin


Properties

Absolute

The pixel position of the exact origin point, relative to the transformed view's top-left corner.

public Microsoft.Xna.Framework.Vector2 Absolute { get; set; }
Property Value

Vector2


EqualityContract

protected System.Type EqualityContract { get; }
Property Value

Type


Relative

The relative position with X and Y values between 0 and 1, where (0, 0) is the top-left, (0.5, 0.5) is the middle, and (1, 1) is the bottom right.

public Microsoft.Xna.Framework.Vector2 Relative { get; set; }
Property Value

Vector2