lottie-ios 3.2.2 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/actions/setup/action.yml +32 -0
- package/.github/issue_template.md +6 -23
- package/.github/workflows/main.yml +98 -0
- package/.spi.yml +6 -0
- package/.swift-version +1 -0
- package/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +7 -0
- package/.swiftpm/xcode/package.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/.swiftpm/xcode/xcuserdata/{brandonwithrow.xcuserdatad → cal.xcuserdatad}/xcschemes/xcschememanagement.plist +25 -15
- package/.swiftpm/xcode/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/Gemfile +4 -0
- package/Gemfile.lock +102 -0
- package/Lottie.xcodeproj/project.pbxproj +2003 -1972
- package/Lottie.xcodeproj/project.xcworkspace/contents.xcworkspacedata +1 -1
- package/Lottie.xcodeproj/project.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/Lottie.xcodeproj/xcshareddata/xcschemes/{Lottie_iOS.xcscheme → Lottie (iOS).xcscheme } +15 -18
- package/Lottie.xcodeproj/xcshareddata/xcschemes/{Lottie_macOS.xcscheme → Lottie (macOS).xcscheme } +7 -20
- package/Lottie.xcodeproj/xcshareddata/xcschemes/{Lottie_tvOS.xcscheme → Lottie (tvOS).xcscheme } +5 -18
- package/Lottie.xcodeproj/xcuserdata/cal.xcuserdatad/xcschemes/xcschememanagement.plist +37 -0
- package/Lottie.xcodeproj/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +24 -0
- package/Lottie.xcworkspace/contents.xcworkspacedata +10 -0
- package/Lottie.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/Lottie.xcworkspace/xcshareddata/swiftpm/Package.resolved +115 -0
- package/Lottie.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/{Lottie.xcodeproj/xcuserdata/brandonwithrow.xcuserdatad → Lottie.xcworkspace/xcuserdata/cal.xcuserdatad}/xcdebugger/Breakpoints_v2.xcbkptlist +2 -2
- package/Lottie.xcworkspace/xcuserdata/cal.xcuserdatad/xcdebugger/Expressions.xcexplist +153 -0
- package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +39 -0
- package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/xcdebugger/Expressions.xcexplist +25 -0
- package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +30 -0
- package/Package.resolved +88 -0
- package/Package.swift +10 -15
- package/README.md +40 -60
- package/Rakefile +121 -0
- package/Sources/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift +81 -0
- package/Sources/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +448 -0
- package/Sources/Private/CoreAnimation/Animations/CombinedShapeAnimation.swift +53 -0
- package/Sources/Private/CoreAnimation/Animations/CustomPathAnimation.swift +41 -0
- package/Sources/Private/CoreAnimation/Animations/EllipseAnimation.swift +28 -0
- package/Sources/Private/CoreAnimation/Animations/GradientAnimations.swift +210 -0
- package/Sources/Private/CoreAnimation/Animations/LayerProperty.swift +229 -0
- package/Sources/Private/CoreAnimation/Animations/OpacityAnimation.swift +52 -0
- package/Sources/Private/CoreAnimation/Animations/RectangleAnimation.swift +31 -0
- package/Sources/Private/CoreAnimation/Animations/ShapeAnimation.swift +246 -0
- package/Sources/Private/CoreAnimation/Animations/StarAnimation.swift +95 -0
- package/Sources/Private/CoreAnimation/Animations/StrokeAnimation.swift +70 -0
- package/Sources/Private/CoreAnimation/Animations/TransformAnimations.swift +205 -0
- package/Sources/Private/CoreAnimation/Animations/VisibilityAnimation.swift +37 -0
- package/Sources/Private/CoreAnimation/CompatibilityTracker.swift +130 -0
- package/Sources/Private/CoreAnimation/CoreAnimationLayer.swift +492 -0
- package/Sources/Private/CoreAnimation/Extensions/CALayer+fillBounds.swift +35 -0
- package/Sources/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift +37 -0
- package/Sources/Private/CoreAnimation/Extensions/Keyframes+combinedIfPossible.swift +73 -0
- package/Sources/Private/CoreAnimation/Layers/AnimationLayer.swift +83 -0
- package/Sources/Private/CoreAnimation/Layers/BaseAnimationLayer.swift +33 -0
- package/Sources/Private/CoreAnimation/Layers/BaseCompositionLayer.swift +87 -0
- package/Sources/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +131 -0
- package/Sources/Private/CoreAnimation/Layers/GradientRenderLayer.swift +94 -0
- package/Sources/Private/CoreAnimation/Layers/ImageLayer.swift +79 -0
- package/Sources/Private/CoreAnimation/Layers/LayerModel+makeAnimationLayer.swift +60 -0
- package/Sources/Private/CoreAnimation/Layers/MaskCompositionLayer.swift +138 -0
- package/Sources/Private/CoreAnimation/Layers/PreCompLayer.swift +140 -0
- package/Sources/Private/CoreAnimation/Layers/ShapeItemLayer.swift +302 -0
- package/Sources/Private/CoreAnimation/Layers/ShapeLayer.swift +319 -0
- package/Sources/Private/CoreAnimation/Layers/SolidLayer.swift +47 -0
- package/Sources/Private/CoreAnimation/Layers/TextLayer.swift +91 -0
- package/Sources/Private/CoreAnimation/Layers/TransformLayer.swift +11 -0
- package/Sources/Private/CoreAnimation/ValueProviderStore.swift +139 -0
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/CompositionLayer.swift +93 -85
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/ImageCompositionLayer.swift +24 -21
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/MaskContainerLayer.swift +75 -54
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/NullCompositionLayer.swift +5 -5
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/PreCompositionLayer.swift +61 -44
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/ShapeCompositionLayer.swift +22 -20
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/SolidCompositionLayer.swift +26 -17
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/CompLayers/TextCompositionLayer.swift +42 -36
- package/{lottie-swift/src/Private/LayerContainers/AnimationContainer.swift → Sources/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift} +200 -140
- package/Sources/Private/MainThread/LayerContainers/Utility/CachedImageProvider.swift +47 -0
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/Utility/CompositionLayersInitializer.swift +33 -24
- package/{lottie-swift/src/Private/LayerContainers/Utility/TextLayer.swift → Sources/Private/MainThread/LayerContainers/Utility/CoreTextRenderLayer.swift} +120 -106
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/Utility/InvertedMatteLayer.swift +25 -24
- package/Sources/Private/MainThread/LayerContainers/Utility/LayerFontProvider.swift +41 -0
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/Utility/LayerImageProvider.swift +20 -16
- package/Sources/Private/MainThread/LayerContainers/Utility/LayerTextProvider.swift +40 -0
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/LayerContainers/Utility/LayerTransformNode.swift +82 -67
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Extensions/ItemsExtension.swift +4 -4
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/NodeProperty.swift +29 -21
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.swift +16 -10
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.swift +6 -6
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/Protocols/KeypathSearchable.swift +5 -5
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.swift +10 -8
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/ValueContainer.swift +25 -21
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift +23 -17
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/ValueProviders/KeyframeInterpolator.swift +125 -108
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.swift +22 -17
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift +110 -79
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/GroupOutputNode.swift +22 -16
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.swift +19 -15
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/PathOutputNode.swift +22 -20
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/Renderables/FillRenderer.swift +22 -23
- package/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift +242 -0
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientStrokeRenderer.swift +30 -24
- package/{lottie-swift/src/Private/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift → Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/LegacyGradientFillRenderer.swift} +93 -66
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift +23 -19
- package/Sources/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +139 -0
- package/Sources/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +170 -0
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/PathNodes/RectNode.swift +95 -58
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/PathNodes/ShapeNode.swift +42 -29
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/PathNodes/StarNode.swift +108 -69
- package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +155 -0
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/RenderNodes/FillNode.swift +51 -37
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/RenderNodes/GradientFillNode.swift +54 -42
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/RenderNodes/GradientStrokeNode.swift +65 -57
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +84 -58
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +138 -119
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Protocols/AnimatorNode.swift +80 -79
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Protocols/PathNode.swift +5 -3
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/Protocols/RenderNode.swift +22 -17
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift +27 -24
- package/{lottie-swift/src/Private → Sources/Private/MainThread}/NodeRenderSystem/RenderLayers/ShapeRenderLayer.swift +34 -25
- package/Sources/Private/Model/Animation.swift +160 -0
- package/Sources/Private/Model/Assets/Asset.swift +43 -0
- package/{lottie-swift/src → Sources}/Private/Model/Assets/AssetLibrary.swift +40 -13
- package/Sources/Private/Model/Assets/ImageAsset.swift +112 -0
- package/{lottie-swift/src → Sources}/Private/Model/Assets/PrecompAsset.swift +20 -10
- package/Sources/Private/Model/DictionaryInitializable.swift +67 -0
- package/Sources/Private/Model/Extensions/Bundle.swift +34 -0
- package/{lottie-swift/src → Sources}/Private/Model/Extensions/KeyedDecodingContainerExtensions.swift +8 -4
- package/Sources/Private/Model/Keyframes/KeyframeData.swift +113 -0
- package/Sources/Private/Model/Keyframes/KeyframeGroup.swift +197 -0
- package/{lottie-swift/src → Sources}/Private/Model/Layers/ImageLayerModel.swift +21 -11
- package/Sources/Private/Model/Layers/LayerModel.swift +228 -0
- package/{lottie-swift/src → Sources}/Private/Model/Layers/PreCompLayerModel.swift +39 -22
- package/{lottie-swift/src → Sources}/Private/Model/Layers/ShapeLayerModel.swift +23 -12
- package/{lottie-swift/src → Sources}/Private/Model/Layers/SolidLayerModel.swift +31 -19
- package/{lottie-swift/src → Sources}/Private/Model/Layers/TextLayerModel.swift +33 -19
- package/Sources/Private/Model/Objects/DashPattern.swift +44 -0
- package/Sources/Private/Model/Objects/Marker.swift +33 -0
- package/Sources/Private/Model/Objects/Mask.swift +80 -0
- package/Sources/Private/Model/Objects/Transform.swift +179 -0
- package/Sources/Private/Model/ShapeItems/Ellipse.swift +75 -0
- package/Sources/Private/Model/ShapeItems/Fill.swift +74 -0
- package/Sources/Private/Model/ShapeItems/GradientFill.swift +124 -0
- package/Sources/Private/Model/ShapeItems/GradientStroke.swift +186 -0
- package/Sources/Private/Model/ShapeItems/Group.swift +48 -0
- package/{lottie-swift/src → Sources}/Private/Model/ShapeItems/Merge.swift +29 -11
- package/Sources/Private/Model/ShapeItems/Rectangle.swift +73 -0
- package/Sources/Private/Model/ShapeItems/Repeater.swift +136 -0
- package/Sources/Private/Model/ShapeItems/Shape.swift +56 -0
- package/Sources/Private/Model/ShapeItems/ShapeItem.swift +163 -0
- package/Sources/Private/Model/ShapeItems/ShapeTransform.swift +136 -0
- package/Sources/Private/Model/ShapeItems/Star.swift +132 -0
- package/Sources/Private/Model/ShapeItems/Stroke.swift +102 -0
- package/Sources/Private/Model/ShapeItems/Trim.swift +78 -0
- package/Sources/Private/Model/Text/Font.swift +61 -0
- package/{lottie-swift/src → Sources}/Private/Model/Text/Glyph.swift +63 -39
- package/Sources/Private/Model/Text/TextAnimator.swift +164 -0
- package/Sources/Private/Model/Text/TextDocument.swift +123 -0
- package/Sources/Private/RootAnimationLayer.swift +51 -0
- package/{lottie-swift/src → Sources}/Private/Utility/Debugging/AnimatorNodeDebugging.swift +7 -7
- package/{lottie-swift/src → Sources}/Private/Utility/Debugging/LayerDebugging.swift +72 -48
- package/Sources/Private/Utility/Debugging/TestHelpers.swift +10 -0
- package/{lottie-swift/src → Sources}/Private/Utility/Extensions/AnimationKeypathExtension.swift +69 -59
- package/Sources/Private/Utility/Extensions/BlendMode+Filter.swift +31 -0
- package/Sources/Private/Utility/Extensions/CGColor+RGB.swift +22 -0
- package/{lottie-swift/src → Sources}/Private/Utility/Extensions/CGFloatExtensions.swift +70 -67
- package/Sources/Private/Utility/Extensions/DataExtension.swift +27 -0
- package/Sources/Private/Utility/Extensions/MathKit.swift +450 -0
- package/Sources/Private/Utility/Extensions/StringExtensions.swift +38 -0
- package/{lottie-swift/src → Sources}/Private/Utility/Helpers/AnimationContext.swift +42 -16
- package/Sources/Private/Utility/Interpolatable/InterpolatableExtensions.swift +134 -0
- package/{lottie-swift/src → Sources}/Private/Utility/Interpolatable/KeyframeExtensions.swift +13 -10
- package/Sources/Private/Utility/Interpolatable/KeyframeGroup+Extensions.swift +59 -0
- package/{lottie-swift/src → Sources}/Private/Utility/Primitives/BezierPath.swift +229 -143
- package/Sources/Private/Utility/Primitives/CGPointExtension.swift +35 -0
- package/{lottie-swift/src → Sources}/Private/Utility/Primitives/ColorExtension.swift +46 -14
- package/{lottie-swift/src → Sources}/Private/Utility/Primitives/CompoundBezierPath.swift +58 -49
- package/Sources/Private/Utility/Primitives/CurveVertex.swift +184 -0
- package/Sources/Private/Utility/Primitives/PathElement.swift +75 -0
- package/Sources/Private/Utility/Primitives/UnitBezier.swift +115 -0
- package/Sources/Private/Utility/Primitives/VectorsExtensions.swift +341 -0
- package/Sources/Public/Animation/AnimationPublic.swift +266 -0
- package/Sources/Public/Animation/AnimationView.swift +1335 -0
- package/Sources/Public/Animation/AnimationViewInitializers.swift +109 -0
- package/Sources/Public/AnimationCache/AnimationCacheProvider.swift +22 -0
- package/{lottie-swift/src → Sources}/Public/AnimationCache/LRUAnimationCache.swift +22 -18
- package/Sources/Public/DynamicProperties/AnimationKeypath.swift +49 -0
- package/Sources/Public/DynamicProperties/AnyValueProvider.swift +132 -0
- package/{lottie-swift/src → Sources}/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +54 -36
- package/{lottie-swift/src → Sources}/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +40 -36
- package/Sources/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +123 -0
- package/{lottie-swift/src → Sources}/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +40 -35
- package/{lottie-swift/src → Sources}/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +40 -35
- package/{lottie-swift/src → Sources}/Public/FontProvider/AnimationFontProvider.swift +15 -8
- package/Sources/Public/ImageProvider/AnimationImageProvider.swift +21 -0
- package/Sources/Public/Keyframes/Interpolatable.swift +253 -0
- package/Sources/Public/Keyframes/Keyframe.swift +92 -0
- package/Sources/Public/Logging/LottieLogger.swift +137 -0
- package/Sources/Public/LottieConfiguration.swift +143 -0
- package/{lottie-swift/src → Sources}/Public/Primitives/AnimationTime.swift +1 -1
- package/{lottie-swift/src → Sources}/Public/Primitives/Color.swift +10 -6
- package/{lottie-swift/src → Sources}/Public/Primitives/Vectors.swift +13 -12
- package/Sources/Public/TextProvider/AnimationTextProvider.swift +53 -0
- package/{lottie-swift/src → Sources}/Public/iOS/AnimatedButton.swift +42 -26
- package/{lottie-swift/src → Sources}/Public/iOS/AnimatedControl.swift +100 -91
- package/{lottie-swift/src → Sources}/Public/iOS/AnimatedSwitch.swift +128 -94
- package/{lottie-swift/src → Sources}/Public/iOS/AnimationSubview.swift +3 -3
- package/Sources/Public/iOS/AnimationViewBase.swift +78 -0
- package/{lottie-swift/src → Sources}/Public/iOS/BundleImageProvider.swift +36 -34
- package/{lottie-swift/src → Sources}/Public/iOS/Compatibility/CompatibleAnimationKeypath.swift +4 -0
- package/{lottie-swift/src → Sources}/Public/iOS/Compatibility/CompatibleAnimationView.swift +38 -29
- package/{lottie-swift/src → Sources}/Public/iOS/FilepathImageProvider.swift +24 -21
- package/{lottie-swift/src → Sources}/Public/iOS/UIColorExtension.swift +4 -4
- package/{lottie-swift/src/Public/MacOS/AnimationSubview.swift → Sources/Public/macOS/AnimationSubview.macOS.swift} +4 -5
- package/{lottie-swift/src/Public/MacOS/LottieView.swift → Sources/Public/macOS/AnimationViewBase.macOS.swift} +58 -50
- package/{lottie-swift/src/Public/MacOS/BundleImageProvider.swift → Sources/Public/macOS/BundleImageProvider.macOS.swift} +31 -32
- package/Sources/Public/macOS/FilepathImageProvider.macOS.swift +67 -0
- package/Tests/AnimationKeypathTests.swift +94 -0
- package/Tests/AutomaticEngineTests.swift +57 -0
- package/Tests/BundleTests.swift +25 -0
- package/Tests/DataURLTests.swift +64 -0
- package/Tests/ParsingTests.swift +43 -0
- package/Tests/PerformanceTests.swift +215 -0
- package/Tests/SnapshotConfiguration.swift +153 -0
- package/Tests/SnapshotTests.swift +265 -0
- package/Tests/Utils/Bundle+Module.swift +30 -0
- package/Tests/Utils/HardcodedFontProvider.swift +19 -0
- package/Tests/Utils/HardcodedImageProvider.swift +23 -0
- package/Tests/Utils/Snapshotting+presentationLayer.swift +47 -0
- package/Tests/ValueProvidersTests.swift +27 -0
- package/lottie-ios.podspec +11 -12
- package/package.json +1 -1
- package/script/test-carthage/Cartfile +1 -0
- package/script/test-carthage/Cartfile.resolved +1 -0
- package/script/test-carthage/CarthageTest/AppDelegate.swift +26 -0
- package/script/test-carthage/CarthageTest/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/script/test-carthage/CarthageTest/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
- package/script/test-carthage/CarthageTest/Assets.xcassets/Contents.json +6 -0
- package/script/test-carthage/CarthageTest/Base.lproj/LaunchScreen.storyboard +25 -0
- package/script/test-carthage/CarthageTest/Base.lproj/Main.storyboard +24 -0
- package/script/test-carthage/CarthageTest/Info.plist +66 -0
- package/script/test-carthage/CarthageTest/SceneDelegate.swift +10 -0
- package/script/test-carthage/CarthageTest/ViewController.swift +15 -0
- package/script/test-carthage/CarthageTest-macOS/AppDelegate.swift +7 -0
- package/script/test-carthage/CarthageTest-macOS/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/script/test-carthage/CarthageTest-macOS/Assets.xcassets/AppIcon.appiconset/Contents.json +58 -0
- package/script/test-carthage/CarthageTest-macOS/Assets.xcassets/Contents.json +6 -0
- package/script/test-carthage/CarthageTest-macOS/Base.lproj/Main.storyboard +717 -0
- package/script/test-carthage/CarthageTest-macOS/CarthageTest_macOS.entitlements +10 -0
- package/script/test-carthage/CarthageTest-macOS/ViewController.swift +15 -0
- package/script/test-carthage/CarthageTest.xcodeproj/project.pbxproj +532 -0
- package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/script/test-carthage/CarthageTest.xcodeproj/project.xcworkspace/xcuserdata/calstephens.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/script/test-carthage/CarthageTest.xcodeproj/xcuserdata/cal.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/script/test-carthage/CarthageTest.xcodeproj/xcuserdata/calstephens.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
- package/script/test-carthage/Mintfile +1 -0
- package/script/test-spm/LottieSPM.xcworkspace/contents.xcworkspacedata +7 -0
- package/script/test-spm/LottieSPM.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/script/test-spm/Mintfile +1 -0
- package/.swiftpm/xcode/package.xcworkspace/xcuserdata/brandonwithrow.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/Lottie/Info.plist +0 -22
- package/Lottie.xcodeproj/project.xcworkspace/xcuserdata/brandonwithrow.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/Lottie.xcodeproj/xcuserdata/brandonwithrow.xcuserdatad/xcschemes/LottieLibraryMacOS.xcscheme +0 -80
- package/Lottie.xcodeproj/xcuserdata/brandonwithrow.xcuserdatad/xcschemes/xcschememanagement.plist +0 -57
- package/lottie-swift/Assets/.gitkeep +0 -0
- package/lottie-swift/src/Private/LayerContainers/Utility/LayerFontProvider.swift +0 -37
- package/lottie-swift/src/Private/LayerContainers/Utility/LayerTextProvider.swift +0 -36
- package/lottie-swift/src/Private/Model/Animation.swift +0 -107
- package/lottie-swift/src/Private/Model/Assets/Asset.swift +0 -27
- package/lottie-swift/src/Private/Model/Assets/ImageAsset.swift +0 -48
- package/lottie-swift/src/Private/Model/Keyframes/Keyframe.swift +0 -128
- package/lottie-swift/src/Private/Model/Keyframes/KeyframeGroup.swift +0 -108
- package/lottie-swift/src/Private/Model/Layers/LayerModel.swift +0 -150
- package/lottie-swift/src/Private/Model/Objects/DashPattern.swift +0 -24
- package/lottie-swift/src/Private/Model/Objects/Marker.swift +0 -23
- package/lottie-swift/src/Private/Model/Objects/Mask.swift +0 -48
- package/lottie-swift/src/Private/Model/Objects/Transform.swift +0 -105
- package/lottie-swift/src/Private/Model/ShapeItems/Ellipse.swift +0 -50
- package/lottie-swift/src/Private/Model/ShapeItems/FillI.swift +0 -49
- package/lottie-swift/src/Private/Model/ShapeItems/GradientFill.swift +0 -86
- package/lottie-swift/src/Private/Model/ShapeItems/GradientStroke.swift +0 -125
- package/lottie-swift/src/Private/Model/ShapeItems/Group.swift +0 -32
- package/lottie-swift/src/Private/Model/ShapeItems/Rectangle.swift +0 -50
- package/lottie-swift/src/Private/Model/ShapeItems/Repeater.swift +0 -80
- package/lottie-swift/src/Private/Model/ShapeItems/Shape.swift +0 -37
- package/lottie-swift/src/Private/Model/ShapeItems/ShapeItem.swift +0 -95
- package/lottie-swift/src/Private/Model/ShapeItems/ShapeTransform.swift +0 -68
- package/lottie-swift/src/Private/Model/ShapeItems/Star.swift +0 -86
- package/lottie-swift/src/Private/Model/ShapeItems/Stroke.swift +0 -67
- package/lottie-swift/src/Private/Model/ShapeItems/Trim.swift +0 -53
- package/lottie-swift/src/Private/Model/Text/Font.swift +0 -35
- package/lottie-swift/src/Private/Model/Text/TextAnimator.swift +0 -99
- package/lottie-swift/src/Private/Model/Text/TextDocument.swift +0 -70
- package/lottie-swift/src/Private/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +0 -109
- package/lottie-swift/src/Private/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +0 -132
- package/lottie-swift/src/Private/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +0 -141
- package/lottie-swift/src/Private/Utility/Extensions/MathKit.swift +0 -539
- package/lottie-swift/src/Private/Utility/Extensions/StringExtensions.swift +0 -32
- package/lottie-swift/src/Private/Utility/Interpolatable/Interpolatable.swift +0 -18
- package/lottie-swift/src/Private/Utility/Interpolatable/InterpolatableExtensions.swift +0 -170
- package/lottie-swift/src/Private/Utility/Primitives/CurveVertex.swift +0 -177
- package/lottie-swift/src/Private/Utility/Primitives/PathElement.swift +0 -68
- package/lottie-swift/src/Private/Utility/Primitives/VectorsExtensions.swift +0 -218
- package/lottie-swift/src/Public/Animation/AnimationPublic.swift +0 -196
- package/lottie-swift/src/Public/Animation/AnimationView.swift +0 -1006
- package/lottie-swift/src/Public/Animation/AnimationViewInitializers.swift +0 -83
- package/lottie-swift/src/Public/AnimationCache/AnimationCacheProvider.swift +0 -24
- package/lottie-swift/src/Public/DynamicProperties/AnimationKeypath.swift +0 -46
- package/lottie-swift/src/Public/DynamicProperties/AnyValueProvider.swift +0 -29
- package/lottie-swift/src/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +0 -114
- package/lottie-swift/src/Public/ImageProvider/AnimationImageProvider.swift +0 -23
- package/lottie-swift/src/Public/MacOS/FilepathImageProvider.swift +0 -67
- package/lottie-swift/src/Public/TextProvider/AnimationTextProvider.swift +0 -39
- package/lottie-swift/src/Public/iOS/LottieView.swift +0 -62
- package/lottie-swift-testing.podspec +0 -32
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Star.swift
|
|
3
|
+
// lottie-swift
|
|
4
|
+
//
|
|
5
|
+
// Created by Brandon Withrow on 1/8/19.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
// MARK: - StarType
|
|
11
|
+
|
|
12
|
+
enum StarType: Int, Codable {
|
|
13
|
+
case none
|
|
14
|
+
case star
|
|
15
|
+
case polygon
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// MARK: - Star
|
|
19
|
+
|
|
20
|
+
/// An item that define an ellipse shape
|
|
21
|
+
final class Star: ShapeItem {
|
|
22
|
+
|
|
23
|
+
// MARK: Lifecycle
|
|
24
|
+
|
|
25
|
+
required init(from decoder: Decoder) throws {
|
|
26
|
+
let container = try decoder.container(keyedBy: Star.CodingKeys.self)
|
|
27
|
+
direction = try container.decodeIfPresent(PathDirection.self, forKey: .direction) ?? .clockwise
|
|
28
|
+
position = try container.decode(KeyframeGroup<Vector3D>.self, forKey: .position)
|
|
29
|
+
outerRadius = try container.decode(KeyframeGroup<Vector1D>.self, forKey: .outerRadius)
|
|
30
|
+
outerRoundness = try container.decode(KeyframeGroup<Vector1D>.self, forKey: .outerRoundness)
|
|
31
|
+
innerRadius = try container.decodeIfPresent(KeyframeGroup<Vector1D>.self, forKey: .innerRadius)
|
|
32
|
+
innerRoundness = try container.decodeIfPresent(KeyframeGroup<Vector1D>.self, forKey: .innerRoundness)
|
|
33
|
+
rotation = try container.decode(KeyframeGroup<Vector1D>.self, forKey: .rotation)
|
|
34
|
+
points = try container.decode(KeyframeGroup<Vector1D>.self, forKey: .points)
|
|
35
|
+
starType = try container.decode(StarType.self, forKey: .starType)
|
|
36
|
+
try super.init(from: decoder)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
required init(dictionary: [String: Any]) throws {
|
|
40
|
+
if
|
|
41
|
+
let directionRawValue = dictionary[CodingKeys.direction.rawValue] as? Int,
|
|
42
|
+
let direction = PathDirection(rawValue: directionRawValue)
|
|
43
|
+
{
|
|
44
|
+
self.direction = direction
|
|
45
|
+
} else {
|
|
46
|
+
direction = .clockwise
|
|
47
|
+
}
|
|
48
|
+
let positionDictionary: [String: Any] = try dictionary.value(for: CodingKeys.position)
|
|
49
|
+
position = try KeyframeGroup<Vector3D>(dictionary: positionDictionary)
|
|
50
|
+
let outerRadiusDictionary: [String: Any] = try dictionary.value(for: CodingKeys.outerRadius)
|
|
51
|
+
outerRadius = try KeyframeGroup<Vector1D>(dictionary: outerRadiusDictionary)
|
|
52
|
+
let outerRoundnessDictionary: [String: Any] = try dictionary.value(for: CodingKeys.outerRoundness)
|
|
53
|
+
outerRoundness = try KeyframeGroup<Vector1D>(dictionary: outerRoundnessDictionary)
|
|
54
|
+
if let innerRadiusDictionary = dictionary[CodingKeys.innerRadius.rawValue] as? [String: Any] {
|
|
55
|
+
innerRadius = try KeyframeGroup<Vector1D>(dictionary: innerRadiusDictionary)
|
|
56
|
+
} else {
|
|
57
|
+
innerRadius = nil
|
|
58
|
+
}
|
|
59
|
+
if let innerRoundnessDictionary = dictionary[CodingKeys.innerRoundness.rawValue] as? [String: Any] {
|
|
60
|
+
innerRoundness = try KeyframeGroup<Vector1D>(dictionary: innerRoundnessDictionary)
|
|
61
|
+
} else {
|
|
62
|
+
innerRoundness = nil
|
|
63
|
+
}
|
|
64
|
+
let rotationDictionary: [String: Any] = try dictionary.value(for: CodingKeys.rotation)
|
|
65
|
+
rotation = try KeyframeGroup<Vector1D>(dictionary: rotationDictionary)
|
|
66
|
+
let pointsDictionary: [String: Any] = try dictionary.value(for: CodingKeys.points)
|
|
67
|
+
points = try KeyframeGroup<Vector1D>(dictionary: pointsDictionary)
|
|
68
|
+
let starTypeRawValue: Int = try dictionary.value(for: CodingKeys.starType)
|
|
69
|
+
guard let starType = StarType(rawValue: starTypeRawValue) else {
|
|
70
|
+
throw InitializableError.invalidInput
|
|
71
|
+
}
|
|
72
|
+
self.starType = starType
|
|
73
|
+
try super.init(dictionary: dictionary)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// MARK: Internal
|
|
77
|
+
|
|
78
|
+
/// The direction of the star.
|
|
79
|
+
let direction: PathDirection
|
|
80
|
+
|
|
81
|
+
/// The position of the star
|
|
82
|
+
let position: KeyframeGroup<Vector3D>
|
|
83
|
+
|
|
84
|
+
/// The outer radius of the star
|
|
85
|
+
let outerRadius: KeyframeGroup<Vector1D>
|
|
86
|
+
|
|
87
|
+
/// The outer roundness of the star
|
|
88
|
+
let outerRoundness: KeyframeGroup<Vector1D>
|
|
89
|
+
|
|
90
|
+
/// The outer radius of the star
|
|
91
|
+
let innerRadius: KeyframeGroup<Vector1D>?
|
|
92
|
+
|
|
93
|
+
/// The outer roundness of the star
|
|
94
|
+
let innerRoundness: KeyframeGroup<Vector1D>?
|
|
95
|
+
|
|
96
|
+
/// The rotation of the star
|
|
97
|
+
let rotation: KeyframeGroup<Vector1D>
|
|
98
|
+
|
|
99
|
+
/// The number of points on the star
|
|
100
|
+
let points: KeyframeGroup<Vector1D>
|
|
101
|
+
|
|
102
|
+
/// The type of star
|
|
103
|
+
let starType: StarType
|
|
104
|
+
|
|
105
|
+
override func encode(to encoder: Encoder) throws {
|
|
106
|
+
try super.encode(to: encoder)
|
|
107
|
+
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
108
|
+
try container.encode(direction, forKey: .direction)
|
|
109
|
+
try container.encode(position, forKey: .position)
|
|
110
|
+
try container.encode(outerRadius, forKey: .outerRadius)
|
|
111
|
+
try container.encode(outerRoundness, forKey: .outerRoundness)
|
|
112
|
+
try container.encode(innerRadius, forKey: .innerRadius)
|
|
113
|
+
try container.encode(innerRoundness, forKey: .innerRoundness)
|
|
114
|
+
try container.encode(rotation, forKey: .rotation)
|
|
115
|
+
try container.encode(points, forKey: .points)
|
|
116
|
+
try container.encode(starType, forKey: .starType)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// MARK: Private
|
|
120
|
+
|
|
121
|
+
private enum CodingKeys: String, CodingKey {
|
|
122
|
+
case direction = "d"
|
|
123
|
+
case position = "p"
|
|
124
|
+
case outerRadius = "or"
|
|
125
|
+
case outerRoundness = "os"
|
|
126
|
+
case innerRadius = "ir"
|
|
127
|
+
case innerRoundness = "is"
|
|
128
|
+
case rotation = "r"
|
|
129
|
+
case points = "pt"
|
|
130
|
+
case starType = "sy"
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Stroke.swift
|
|
3
|
+
// lottie-swift
|
|
4
|
+
//
|
|
5
|
+
// Created by Brandon Withrow on 1/8/19.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
/// An item that define an ellipse shape
|
|
11
|
+
final class Stroke: ShapeItem {
|
|
12
|
+
|
|
13
|
+
// MARK: Lifecycle
|
|
14
|
+
|
|
15
|
+
required init(from decoder: Decoder) throws {
|
|
16
|
+
let container = try decoder.container(keyedBy: Stroke.CodingKeys.self)
|
|
17
|
+
opacity = try container.decode(KeyframeGroup<Vector1D>.self, forKey: .opacity)
|
|
18
|
+
color = try container.decode(KeyframeGroup<Color>.self, forKey: .color)
|
|
19
|
+
width = try container.decode(KeyframeGroup<Vector1D>.self, forKey: .width)
|
|
20
|
+
lineCap = try container.decodeIfPresent(LineCap.self, forKey: .lineCap) ?? .round
|
|
21
|
+
lineJoin = try container.decodeIfPresent(LineJoin.self, forKey: .lineJoin) ?? .round
|
|
22
|
+
miterLimit = try container.decodeIfPresent(Double.self, forKey: .miterLimit) ?? 4
|
|
23
|
+
dashPattern = try container.decodeIfPresent([DashElement].self, forKey: .dashPattern)
|
|
24
|
+
try super.init(from: decoder)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
required init(dictionary: [String: Any]) throws {
|
|
28
|
+
let opacityDictionary: [String: Any] = try dictionary.value(for: CodingKeys.opacity)
|
|
29
|
+
opacity = try KeyframeGroup<Vector1D>(dictionary: opacityDictionary)
|
|
30
|
+
let colorDictionary: [String: Any] = try dictionary.value(for: CodingKeys.color)
|
|
31
|
+
color = try KeyframeGroup<Color>(dictionary: colorDictionary)
|
|
32
|
+
let widthDictionary: [String: Any] = try dictionary.value(for: CodingKeys.width)
|
|
33
|
+
width = try KeyframeGroup<Vector1D>(dictionary: widthDictionary)
|
|
34
|
+
if
|
|
35
|
+
let lineCapRawValue = dictionary[CodingKeys.lineCap.rawValue] as? Int,
|
|
36
|
+
let lineCap = LineCap(rawValue: lineCapRawValue)
|
|
37
|
+
{
|
|
38
|
+
self.lineCap = lineCap
|
|
39
|
+
} else {
|
|
40
|
+
lineCap = .round
|
|
41
|
+
}
|
|
42
|
+
if
|
|
43
|
+
let lineJoinRawValue = dictionary[CodingKeys.lineJoin.rawValue] as? Int,
|
|
44
|
+
let lineJoin = LineJoin(rawValue: lineJoinRawValue)
|
|
45
|
+
{
|
|
46
|
+
self.lineJoin = lineJoin
|
|
47
|
+
} else {
|
|
48
|
+
lineJoin = .round
|
|
49
|
+
}
|
|
50
|
+
miterLimit = (try? dictionary.value(for: CodingKeys.miterLimit)) ?? 4
|
|
51
|
+
let dashPatternDictionaries = dictionary[CodingKeys.dashPattern.rawValue] as? [[String: Any]]
|
|
52
|
+
dashPattern = try? dashPatternDictionaries?.map({ try DashElement(dictionary: $0) })
|
|
53
|
+
try super.init(dictionary: dictionary)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// MARK: Internal
|
|
57
|
+
|
|
58
|
+
/// The opacity of the stroke
|
|
59
|
+
let opacity: KeyframeGroup<Vector1D>
|
|
60
|
+
|
|
61
|
+
/// The Color of the stroke
|
|
62
|
+
let color: KeyframeGroup<Color>
|
|
63
|
+
|
|
64
|
+
/// The width of the stroke
|
|
65
|
+
let width: KeyframeGroup<Vector1D>
|
|
66
|
+
|
|
67
|
+
/// Line Cap
|
|
68
|
+
let lineCap: LineCap
|
|
69
|
+
|
|
70
|
+
/// Line Join
|
|
71
|
+
let lineJoin: LineJoin
|
|
72
|
+
|
|
73
|
+
/// Miter Limit
|
|
74
|
+
let miterLimit: Double
|
|
75
|
+
|
|
76
|
+
/// The dash pattern of the stroke
|
|
77
|
+
let dashPattern: [DashElement]?
|
|
78
|
+
|
|
79
|
+
override func encode(to encoder: Encoder) throws {
|
|
80
|
+
try super.encode(to: encoder)
|
|
81
|
+
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
82
|
+
try container.encode(opacity, forKey: .opacity)
|
|
83
|
+
try container.encode(color, forKey: .color)
|
|
84
|
+
try container.encode(width, forKey: .width)
|
|
85
|
+
try container.encode(lineCap, forKey: .lineCap)
|
|
86
|
+
try container.encode(lineJoin, forKey: .lineJoin)
|
|
87
|
+
try container.encode(miterLimit, forKey: .miterLimit)
|
|
88
|
+
try container.encodeIfPresent(dashPattern, forKey: .dashPattern)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// MARK: Private
|
|
92
|
+
|
|
93
|
+
private enum CodingKeys: String, CodingKey {
|
|
94
|
+
case opacity = "o"
|
|
95
|
+
case color = "c"
|
|
96
|
+
case width = "w"
|
|
97
|
+
case lineCap = "lc"
|
|
98
|
+
case lineJoin = "lj"
|
|
99
|
+
case miterLimit = "ml"
|
|
100
|
+
case dashPattern = "d"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Trim.swift
|
|
3
|
+
// lottie-swift
|
|
4
|
+
//
|
|
5
|
+
// Created by Brandon Withrow on 1/8/19.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
// MARK: - TrimType
|
|
11
|
+
|
|
12
|
+
enum TrimType: Int, Codable {
|
|
13
|
+
case simultaneously = 1
|
|
14
|
+
case individually = 2
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// MARK: - Trim
|
|
18
|
+
|
|
19
|
+
/// An item that define an ellipse shape
|
|
20
|
+
final class Trim: ShapeItem {
|
|
21
|
+
|
|
22
|
+
// MARK: Lifecycle
|
|
23
|
+
|
|
24
|
+
required init(from decoder: Decoder) throws {
|
|
25
|
+
let container = try decoder.container(keyedBy: Trim.CodingKeys.self)
|
|
26
|
+
start = try container.decode(KeyframeGroup<Vector1D>.self, forKey: .start)
|
|
27
|
+
end = try container.decode(KeyframeGroup<Vector1D>.self, forKey: .end)
|
|
28
|
+
offset = try container.decode(KeyframeGroup<Vector1D>.self, forKey: .offset)
|
|
29
|
+
trimType = try container.decode(TrimType.self, forKey: .trimType)
|
|
30
|
+
try super.init(from: decoder)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
required init(dictionary: [String: Any]) throws {
|
|
34
|
+
let startDictionary: [String: Any] = try dictionary.value(for: CodingKeys.start)
|
|
35
|
+
start = try KeyframeGroup<Vector1D>(dictionary: startDictionary)
|
|
36
|
+
let endDictionary: [String: Any] = try dictionary.value(for: CodingKeys.end)
|
|
37
|
+
end = try KeyframeGroup<Vector1D>(dictionary: endDictionary)
|
|
38
|
+
let offsetDictionary: [String: Any] = try dictionary.value(for: CodingKeys.offset)
|
|
39
|
+
offset = try KeyframeGroup<Vector1D>(dictionary: offsetDictionary)
|
|
40
|
+
let trimTypeRawValue: Int = try dictionary.value(for: CodingKeys.trimType)
|
|
41
|
+
guard let trimType = TrimType(rawValue: trimTypeRawValue) else {
|
|
42
|
+
throw InitializableError.invalidInput
|
|
43
|
+
}
|
|
44
|
+
self.trimType = trimType
|
|
45
|
+
try super.init(dictionary: dictionary)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// MARK: Internal
|
|
49
|
+
|
|
50
|
+
/// The start of the trim
|
|
51
|
+
let start: KeyframeGroup<Vector1D>
|
|
52
|
+
|
|
53
|
+
/// The end of the trim
|
|
54
|
+
let end: KeyframeGroup<Vector1D>
|
|
55
|
+
|
|
56
|
+
/// The offset of the trim
|
|
57
|
+
let offset: KeyframeGroup<Vector1D>
|
|
58
|
+
|
|
59
|
+
let trimType: TrimType
|
|
60
|
+
|
|
61
|
+
override func encode(to encoder: Encoder) throws {
|
|
62
|
+
try super.encode(to: encoder)
|
|
63
|
+
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
64
|
+
try container.encode(start, forKey: .start)
|
|
65
|
+
try container.encode(end, forKey: .end)
|
|
66
|
+
try container.encode(offset, forKey: .offset)
|
|
67
|
+
try container.encode(trimType, forKey: .trimType)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// MARK: Private
|
|
71
|
+
|
|
72
|
+
private enum CodingKeys: String, CodingKey {
|
|
73
|
+
case start = "s"
|
|
74
|
+
case end = "e"
|
|
75
|
+
case offset = "o"
|
|
76
|
+
case trimType = "m"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Font.swift
|
|
3
|
+
// lottie-swift
|
|
4
|
+
//
|
|
5
|
+
// Created by Brandon Withrow on 1/9/19.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
// MARK: - Font
|
|
11
|
+
|
|
12
|
+
final class Font: Codable, DictionaryInitializable {
|
|
13
|
+
|
|
14
|
+
// MARK: Lifecycle
|
|
15
|
+
|
|
16
|
+
init(dictionary: [String: Any]) throws {
|
|
17
|
+
name = try dictionary.value(for: CodingKeys.name)
|
|
18
|
+
familyName = try dictionary.value(for: CodingKeys.familyName)
|
|
19
|
+
style = try dictionary.value(for: CodingKeys.style)
|
|
20
|
+
ascent = try dictionary.value(for: CodingKeys.ascent)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// MARK: Internal
|
|
24
|
+
|
|
25
|
+
let name: String
|
|
26
|
+
let familyName: String
|
|
27
|
+
let style: String
|
|
28
|
+
let ascent: Double
|
|
29
|
+
|
|
30
|
+
// MARK: Private
|
|
31
|
+
|
|
32
|
+
private enum CodingKeys: String, CodingKey {
|
|
33
|
+
case name = "fName"
|
|
34
|
+
case familyName = "fFamily"
|
|
35
|
+
case style = "fStyle"
|
|
36
|
+
case ascent
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// MARK: - FontList
|
|
42
|
+
|
|
43
|
+
/// A list of fonts
|
|
44
|
+
final class FontList: Codable, DictionaryInitializable {
|
|
45
|
+
|
|
46
|
+
// MARK: Lifecycle
|
|
47
|
+
|
|
48
|
+
init(dictionary: [String: Any]) throws {
|
|
49
|
+
let fontDictionaries: [[String: Any]] = try dictionary.value(for: CodingKeys.fonts)
|
|
50
|
+
fonts = try fontDictionaries.map({ try Font(dictionary: $0) })
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// MARK: Internal
|
|
54
|
+
|
|
55
|
+
enum CodingKeys: String, CodingKey {
|
|
56
|
+
case fonts = "list"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let fonts: [Font]
|
|
60
|
+
|
|
61
|
+
}
|
|
@@ -8,65 +8,89 @@
|
|
|
8
8
|
import Foundation
|
|
9
9
|
|
|
10
10
|
/// A model that holds a vector character
|
|
11
|
-
final class Glyph: Codable {
|
|
12
|
-
|
|
11
|
+
final class Glyph: Codable, DictionaryInitializable {
|
|
12
|
+
|
|
13
|
+
// MARK: Lifecycle
|
|
14
|
+
|
|
15
|
+
required init(from decoder: Decoder) throws {
|
|
16
|
+
let container = try decoder.container(keyedBy: Glyph.CodingKeys.self)
|
|
17
|
+
character = try container.decode(String.self, forKey: .character)
|
|
18
|
+
fontSize = try container.decode(Double.self, forKey: .fontSize)
|
|
19
|
+
fontFamily = try container.decode(String.self, forKey: .fontFamily)
|
|
20
|
+
fontStyle = try container.decode(String.self, forKey: .fontStyle)
|
|
21
|
+
width = try container.decode(Double.self, forKey: .width)
|
|
22
|
+
if
|
|
23
|
+
container.contains(.shapeWrapper),
|
|
24
|
+
let shapeContainer = try? container.nestedContainer(keyedBy: ShapeKey.self, forKey: .shapeWrapper),
|
|
25
|
+
shapeContainer.contains(.shapes)
|
|
26
|
+
{
|
|
27
|
+
shapes = try shapeContainer.decode([ShapeItem].self, ofFamily: ShapeType.self, forKey: .shapes)
|
|
28
|
+
} else {
|
|
29
|
+
shapes = []
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
init(dictionary: [String: Any]) throws {
|
|
34
|
+
character = try dictionary.value(for: CodingKeys.character)
|
|
35
|
+
fontSize = try dictionary.value(for: CodingKeys.fontSize)
|
|
36
|
+
fontFamily = try dictionary.value(for: CodingKeys.fontFamily)
|
|
37
|
+
fontStyle = try dictionary.value(for: CodingKeys.fontStyle)
|
|
38
|
+
width = try dictionary.value(for: CodingKeys.width)
|
|
39
|
+
if
|
|
40
|
+
let shapes = dictionary[CodingKeys.shapeWrapper.rawValue] as? [String: Any],
|
|
41
|
+
let shapeDictionaries = shapes[ShapeKey.shapes.rawValue] as? [[String: Any]]
|
|
42
|
+
{
|
|
43
|
+
self.shapes = try [ShapeItem].fromDictionaries(shapeDictionaries)
|
|
44
|
+
} else {
|
|
45
|
+
shapes = [ShapeItem]()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// MARK: Internal
|
|
50
|
+
|
|
13
51
|
/// The character
|
|
14
52
|
let character: String
|
|
15
|
-
|
|
53
|
+
|
|
16
54
|
/// The font size of the character
|
|
17
55
|
let fontSize: Double
|
|
18
|
-
|
|
56
|
+
|
|
19
57
|
/// The font family of the character
|
|
20
58
|
let fontFamily: String
|
|
21
|
-
|
|
59
|
+
|
|
22
60
|
/// The Style of the character
|
|
23
61
|
let fontStyle: String
|
|
24
|
-
|
|
62
|
+
|
|
25
63
|
/// The Width of the character
|
|
26
64
|
let width: Double
|
|
27
|
-
|
|
65
|
+
|
|
28
66
|
/// The Shape Data of the Character
|
|
29
67
|
let shapes: [ShapeItem]
|
|
30
|
-
|
|
31
|
-
private enum CodingKeys: String, CodingKey {
|
|
32
|
-
case character = "ch"
|
|
33
|
-
case fontSize = "size"
|
|
34
|
-
case fontFamily = "fFamily"
|
|
35
|
-
case fontStyle = "style"
|
|
36
|
-
case width = "w"
|
|
37
|
-
case shapeWrapper = "data"
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
private enum ShapeKey: String, CodingKey {
|
|
41
|
-
case shapes = "shapes"
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
required init(from decoder: Decoder) throws {
|
|
45
|
-
let container = try decoder.container(keyedBy: Glyph.CodingKeys.self)
|
|
46
|
-
self.character = try container.decode(String.self, forKey: .character)
|
|
47
|
-
self.fontSize = try container.decode(Double.self, forKey: .fontSize)
|
|
48
|
-
self.fontFamily = try container.decode(String.self, forKey: .fontFamily)
|
|
49
|
-
self.fontStyle = try container.decode(String.self, forKey: .fontStyle)
|
|
50
|
-
self.width = try container.decode(Double.self, forKey: .width)
|
|
51
|
-
if container.contains(.shapeWrapper),
|
|
52
|
-
let shapeContainer = try? container.nestedContainer(keyedBy: ShapeKey.self, forKey: .shapeWrapper),
|
|
53
|
-
shapeContainer.contains(.shapes) {
|
|
54
|
-
self.shapes = try shapeContainer.decode([ShapeItem].self, ofFamily: ShapeType.self, forKey: .shapes)
|
|
55
|
-
} else {
|
|
56
|
-
self.shapes = []
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
68
|
+
|
|
60
69
|
func encode(to encoder: Encoder) throws {
|
|
61
70
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
62
|
-
|
|
71
|
+
|
|
63
72
|
try container.encode(character, forKey: .character)
|
|
64
73
|
try container.encode(fontSize, forKey: .fontSize)
|
|
65
74
|
try container.encode(fontFamily, forKey: .fontFamily)
|
|
66
75
|
try container.encode(fontStyle, forKey: .fontStyle)
|
|
67
76
|
try container.encode(width, forKey: .width)
|
|
68
|
-
|
|
77
|
+
|
|
69
78
|
var shapeContainer = container.nestedContainer(keyedBy: ShapeKey.self, forKey: .shapeWrapper)
|
|
70
79
|
try shapeContainer.encode(shapes, forKey: .shapes)
|
|
71
80
|
}
|
|
81
|
+
|
|
82
|
+
// MARK: Private
|
|
83
|
+
|
|
84
|
+
private enum CodingKeys: String, CodingKey {
|
|
85
|
+
case character = "ch"
|
|
86
|
+
case fontSize = "size"
|
|
87
|
+
case fontFamily = "fFamily"
|
|
88
|
+
case fontStyle = "style"
|
|
89
|
+
case width = "w"
|
|
90
|
+
case shapeWrapper = "data"
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private enum ShapeKey: String, CodingKey {
|
|
94
|
+
case shapes
|
|
95
|
+
}
|
|
72
96
|
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
//
|
|
2
|
+
// TextAnimator.swift
|
|
3
|
+
// lottie-swift
|
|
4
|
+
//
|
|
5
|
+
// Created by Brandon Withrow on 1/9/19.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
final class TextAnimator: Codable, DictionaryInitializable {
|
|
11
|
+
|
|
12
|
+
// MARK: Lifecycle
|
|
13
|
+
|
|
14
|
+
required init(from decoder: Decoder) throws {
|
|
15
|
+
let container = try decoder.container(keyedBy: TextAnimator.CodingKeys.self)
|
|
16
|
+
name = try container.decodeIfPresent(String.self, forKey: .name) ?? ""
|
|
17
|
+
let animatorContainer = try container.nestedContainer(keyedBy: TextAnimatorKeys.self, forKey: .textAnimator)
|
|
18
|
+
fillColor = try animatorContainer.decodeIfPresent(KeyframeGroup<Color>.self, forKey: .fillColor)
|
|
19
|
+
strokeColor = try animatorContainer.decodeIfPresent(KeyframeGroup<Color>.self, forKey: .strokeColor)
|
|
20
|
+
strokeWidth = try animatorContainer.decodeIfPresent(KeyframeGroup<Vector1D>.self, forKey: .strokeWidth)
|
|
21
|
+
tracking = try animatorContainer.decodeIfPresent(KeyframeGroup<Vector1D>.self, forKey: .tracking)
|
|
22
|
+
anchor = try animatorContainer.decodeIfPresent(KeyframeGroup<Vector3D>.self, forKey: .anchor)
|
|
23
|
+
position = try animatorContainer.decodeIfPresent(KeyframeGroup<Vector3D>.self, forKey: .position)
|
|
24
|
+
scale = try animatorContainer.decodeIfPresent(KeyframeGroup<Vector3D>.self, forKey: .scale)
|
|
25
|
+
skew = try animatorContainer.decodeIfPresent(KeyframeGroup<Vector1D>.self, forKey: .skew)
|
|
26
|
+
skewAxis = try animatorContainer.decodeIfPresent(KeyframeGroup<Vector1D>.self, forKey: .skewAxis)
|
|
27
|
+
rotation = try animatorContainer.decodeIfPresent(KeyframeGroup<Vector1D>.self, forKey: .rotation)
|
|
28
|
+
opacity = try animatorContainer.decodeIfPresent(KeyframeGroup<Vector1D>.self, forKey: .opacity)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
init(dictionary: [String: Any]) throws {
|
|
32
|
+
name = (try? dictionary.value(for: CodingKeys.name)) ?? ""
|
|
33
|
+
let animatorDictionary: [String: Any] = try dictionary.value(for: CodingKeys.textAnimator)
|
|
34
|
+
if let fillColorDictionary = animatorDictionary[TextAnimatorKeys.fillColor.rawValue] as? [String: Any] {
|
|
35
|
+
fillColor = try? KeyframeGroup<Color>(dictionary: fillColorDictionary)
|
|
36
|
+
} else {
|
|
37
|
+
fillColor = nil
|
|
38
|
+
}
|
|
39
|
+
if let strokeColorDictionary = animatorDictionary[TextAnimatorKeys.strokeColor.rawValue] as? [String: Any] {
|
|
40
|
+
strokeColor = try? KeyframeGroup<Color>(dictionary: strokeColorDictionary)
|
|
41
|
+
} else {
|
|
42
|
+
strokeColor = nil
|
|
43
|
+
}
|
|
44
|
+
if let strokeWidthDictionary = animatorDictionary[TextAnimatorKeys.strokeWidth.rawValue] as? [String: Any] {
|
|
45
|
+
strokeWidth = try? KeyframeGroup<Vector1D>(dictionary: strokeWidthDictionary)
|
|
46
|
+
} else {
|
|
47
|
+
strokeWidth = nil
|
|
48
|
+
}
|
|
49
|
+
if let trackingDictionary = animatorDictionary[TextAnimatorKeys.tracking.rawValue] as? [String: Any] {
|
|
50
|
+
tracking = try? KeyframeGroup<Vector1D>(dictionary: trackingDictionary)
|
|
51
|
+
} else {
|
|
52
|
+
tracking = nil
|
|
53
|
+
}
|
|
54
|
+
if let anchorDictionary = animatorDictionary[TextAnimatorKeys.anchor.rawValue] as? [String: Any] {
|
|
55
|
+
anchor = try? KeyframeGroup<Vector3D>(dictionary: anchorDictionary)
|
|
56
|
+
} else {
|
|
57
|
+
anchor = nil
|
|
58
|
+
}
|
|
59
|
+
if let positionDictionary = animatorDictionary[TextAnimatorKeys.position.rawValue] as? [String: Any] {
|
|
60
|
+
position = try? KeyframeGroup<Vector3D>(dictionary: positionDictionary)
|
|
61
|
+
} else {
|
|
62
|
+
position = nil
|
|
63
|
+
}
|
|
64
|
+
if let scaleDictionary = animatorDictionary[TextAnimatorKeys.scale.rawValue] as? [String: Any] {
|
|
65
|
+
scale = try? KeyframeGroup<Vector3D>(dictionary: scaleDictionary)
|
|
66
|
+
} else {
|
|
67
|
+
scale = nil
|
|
68
|
+
}
|
|
69
|
+
if let skewDictionary = animatorDictionary[TextAnimatorKeys.skew.rawValue] as? [String: Any] {
|
|
70
|
+
skew = try? KeyframeGroup<Vector1D>(dictionary: skewDictionary)
|
|
71
|
+
} else {
|
|
72
|
+
skew = nil
|
|
73
|
+
}
|
|
74
|
+
if let skewAxisDictionary = animatorDictionary[TextAnimatorKeys.skewAxis.rawValue] as? [String: Any] {
|
|
75
|
+
skewAxis = try? KeyframeGroup<Vector1D>(dictionary: skewAxisDictionary)
|
|
76
|
+
} else {
|
|
77
|
+
skewAxis = nil
|
|
78
|
+
}
|
|
79
|
+
if let rotationDictionary = animatorDictionary[TextAnimatorKeys.rotation.rawValue] as? [String: Any] {
|
|
80
|
+
rotation = try? KeyframeGroup<Vector1D>(dictionary: rotationDictionary)
|
|
81
|
+
} else {
|
|
82
|
+
rotation = nil
|
|
83
|
+
}
|
|
84
|
+
if let opacityDictionary = animatorDictionary[TextAnimatorKeys.opacity.rawValue] as? [String: Any] {
|
|
85
|
+
opacity = try KeyframeGroup<Vector1D>(dictionary: opacityDictionary)
|
|
86
|
+
} else {
|
|
87
|
+
opacity = nil
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// MARK: Internal
|
|
92
|
+
|
|
93
|
+
let name: String
|
|
94
|
+
|
|
95
|
+
/// Anchor
|
|
96
|
+
let anchor: KeyframeGroup<Vector3D>?
|
|
97
|
+
|
|
98
|
+
/// Position
|
|
99
|
+
let position: KeyframeGroup<Vector3D>?
|
|
100
|
+
|
|
101
|
+
/// Scale
|
|
102
|
+
let scale: KeyframeGroup<Vector3D>?
|
|
103
|
+
|
|
104
|
+
/// Skew
|
|
105
|
+
let skew: KeyframeGroup<Vector1D>?
|
|
106
|
+
|
|
107
|
+
/// Skew Axis
|
|
108
|
+
let skewAxis: KeyframeGroup<Vector1D>?
|
|
109
|
+
|
|
110
|
+
/// Rotation
|
|
111
|
+
let rotation: KeyframeGroup<Vector1D>?
|
|
112
|
+
|
|
113
|
+
/// Opacity
|
|
114
|
+
let opacity: KeyframeGroup<Vector1D>?
|
|
115
|
+
|
|
116
|
+
/// Stroke Color
|
|
117
|
+
let strokeColor: KeyframeGroup<Color>?
|
|
118
|
+
|
|
119
|
+
/// Fill Color
|
|
120
|
+
let fillColor: KeyframeGroup<Color>?
|
|
121
|
+
|
|
122
|
+
/// Stroke Width
|
|
123
|
+
let strokeWidth: KeyframeGroup<Vector1D>?
|
|
124
|
+
|
|
125
|
+
/// Tracking
|
|
126
|
+
let tracking: KeyframeGroup<Vector1D>?
|
|
127
|
+
|
|
128
|
+
func encode(to encoder: Encoder) throws {
|
|
129
|
+
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
130
|
+
var animatorContainer = container.nestedContainer(keyedBy: TextAnimatorKeys.self, forKey: .textAnimator)
|
|
131
|
+
try animatorContainer.encodeIfPresent(fillColor, forKey: .fillColor)
|
|
132
|
+
try animatorContainer.encodeIfPresent(strokeColor, forKey: .strokeColor)
|
|
133
|
+
try animatorContainer.encodeIfPresent(strokeWidth, forKey: .strokeWidth)
|
|
134
|
+
try animatorContainer.encodeIfPresent(tracking, forKey: .tracking)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// MARK: Private
|
|
138
|
+
|
|
139
|
+
private enum CodingKeys: String, CodingKey {
|
|
140
|
+
// case textSelector = "s" TODO
|
|
141
|
+
case textAnimator = "a"
|
|
142
|
+
case name = "nm"
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private enum TextSelectorKeys: String, CodingKey {
|
|
146
|
+
case start = "s"
|
|
147
|
+
case end = "e"
|
|
148
|
+
case offset = "o"
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private enum TextAnimatorKeys: String, CodingKey {
|
|
152
|
+
case fillColor = "fc"
|
|
153
|
+
case strokeColor = "sc"
|
|
154
|
+
case strokeWidth = "sw"
|
|
155
|
+
case tracking = "t"
|
|
156
|
+
case anchor = "a"
|
|
157
|
+
case position = "p"
|
|
158
|
+
case scale = "s"
|
|
159
|
+
case skew = "sk"
|
|
160
|
+
case skewAxis = "sa"
|
|
161
|
+
case rotation = "r"
|
|
162
|
+
case opacity = "o"
|
|
163
|
+
}
|
|
164
|
+
}
|