YamlObject FromShapeLayerContent(ShapeLayerContent content, YamlMap superclassContent) { superclassContent.Add("MatchName", content.MatchName); superclassContent.Add("ContentType", content.ContentType); switch (content.ContentType) { case ShapeContentType.Group: return(FromShapeGroup((ShapeGroup)content, superclassContent)); case ShapeContentType.SolidColorStroke: return(FromSolidColorStroke((SolidColorStroke)content, superclassContent)); case ShapeContentType.LinearGradientStroke: return(FromLinearGradientStroke((LinearGradientStroke)content, superclassContent)); case ShapeContentType.RadialGradientStroke: return(FromRadialGradientStroke((RadialGradientStroke)content, superclassContent)); case ShapeContentType.SolidColorFill: return(FromSolidColorFill((SolidColorFill)content, superclassContent)); case ShapeContentType.LinearGradientFill: return(FromLinearGradientFill((LinearGradientFill)content, superclassContent)); case ShapeContentType.RadialGradientFill: return(FromRadialGradientFill((RadialGradientFill)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 new InvalidOperationException(); } }
XElement FromShapeLayerContent(ShapeLayerContent content) { switch (content.ContentType) { case ShapeContentType.Group: return(FromShapeGroup((ShapeGroup)content)); case ShapeContentType.SolidColorStroke: return(FromSolidColorStroke((SolidColorStroke)content)); case ShapeContentType.LinearGradientStroke: return(FromLinearGradientStroke((LinearGradientStroke)content)); case ShapeContentType.RadialGradientStroke: return(FromRadialGradientStroke((RadialGradientStroke)content)); case ShapeContentType.SolidColorFill: return(FromSolidColorFill((SolidColorFill)content)); case ShapeContentType.LinearGradientFill: return(FromLinearGradientFill((LinearGradientFill)content)); case ShapeContentType.RadialGradientFill: return(FromRadialGradientFill((RadialGradientFill)content)); case ShapeContentType.Transform: return(FromTransform((Transform)content)); case ShapeContentType.Path: return(FromPath((Path)content)); case ShapeContentType.Ellipse: return(FromEllipse((Ellipse)content)); case ShapeContentType.Rectangle: return(FromRectangle((Rectangle)content)); case ShapeContentType.Polystar: return(FromPolystar((Polystar)content)); case ShapeContentType.TrimPath: return(FromTrimPath((TrimPath)content)); case ShapeContentType.MergePaths: return(FromMergePaths((MergePaths)content)); case ShapeContentType.Repeater: return(FromRepeater((Repeater)content)); case ShapeContentType.RoundedCorner: return(FromRoundedCorner((RoundedCorner)content)); default: throw Unreachable; } }
IEnumerable <XObject> GetShapeLayerContentContents(ShapeLayerContent content) { foreach (var item in GetLottieObjectContents(content)) { yield return(item); } if (!string.IsNullOrWhiteSpace(content.MatchName)) { yield return(new XAttribute(nameof(content.MatchName), content.MatchName)); } }
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 FromShapeLayerContent(ShapeLayerContent content) => FromShapeLayerContent(content, GetLottieObjectContent(content));
void VisitShapeLayerContent(ShapeLayerContent content) { switch (content.ContentType) { case ShapeContentType.Ellipse: break; case ShapeContentType.Group: VisitShapeGroup((ShapeGroup)content); break; case ShapeContentType.LinearGradientFill: LinearGradientFillCount++; break; case ShapeContentType.LinearGradientStroke: LinearGradientStrokeCount++; break; case ShapeContentType.MergePaths: break; case ShapeContentType.Path: break; case ShapeContentType.Polystar: break; case ShapeContentType.RadialGradientFill: RadialGradientFillCount++; break; case ShapeContentType.RadialGradientStroke: RadialGradientStrokeCount++; break; case ShapeContentType.Rectangle: break; case ShapeContentType.Repeater: break; case ShapeContentType.RoundCorners: break; case ShapeContentType.SolidColorFill: break; case ShapeContentType.SolidColorStroke: break; case ShapeContentType.Transform: break; case ShapeContentType.TrimPath: break; default: throw new InvalidOperationException(); } }