1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-26 17:52:54 +08:00
osu-lazer/osu.Game/Graphics/IHasAccentColour.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.7 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
2022-06-17 15:37:17 +08:00
#nullable disable
2018-11-20 15:51:59 +08:00
using osuTK.Graphics;
using osu.Framework.Graphics;
2017-06-21 10:18:52 +08:00
using osu.Framework.Graphics.Transforms;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Graphics
{
/// <summary>
/// A type of drawable that has an accent colour.
/// The accent colour is used to colorize various objects inside a drawable
/// without colorizing the drawable itself.
/// </summary>
2017-03-31 13:47:59 +08:00
public interface IHasAccentColour : IDrawable
{
Color4 AccentColour { get; set; }
}
2018-04-13 17:19:50 +08:00
2017-03-31 13:47:59 +08:00
public static class AccentedColourExtensions
{
/// <summary>
/// Smoothly adjusts <see cref="IHasAccentColour.AccentColour"/> over time.
/// </summary>
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
2017-07-23 02:50:25 +08:00
public static TransformSequence<T> FadeAccent<T>(this T accentedDrawable, Color4 newColour, double duration = 0, Easing easing = Easing.None)
2019-12-07 19:49:52 +08:00
where T : class, IHasAccentColour
2017-07-16 18:59:26 +08:00
=> accentedDrawable.TransformTo(nameof(accentedDrawable.AccentColour), newColour, duration, easing);
2018-04-13 17:19:50 +08:00
/// <summary>
/// Smoothly adjusts <see cref="IHasAccentColour.AccentColour"/> over time.
/// </summary>
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
public static TransformSequence<T> FadeAccent<T>(this TransformSequence<T> t, Color4 newColour, double duration = 0, Easing easing = Easing.None)
where T : Drawable, IHasAccentColour
=> t.Append(o => o.FadeAccent(newColour, duration, easing));
}
}