// 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.Bindables; using osu.Framework.Utils; namespace osu.Framework.Graphics.Transforms { internal class TransformBindable : Transform where T : class, ITransformable where TEasing : IEasingFunction { public override string TargetMember { get; } private readonly Bindable targetBindable; public TransformBindable(Bindable targetBindable) { this.targetBindable = targetBindable; TargetMember = $"{targetBindable.GetHashCode()}.Value"; } private TValue valueAt(double time) { if (time < StartTime) return StartValue; if (time >= EndTime) return EndValue; return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); } protected override void Apply(T d, double time) => targetBindable.Value = valueAt(time); protected override void ReadIntoStartValue(T d) => StartValue = targetBindable.Value; } }