2019-01-24 16:43:03 +08: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 17:19:50 +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.Blending"/> 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;
|
|
|
|
|
|
|
|
|
|
public override string TargetMember => nameof(Drawable.Blending);
|
|
|
|
|
|
|
|
|
|
protected override void Apply(Drawable d, double time) => d.Blending = valueAt(time);
|
|
|
|
|
protected override void ReadIntoStartValue(Drawable d) => StartValue = d.Blending.Mode;
|
|
|
|
|
}
|
|
|
|
|
}
|