1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 08:07:26 +08:00
osu-lazer/osu.Game/Storyboards/Drawables/DrawablesExtensions.cs

28 lines
1.1 KiB
C#
Raw Normal View History

2017-09-09 21:34:26 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transforms;
namespace osu.Game.Storyboards.Drawables
{
public static class DrawablesExtensions
{
/// <summary>
/// Adjusts <see cref="Drawable.BlendingMode"/> after a delay.
/// </summary>
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
public static TransformSequence<T> TransformBlendingMode<T>(this T drawable, BlendingMode newValue, double delay = 0)
where T : Drawable
=> drawable.TransformTo(drawable.PopulateTransform(new TransformBlendingMode(), newValue, delay));
}
public class TransformBlendingMode : Transform<BlendingMode, Drawable>
{
private BlendingMode valueAt(double time)
=> time < EndTime ? StartValue : EndValue;
2017-09-11 18:23:32 +08:00
public override string TargetMember => nameof(Drawable.Blending);
2017-09-09 21:34:26 +08:00
2017-09-11 18:23:32 +08:00
protected override void Apply(Drawable d, double time) => d.Blending = valueAt(time);
protected override void ReadIntoStartValue(Drawable d) => StartValue = d.Blending.Mode;
2017-09-09 21:34:26 +08:00
}
}