示例#1
0
        public static CompositionColorBrush CreateNonAnimatedColorBrush(TranslationContext context, Color color)
        {
            var nonAnimatedColorBrushes = context.GetStateCache <StateCache>().NonAnimatedColorBrushes;

            if (!nonAnimatedColorBrushes.TryGetValue(color, out var result))
            {
                result = context.ObjectFactory.CreateNonAnimatedColorBrush(color);
                nonAnimatedColorBrushes.Add(color, result);
            }

            return(result);
        }
示例#2
0
        public static void WithKeyFrame(
            TranslationContext context,
            CompositionObject compObject,
            string target,
            KeyFrameAnimation_ animation,
            double scale  = 1,
            double offset = 0)
        {
            Debug.Assert(offset >= 0, "Precondition");
            Debug.Assert(scale <= 1, "Precondition");
            Debug.Assert(animation.KeyFrameCount > 0, "Precondition");

            var state = context.GetStateCache <StateCache>();

            // Start the animation ...
            compObject.StartAnimation(target, animation);

            // ... but pause it immediately so that it doesn't react to time. Instead, bind
            // its progress to the progress of the composition.
            var controller = compObject.TryGetAnimationController(target);

            controller !.Pause();

            // Bind it to the root visual's Progress property, scaling and offsetting if necessary.
            var key = new ScaleAndOffset(scale, offset);

            if (!state.ProgressBindingAnimations.TryGetValue(key, out var bindingAnimation))
            {
                bindingAnimation = context.ObjectFactory.CreateExpressionAnimation(ExpressionFactory.ScaledAndOffsetRootProgress(scale, offset));
                bindingAnimation.SetReferenceParameter(ExpressionFactory.RootName, context.RootVisual !);
                if (context.AddDescriptions)
                {
                    // Give the animation a nice readable name in codegen.
                    var name = key.Offset != 0 || key.Scale != 1
                        ? "RootProgressRemapped"
                        : "RootProgress";

                    bindingAnimation.SetName(name);
                }

                state.ProgressBindingAnimations.Add(key, bindingAnimation);
            }

            // Bind the controller's Progress with a single Progress property on the scene root.
            // The Progress property provides the time reference for the animation.
            controller.StartAnimation("Progress", bindingAnimation);
        }
示例#3
0
        public static CompositionPropertySet GetThemePropertySet(TranslationContext context)
        {
            var cache = context.GetStateCache <StateCache>();

            return(cache.GetThemePropertySet(context));
        }
示例#4
0
        public static Animatable <PathGeometry> GetOptimized(TranslationContext context, Animatable <PathGeometry> value)
        {
            var lottieOptimizer = context.GetStateCache <StateCache>().LottieOptimizer;

            return(lottieOptimizer.GetOptimized(value));
        }