Пример #1
0
        YamlObject FromImageAsset(ImageAsset asset, YamlMap superclassContent)
        {
            superclassContent.Add(nameof(asset.Width), asset.Width);
            superclassContent.Add(nameof(asset.Height), asset.Height);

            switch (asset.ImageType)
            {
            case ImageAsset.ImageAssetType.Embedded:
                return(FromEmbeddedImageAsset((EmbeddedImageAsset)asset, superclassContent));

            case ImageAsset.ImageAssetType.External:
                return(FromExternalImageAsset((ExternalImageAsset)asset, superclassContent));

            default:
                throw Unreachable;
            }
        }
Пример #2
0
        YamlObject FromShapeFill(ShapeFill content, YamlMap superclassContent)
        {
            superclassContent.Add(nameof(content.Opacity), FromAnimatable(content.Opacity));
            superclassContent.Add(nameof(content.FillType), Scalar(content.FillType));
            switch (content.FillKind)
            {
            case ShapeFill.ShapeFillKind.SolidColor:
                return(FromSolidColorFill((SolidColorFill)content, superclassContent));

            case ShapeFill.ShapeFillKind.LinearGradient:
                return(FromLinearGradientFill((LinearGradientFill)content, superclassContent));

            case ShapeFill.ShapeFillKind.RadialGradient:
                return(FromRadialGradientFill((RadialGradientFill)content, superclassContent));

            default:
                throw Unreachable;
            }
        }
Пример #3
0
        YamlObject FromShapeStroke(ShapeStroke content, YamlMap superclassContent)
        {
            superclassContent.Add(nameof(content.Opacity), FromAnimatable(content.Opacity));
            superclassContent.Add(nameof(content.StrokeWidth), FromAnimatable(content.StrokeWidth));
            superclassContent.Add(nameof(content.CapType), Scalar(content.CapType));
            superclassContent.Add(nameof(content.JoinType), Scalar(content.JoinType));
            superclassContent.Add(nameof(content.MiterLimit), Scalar(content.MiterLimit));
            switch (content.StrokeKind)
            {
            case ShapeStroke.ShapeStrokeKind.SolidColor:
                return(FromSolidColorStroke((SolidColorStroke)content, superclassContent));

            case ShapeStroke.ShapeStrokeKind.LinearGradient:
                return(FromLinearGradientStroke((LinearGradientStroke)content, superclassContent));

            case ShapeStroke.ShapeStrokeKind.RadialGradient:
                return(FromRadialGradientStroke((RadialGradientStroke)content, superclassContent));

            default:
                throw Unreachable;
            }
        }
        YamlObject FromShapeLayerContent(ShapeLayerContent content, YamlMap superclassContent)
        {
            superclassContent.Add(nameof(content.ContentType), Scalar(content.ContentType));

            switch (content.ContentType)
            {
            case ShapeContentType.Group:
                return(FromShapeGroup((ShapeGroup)content, superclassContent));

            case ShapeContentType.LinearGradientStroke:
            case ShapeContentType.RadialGradientStroke:
            case ShapeContentType.SolidColorStroke:
                return(FromShapeStroke((ShapeStroke)content, superclassContent));

            case ShapeContentType.LinearGradientFill:
            case ShapeContentType.RadialGradientFill:
            case ShapeContentType.SolidColorFill:
                return(FromShapeFill((ShapeFill)content, superclassContent));

            case ShapeContentType.Transform:
                return(FromTransform((Transform)content, superclassContent));

            case ShapeContentType.Path:
                return(FromPath((Path)content, superclassContent));

            case ShapeContentType.Ellipse:
                return(FromEllipse((Ellipse)content, superclassContent));

            case ShapeContentType.Rectangle:
                return(FromRectangle((Rectangle)content, superclassContent));

            case ShapeContentType.Polystar:
                return(FromPolystar((Polystar)content, superclassContent));

            case ShapeContentType.TrimPath:
                return(FromTrimPath((TrimPath)content, superclassContent));

            case ShapeContentType.MergePaths:
                return(FromMergePaths((MergePaths)content, superclassContent));

            case ShapeContentType.Repeater:
                return(FromRepeater((Repeater)content, superclassContent));

            case ShapeContentType.RoundedCorner:
                return(FromRoundedCorner((RoundedCorner)content, superclassContent));

            default:
                throw Unreachable;
            }
        }
        YamlObject FromLayer(Layer layer, YamlMap superclassContent)
        {
            superclassContent.Add("Type", layer.Type);
            superclassContent.Add("Parent", layer.Parent);
            superclassContent.Add("Index", layer.Index);
            superclassContent.Add("IsHidden", layer.IsHidden);
            superclassContent.Add("StartTime", layer.StartTime);
            superclassContent.Add("InPoint", layer.InPoint);
            superclassContent.Add("OutPoint", layer.OutPoint);
            superclassContent.Add("TimeStretch", layer.TimeStretch);
            superclassContent.Add("Transform", FromShapeLayerContent(layer.Transform));
            superclassContent.Add("Masks", FromSpan(layer.Masks, FromMask));

            switch (layer.Type)
            {
            case Layer.LayerType.PreComp:
                return(FromPreCompLayer((PreCompLayer)layer, superclassContent));

            case Layer.LayerType.Solid:
                return(FromSolidLayer((SolidLayer)layer, superclassContent));

            case Layer.LayerType.Image:
                return(FromImageLayer((ImageLayer)layer, superclassContent));

            case Layer.LayerType.Null:
                return(FromNullLayer((NullLayer)layer, superclassContent));

            case Layer.LayerType.Shape:
                return(FromShapeLayer((ShapeLayer)layer, superclassContent));

            case Layer.LayerType.Text:
                return(FromTextLayer((TextLayer)layer, superclassContent));

            default:
                throw new InvalidOperationException();
            }
        }
Пример #6
0
        YamlMap FromKeyFrame <T>(KeyFrame <T> keyFrame, Func <T, YamlObject> valueSelector)
            where T : IEquatable <T>
        {
            var result = new YamlMap
            {
                { nameof(keyFrame.Frame), keyFrame.Frame },
                { nameof(keyFrame.Value), valueSelector(keyFrame.Value) },
                { nameof(keyFrame.Easing), FromEasing(keyFrame.Easing) },
            };

            if (keyFrame is KeyFrame <Vector3> v3kf)
            {
                var cp1 = v3kf.SpatialControlPoint1;
                var cp2 = v3kf.SpatialControlPoint2;
                if (cp1 != Vector3.Zero || cp2 != Vector3.Zero)
                {
                    // Spatial Bezier
                    result.Add(nameof(v3kf.SpatialControlPoint1), FromVector3(cp1));
                    result.Add(nameof(v3kf.SpatialControlPoint2), FromVector3(cp2));
                }
            }

            return(result);
        }
        YamlMap FromKeyFrame <T>(KeyFrame <T> keyFrame, Func <T, YamlObject> valueSelector)
            where T : IEquatable <T>
        {
            var result = new YamlMap
            {
                { nameof(keyFrame.Frame), keyFrame.Frame },
                { nameof(keyFrame.Value), valueSelector(keyFrame.Value) },
                { nameof(keyFrame.Easing), FromEasing(keyFrame.Easing) },
            };

            if (keyFrame is KeyFrame <Vector3> v3kf)
            {
                if (v3kf.SpatialBezier?.IsLinear == false)
                {
                    // Spatial Bezier
                    result.Add(nameof(v3kf.SpatialBezier), FromCubicBezier(v3kf.SpatialBezier.Value));
                }
            }

            return(result);
        }
Пример #8
0
        YamlObject FromShape(Shape content, YamlMap superclassContent)
        {
            superclassContent.Add(nameof(content.DrawingDirection), Scalar(content.DrawingDirection));

            switch (content.ContentType)
            {
            case ShapeContentType.Path:
                return(FromPath((Path)content, superclassContent));

            case ShapeContentType.Ellipse:
                return(FromEllipse((Ellipse)content, superclassContent));

            case ShapeContentType.Rectangle:
                return(FromRectangle((Rectangle)content, superclassContent));

            case ShapeContentType.Polystar:
                return(FromPolystar((Polystar)content, superclassContent));

            default:
                throw Unreachable;
            }
        }
Пример #9
0
 void AddFromIRadialGradient(IRadialGradient content, YamlMap result)
 {
     AddFromIGradient(content, result);
     result.Add(nameof(content.HighlightDegrees), FromAnimatable(content.HighlightDegrees));
     result.Add(nameof(content.HighlightLength), FromAnimatable(content.HighlightLength));
 }
Пример #10
0
 void AddFromIGradient(IGradient content, YamlMap result)
 {
     result.Add(nameof(content.StartPoint), FromAnimatable(content.StartPoint));
     result.Add(nameof(content.EndPoint), FromAnimatable(content.EndPoint));
     result.Add(nameof(content.GradientStops), FromAnimatable(content.GradientStops, p => FromSequence(p, FromGradientStop)));
 }
Пример #11
0
        YamlObject FromLayer(Layer layer, YamlMap superclassContent)
        {
            superclassContent.Add(nameof(layer.Type), Scalar(layer.Type));
            superclassContent.Add(nameof(layer.Parent), layer.Parent);
            superclassContent.Add(nameof(layer.Index), layer.Index);
            superclassContent.Add(nameof(layer.IsHidden), layer.IsHidden);
            superclassContent.Add(nameof(layer.StartTime), layer.StartTime);
            superclassContent.Add(nameof(layer.InPoint), layer.InPoint);
            superclassContent.Add(nameof(layer.OutPoint), layer.OutPoint);
            superclassContent.Add(nameof(layer.TimeStretch), layer.TimeStretch);
            superclassContent.Add(nameof(layer.Transform), FromShapeLayerContent(layer.Transform));
            superclassContent.Add(nameof(layer.Masks), FromSpan(layer.Masks, FromMask));
            superclassContent.Add(nameof(layer.LayerMatteType), Scalar(layer.LayerMatteType));

            switch (layer.Type)
            {
            case Layer.LayerType.PreComp:
                return(FromPreCompLayer((PreCompLayer)layer, superclassContent));

            case Layer.LayerType.Solid:
                return(FromSolidLayer((SolidLayer)layer, superclassContent));

            case Layer.LayerType.Image:
                return(FromImageLayer((ImageLayer)layer, superclassContent));

            case Layer.LayerType.Null:
                return(FromNullLayer((NullLayer)layer, superclassContent));

            case Layer.LayerType.Shape:
                return(FromShapeLayer((ShapeLayer)layer, superclassContent));

            case Layer.LayerType.Text:
                return(FromTextLayer((TextLayer)layer, superclassContent));

            default:
                throw Unreachable;
            }
        }