1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 20:58:34 +01:00

added ScaleOrigin to RootElement

This commit is contained in:
Ellpeck 2020-06-02 16:15:41 +02:00
parent 95917e08d6
commit b0309c9707
2 changed files with 10 additions and 1 deletions

View file

@ -71,7 +71,7 @@ namespace MLEM.Ui.Elements {
/// <param name="scale">The scale to use</param> /// <param name="scale">The scale to use</param>
/// <param name="origin">The origin to use for scaling, or null to use this element's center point</param> /// <param name="origin">The origin to use for scaling, or null to use this element's center point</param>
public void ScaleOrigin(float scale, Vector2? origin = null) { public void ScaleOrigin(float scale, Vector2? origin = null) {
this.Transform = Matrix.CreateScale(scale, scale, 0) * Matrix.CreateTranslation(new Vector3((1 - scale) * (origin ?? this.DisplayArea.Center), 0)); this.Transform = Matrix.CreateScale(scale, scale, 1) * Matrix.CreateTranslation(new Vector3((1 - scale) * (origin ?? this.DisplayArea.Center), 0));
} }
/// <summary> /// <summary>

View file

@ -442,5 +442,14 @@ namespace MLEM.Ui {
this.System.Controls.SelectElement(this, element, autoNav); this.System.Controls.SelectElement(this, element, autoNav);
} }
/// <summary>
/// Scales this root element's <see cref="Transform"/> matrix based on the given scale and origin.
/// </summary>
/// <param name="scale">The scale to use</param>
/// <param name="origin">The origin to use for scaling, or null to use this root's element's center point</param>
public void ScaleOrigin(float scale, Vector2? origin = null) {
this.Transform = Matrix.CreateScale(scale, scale, 1) * Matrix.CreateTranslation(new Vector3((1 - scale) * (origin ?? this.Element.DisplayArea.Center), 0));
}
} }
} }