2019-01-24 08:43:03 +00: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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK.Graphics;
|
2017-03-31 02:01:42 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-06-21 02:18:52 +00:00
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-03-31 02:01:42 +00: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 05:47:59 +00:00
|
|
|
|
public interface IHasAccentColour : IDrawable
|
2017-03-31 02:01:42 +00:00
|
|
|
|
{
|
|
|
|
|
Color4 AccentColour { get; set; }
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-03-31 05:47:59 +00:00
|
|
|
|
public static class AccentedColourExtensions
|
2017-03-31 02:01:42 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-08-07 05:20:18 +00:00
|
|
|
|
/// Smoothly adjusts <see cref="IHasAccentColour.AccentColour"/> over time.
|
2017-03-31 02:01:42 +00:00
|
|
|
|
/// </summary>
|
2017-08-07 05:20:18 +00:00
|
|
|
|
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
|
2017-07-22 18:50:25 +00:00
|
|
|
|
public static TransformSequence<T> FadeAccent<T>(this T accentedDrawable, Color4 newColour, double duration = 0, Easing easing = Easing.None)
|
2019-12-07 11:49:52 +00:00
|
|
|
|
where T : class, IHasAccentColour
|
2017-07-16 10:59:26 +00:00
|
|
|
|
=> accentedDrawable.TransformTo(nameof(accentedDrawable.AccentColour), newColour, duration, easing);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-08-07 05:09:49 +00:00
|
|
|
|
/// <summary>
|
2017-08-07 05:20:18 +00:00
|
|
|
|
/// Smoothly adjusts <see cref="IHasAccentColour.AccentColour"/> over time.
|
2017-08-07 05:09:49 +00:00
|
|
|
|
/// </summary>
|
2017-08-07 05:20:18 +00:00
|
|
|
|
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
|
2017-08-07 05:09:49 +00:00
|
|
|
|
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));
|
2017-03-31 02:01:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|