//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//       LottieGen version:
//           8.1.240821.1+077322fa26
//       
//       Command:
//           LottieGen -Language CSharp -Public -WinUIVersion 3.0 -InputFile StarBlack.json
//       
//       Input file:
//           StarBlack.json (52099 bytes created 15:26+02:00 Nov 17 2024)
//       
//       LottieGen source:
//           http://aka.ms/Lottie
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
// ____________________________________
// |       Object stats       | Count |
// |__________________________|_______|
// | All CompositionObjects   |    58 |
// |--------------------------+-------|
// | Expression animators     |     1 |
// | KeyFrame animators       |     1 |
// | Reference parameters     |     1 |
// | Expression operations    |     0 |
// |--------------------------+-------|
// | Animated brushes         |     - |
// | Animated gradient stops  |     - |
// | ExpressionAnimations     |     1 |
// | PathKeyFrameAnimations   |     - |
// |--------------------------+-------|
// | ContainerVisuals         |     3 |
// | ShapeVisuals             |     3 |
// |--------------------------+-------|
// | ContainerShapes          |     1 |
// | CompositionSpriteShapes  |     3 |
// |--------------------------+-------|
// | Brushes                  |     5 |
// | Gradient stops           |     - |
// | CompositionVisualSurface |     2 |
// ------------------------------------
using Microsoft.Graphics;
using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Effects;
using Microsoft.Graphics.Canvas.Geometry;
using Microsoft.UI.Composition;
using System;
using System.Collections.Generic;
using System.Numerics;
using Windows.UI;

namespace AnimatedVisuals
{
    // Name:        add-to-favorites
    // Frame rate:  24 fps
    // Frame count: 28
    // Duration:    1166.7 mS
    // _____________________________________________________________________________________________
    // |           Marker           |           Constant           | Frame |   mS   |   Progress   |
    // |____________________________|______________________________|_______|________|______________|
    // | NormalToPressed_Start      | M_NormalToPressed_Start      |     0 |    0.0 | 0F           |
    // | NormalToPressed_End        | M_NormalToPressed_End        |     9 |  375.0 | 0.323214293F |
    // | PointerOverToPressed_Start | M_PointerOverToPressed_Start |     9 |  375.0 | 0.323214293F |
    // | PointerOverToPressed_End   | M_PointerOverToPressed_End   |    19 |  791.7 | 0.680357158F |
    // | PressedToNormal_Start      | M_PressedToNormal_Start      |    20 |  833.3 | 0.716071427F |
    // | PressedToNormal_End        | M_PressedToNormal_End        |    28 | 1166.7 | 1F           |
    // | PressedToPointerOver_Start | M_PressedToPointerOver_Start |    28 | 1166.7 | 1F           |
    // | PressedToPointerOver_End   | M_PressedToPointerOver_End   |    28 | 1166.7 | 1F           |
    // ---------------------------------------------------------------------------------------------
    sealed partial class StarBlack
        : Microsoft.UI.Xaml.Controls.IAnimatedVisualSource
        , Microsoft.UI.Xaml.Controls.IAnimatedVisualSource2
    {
        // Animation duration: 1.167 seconds.
        internal const long c_durationTicks = 11666666;

        // Marker: NormalToPressed_Start.
        internal const float M_NormalToPressed_Start = 0F;

        // Marker: NormalToPressed_End.
        internal const float M_NormalToPressed_End = 0.323214293F;

        // Marker: PointerOverToPressed_Start.
        internal const float M_PointerOverToPressed_Start = 0.323214293F;

        // Marker: PointerOverToPressed_End.
        internal const float M_PointerOverToPressed_End = 0.680357158F;

        // Marker: PressedToNormal_Start.
        internal const float M_PressedToNormal_Start = 0.716071427F;

        // Marker: PressedToNormal_End.
        internal const float M_PressedToNormal_End = 1F;

        // Marker: PressedToPointerOver_Start.
        internal const float M_PressedToPointerOver_Start = 1F;

        // Marker: PressedToPointerOver_End.
        internal const float M_PressedToPointerOver_End = 1F;

        public Microsoft.UI.Xaml.Controls.IAnimatedVisual TryCreateAnimatedVisual(Compositor compositor)
        {
            object ignored = null;
            return TryCreateAnimatedVisual(compositor, out ignored);
        }

        public Microsoft.UI.Xaml.Controls.IAnimatedVisual TryCreateAnimatedVisual(Compositor compositor, out object diagnostics)
        {
            diagnostics = null;

            var res = 
                new StarBlack_AnimatedVisual(
                    compositor
                    );
                res.CreateAnimations();
                return res;
        }

        /// <summary>
        /// Gets the number of frames in the animation.
        /// </summary>
        public double FrameCount => 28d;

        /// <summary>
        /// Gets the frame rate of the animation.
        /// </summary>
        public double Framerate => 24d;

        /// <summary>
        /// Gets the duration of the animation.
        /// </summary>
        public TimeSpan Duration => TimeSpan.FromTicks(11666666);

        /// <summary>
        /// Converts a zero-based frame number to the corresponding progress value denoting the
        /// start of the frame.
        /// </summary>
        public double FrameToProgress(double frameNumber)
        {
            return frameNumber / 28d;
        }

        /// <summary>
        /// Returns a map from marker names to corresponding progress values.
        /// </summary>
        public IReadOnlyDictionary<string, double> Markers =>
            new Dictionary<string, double>
            {
                { "NormalToPressed_Start", 0d },
                { "NormalToPressed_End", 0.323214285714286 },
                { "PointerOverToPressed_Start", 0.323214285714286 },
                { "PointerOverToPressed_End", 0.680357142857143 },
                { "PressedToNormal_Start", 0.716071428571429 },
                { "PressedToNormal_End", 1d },
                { "PressedToPointerOver_Start", 1d },
                { "PressedToPointerOver_End", 1d },
            };

        /// <summary>
        /// Sets the color property with the given name, or does nothing if no such property
        /// exists.
        /// </summary>
        public void SetColorProperty(string propertyName, Color value)
        {
        }

        /// <summary>
        /// Sets the scalar property with the given name, or does nothing if no such property
        /// exists.
        /// </summary>
        public void SetScalarProperty(string propertyName, double value)
        {
        }

        sealed partial class StarBlack_AnimatedVisual
            : Microsoft.UI.Xaml.Controls.IAnimatedVisual
            , Microsoft.UI.Xaml.Controls.IAnimatedVisual2
        {
            const long c_durationTicks = 11666666;
            readonly Compositor _c;
            readonly ExpressionAnimation _reusableExpressionAnimation;
            AnimationController _animationController_0;
            CompositionColorBrush _colorBrush_Black;
            CompositionContainerShape _containerShape;
            ContainerVisual _root;
            CubicBezierEasingFunction _cubicBezierEasingFunction_0;

            void BindProperty(
                CompositionObject target,
                string animatedPropertyName,
                string expression,
                string referenceParameterName,
                CompositionObject referencedObject)
            {
                _reusableExpressionAnimation.ClearAllParameters();
                _reusableExpressionAnimation.Expression = expression;
                _reusableExpressionAnimation.SetReferenceParameter(referenceParameterName, referencedObject);
                target.StartAnimation(animatedPropertyName, _reusableExpressionAnimation);
            }

            Vector2KeyFrameAnimation CreateVector2KeyFrameAnimation(float initialProgress, Vector2 initialValue, CompositionEasingFunction initialEasingFunction)
            {
                var result = _c.CreateVector2KeyFrameAnimation();
                result.Duration = TimeSpan.FromTicks(c_durationTicks);
                result.InsertKeyFrame(initialProgress, initialValue, initialEasingFunction);
                return result;
            }

            CompositionSpriteShape CreateSpriteShape(CompositionGeometry geometry, Matrix3x2 transformMatrix)
            {
                var result = _c.CreateSpriteShape(geometry);
                result.TransformMatrix = transformMatrix;
                return result;
            }

            CompositionSpriteShape CreateSpriteShape(CompositionGeometry geometry, Matrix3x2 transformMatrix, CompositionBrush fillBrush)
            {
                var result = _c.CreateSpriteShape(geometry);
                result.TransformMatrix = transformMatrix;
                result.FillBrush = fillBrush;
                return result;
            }

            // - Shape tree root for layer: plus
            AnimationController AnimationController_0()
            {
                if (_animationController_0 != null) { return _animationController_0; }
                var result = _animationController_0 = _c.CreateAnimationController();
                result.Pause();
                BindProperty(_animationController_0, "Progress", "_.Progress", "_", _root);
                return result;
            }

            // - - - Shape tree root for layer: outline
            // - - ShapeGroup: Group 1 Offset:<25, 25>
            CanvasGeometry Geometry_0()
            {
                CanvasGeometry result;
                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.BeginFigure(new Vector2(0F, -23F));
                    builder.AddLine(new Vector2(6.4000001F, -6.4000001F));
                    builder.AddLine(new Vector2(24F, -5.4000001F));
                    builder.AddLine(new Vector2(10.3000002F, 5.80000019F));
                    builder.AddLine(new Vector2(15F, 23F));
                    builder.AddLine(new Vector2(0F, 13.3000002F));
                    builder.AddLine(new Vector2(-15F, 23F));
                    builder.AddLine(new Vector2(-10.3000002F, 5.80000019F));
                    builder.AddLine(new Vector2(-24F, -5.4000001F));
                    builder.AddLine(new Vector2(-6.4000001F, -6.4000001F));
                    builder.AddLine(new Vector2(0F, -23F));
                    builder.EndFigure(CanvasFigureLoop.Closed);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return result;
            }

            // - - - Shape tree root for layer: star 
            // - - ShapeGroup: Group 1 Offset:<25, 25.05>
            CanvasGeometry Geometry_1()
            {
                CanvasGeometry result;
                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.SetFilledRegionDetermination(CanvasFilledRegionDetermination.Winding);
                    builder.BeginFigure(new Vector2(25F, -5.75F));
                    builder.AddCubicBezier(new Vector2(24.8999996F, -6.1500001F), new Vector2(24.5F, -6.44999981F), new Vector2(24.1000004F, -6.44999981F));
                    builder.AddLine(new Vector2(7.0999999F, -7.44999981F));
                    builder.AddLine(new Vector2(0.899999976F, -23.4500008F));
                    builder.AddCubicBezier(new Vector2(0.800000012F, -23.75F), new Vector2(0.400000006F, -24.0499992F), new Vector2(0F, -24.0499992F));
                    builder.AddCubicBezier(new Vector2(-0.400000006F, -24.0499992F), new Vector2(-0.800000012F, -23.75F), new Vector2(-0.899999976F, -23.4500008F));
                    builder.AddLine(new Vector2(-7.0999999F, -7.44999981F));
                    builder.AddLine(new Vector2(-24.1000004F, -6.44999981F));
                    builder.AddCubicBezier(new Vector2(-24.5F, -6.44999981F), new Vector2(-24.8999996F, -6.1500001F), new Vector2(-25F, -5.75F));
                    builder.AddCubicBezier(new Vector2(-25.1000004F, -5.3499999F), new Vector2(-25F, -4.94999981F), new Vector2(-24.7000008F, -4.6500001F));
                    builder.AddLine(new Vector2(-11.5F, 6.1500001F));
                    builder.AddLine(new Vector2(-16F, 22.6499996F));
                    builder.AddCubicBezier(new Vector2(-16.1000004F, 23.0499992F), new Vector2(-16F, 23.4500008F), new Vector2(-15.6000004F, 23.75F));
                    builder.AddCubicBezier(new Vector2(-15.3000002F, 23.9500008F), new Vector2(-14.8000002F, 24.0499992F), new Vector2(-14.5F, 23.75F));
                    builder.AddLine(new Vector2(0F, 14.4499998F));
                    builder.AddLine(new Vector2(14.5F, 23.75F));
                    builder.AddCubicBezier(new Vector2(14.6999998F, 23.8500004F), new Vector2(14.8999996F, 23.9500008F), new Vector2(15F, 23.9500008F));
                    builder.AddCubicBezier(new Vector2(15.1999998F, 23.9500008F), new Vector2(15.3999996F, 23.8500004F), new Vector2(15.6000004F, 23.75F));
                    builder.AddCubicBezier(new Vector2(15.8999996F, 23.5499992F), new Vector2(16.1000004F, 23.0499992F), new Vector2(16F, 22.6499996F));
                    builder.AddLine(new Vector2(11.5F, 6.05000019F));
                    builder.AddLine(new Vector2(24.7000008F, -4.75F));
                    builder.AddCubicBezier(new Vector2(25F, -4.94999981F), new Vector2(25.1000004F, -5.3499999F), new Vector2(25F, -5.75F));
                    builder.EndFigure(CanvasFigureLoop.Closed);
                    builder.BeginFigure(new Vector2(7F, 2.95000005F));
                    builder.AddLine(new Vector2(1F, 2.95000005F));
                    builder.AddLine(new Vector2(1F, 8.94999981F));
                    builder.AddLine(new Vector2(-1F, 8.94999981F));
                    builder.AddLine(new Vector2(-1F, 2.95000005F));
                    builder.AddLine(new Vector2(-7F, 2.95000005F));
                    builder.AddLine(new Vector2(-7F, 0.949999988F));
                    builder.AddLine(new Vector2(-1F, 0.949999988F));
                    builder.AddLine(new Vector2(-1F, -5.05000019F));
                    builder.AddLine(new Vector2(1F, -5.05000019F));
                    builder.AddLine(new Vector2(1F, 0.949999988F));
                    builder.AddLine(new Vector2(7F, 0.949999988F));
                    builder.AddLine(new Vector2(7F, 2.95000005F));
                    builder.EndFigure(CanvasFigureLoop.Closed);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return result;
            }

            // - - - - Shape tree root for layer: plus
            // - - ShapeGroup: Group 1 Offset:<25, 27>
            CanvasGeometry Geometry_2()
            {
                CanvasGeometry result;
                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.SetFilledRegionDetermination(CanvasFilledRegionDetermination.Winding);
                    builder.BeginFigure(new Vector2(7F, -1F));
                    builder.AddLine(new Vector2(1F, -1F));
                    builder.AddLine(new Vector2(1F, -7F));
                    builder.AddLine(new Vector2(-1F, -7F));
                    builder.AddLine(new Vector2(-1F, -1F));
                    builder.AddLine(new Vector2(-7F, -1F));
                    builder.AddLine(new Vector2(-7F, 1F));
                    builder.AddLine(new Vector2(-1F, 1F));
                    builder.AddLine(new Vector2(-1F, 7F));
                    builder.AddLine(new Vector2(1F, 7F));
                    builder.AddLine(new Vector2(1F, 1F));
                    builder.AddLine(new Vector2(7F, 1F));
                    builder.AddLine(new Vector2(7F, -1F));
                    builder.EndFigure(CanvasFigureLoop.Closed);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return result;
            }

            CompositionColorBrush ColorBrush_Black()
            {
                return (_colorBrush_Black == null)
                    ? _colorBrush_Black = _c.CreateColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00))
                    : _colorBrush_Black;
            }

            // - - Shape tree root for layer: plus
            // ShapeGroup: Group 1 Offset:<25, 27>
            CompositionColorBrush ColorBrush_White()
            {
                return _c.CreateColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
            }

            // Shape tree root for layer: plus
            CompositionContainerShape ContainerShape()
            {
                if (_containerShape != null) { return _containerShape; }
                var result = _containerShape = _c.CreateContainerShape();
                result.CenterPoint = new Vector2(25F, 27F);
                // ShapeGroup: Group 1 Offset:<25, 27>
                result.Shapes.Add(SpriteShape_2());
                return result;
            }

            CompositionEffectBrush EffectBrush()
            {
                var effectFactory = EffectFactory();
                var result = effectFactory.CreateBrush();
                result.SetSourceParameter("destination", SurfaceBrush_0());
                result.SetSourceParameter("source", SurfaceBrush_1());
                return result;
            }

            CompositionEffectFactory EffectFactory()
            {
                var compositeEffect = new CompositeEffect();
                compositeEffect.Mode = CanvasComposite.DestinationOut;
                compositeEffect.Sources.Add(new CompositionEffectSourceParameter("destination"));
                compositeEffect.Sources.Add(new CompositionEffectSourceParameter("source"));
                var result = _c.CreateEffectFactory(compositeEffect);
                return result;
            }

            // - Shape tree root for layer: outline
            // ShapeGroup: Group 1 Offset:<25, 25>
            CompositionPathGeometry PathGeometry_0()
            {
                return _c.CreatePathGeometry(new CompositionPath(Geometry_0()));
            }

            // - Shape tree root for layer: star 
            // ShapeGroup: Group 1 Offset:<25, 25.05>
            CompositionPathGeometry PathGeometry_1()
            {
                return _c.CreatePathGeometry(new CompositionPath(Geometry_1()));
            }

            // - - Shape tree root for layer: plus
            // ShapeGroup: Group 1 Offset:<25, 27>
            CompositionPathGeometry PathGeometry_2()
            {
                return _c.CreatePathGeometry(new CompositionPath(Geometry_2()));
            }

            // Shape tree root for layer: outline
            // Path 1
            CompositionSpriteShape SpriteShape_0()
            {
                // Offset:<25, 25>
                var result = CreateSpriteShape(PathGeometry_0(), new Matrix3x2(1F, 0F, 0F, 1F, 25F, 25F));;
                result.StrokeBrush = ColorBrush_Black();
                result.StrokeLineJoin = CompositionStrokeLineJoin.Round;
                result.StrokeMiterLimit = 2F;
                result.StrokeThickness = 2F;
                return result;
            }

            // Shape tree root for layer: star 
            // ShapeGroup: Group 1 Offset:<25, 25.05>
            CompositionSpriteShape SpriteShape_1()
            {
                // Offset:<25, 25.05>
                var geometry = PathGeometry_1();
                var result = CreateSpriteShape(geometry, new Matrix3x2(1F, 0F, 0F, 1F, 25F, 25.0499992F), ColorBrush_Black());;
                return result;
            }

            // - Shape tree root for layer: plus
            // Path 1
            CompositionSpriteShape SpriteShape_2()
            {
                // Offset:<25, 27>
                var geometry = PathGeometry_2();
                var result = CreateSpriteShape(geometry, new Matrix3x2(1F, 0F, 0F, 1F, 25F, 27F), ColorBrush_White());;
                return result;
            }

            CompositionSurfaceBrush SurfaceBrush_0()
            {
                return _c.CreateSurfaceBrush(VisualSurface_0());
            }

            CompositionSurfaceBrush SurfaceBrush_1()
            {
                return _c.CreateSurfaceBrush(VisualSurface_1());
            }

            CompositionVisualSurface VisualSurface_0()
            {
                var result = _c.CreateVisualSurface();
                result.SourceVisual = ContainerVisual_0();
                result.SourceSize = new Vector2(50F, 50F);
                return result;
            }

            CompositionVisualSurface VisualSurface_1()
            {
                var result = _c.CreateVisualSurface();
                result.SourceVisual = ContainerVisual_1();
                result.SourceSize = new Vector2(50F, 50F);
                return result;
            }

            ContainerVisual ContainerVisual_0()
            {
                var result = _c.CreateContainerVisual();
                result.BorderMode = CompositionBorderMode.Soft;
                // Shape tree root for layer: star
                result.Children.InsertAtTop(ShapeVisual_1());
                return result;
            }

            ContainerVisual ContainerVisual_1()
            {
                var result = _c.CreateContainerVisual();
                result.BorderMode = CompositionBorderMode.Soft;
                // Shape tree root for layer: plus
                result.Children.InsertAtTop(ShapeVisual_2());
                return result;
            }

            // The root of the composition.
            ContainerVisual Root()
            {
                if (_root != null) { return _root; }
                var result = _root = _c.CreateContainerVisual();
                var propertySet = result.Properties;
                propertySet.InsertScalar("Progress", 0F);
                var children = result.Children;
                // Shape tree root for layer: outline
                children.InsertAtTop(ShapeVisual_0());
                children.InsertAtTop(SpriteVisual_0());
                return result;
            }

            CubicBezierEasingFunction CubicBezierEasingFunction_0()
            {
                return (_cubicBezierEasingFunction_0 == null)
                    ? _cubicBezierEasingFunction_0 = _c.CreateCubicBezierEasingFunction(new Vector2(0.333000004F, 0F), new Vector2(0.666999996F, 1F))
                    : _cubicBezierEasingFunction_0;
            }

            // Shape tree root for layer: outline
            ShapeVisual ShapeVisual_0()
            {
                var result = _c.CreateShapeVisual();
                result.Size = new Vector2(50F, 50F);
                // ShapeGroup: Group 1 Offset:<25, 25>
                result.Shapes.Add(SpriteShape_0());
                return result;
            }

            // Shape tree root for layer: star
            ShapeVisual ShapeVisual_1()
            {
                var result = _c.CreateShapeVisual();
                result.Size = new Vector2(50F, 50F);
                // ShapeGroup: Group 1 Offset:<25, 25.05>
                result.Shapes.Add(SpriteShape_1());
                return result;
            }

            // Shape tree root for layer: plus
            ShapeVisual ShapeVisual_2()
            {
                var result = _c.CreateShapeVisual();
                result.Size = new Vector2(50F, 50F);
                result.Shapes.Add(ContainerShape());
                return result;
            }

            SpriteVisual SpriteVisual_0()
            {
                var result = _c.CreateSpriteVisual();
                result.Size = new Vector2(50F, 50F);
                result.Brush = EffectBrush();
                return result;
            }

            // - - Shape tree root for layer: plus
            // Scale
            StepEasingFunction HoldThenStepEasingFunction()
            {
                var result = _c.CreateStepEasingFunction();
                result.IsFinalStepSingleFrame = true;
                return result;
            }

            // - - Shape tree root for layer: plus
            // Scale
            StepEasingFunction StepThenHoldEasingFunction()
            {
                var result = _c.CreateStepEasingFunction();
                result.IsInitialStepSingleFrame = true;
                return result;
            }

            // - Shape tree root for layer: plus
            // Scale
            Vector2KeyFrameAnimation ScaleVector2Animation()
            {
                // Frame 0.
                var result = CreateVector2KeyFrameAnimation(0F, new Vector2(1F, 1F), StepThenHoldEasingFunction());
                // Frame 3.
                result.InsertKeyFrame(0.107142858F, new Vector2(1F, 1F), HoldThenStepEasingFunction());
                // Frame 11.
                result.InsertKeyFrame(0.392857134F, new Vector2(17.3600006F, 17.3600006F), CubicBezierEasingFunction_0());
                // Frame 17.
                result.InsertKeyFrame(0.607142866F, new Vector2(17.3600006F, 17.3600006F), _c.CreateCubicBezierEasingFunction(new Vector2(0.166999996F, 0.166999996F), new Vector2(0.833000004F, 0.833000004F)));
                // Frame 25.
                result.InsertKeyFrame(0.892857134F, new Vector2(1F, 1F), CubicBezierEasingFunction_0());
                return result;
            }

            internal StarBlack_AnimatedVisual(
                Compositor compositor
                )
            {
                _c = compositor;
                _reusableExpressionAnimation = compositor.CreateExpressionAnimation();
                Root();
            }

            public Visual RootVisual => _root;
            public TimeSpan Duration => TimeSpan.FromTicks(c_durationTicks);
            public Vector2 Size => new Vector2(50F, 50F);
            void IDisposable.Dispose() => _root?.Dispose();

            public void CreateAnimations()
            {
                _containerShape.StartAnimation("Scale", ScaleVector2Animation(), AnimationController_0());
            }

            public void DestroyAnimations()
            {
                _containerShape.StopAnimation("Scale");
            }

        }
    }
}
