public override IObservable <Color> DoTransition(IObservable <double> progress, Color oldValue, Color newValue) { return(progress.Select(p => { (double L1, double a1, double b1) = Lab.ToLab(oldValue); (double L2, double a2, double b2) = Lab.ToLab(newValue); double f = Easing.Ease(p); byte A = (byte)(oldValue.A + ((double)newValue.A - oldValue.A) * f); Lab.FromLab(L1 + (L2 - L1) * f, a1 + (a2 - a1) * f, b1 + (b2 - b1) * f, out byte R, out byte G, out byte B); return Color.FromArgb(A, R, G, B); })); }
public override IObservable <IBrush> DoTransition(IObservable <double> progress, IBrush oldBrush, IBrush newBrush) { return(progress.Select(p => { if (oldBrush is SolidColorBrush oldSolidBrush && newBrush is SolidColorBrush newSolidBrush) { Color oldValue = oldSolidBrush.Color; Color newValue = newSolidBrush.Color; (double L1, double a1, double b1) = Lab.ToLab(oldValue); (double L2, double a2, double b2) = Lab.ToLab(newValue); double f = Easing.Ease(p); byte A = (byte)(oldValue.A + ((double)newValue.A - oldValue.A) * f); Lab.FromLab(L1 + (L2 - L1) * f, a1 + (a2 - a1) * f, b1 + (b2 - b1) * f, out byte R, out byte G, out byte B); return new SolidColorBrush(Color.FromArgb(A, R, G, B)); }