Exemplo n.º 1
0
 public static void TranslateAndApplyShapeContext(
     ShapeContext context,
     CompositionSpriteShape shape,
     bool reverseDirection,
     double trimOffsetDegrees)
 {
     shape.FillBrush = Brushes.TranslateShapeFill(context, context.Fill, context.Opacity);
     Brushes.TranslateAndApplyStroke(context, context.Stroke, shape, context.Opacity);
     TranslateAndApplyTrimPath(
         context,
         shape.Geometry,
         reverseDirection,
         trimOffsetDegrees);
 }
Exemplo n.º 2
0
        public static void TranslateAndApplyShapeContextWithTrimOffset(
            ShapeContext context,
            CompositionSpriteShape shape,
            bool reverseDirection,
            double trimOffsetDegrees)
        {
            Debug.Assert(shape.Geometry != null, "Precondition");

            shape.FillBrush = Brushes.TranslateShapeFill(context, context.Fill, context.Opacity);
            Brushes.TranslateAndApplyStroke(context, context.Stroke, shape, context.Opacity);

            TranslateAndApplyTrimPath(
                context,
                geometry: shape.Geometry !,
                reverseDirection,
                trimOffsetDegrees);
        }
Exemplo n.º 3
0
        public static void TranslateAndApplyShapeContextWithTrimOffset(
            ShapeContext context,
            CompositionSpriteShape shape,
            bool reverseDirection,
            double trimOffsetDegrees)
        {
            Debug.Assert(shape.Geometry is not null, "Precondition");

            shape.FillBrush = Brushes.TranslateShapeFill(context, context.Fill, context.Opacity);

            // OriginOffset is used to adjust cordinates of FillBrush for Rectangle shapes.
            // It is not needed afterwards, so we clean it up to not affect other code.
            context.LayerContext.OriginOffset = null;

            Brushes.TranslateAndApplyStroke(context, context.Stroke, shape, context.Opacity);

            TranslateAndApplyTrimPath(
                context,
                geometry: shape.Geometry !,
                reverseDirection,
                trimOffsetDegrees);
        }
Exemplo n.º 4
0
            internal override Visual?GetVisualRoot(CompositionContext context)
            {
                // Translate the SolidLayer to a Visual.
                if (_context.Layer.IsHidden || _context.Layer.Transform.Opacity.IsAlways(LottieData.Opacity.Transparent))
                {
                    // The layer does not render anything. Nothing to translate. This can happen when someone
                    // creates a solid layer to act like a Null layer.
                    return(null);
                }

                if (!Transforms.TryCreateContainerVisualTransformChain(_context, out var containerRootNode, out var containerContentNode))
                {
                    // The layer is never visible.
                    return(null);
                }

                var rectangle = context.ObjectFactory.CreateSpriteVisual();

                rectangle.Size = ConvertTo.Vector2(_context.Layer.Width, _context.Layer.Height);

                containerContentNode.Children.Add(rectangle);

                var layerHasMasks = false;

#if !NoClipping
                layerHasMasks = _context.Layer.Masks.Any();
#endif
                rectangle.Brush = Brushes.CreateNonAnimatedColorBrush(_context, _context.Layer.Color);

                rectangle.SetDescription(context, () => "SolidLayerRectangle");

                var result = layerHasMasks
                    ? Masks.TranslateAndApplyMasksForLayer(_context, containerRootNode)
                    : containerRootNode;

                Describe(context, result);

                return(result);
            }