@octane-xplat/lottie 0.9.0 → 0.10.0

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.
Files changed (313) hide show
  1. package/README.md +36 -16
  2. package/dist/native/index.js +10 -9
  3. package/dist/native/octane-client-build.json +1 -1
  4. package/dist/web/index.js +39 -25
  5. package/dist/web/octane-client-build.json +1 -1
  6. package/package.json +25 -3
  7. package/platforms/macos/LICENSE-EpoxyCore-Apache-2.0.txt +201 -0
  8. package/platforms/macos/LICENSE-LRUCache-MIT.txt +22 -0
  9. package/platforms/macos/LICENSE-Lottie-Apache-2.0.txt +201 -0
  10. package/platforms/macos/LICENSE-ZIPFoundation-MIT.txt +21 -0
  11. package/platforms/macos/UPSTREAM.md +13 -0
  12. package/platforms/macos/resources/PrivacyInfo.xcprivacy +23 -0
  13. package/platforms/macos/resources/THIRD-PARTY-NOTICES.txt +10 -0
  14. package/platforms/macos/src/XplatAppKitLottie.swift +246 -0
  15. package/platforms/macos/src/vendor/Lottie/PrivacyInfo.xcprivacy +23 -0
  16. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift +81 -0
  17. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +476 -0
  18. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CombinedShapeAnimation.swift +92 -0
  19. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CustomPathAnimation.swift +89 -0
  20. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/DropShadowAnimation.swift +179 -0
  21. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/EllipseAnimation.swift +53 -0
  22. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/GradientAnimations.swift +287 -0
  23. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/LayerProperty.swift +440 -0
  24. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/OpacityAnimation.swift +53 -0
  25. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/RectangleAnimation.swift +59 -0
  26. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/ShapeAnimation.swift +246 -0
  27. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StarAnimation.swift +119 -0
  28. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StrokeAnimation.swift +96 -0
  29. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/TransformAnimations.swift +380 -0
  30. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/VisibilityAnimation.swift +63 -0
  31. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CompatibilityTracker.swift +129 -0
  32. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CoreAnimationLayer.swift +645 -0
  33. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/CALayer+fillBounds.swift +35 -0
  34. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift +28 -0
  35. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+combined.swift +345 -0
  36. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+timeRemapping.swift +46 -0
  37. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/AnimationLayer.swift +169 -0
  38. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseAnimationLayer.swift +46 -0
  39. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseCompositionLayer.swift +120 -0
  40. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +169 -0
  41. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/GradientRenderLayer.swift +101 -0
  42. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ImageLayer.swift +81 -0
  43. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/InfiniteOpaqueAnimationLayer.swift +57 -0
  44. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/LayerModel+makeAnimationLayer.swift +59 -0
  45. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/MaskCompositionLayer.swift +139 -0
  46. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/PreCompLayer.swift +107 -0
  47. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/RepeaterLayer.swift +113 -0
  48. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeItemLayer.swift +346 -0
  49. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeLayer.swift +569 -0
  50. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/SolidLayer.swift +66 -0
  51. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TextLayer.swift +157 -0
  52. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TransformLayer.swift +13 -0
  53. package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/ValueProviderStore.swift +157 -0
  54. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Collection+Diff.swift +267 -0
  55. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Diffable.swift +19 -0
  56. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/DiffableSection.swift +16 -0
  57. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/IndexChangeset.swift +187 -0
  58. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/SectionedChangeset.swift +22 -0
  59. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Logging/EpoxyLogger.swift +102 -0
  60. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/CallbackContextEpoxyModeled.swift +8 -0
  61. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelArrayBuilder.swift +48 -0
  62. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelProperty.swift +158 -0
  63. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelStorage.swift +88 -0
  64. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModeled.swift +54 -0
  65. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/AnyEpoxyModelProperty.swift +31 -0
  66. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/ClassReference.swift +39 -0
  67. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/AnimatedProviding.swift +10 -0
  68. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DataIDProviding.swift +58 -0
  69. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidDisplayProviding.swift +41 -0
  70. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidEndDisplayingProviding.swift +42 -0
  71. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidSelectProviding.swift +36 -0
  72. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ErasedContentProviding.swift +49 -0
  73. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/MakeViewProviding.swift +61 -0
  74. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetBehaviorsProviding.swift +38 -0
  75. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetContentProviding.swift +38 -0
  76. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/StyleIDProviding.swift +38 -0
  77. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/TraitCollectionProviding.swift +14 -0
  78. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewDifferentiatorProviding.swift +34 -0
  79. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewProviding.swift +13 -0
  80. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/WillDisplayProviding.swift +41 -0
  81. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/ViewEpoxyModeled.swift +10 -0
  82. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/README.md +30 -0
  83. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUIIntrinsicContentSizeInvalidator.swift +34 -0
  84. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUILayoutMargins.swift +38 -0
  85. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxyableView+SwiftUIView.swift +165 -0
  86. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/MeasuringViewRepresentable.swift +127 -0
  87. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/SwiftUIMeasurementContainer.swift +468 -0
  88. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/SwiftUIView.swift +146 -0
  89. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIView+SwiftUIView.swift +39 -0
  90. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIViewConfiguringSwiftUIView.swift +41 -0
  91. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/BehaviorsConfigurableView.swift +45 -0
  92. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ContentConfigurableView.swift +36 -0
  93. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/EpoxyableView.swift +5 -0
  94. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/StyledView.swift +43 -0
  95. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ViewType.swift +47 -0
  96. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/LRUCache.swift +257 -0
  97. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/README.md +24 -0
  98. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/README.md +43 -0
  99. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+BackingConfiguration.swift +149 -0
  100. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Deprecated.swift +23 -0
  101. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Helpers.swift +361 -0
  102. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+MemoryFile.swift +205 -0
  103. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Progress.swift +66 -0
  104. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Reading.swift +160 -0
  105. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ReadingDeprecated.swift +50 -0
  106. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Writing.swift +403 -0
  107. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+WritingDeprecated.swift +95 -0
  108. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ZIP64.swift +191 -0
  109. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive.swift +404 -0
  110. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Compression.swift +632 -0
  111. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+CompressionDeprecated.swift +43 -0
  112. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Serialization.swift +146 -0
  113. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Date+ZIP.swift +101 -0
  114. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+Serialization.swift +191 -0
  115. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+ZIP64.swift +170 -0
  116. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry.swift +669 -0
  117. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIP.swift +405 -0
  118. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIPDeprecated.swift +28 -0
  119. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/README.md +24 -0
  120. package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/URL+ZIP.swift +34 -0
  121. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.swift +177 -0
  122. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ImageCompositionLayer.swift +54 -0
  123. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift +191 -0
  124. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/NullCompositionLayer.swift +28 -0
  125. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift +137 -0
  126. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.swift +60 -0
  127. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/SolidCompositionLayer.swift +57 -0
  128. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/TextCompositionLayer.swift +247 -0
  129. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift +321 -0
  130. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CachedImageProvider.swift +56 -0
  131. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.swift +103 -0
  132. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CoreTextRenderLayer.swift +424 -0
  133. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/InvertedMatteLayer.swift +55 -0
  134. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerFontProvider.swift +39 -0
  135. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerImageProvider.swift +52 -0
  136. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTextProvider.swift +38 -0
  137. package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTransformNode.swift +149 -0
  138. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Extensions/ItemsExtension.swift +146 -0
  139. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/NodeProperty.swift +62 -0
  140. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.swift +53 -0
  141. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.swift +26 -0
  142. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/KeypathSearchable.swift +23 -0
  143. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.swift +43 -0
  144. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueContainer.swift +47 -0
  145. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift +39 -0
  146. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.swift +43 -0
  147. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/DropShadowNode.swift +102 -0
  148. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/LayerEffectNode.swift +25 -0
  149. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/RoundedCornersNode.swift +85 -0
  150. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift +281 -0
  151. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/GroupOutputNode.swift +74 -0
  152. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.swift +47 -0
  153. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PathOutputNode.swift +89 -0
  154. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/FillRenderer.swift +69 -0
  155. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift +253 -0
  156. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientStrokeRenderer.swift +64 -0
  157. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/LegacyGradientFillRenderer.swift +158 -0
  158. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift +165 -0
  159. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +143 -0
  160. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +173 -0
  161. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/RectNode.swift +238 -0
  162. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/ShapeNode.swift +73 -0
  163. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/StarNode.swift +224 -0
  164. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +162 -0
  165. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/FillNode.swift +88 -0
  166. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientFillNode.swift +103 -0
  167. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientStrokeNode.swift +149 -0
  168. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +179 -0
  169. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +345 -0
  170. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/AnimatorNode.swift +197 -0
  171. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/PathNode.swift +20 -0
  172. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/RenderNode.swift +60 -0
  173. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift +78 -0
  174. package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeRenderLayer.swift +98 -0
  175. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/Asset.swift +51 -0
  176. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/AssetLibrary.swift +75 -0
  177. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/ImageAsset.swift +141 -0
  178. package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/PrecompAsset.swift +47 -0
  179. package/platforms/macos/src/vendor/Lottie/Private/Model/DictionaryInitializable.swift +73 -0
  180. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieAnimation.swift +57 -0
  181. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieImageProvider.swift +89 -0
  182. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieManifest.swift +42 -0
  183. package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieUtils.swift +71 -0
  184. package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/Bundle.swift +58 -0
  185. package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/KeyedDecodingContainerExtensions.swift +71 -0
  186. package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeData.swift +111 -0
  187. package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeGroup.swift +265 -0
  188. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/DropShadowEffect.swift +52 -0
  189. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/ColorEffectValue.swift +45 -0
  190. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/EffectValue.swift +98 -0
  191. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/Vector1DEffectValue.swift +45 -0
  192. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/LayerEffect.swift +103 -0
  193. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/DropShadowStyle.swift +79 -0
  194. package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/LayerStyle.swift +85 -0
  195. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ImageLayerModel.swift +49 -0
  196. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/LayerModel.swift +266 -0
  197. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/PreCompLayerModel.swift +74 -0
  198. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ShapeLayerModel.swift +50 -0
  199. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/SolidLayerModel.swift +63 -0
  200. package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/TextLayerModel.swift +65 -0
  201. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/DashPattern.swift +42 -0
  202. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Marker.swift +35 -0
  203. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Mask.swift +80 -0
  204. package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Transform.swift +261 -0
  205. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Ellipse.swift +79 -0
  206. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Fill.swift +79 -0
  207. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientFill.swift +142 -0
  208. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientStroke.swift +244 -0
  209. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Group.swift +55 -0
  210. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Merge.swift +63 -0
  211. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Rectangle.swift +79 -0
  212. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Repeater.swift +181 -0
  213. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/RoundedCorners.swift +53 -0
  214. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Shape.swift +63 -0
  215. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeItem.swift +171 -0
  216. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeTransform.swift +202 -0
  217. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Star.swift +136 -0
  218. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Stroke.swift +144 -0
  219. package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Trim.swift +90 -0
  220. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Font.swift +67 -0
  221. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Glyph.swift +94 -0
  222. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextAnimator.swift +240 -0
  223. package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextDocument.swift +142 -0
  224. package/platforms/macos/src/vendor/Lottie/Private/RootAnimationLayer.swift +54 -0
  225. package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/AnimatorNodeDebugging.swift +23 -0
  226. package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/LayerDebugging.swift +231 -0
  227. package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/TestHelpers.swift +10 -0
  228. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/AnimationKeypathExtension.swift +303 -0
  229. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/BlendMode+Filter.swift +31 -0
  230. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGColor+RGB.swift +45 -0
  231. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGFloatExtensions.swift +152 -0
  232. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/DataExtension.swift +33 -0
  233. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/MathKit.swift +454 -0
  234. package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/StringExtensions.swift +44 -0
  235. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnimationContext.swift +95 -0
  236. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnyEquatable.swift +23 -0
  237. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/Binding+Map.swift +19 -0
  238. package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/View+ValueChanged.swift +35 -0
  239. package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/InterpolatableExtensions.swift +143 -0
  240. package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeExtensions.swift +47 -0
  241. package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeInterpolator.swift +250 -0
  242. package/platforms/macos/src/vendor/Lottie/Private/Utility/LottieAnimationSource.swift +51 -0
  243. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPath.swift +509 -0
  244. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPathRoundExtension.swift +163 -0
  245. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CGPointExtension.swift +35 -0
  246. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/ColorExtension.swift +101 -0
  247. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CompoundBezierPath.swift +169 -0
  248. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CurveVertex.swift +190 -0
  249. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/PathElement.swift +78 -0
  250. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/UnitBezier.swift +119 -0
  251. package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/VectorsExtensions.swift +368 -0
  252. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimation.swift +179 -0
  253. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationHelpers.swift +317 -0
  254. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationLayer.swift +1582 -0
  255. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationView.swift +1090 -0
  256. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationViewInitializers.swift +226 -0
  257. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottiePlaybackMode.swift +266 -0
  258. package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieView.swift +643 -0
  259. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/AnimationCacheProvider.swift +21 -0
  260. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/DefaultAnimationCache.swift +67 -0
  261. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LRUAnimationCache.swift +11 -0
  262. package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LottieAnimationCache.swift +15 -0
  263. package/platforms/macos/src/vendor/Lottie/Public/Configuration/DecodingStrategy.swift +15 -0
  264. package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieConfiguration.swift +54 -0
  265. package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieURLSession.swift +31 -0
  266. package/platforms/macos/src/vendor/Lottie/Public/Configuration/ReducedMotionOption.swift +128 -0
  267. package/platforms/macos/src/vendor/Lottie/Public/Configuration/RenderingEngineOption.swift +117 -0
  268. package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedButton.swift +128 -0
  269. package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedControl.swift +248 -0
  270. package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedSwitch.swift +271 -0
  271. package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieButton.swift +119 -0
  272. package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieSwitch.swift +144 -0
  273. package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieViewType.swift +79 -0
  274. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCache.swift +66 -0
  275. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCacheProvider.swift +21 -0
  276. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieConfiguration.swift +72 -0
  277. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFile.swift +186 -0
  278. package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFileHelpers.swift +386 -0
  279. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnimationKeypath.swift +57 -0
  280. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnyValueProvider.swift +132 -0
  281. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +96 -0
  282. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +81 -0
  283. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +138 -0
  284. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +81 -0
  285. package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +81 -0
  286. package/platforms/macos/src/vendor/Lottie/Public/FontProvider/AnimationFontProvider.swift +41 -0
  287. package/platforms/macos/src/vendor/Lottie/Public/ImageProvider/AnimationImageProvider.swift +43 -0
  288. package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Interpolatable.swift +285 -0
  289. package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Keyframe.swift +98 -0
  290. package/platforms/macos/src/vendor/Lottie/Public/Logging/LottieLogger.swift +138 -0
  291. package/platforms/macos/src/vendor/Lottie/Public/Primitives/AnimationTime.swift +15 -0
  292. package/platforms/macos/src/vendor/Lottie/Public/Primitives/LottieColor.swift +43 -0
  293. package/platforms/macos/src/vendor/Lottie/Public/Primitives/Vectors.swift +36 -0
  294. package/platforms/macos/src/vendor/Lottie/Public/TextProvider/AnimationTextProvider.swift +135 -0
  295. package/platforms/macos/src/vendor/Lottie/Public/iOS/AnimationSubview.swift +19 -0
  296. package/platforms/macos/src/vendor/Lottie/Public/iOS/BundleImageProvider.swift +98 -0
  297. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationKeypath.swift +33 -0
  298. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationView.swift +567 -0
  299. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleFontProvider.swift +41 -0
  300. package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleImageProvider.swift +43 -0
  301. package/platforms/macos/src/vendor/Lottie/Public/iOS/FilepathImageProvider.swift +78 -0
  302. package/platforms/macos/src/vendor/Lottie/Public/iOS/LottieAnimationViewBase.swift +85 -0
  303. package/platforms/macos/src/vendor/Lottie/Public/iOS/UIColorExtension.swift +23 -0
  304. package/platforms/macos/src/vendor/Lottie/Public/macOS/AnimationSubview.macOS.swift +19 -0
  305. package/platforms/macos/src/vendor/Lottie/Public/macOS/BundleImageProvider.macOS.swift +90 -0
  306. package/platforms/macos/src/vendor/Lottie/Public/macOS/FilepathImageProvider.macOS.swift +86 -0
  307. package/platforms/macos/src/vendor/Lottie/Public/macOS/LottieAnimationViewBase.macOS.swift +102 -0
  308. package/src/Lottie.macos.tsrx +129 -0
  309. package/src/Lottie.tsrx +3 -2
  310. package/src/Lottie.web.tsrx +28 -11
  311. package/src/index.macos.ts +2 -0
  312. package/src/props.ts +6 -1
  313. package/types/generated/props.d.ts +5 -1
@@ -0,0 +1,101 @@
1
+ //
2
+ // LottieColor.swift
3
+ // lottie-swift
4
+ //
5
+ // Created by Brandon Withrow on 1/14/19.
6
+ //
7
+
8
+ import CoreGraphics
9
+
10
+ // MARK: - LottieColor + Codable
11
+
12
+ extension LottieColor: Codable {
13
+
14
+ // MARK: Lifecycle
15
+
16
+ public init(from decoder: Decoder) throws {
17
+ var container = try decoder.unkeyedContainer()
18
+
19
+ var r1: Double =
20
+ if !container.isAtEnd {
21
+ try container.decode(Double.self)
22
+ } else {
23
+ 0
24
+ }
25
+
26
+ var g1: Double =
27
+ if !container.isAtEnd {
28
+ try container.decode(Double.self)
29
+ } else {
30
+ 0
31
+ }
32
+
33
+ var b1: Double =
34
+ if !container.isAtEnd {
35
+ try container.decode(Double.self)
36
+ } else {
37
+ 0
38
+ }
39
+
40
+ if r1 > 1, g1 > 1, b1 > 1 {
41
+ r1 = r1 / 255
42
+ g1 = g1 / 255
43
+ b1 = b1 / 255
44
+ }
45
+ r = r1
46
+ g = g1
47
+ b = b1
48
+
49
+ // The Lottie JSON schema supports alpha values in theory, as the fourth value in this array.
50
+ // We intentionally do not support this, though, for consistency with Lottie on other platforms.
51
+ a = 1
52
+ }
53
+
54
+ // MARK: Public
55
+
56
+ public func encode(to encoder: Encoder) throws {
57
+ var container = encoder.unkeyedContainer()
58
+ try container.encode(r)
59
+ try container.encode(g)
60
+ try container.encode(b)
61
+ try container.encode(a)
62
+ }
63
+
64
+ }
65
+
66
+ // MARK: - LottieColor + AnyInitializable
67
+
68
+ extension LottieColor: AnyInitializable {
69
+
70
+ init(value: Any) throws {
71
+ guard var array = value as? [Double] else {
72
+ throw InitializableError.invalidInput()
73
+ }
74
+ var r: Double = array.count > 0 ? array.removeFirst() : 0
75
+ var g: Double = array.count > 0 ? array.removeFirst() : 0
76
+ var b: Double = array.count > 0 ? array.removeFirst() : 0
77
+ if r > 1, g > 1, b > 1 {
78
+ r /= 255
79
+ g /= 255
80
+ b /= 255
81
+ }
82
+ self.r = r
83
+ self.g = g
84
+ self.b = b
85
+
86
+ // The Lottie JSON schema supports alpha values in theory, as the fourth value in this array.
87
+ // We intentionally do not support this, though, for consistency with Lottie on other platforms.
88
+ a = 1
89
+ }
90
+
91
+ }
92
+
93
+ extension LottieColor {
94
+ static var clearColor: CGColor {
95
+ .rgba(0, 0, 0, 0)
96
+ }
97
+
98
+ var cgColorValue: CGColor {
99
+ .rgba(CGFloat(r), CGFloat(g), CGFloat(b), CGFloat(a))
100
+ }
101
+ }
@@ -0,0 +1,169 @@
1
+ //
2
+ // CompoundBezierPath.swift
3
+ // lottie-swift
4
+ //
5
+ // Created by Brandon Withrow on 1/14/19.
6
+ //
7
+
8
+ import CoreGraphics
9
+ import Foundation
10
+
11
+ /// A collection of BezierPath objects that can be trimmed and added.
12
+ ///
13
+ struct CompoundBezierPath {
14
+
15
+ // MARK: Lifecycle
16
+
17
+ init() {
18
+ paths = []
19
+ length = 0
20
+ }
21
+
22
+ init(path: BezierPath) {
23
+ paths = [path]
24
+ length = path.length
25
+ }
26
+
27
+ init(paths: [BezierPath], length: CGFloat) {
28
+ self.paths = paths
29
+ self.length = length
30
+ }
31
+
32
+ init(paths: [BezierPath]) {
33
+ self.paths = paths
34
+ var l: CGFloat = 0
35
+ for path in paths {
36
+ l = l + path.length
37
+ }
38
+ length = l
39
+ }
40
+
41
+ // MARK: Internal
42
+
43
+ let paths: [BezierPath]
44
+
45
+ let length: CGFloat
46
+
47
+ func addPath(path: BezierPath) -> CompoundBezierPath {
48
+ var newPaths = paths
49
+ newPaths.append(path)
50
+ return CompoundBezierPath(paths: newPaths, length: length + path.length)
51
+ }
52
+
53
+ func combine(_ compoundBezier: CompoundBezierPath) -> CompoundBezierPath {
54
+ var newPaths = paths
55
+ newPaths.append(contentsOf: compoundBezier.paths)
56
+ return CompoundBezierPath(paths: newPaths, length: length + compoundBezier.length)
57
+ }
58
+
59
+ func trim(fromPosition: CGFloat, toPosition: CGFloat, offset: CGFloat, trimSimultaneously: Bool) -> CompoundBezierPath {
60
+ if fromPosition == toPosition {
61
+ return CompoundBezierPath()
62
+ }
63
+
64
+ if trimSimultaneously {
65
+ /// Trim each path individually.
66
+ var newPaths = [BezierPath]()
67
+ for path in paths {
68
+ newPaths.append(contentsOf: path.trim(
69
+ fromLength: fromPosition * path.length,
70
+ toLength: toPosition * path.length,
71
+ offsetLength: offset * path.length
72
+ ))
73
+ }
74
+ return CompoundBezierPath(paths: newPaths)
75
+ }
76
+
77
+ /// Normalize lengths to the curve length.
78
+ var startPosition = (fromPosition + offset).truncatingRemainder(dividingBy: 1)
79
+ var endPosition = (toPosition + offset).truncatingRemainder(dividingBy: 1)
80
+
81
+ if startPosition < 0 {
82
+ startPosition = 1 + startPosition
83
+ }
84
+
85
+ if endPosition < 0 {
86
+ endPosition = 1 + endPosition
87
+ }
88
+
89
+ if startPosition == 1 {
90
+ startPosition = 0
91
+ }
92
+ if endPosition == 0 {
93
+ endPosition = 1
94
+ }
95
+
96
+ if
97
+ startPosition == 0 && endPosition == 1 ||
98
+ startPosition == endPosition ||
99
+ startPosition == 1 && endPosition == 0
100
+ {
101
+ /// The trim encompasses the entire path. Return.
102
+ return self
103
+ }
104
+
105
+ var positions: [(start: CGFloat, end: CGFloat)] =
106
+ if endPosition < startPosition {
107
+ [
108
+ (start: 0, end: endPosition * length),
109
+ (start: startPosition * length, end: length),
110
+ ]
111
+ } else {
112
+ [(start: startPosition * length, end: endPosition * length)]
113
+ }
114
+
115
+ var compoundPath = CompoundBezierPath()
116
+ var trim = positions.remove(at: 0)
117
+ var pathStartPosition: CGFloat = 0
118
+
119
+ var finishedTrimming = false
120
+ var i = 0
121
+
122
+ while !finishedTrimming {
123
+ if paths.count <= i {
124
+ /// Rounding errors
125
+ finishedTrimming = true
126
+ continue
127
+ }
128
+ let path = paths[i]
129
+
130
+ let pathEndPosition = pathStartPosition + path.length
131
+
132
+ if pathEndPosition < trim.start {
133
+ /// Path is not included in the trim, continue.
134
+ pathStartPosition = pathEndPosition
135
+ i = i + 1
136
+ continue
137
+
138
+ } else if trim.start <= pathStartPosition, pathEndPosition <= trim.end {
139
+ /// Full Path is inside of trim. Add full path.
140
+ compoundPath = compoundPath.addPath(path: path)
141
+ } else {
142
+ if
143
+ let trimPath = path.trim(
144
+ fromLength: trim.start > pathStartPosition ? (trim.start - pathStartPosition) : 0,
145
+ toLength: trim.end < pathEndPosition ? (trim.end - pathStartPosition) : path.length,
146
+ offsetLength: 0
147
+ ).first
148
+ {
149
+ compoundPath = compoundPath.addPath(path: trimPath)
150
+ }
151
+ }
152
+
153
+ if trim.end <= pathEndPosition {
154
+ /// We are done with the current trim.
155
+ /// Advance trim but remain on the same path in case the next trim overlaps it.
156
+ if positions.count > 0 {
157
+ trim = positions.remove(at: 0)
158
+ } else {
159
+ finishedTrimming = true
160
+ }
161
+ } else {
162
+ pathStartPosition = pathEndPosition
163
+ i = i + 1
164
+ }
165
+ }
166
+ return compoundPath
167
+ }
168
+
169
+ }
@@ -0,0 +1,190 @@
1
+ //
2
+ // CurveVertex.swift
3
+ // lottie-swift
4
+ //
5
+ // Created by Brandon Withrow on 1/11/19.
6
+ //
7
+
8
+ import CoreGraphics
9
+ import Foundation
10
+
11
+ /// A single vertex with an in and out tangent
12
+ struct CurveVertex {
13
+
14
+ // MARK: Lifecycle
15
+
16
+ /// Initializes a curve point with absolute values
17
+ init(_ inTangent: CGPoint, _ point: CGPoint, _ outTangent: CGPoint) {
18
+ self.point = point
19
+ self.inTangent = inTangent
20
+ self.outTangent = outTangent
21
+ }
22
+
23
+ /// Initializes a curve point with relative values
24
+ init(point: CGPoint, inTangentRelative: CGPoint, outTangentRelative: CGPoint) {
25
+ self.point = point
26
+ inTangent = point.add(inTangentRelative)
27
+ outTangent = point.add(outTangentRelative)
28
+ }
29
+
30
+ /// Initializes a curve point with absolute values
31
+ init(point: CGPoint, inTangent: CGPoint, outTangent: CGPoint) {
32
+ self.point = point
33
+ self.inTangent = inTangent
34
+ self.outTangent = outTangent
35
+ }
36
+
37
+ // MARK: Internal
38
+
39
+ let point: CGPoint
40
+
41
+ let inTangent: CGPoint
42
+ let outTangent: CGPoint
43
+
44
+ var inTangentRelative: CGPoint {
45
+ inTangent.subtract(point)
46
+ }
47
+
48
+ var outTangentRelative: CGPoint {
49
+ outTangent.subtract(point)
50
+ }
51
+
52
+ func reversed() -> CurveVertex {
53
+ CurveVertex(point: point, inTangent: outTangent, outTangent: inTangent)
54
+ }
55
+
56
+ func translated(_ translation: CGPoint) -> CurveVertex {
57
+ CurveVertex(point: point + translation, inTangent: inTangent + translation, outTangent: outTangent + translation)
58
+ }
59
+
60
+ /// Trims a path defined by two Vertices at a specific position, from 0 to 1
61
+ ///
62
+ /// The path can be visualized below.
63
+ ///
64
+ /// F is fromVertex.
65
+ /// V is the vertex of the receiver.
66
+ /// P is the position from 0-1.
67
+ /// O is the outTangent of fromVertex.
68
+ /// F====O=========P=======I====V
69
+ ///
70
+ /// After trimming the curve can be visualized below.
71
+ ///
72
+ /// S is the returned Start vertex.
73
+ /// E is the returned End vertex.
74
+ /// T is the trim point.
75
+ /// TI and TO are the new tangents for the trimPoint
76
+ /// NO and NI are the new tangents for the startPoint and endPoints
77
+ /// S==NO=========TI==T==TO=======NI==E
78
+ func splitCurve(toVertex: CurveVertex, position: CGFloat) ->
79
+ (start: CurveVertex, trimPoint: CurveVertex, end: CurveVertex)
80
+ {
81
+ /// If position is less than or equal to 0, trim at start.
82
+ if position <= 0 {
83
+ return (
84
+ start: CurveVertex(point: point, inTangentRelative: inTangentRelative, outTangentRelative: .zero),
85
+ trimPoint: CurveVertex(point: point, inTangentRelative: .zero, outTangentRelative: outTangentRelative),
86
+ end: toVertex
87
+ )
88
+ }
89
+
90
+ /// If position is greater than or equal to 1, trim at end.
91
+ if position >= 1 {
92
+ return (
93
+ start: self,
94
+ trimPoint: CurveVertex(
95
+ point: toVertex.point,
96
+ inTangentRelative: toVertex.inTangentRelative,
97
+ outTangentRelative: .zero
98
+ ),
99
+ end: CurveVertex(
100
+ point: toVertex.point,
101
+ inTangentRelative: .zero,
102
+ outTangentRelative: toVertex.outTangentRelative
103
+ )
104
+ )
105
+ }
106
+
107
+ if outTangentRelative.isZero, toVertex.inTangentRelative.isZero {
108
+ /// If both tangents are zero, then span to be trimmed is a straight line.
109
+ let trimPoint = point.interpolate(to: toVertex.point, amount: position)
110
+ return (
111
+ start: self,
112
+ trimPoint: CurveVertex(point: trimPoint, inTangentRelative: .zero, outTangentRelative: .zero),
113
+ end: toVertex
114
+ )
115
+ }
116
+ /// Cutting by amount gives incorrect length....
117
+ /// One option is to cut by a stride until it gets close then edge it down.
118
+ /// Measuring a percentage of the spans does not equal the same as measuring a percentage of length.
119
+ /// This is where the historical trim path bugs come from.
120
+ let a = point.interpolate(to: outTangent, amount: position)
121
+ let b = outTangent.interpolate(to: toVertex.inTangent, amount: position)
122
+ let c = toVertex.inTangent.interpolate(to: toVertex.point, amount: position)
123
+ let d = a.interpolate(to: b, amount: position)
124
+ let e = b.interpolate(to: c, amount: position)
125
+ let f = d.interpolate(to: e, amount: position)
126
+ return (
127
+ start: CurveVertex(point: point, inTangent: inTangent, outTangent: a),
128
+ trimPoint: CurveVertex(point: f, inTangent: d, outTangent: e),
129
+ end: CurveVertex(point: toVertex.point, inTangent: c, outTangent: toVertex.outTangent)
130
+ )
131
+ }
132
+
133
+ /// Trims a curve of a known length to a specific length and returns the points.
134
+ ///
135
+ /// There is not a performant yet accurate way to cut a curve to a specific length.
136
+ /// This calls splitCurve(toVertex: position:) to split the curve and then measures
137
+ /// the length of the new curve. The function then iterates through the samples,
138
+ /// adjusting the position of the cut for a more precise cut.
139
+ /// Usually a single iteration is enough to get within 0.5 points of the desired
140
+ /// length.
141
+ ///
142
+ /// This function should probably live in PathElement, since it deals with curve
143
+ /// lengths.
144
+ func trimCurve(toVertex: CurveVertex, atLength: CGFloat, curveLength: CGFloat, maxSamples: Int, accuracy: CGFloat = 1) ->
145
+ (start: CurveVertex, trimPoint: CurveVertex, end: CurveVertex)
146
+ {
147
+ var currentPosition = atLength / curveLength
148
+ var results = splitCurve(toVertex: toVertex, position: currentPosition)
149
+
150
+ if maxSamples == 0 {
151
+ return results
152
+ }
153
+
154
+ for _ in 1...maxSamples {
155
+ let length = results.start.distanceTo(results.trimPoint)
156
+ let lengthDiff = atLength - length
157
+ /// Check if length is correct.
158
+ if lengthDiff < accuracy {
159
+ return results
160
+ }
161
+ let diffPosition = max(min((currentPosition / length) * lengthDiff, currentPosition * 0.5), currentPosition * -0.5)
162
+ currentPosition = diffPosition + currentPosition
163
+ results = splitCurve(toVertex: toVertex, position: currentPosition)
164
+ }
165
+ return results
166
+ }
167
+
168
+ /// The distance from the receiver to the provided vertex.
169
+ ///
170
+ /// For lines (zeroed tangents) the distance between the two points is measured.
171
+ /// For curves the curve is iterated over by sample count and the points are measured.
172
+ /// This is ~99% accurate at a sample count of 30
173
+ func distanceTo(_ toVertex: CurveVertex, sampleCount: Int = 25) -> CGFloat {
174
+ if outTangentRelative.isZero, toVertex.inTangentRelative.isZero {
175
+ /// Return a linear distance.
176
+ return point.distanceTo(toVertex.point)
177
+ }
178
+
179
+ var distance: CGFloat = 0
180
+
181
+ var previousPoint = point
182
+ for i in 0..<sampleCount {
183
+ let pointOnCurve = splitCurve(toVertex: toVertex, position: CGFloat(i) / CGFloat(sampleCount)).trimPoint
184
+ distance = distance + previousPoint.distanceTo(pointOnCurve.point)
185
+ previousPoint = pointOnCurve.point
186
+ }
187
+ distance = distance + previousPoint.distanceTo(toVertex.point)
188
+ return distance
189
+ }
190
+ }
@@ -0,0 +1,78 @@
1
+ //
2
+ // PathElement.swift
3
+ // lottie-swift
4
+ //
5
+ // Created by Brandon Withrow on 1/11/19.
6
+ //
7
+
8
+ import CoreGraphics
9
+ import Foundation
10
+
11
+ /// A path section, containing one point and its length to the previous point.
12
+ ///
13
+ /// The relationship between this path element and the previous is implicit.
14
+ /// Ideally a path section would be defined by two vertices and a length.
15
+ /// We don't do this however, as it would effectively double the memory footprint
16
+ /// of path data.
17
+ ///
18
+ struct PathElement {
19
+
20
+ // MARK: Lifecycle
21
+
22
+ /// Initializes a new path with length of 0
23
+ init(vertex: CurveVertex) {
24
+ length = 0
25
+ self.vertex = vertex
26
+ }
27
+
28
+ /// Initializes a new path with length
29
+ private init(length: CGFloat, vertex: CurveVertex) {
30
+ self.length = length
31
+ self.vertex = vertex
32
+ }
33
+
34
+ // MARK: Internal
35
+
36
+ /// The absolute Length of the path element.
37
+ let length: CGFloat
38
+
39
+ /// The vertex of the element
40
+ let vertex: CurveVertex
41
+
42
+ /// Returns a new path element define the span from the receiver to the new vertex.
43
+ func pathElementTo(_ toVertex: CurveVertex) -> PathElement {
44
+ PathElement(length: vertex.distanceTo(toVertex), vertex: toVertex)
45
+ }
46
+
47
+ func updateVertex(newVertex: CurveVertex) -> PathElement {
48
+ PathElement(length: length, vertex: newVertex)
49
+ }
50
+
51
+ /// Splits an element span defined by the receiver and fromElement to a position 0-1
52
+ func splitElementAtPosition(fromElement: PathElement, atLength: CGFloat) ->
53
+ (leftSpan: (start: PathElement, end: PathElement), rightSpan: (start: PathElement, end: PathElement))
54
+ {
55
+ /// Trim the span. Start and trim go into the first, trim and end go into second.
56
+ let trimResults = fromElement.vertex.trimCurve(toVertex: vertex, atLength: atLength, curveLength: length, maxSamples: 3)
57
+
58
+ /// Create the elements for the break
59
+ let spanAStart = PathElement(
60
+ length: fromElement.length,
61
+ vertex: CurveVertex(
62
+ point: fromElement.vertex.point,
63
+ inTangent: fromElement.vertex.inTangent,
64
+ outTangent: trimResults.start.outTangent
65
+ )
66
+ )
67
+ /// Recalculating the length here is a waste as the trimCurve function also accurately calculates this length.
68
+ let spanAEnd = spanAStart.pathElementTo(trimResults.trimPoint)
69
+
70
+ let spanBStart = PathElement(vertex: trimResults.trimPoint)
71
+ let spanBEnd = spanBStart.pathElementTo(trimResults.end)
72
+ return (
73
+ leftSpan: (start: spanAStart, end: spanAEnd),
74
+ rightSpan: (start: spanBStart, end: spanBEnd)
75
+ )
76
+ }
77
+
78
+ }
@@ -0,0 +1,119 @@
1
+ // Copyright (C) 2008 Apple Inc. All Rights Reserved.
2
+ //
3
+ // Redistribution and use in source and binary forms, with or without
4
+ // modification, are permitted provided that the following conditions
5
+ // are met:
6
+ // 1. Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // 2. Redistributions in binary form must reproduce the above copyright
9
+ // notice, this list of conditions and the following disclaimer in the
10
+ // documentation and/or other materials provided with the distribution.
11
+ //
12
+ // THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
13
+ // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15
+ // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
16
+ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17
+ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18
+ // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
19
+ // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
20
+ // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+
24
+ import CoreGraphics
25
+ import Foundation
26
+
27
+ /// Defines a cubic-bezier where the endpoints are (0, 0) and (1, 1)
28
+ ///
29
+ /// The main use case is computing the progress of an animation at a given percent completion. For instance,
30
+ /// for a linear animation, the expected progress at `0.5` is `0.5`.
31
+ ///
32
+ /// - Note: This is a Swift port of [Apple's WebKit code](
33
+ /// http://svn.webkit.org/repository/webkit/trunk/Source/WebCore/platform/graphics/UnitBezier.h
34
+ /// )
35
+ ///
36
+ struct UnitBezier {
37
+
38
+ // MARK: Lifecycle
39
+
40
+ init(controlPoint1: CGPoint, controlPoint2: CGPoint) {
41
+ cx = 3.0 * controlPoint1.x
42
+ bx = 3.0 * (controlPoint2.x - controlPoint1.x) - cx
43
+ ax = 1.0 - cx - bx
44
+ cy = 3.0 * controlPoint1.y
45
+ by = 3.0 * (controlPoint2.y - controlPoint1.y) - cy
46
+ ay = 1.0 - cy - by
47
+ }
48
+
49
+ // MARK: Internal
50
+
51
+ /// Computes the progress `y` value for a given `x` value
52
+ func value(for x: CGFloat, epsilon: CGFloat) -> CGFloat {
53
+ sampleCurveY(solveCurveX(x, epsilon: epsilon))
54
+ }
55
+
56
+ // MARK: Private
57
+
58
+ private let ax: CGFloat
59
+ private let bx: CGFloat
60
+ private let cx: CGFloat
61
+ private let ay: CGFloat
62
+ private let by: CGFloat
63
+ private let cy: CGFloat
64
+
65
+ /// Compute `x(t)` for a given `t`
66
+ private func sampleCurveX(_ t: CGFloat) -> CGFloat {
67
+ // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule.
68
+ ((ax * t + bx) * t + cx) * t
69
+ }
70
+
71
+ /// Compute `y(t)` for a given `t`
72
+ private func sampleCurveY(_ t: CGFloat) -> CGFloat {
73
+ ((ay * t + by) * t + cy) * t
74
+ }
75
+
76
+ /// Compute `x'(t)` for a given `t`
77
+ private func sampleCurveDerivativeX(_ t: CGFloat) -> CGFloat {
78
+ (3.0 * ax * t + 2.0 * bx) * t + cx
79
+ }
80
+
81
+ /// Given an `x` value solve for the parametric value `t`
82
+ private func solveCurveX(_ x: CGFloat, epsilon: CGFloat) -> CGFloat {
83
+ var t0: CGFloat
84
+ var t1: CGFloat
85
+ var t2: CGFloat
86
+ var x2: CGFloat
87
+ var d2: CGFloat
88
+
89
+ // First try a few iterations of Newton-Raphson -- normally very fast.
90
+ t2 = x
91
+ for _ in 0..<8 {
92
+ x2 = sampleCurveX(t2) - x
93
+ guard abs(x2) >= epsilon else { return t2 }
94
+ d2 = sampleCurveDerivativeX(t2)
95
+ guard abs(d2) >= 1e-6 else { break }
96
+ t2 = t2 - x2 / d2
97
+ }
98
+
99
+ // Fall back to the bisection method for reliability.
100
+ t0 = 0.0
101
+ t1 = 1.0
102
+ t2 = x
103
+ guard t2 >= t0 else { return t0 }
104
+ guard t2 <= t1 else { return t1 }
105
+
106
+ while t0 < t1 {
107
+ x2 = sampleCurveX(t2)
108
+ guard abs(x2 - x) >= epsilon else { return t2 }
109
+ if x > x2 {
110
+ t0 = t2
111
+ } else {
112
+ t1 = t2
113
+ }
114
+ t2 = (t1 - t0) * 0.5 + t0
115
+ }
116
+
117
+ return t2
118
+ }
119
+ }