From cb563199249a6e065927e7aed84cdc41ea9d826d Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 18 Mar 2020 16:47:14 +0100 Subject: [PATCH] added easy scale origin function to custom draw groups --- MLEM.Ui/Elements/CustomDrawGroup.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MLEM.Ui/Elements/CustomDrawGroup.cs b/MLEM.Ui/Elements/CustomDrawGroup.cs index 43651d5..8220975 100644 --- a/MLEM.Ui/Elements/CustomDrawGroup.cs +++ b/MLEM.Ui/Elements/CustomDrawGroup.cs @@ -42,6 +42,10 @@ namespace MLEM.Ui.Elements { } } + 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)); + } + public delegate void BeginDelegate(CustomDrawGroup element, GameTime time, SpriteBatch batch, float alpha, BlendState blendState, SamplerState samplerState, Matrix matrix); public delegate Matrix TransformCallback(CustomDrawGroup element, GameTime time, Matrix matrix);