1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 01:27:29 +08:00

Refactor getTieredComponent

This commit is contained in:
Robin Avery 2021-06-06 09:40:58 -04:00
parent 11b1b8c633
commit 63346f6b75
No known key found for this signature in database
GPG Key ID: 0496DF10CEF7E226

View File

@ -69,19 +69,23 @@ namespace osu.Game.Skinning.Editor
var result = default(Anchor);
static Anchor getTieredComponent(float component, Anchor tier0, Anchor tier1, Anchor tier2) =>
component >= 2 / 3f
? tier2
: component >= 1 / 3f
? tier1
: tier0;
result |= getTieredComponent(absolutePosition.X / factor.X, Anchor.x0, Anchor.x1, Anchor.x2);
result |= getTieredComponent(absolutePosition.Y / factor.Y, Anchor.y0, Anchor.y1, Anchor.y2);
return result;
}
private static Anchor getTieredComponent(float component, Anchor tier0, Anchor tier1, Anchor tier2)
{
if (component >= 2 / 3f)
return tier2;
if (component >= 1 / 3f)
return tier1;
return tier0;
}
private Vector2 getOriginPositionFromQuad(in Quad quad, Anchor origin)
{
var result = quad.TopLeft;