// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Graphics; using osu.Framework.Graphics.Transforms; namespace osu.Game.Storyboards.Drawables { internal interface IFlippable : ITransformable { bool FlipH { get; set; } bool FlipV { get; set; } } internal class TransformFlipH : Transform { private bool valueAt(double time) => time < EndTime ? StartValue : EndValue; public override string TargetMember => nameof(IFlippable.FlipH); protected override void Apply(IFlippable d, double time) => d.FlipH = valueAt(time); protected override void ReadIntoStartValue(IFlippable d) => StartValue = d.FlipH; } internal class TransformFlipV : Transform { private bool valueAt(double time) => time < EndTime ? StartValue : EndValue; public override string TargetMember => nameof(IFlippable.FlipV); protected override void Apply(IFlippable d, double time) => d.FlipV = valueAt(time); protected override void ReadIntoStartValue(IFlippable d) => StartValue = d.FlipV; } internal static class FlippableExtensions { /// /// Adjusts after a delay. /// /// A to which further transforms can be added. public static TransformSequence TransformFlipH(this T flippable, bool newValue, double delay = 0) where T : class, IFlippable => flippable.TransformTo(flippable.PopulateTransform(new TransformFlipH(), newValue, delay)); /// /// Adjusts after a delay. /// /// A to which further transforms can be added. public static TransformSequence TransformFlipV(this T flippable, bool newValue, double delay = 0) where T : class, IFlippable => flippable.TransformTo(flippable.PopulateTransform(new TransformFlipV(), newValue, delay)); } }