2019-12-17 17:16:25 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2019-12-18 14:39:36 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2020-12-04 19:21:53 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Skinning.Default;
|
2021-09-01 14:10:56 +08:00
|
|
|
using osu.Game.Skinning;
|
2021-08-09 16:56:47 +08:00
|
|
|
using osu.Game.Utils;
|
2019-12-17 17:16:25 +08:00
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2020-12-04 19:21:53 +08:00
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
2019-12-17 17:16:25 +08:00
|
|
|
{
|
2019-12-17 18:29:27 +08:00
|
|
|
public partial class LegacySliderBody : PlaySliderBody
|
2019-12-17 17:16:25 +08:00
|
|
|
{
|
|
|
|
protected override DrawableSliderPath CreateSliderPath() => new LegacyDrawableSliderPath();
|
|
|
|
|
2021-09-01 14:10:56 +08:00
|
|
|
protected override Color4 GetBodyAccentColour(ISkinSource skin, Color4 hitObjectAccentColour)
|
|
|
|
{
|
|
|
|
// legacy skins use a constant value for slider track alpha, regardless of the source colour.
|
|
|
|
return base.GetBodyAccentColour(skin, hitObjectAccentColour).Opacity(0.7f);
|
|
|
|
}
|
|
|
|
|
2019-12-17 17:16:25 +08:00
|
|
|
private partial class LegacyDrawableSliderPath : DrawableSliderPath
|
|
|
|
{
|
|
|
|
protected override Color4 ColourAt(float position)
|
|
|
|
{
|
2024-02-27 07:11:32 +08:00
|
|
|
const float aa_width = 0.5f / 64f;
|
|
|
|
const float shadow_portion = 1 - (OsuLegacySkinTransformer.LEGACY_CIRCLE_RADIUS / OsuHitObject.OBJECT_RADIUS);
|
|
|
|
const float border_portion = 0.1875f;
|
2019-12-18 12:37:37 +08:00
|
|
|
|
2024-02-27 07:11:32 +08:00
|
|
|
Color4 shadow = new Color4(0, 0, 0, 0.25f);
|
|
|
|
Color4 outerColour = AccentColour.Darken(0.1f);
|
|
|
|
Color4 innerColour = lighten(AccentColour, 0.5f);
|
2019-12-18 12:37:37 +08:00
|
|
|
|
2024-02-27 07:11:32 +08:00
|
|
|
if (position <= shadow_portion - aa_width)
|
|
|
|
return LegacyUtils.InterpolateNonLinear(position, Color4.Black.Opacity(0f), shadow, 0, shadow_portion - aa_width);
|
2019-12-17 17:16:25 +08:00
|
|
|
|
2024-02-27 07:11:32 +08:00
|
|
|
if (position <= shadow_portion + aa_width)
|
|
|
|
return LegacyUtils.InterpolateNonLinear(position, shadow, BorderColour, shadow_portion - aa_width, shadow_portion + aa_width);
|
2019-12-17 17:16:25 +08:00
|
|
|
|
2024-02-27 07:11:32 +08:00
|
|
|
if (position <= border_portion - aa_width)
|
|
|
|
return BorderColour;
|
|
|
|
|
|
|
|
if (position <= border_portion + aa_width)
|
|
|
|
return LegacyUtils.InterpolateNonLinear(position, BorderColour, outerColour, border_portion - aa_width, border_portion + aa_width);
|
2019-12-17 17:16:25 +08:00
|
|
|
|
2024-02-27 07:11:32 +08:00
|
|
|
return LegacyUtils.InterpolateNonLinear(position, outerColour, innerColour, border_portion + aa_width, 1);
|
2019-12-17 17:16:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Lightens a colour in a way more friendly to dark or strong colours.
|
|
|
|
/// </summary>
|
|
|
|
private static Color4 lighten(Color4 color, float amount)
|
|
|
|
{
|
|
|
|
amount *= 0.5f;
|
|
|
|
return new Color4(
|
|
|
|
Math.Min(1, color.R * (1 + 0.5f * amount) + 1 * amount),
|
|
|
|
Math.Min(1, color.G * (1 + 0.5f * amount) + 1 * amount),
|
|
|
|
Math.Min(1, color.B * (1 + 0.5f * amount) + 1 * amount),
|
|
|
|
color.A);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|