From 9e86a08405db8a88fec2066975843b13ae831eed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= <dach.bartlomiej@gmail.com>
Date: Thu, 23 May 2024 14:07:43 +0200
Subject: [PATCH] Simplify scale origin computation

---
 .../Components/SelectionBoxScaleHandle.cs      | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionBoxScaleHandle.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionBoxScaleHandle.cs
index 12787a1c55..352a4985d6 100644
--- a/osu.Game/Screens/Edit/Compose/Components/SelectionBoxScaleHandle.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/SelectionBoxScaleHandle.cs
@@ -2,6 +2,7 @@
 // See the LICENCE file in the repository root for full licence text.
 
 using osu.Framework.Allocation;
+using osu.Framework.Extensions;
 using osu.Framework.Graphics;
 using osu.Framework.Input.Events;
 using osu.Framework.Utils;
@@ -102,21 +103,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
                 ? new Vector2((rawScale.X + rawScale.Y) * 0.5f)
                 : rawScale;
 
-            scaleHandler!.Update(newScale, getOriginPosition(), getAdjustAxis());
-        }
-
-        private Vector2 getOriginPosition()
-        {
-            var quad = scaleHandler!.OriginalSurroundingQuad!.Value;
-            Vector2 origin = quad.TopLeft;
-
-            if ((originalAnchor & Anchor.x0) > 0)
-                origin.X += quad.Width;
-
-            if ((originalAnchor & Anchor.y0) > 0)
-                origin.Y += quad.Height;
-
-            return origin;
+            var scaleOrigin = originalAnchor.Opposite().PositionOnQuad(scaleHandler!.OriginalSurroundingQuad!.Value);
+            scaleHandler!.Update(newScale, scaleOrigin, getAdjustAxis());
         }
 
         private Axes getAdjustAxis()