/// <summary> /// Converts the input to the outputType using a fast conversion, for known system types. /// </summary> /// <param name="outputType">The target type</param> /// <param name="input">The input value to use</param> /// <param name="output">The input value converted to the <paramref name="outputType"/>.</param> /// <returns>True if the conversion succeeded, otherwise false.</returns> /// <remarks> /// This is a fast path conversion that avoids going through the TypeConverter /// infrastructure for known system types. /// </remarks> private static bool FastConvert(Type outputType, object input, out object output) { output = null; if ( input is string stringInput && FastStringConvert(outputType, stringInput, ref output) ) { return(true); } if (FastNumberConvert(outputType, input, ref output)) { return(true); } return(input switch { Enum _ => FastEnumConvert(outputType, input, ref output), bool boolInput => FastBooleanConvert(outputType, boolInput, ref output), Windows.UI.Color color => FastColorConvert(outputType, color, ref output), SolidColorBrush solidColorBrush => FastSolidColorBrushConvert(outputType, solidColorBrush, ref output), ColorOffset colorOffsetInput => FastColorOffsetConvert(outputType, colorOffsetInput, ref output), Thickness thicknessInput => FastThicknessConvert(outputType, thicknessInput, ref output), _ => false });
/// <summary> /// Apply easing function on each component of a ColorOffset /// </summary> public static ColorOffset Ease(this IEasingFunction easing, long frame, ColorOffset from, ColorOffset to, long duration) { var a = (int)easing.Ease(frame, from.A, to.A, duration); var r = (int)easing.Ease(frame, from.R, to.R, duration); var g = (int)easing.Ease(frame, from.G, to.G, duration); var b = (int)easing.Ease(frame, from.B, to.B, duration); return(ColorOffset.FromArgb(a, r, g, b)); }
/// <summary> /// Creates the actual animator instance /// </summary> private static IValueAnimator CreateColor(Timeline timeline, ColorOffset startingValue, ColorOffset targetValue) { // TODO: GPU-bound color animations - https://github.com/unoplatform/uno/issues/2947 var startingColor = (Android.Graphics.Color)(Color) startingValue; var targetColor = (Android.Graphics.Color)(Color) targetValue; var valueAnimator = ValueAnimator.OfArgb(startingColor, targetColor); return(new NativeValueAnimatorAdapter(valueAnimator)); }
private static bool FastColorOffsetConvert(Type outputType, ColorOffset input, ref object output) { if (outputType == typeof(Windows.UI.Color)) { output = (Windows.UI.Color)input; return(true); } return(false); }
private static IValueAnimator CreateColor(Timeline timeline, ColorOffset startingValue, ColorOffset targetValue) { if (timeline.GetIsDurationZero()) { // Avoid unnecessary JS interop in the case of a zero-duration animation return(new ImmediateAnimator <ColorOffset>(startingValue, targetValue)); } // TODO: GPU-bound color animations - https://github.com/unoplatform/uno/issues/2947 return(new RenderingLoopColorAnimator(startingValue, targetValue)); }
private static IValueAnimator CreateColor(Timeline timeline, ColorOffset startingValue, ColorOffset targetValue) { // TODO: GPU-bound color animations - https://github.com/unoplatform/uno/issues/2947 return(new ColorValueAnimator(startingValue, targetValue)); }
private static byte GetColorByte(ColorOffset offset, int pixel) { return(Convert.ToByte((pixel >> (int)offset) & 0xff)); }
private static IValueAnimator CreateColor(Timeline timeline, ColorOffset startingValue, ColorOffset targetValue) { return(new NotSupportedAnimator()); }
public static int GetPixelColorIndex(int row, int column, ColorOffset colorOffset, int stride, int bytesPerPixel) { return((row * stride) + column * bytesPerPixel + (int)colorOffset); }
private static IValueAnimator CreateColor(Timeline timeline, ColorOffset startingValue, ColorOffset targetValue) => new ImmediateAnimator <ColorOffset>(startingValue, targetValue);
public ColorValueAnimator(ColorOffset from, ColorOffset to) { _to = to; _from = from; }