2017-03-31 02:01:42 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Graphics;
|
2017-06-21 02:18:52 +00:00
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
2017-03-31 02:01:42 +00:00
|
|
|
|
using osu.Game.Graphics.Transforms;
|
|
|
|
|
|
|
|
|
|
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; }
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-31 05:47:59 +00:00
|
|
|
|
public static class AccentedColourExtensions
|
2017-03-31 02:01:42 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Tweens the accent colour of a drawable to another colour.
|
|
|
|
|
/// </summary>
|
2017-03-31 06:05:14 +00:00
|
|
|
|
/// <param name="accentedDrawable">The drawable to apply the accent colour to.</param>
|
2017-03-31 02:01:42 +00:00
|
|
|
|
/// <param name="newColour">The new accent colour.</param>
|
|
|
|
|
/// <param name="duration">The tween duration.</param>
|
|
|
|
|
/// <param name="easing">The tween easing.</param>
|
2017-06-21 02:18:52 +00:00
|
|
|
|
public static void FadeAccent<T>(this T accentedDrawable, Color4 newColour, double duration = 0, EasingTypes easing = EasingTypes.None)
|
|
|
|
|
where T : Transformable<Drawable>, IHasAccentColour
|
2017-03-31 02:01:42 +00:00
|
|
|
|
{
|
2017-07-09 22:01:25 +00:00
|
|
|
|
accentedDrawable.TransformTo(newColour, duration, easing, new TransformAccent());
|
2017-03-31 02:01:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|