2018-01-05 11:21:19 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-09-11 10:33:11 +00:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
2017-09-09 13:34:26 +00:00
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Storyboards.Drawables
|
|
|
|
|
{
|
|
|
|
|
public static class DrawablesExtensions
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-09-11 10:33:11 +00:00
|
|
|
|
/// Adjusts <see cref="Drawable.Blending"/> after a delay.
|
2017-09-09 13:34:26 +00:00
|
|
|
|
/// </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 10:23:32 +00:00
|
|
|
|
public override string TargetMember => nameof(Drawable.Blending);
|
2017-09-09 13:34:26 +00:00
|
|
|
|
|
2017-09-11 10:23:32 +00: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 13:34:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|