mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:07:52 +08:00
Use helper methods instead of local valueAt() method
This commit is contained in:
parent
9e805dcd44
commit
140d29d537
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Skinning.Default;
|
||||
using osuTK.Graphics;
|
||||
@ -36,13 +37,14 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
|
||||
position -= realBorderPortion;
|
||||
|
||||
Color4 outerColour = AccentColour.Darken(0.1f);
|
||||
Color4 innerColour = lighten(AccentColour, 0.5f);
|
||||
// Stable interpolates slider body colour directly in sRGB space, and because
|
||||
// Interpolation.ValueAt() uses linear space, we have to counteract applying it
|
||||
// by calling ToSRGB() on the input colours, and ToLinear() on the resulting colour.
|
||||
|
||||
// Stable doesn't use linear space / gamma-correct colour interpolation
|
||||
// for slider bodies, so we can't use Interpolation.ValueAt().
|
||||
// Instead, we use a local method that interpolates between the colours directly in sRGB space.
|
||||
return valueAt(position / realGradientPortion, outerColour, innerColour, 0, 1);
|
||||
Color4 outerColour = AccentColour.Darken(0.1f).ToSRGB();
|
||||
Color4 innerColour = lighten(AccentColour, 0.5f).ToSRGB();
|
||||
|
||||
return Interpolation.ValueAt(position / realGradientPortion, outerColour, innerColour, 0, 1).ToLinear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -57,26 +59,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
Math.Min(1, color.B * (1 + 0.5f * amount) + 1 * amount),
|
||||
color.A);
|
||||
}
|
||||
|
||||
private static Color4 valueAt(double time, Color4 startColour, Color4 endColour, double startTime, double endTime)
|
||||
{
|
||||
if (startColour == endColour)
|
||||
return startColour;
|
||||
|
||||
double current = time - startTime;
|
||||
double duration = endTime - startTime;
|
||||
|
||||
if (duration == 0 || current == 0)
|
||||
return startColour;
|
||||
|
||||
float t = (float)Math.Max(0, Math.Min(1, current / duration));
|
||||
|
||||
return new Color4(
|
||||
startColour.R + t * (endColour.R - startColour.R),
|
||||
startColour.G + t * (endColour.G - startColour.G),
|
||||
startColour.B + t * (endColour.B - startColour.B),
|
||||
startColour.A + t * (endColour.A - startColour.A));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user