Last active
September 11, 2019 02:12
-
-
Save danvanderboom/0319256fa3f1f2f50be2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
using Xamarin.Forms; | |
public static class ViewExtensions | |
{ | |
public static void ShiftColorTo (this VisualElement view, Color sourceColor, Color targetColor, Action<Color> setter, uint length = 250, Easing easing = null) | |
{ | |
view.Animate ("ShiftColorTo", | |
x => | |
{ | |
var red = sourceColor.R + (x * (targetColor.R - sourceColor.R)); | |
var green = sourceColor.G + (x * (targetColor.G - sourceColor.G)); | |
var blue = sourceColor.B + (x * (targetColor.B - sourceColor.B)); | |
var alpha = sourceColor.A + (x * (targetColor.A - sourceColor.A)); | |
setter(Color.FromRgba(red, green, blue, alpha)); | |
}, | |
length: length, | |
easing: easing); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment