Class GlobalTransform
Definition
Namespace: StardewUI.Graphics
Assembly: StardewUI.dll
Global transform applied to an ISpriteBatch.
Inheritance
Object ⇦ GlobalTransform
Implements
IEquatable<GlobalTransform>
Remarks
Because the SpriteBatch in MonoGame/XNA has scale and rotation parameters for individual draw methods (whether texture or text), which are presumably more optimized than computing a new global transform matrix and restarting the sprite batch, the global transform maintains a current local transform and only "merges" it into the transform matrix once the accumulated local transform can no longer be represented in one Transform.
These "local" transforms actually represent the model matrix, while the accumulated global transform is the view matrix, so the relationship between them is quirky; see CanMergeLocally(Transform) for more details on the process.
Global transforms are always "around" the viewport origin (0, 0). To use a different origin relative to the current view, first translated by the negated origin position, then apply regular transforms, then translate by the (positive) origin position again.
Members
Constructors
Name | Description |
---|---|
GlobalTransform(Matrix, Transform, TransformOrigin) | Global transform applied to an ISpriteBatch. |
Fields
Name | Description |
---|---|
Default | The default instance, which applies no transformation. |
Properties
Name | Description |
---|---|
EqualityContract | |
Local | Local transform to apply after the Matrix takes effect. |
LocalOrigin | Origin for the Local transform. |
Matrix | The cumulative transformation matrix. |
Methods
Name | Description |
---|---|
Apply(Transform, TransformOrigin, Boolean) | Applies a local transformation and returns the new, accumulated global transform. |
Collapse() | Merges the Local component into the global Matrix. |
Details
Constructors
GlobalTransform(Matrix, Transform, TransformOrigin)
Global transform applied to an ISpriteBatch.
public GlobalTransform(Microsoft.Xna.Framework.Matrix Matrix, StardewUI.Graphics.Transform Local, StardewUI.Graphics.TransformOrigin LocalOrigin);
Parameters
Matrix
Matrix
The cumulative transformation matrix.
Local
Transform
Local transform to apply after the Matrix
takes effect.
LocalOrigin
TransformOrigin
Origin for the Local transform.
Remarks
Because the SpriteBatch in MonoGame/XNA has scale and rotation parameters for individual draw methods (whether texture or text), which are presumably more optimized than computing a new global transform matrix and restarting the sprite batch, the global transform maintains a current local transform and only "merges" it into the transform matrix once the accumulated local transform can no longer be represented in one Transform.
These "local" transforms actually represent the model matrix, while the accumulated global transform is the view matrix, so the relationship between them is quirky; see CanMergeLocally(Transform) for more details on the process.
Global transforms are always "around" the viewport origin (0, 0). To use a different origin relative to the current view, first translated by the negated origin position, then apply regular transforms, then translate by the (positive) origin position again.
Fields
Default
The default instance, which applies no transformation.
Field Value
Properties
EqualityContract
Property Value
Local
Local transform to apply after the Matrix
takes effect.
Property Value
LocalOrigin
Origin for the Local transform.
Property Value
Matrix
The cumulative transformation matrix.
Property Value
Methods
Apply(Transform, TransformOrigin, Boolean)
Applies a local transformation and returns the new, accumulated global transform.
public StardewUI.Graphics.GlobalTransform Apply(StardewUI.Graphics.Transform transform, StardewUI.Graphics.TransformOrigin origin, out System.Boolean isNewMatrix);
Parameters
transform
Transform
The local transform to apply.
origin
TransformOrigin
Origin position for the transform
.
isNewMatrix
Boolean
Whether the newly-created GlobalTransform has a different Matrix from the current instance.
Returns
A new GlobalTransform that combines the accumulated transformation of this instance with the specified transform
.
Collapse()
Merges the Local component into the global Matrix.
Returns
A new GlobalTransform whose Matrix is the combined Matrix and Local components of this instance, and whose Local transform is reset to the Default.
Remarks
For use when the Local transform cannot be combined with the model transform of a specific drawing operation.