using System.Linq; namespace JD.Serialization { public partial class AlphaClip { /// /// Computes whether the curve is a fade in or fade out curve. /// public static bool? FadesToOpaque(BezierCurveFloat curve) { if (curve.Keys.Count == 0) { // No fading return null; } else if (curve.Keys.Count == 1) { return IsOpaque(curve.Keys.First()); } float minFrame = curve.Keys.Min(point => point.Frame); var from = IsOpaque(curve.Keys.First(x => x.Frame.Equals(minFrame))); float maxFrame = curve.Keys.Max(point => point.Frame); var to = IsOpaque(curve.Keys.First(x => x.Frame.Equals(maxFrame))); if (@from != to) { return to; } // No fading, returns a normal type return null; } private static bool IsOpaque(KeyFloat key) { return key.Position.Y > 0.5f; } } }