mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 07:43:00 +08:00
Simplify scale origin computation
This commit is contained in:
parent
070668c96f
commit
9e86a08405
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
@ -102,21 +103,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
? new Vector2((rawScale.X + rawScale.Y) * 0.5f)
|
? new Vector2((rawScale.X + rawScale.Y) * 0.5f)
|
||||||
: rawScale;
|
: rawScale;
|
||||||
|
|
||||||
scaleHandler!.Update(newScale, getOriginPosition(), getAdjustAxis());
|
var scaleOrigin = originalAnchor.Opposite().PositionOnQuad(scaleHandler!.OriginalSurroundingQuad!.Value);
|
||||||
}
|
scaleHandler!.Update(newScale, scaleOrigin, 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Axes getAdjustAxis()
|
private Axes getAdjustAxis()
|
||||||
|
Loading…
Reference in New Issue
Block a user