From 765b4b4834f18b8c98a1eb57211289b06bc69ef2 Mon Sep 17 00:00:00 2001 From: Brandon Withrow Date: Wed, 15 Feb 2017 11:23:34 -0800 Subject: [PATCH] Namespaces CGGeomteryAdditions --- Example/Pods/Pods.xcodeproj/project.pbxproj | 30 +-- Lottie.xcodeproj/project.pbxproj | 26 ++- .../Classes/AnimatableLayers/LOTLayerView.m | 2 +- .../AnimatableLayers/LOTRectShapeLayer.m | 16 +- .../LOTAnimatableNumberValue.m | 2 +- .../LOTAnimatablePointValue.m | 14 +- .../LOTAnimatableShapeValue.m | 26 +-- .../Extensions/CGGeometry+LOTAdditions.h | 89 +++++++++ ...yAdditions.m => CGGeometry+LOTAdditions.m} | 178 +++++++----------- .../Classes/Extensions/CGGeometryAdditions.h | 106 ----------- lottie-ios/Classes/Extensions/LOTHelpers.h | 2 +- lottie-ios/Classes/Models/LOTLayer.m | 2 +- lottie-ios/Classes/Models/LOTShapeTransform.m | 2 +- lottie-ios/Classes/Private/LOTAnimationView.m | 32 ++-- 14 files changed, 233 insertions(+), 294 deletions(-) create mode 100644 lottie-ios/Classes/Extensions/CGGeometry+LOTAdditions.h rename lottie-ios/Classes/Extensions/{CGGeometryAdditions.m => CGGeometry+LOTAdditions.m} (60%) delete mode 100644 lottie-ios/Classes/Extensions/CGGeometryAdditions.h diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index 5b1b0f69c5..d9e40e8831 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -17,7 +17,6 @@ 08EEF536571B1944EEE24963FE47D796 /* UIBezierPath.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FBF1CDED2D52DF6430B4E8BB3F0B650 /* UIBezierPath.m */; }; 099861D88F2BD9EEFDAF48C506F7E759 /* LOTShapeStroke.m in Sources */ = {isa = PBXBuildFile; fileRef = 16C8676DB5D0B04ECB624FF8744D0C1D /* LOTShapeStroke.m */; }; 0B29280A9ADDDD0EE1FA1575967AC5BD /* LOTShapeLayerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B4F91019A41754A4617A095209FAEFB /* LOTShapeLayerView.m */; }; - 0CABCE1BA137EC951B04F8765A3ECD2E /* CGGeometryAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 853ADCB5AF0B129F0F8521140BB3F6B8 /* CGGeometryAdditions.h */; settings = {ATTRIBUTES = (Project, ); }; }; 0F981EA0F990063F90AB32883A53CE20 /* CALayer+Compat.m in Sources */ = {isa = PBXBuildFile; fileRef = 2221C72141CA0F9E4A74F081D3487A50 /* CALayer+Compat.m */; }; 0FE6D67AC31B34E5650ABE9F9DD2F12C /* LOTShapeLayerView.h in Headers */ = {isa = PBXBuildFile; fileRef = 16A063CC12991C8327B36E9D8C92CDC0 /* LOTShapeLayerView.h */; settings = {ATTRIBUTES = (Project, ); }; }; 125FD7A203E94B904350E4DCF69758F0 /* LOTAnimatableBoundsValue.m in Sources */ = {isa = PBXBuildFile; fileRef = EDFE7F79A4FF48FA8ECE09662E91458C /* LOTAnimatableBoundsValue.m */; }; @@ -35,7 +34,6 @@ 1B64907E5DC216E111CFB12FE773C603 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CA13E2F72B2A84E8D774F18DD936CA54 /* UIKit.framework */; }; 1B7AD1DB3B240B3F6075DAC7A2C60327 /* LOTPlatformCompat.h in Headers */ = {isa = PBXBuildFile; fileRef = F24E0C925C4270DDE18CBB23F53F913E /* LOTPlatformCompat.h */; settings = {ATTRIBUTES = (Project, ); }; }; 1C1FD4859F03CD5975789890C67FDE5B /* LOTShapeGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A37C29AA31036ACF0E3F7FB465FE25 /* LOTShapeGroup.m */; }; - 1C636B64825FE9F560CDFD9315069210 /* CGGeometryAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 82F6132D0F382F569E146FA58E4DAA27 /* CGGeometryAdditions.m */; }; 1D1543E455046617A8F412994A6B8713 /* LOTAnimatableBoundsValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A82B58FA427565C666E5DA0D725093 /* LOTAnimatableBoundsValue.h */; settings = {ATTRIBUTES = (Project, ); }; }; 1E1DE2EBC07D431A387942FCD8EA724B /* LOTShapeRectangle.m in Sources */ = {isa = PBXBuildFile; fileRef = 00D983F9220AE1924E72BFFEDBA59D4B /* LOTShapeRectangle.m */; }; 204B15A3A04FF0F15CA4AA8D6E3F3E71 /* LOTAnimatableValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AA3D46A24675B28BBB71E39E7D1548DF /* LOTAnimatableValue.h */; settings = {ATTRIBUTES = (Project, ); }; }; @@ -50,7 +48,6 @@ 29CA4EE59B08D1ED8109B415457D3CDC /* LOTGroupLayerView.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C8E46C27F65CF9753008BA18A44A91 /* LOTGroupLayerView.h */; settings = {ATTRIBUTES = (Project, ); }; }; 2CDB9C2783AEFB59BD0E027E2E0F88A7 /* LOTMask.h in Headers */ = {isa = PBXBuildFile; fileRef = CCFB05FD8351F6DF6D9DB1678426591E /* LOTMask.h */; settings = {ATTRIBUTES = (Project, ); }; }; 2E8B54E6D3C436614572A1331766E9C2 /* LOTAnimatablePointValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 253B264574F52915783E6B9A79E1B0D7 /* LOTAnimatablePointValue.h */; settings = {ATTRIBUTES = (Project, ); }; }; - 308BAC9046FD2B69BB7CCDA6F24FE59D /* CGGeometryAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 853ADCB5AF0B129F0F8521140BB3F6B8 /* CGGeometryAdditions.h */; settings = {ATTRIBUTES = (Project, ); }; }; 32D0A6870FA6569B8C751F792E3DBA4B /* LOTAnimatableValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AA3D46A24675B28BBB71E39E7D1548DF /* LOTAnimatableValue.h */; settings = {ATTRIBUTES = (Project, ); }; }; 362836E5A94EEC788130DAB3D72E04E8 /* LOTEllipseShapeLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E770FF8A8E7B0E14EB69C241E457F8 /* LOTEllipseShapeLayer.m */; }; 381DE86C0D48DA6EB48C96B2EC366E00 /* LOTAnimationTransitionController.h in Headers */ = {isa = PBXBuildFile; fileRef = 199792E3A60E47FA2A14B052B41C0E33 /* LOTAnimationTransitionController.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -62,6 +59,10 @@ 43525BF925E577FA5BC55FA8722D3C95 /* LOTShapeCircle.h in Headers */ = {isa = PBXBuildFile; fileRef = 67A217DEE8582AD940BEAF7BA905E0BE /* LOTShapeCircle.h */; settings = {ATTRIBUTES = (Project, ); }; }; 46F17145DD61E422E878E2625D0588FA /* LOTLayerView.h in Headers */ = {isa = PBXBuildFile; fileRef = 604821344D6182F76D74EAFC3DC8A31B /* LOTLayerView.h */; settings = {ATTRIBUTES = (Project, ); }; }; 4732ECB066C837C3484D9DB2F226773D /* LOTComposition.m in Sources */ = {isa = PBXBuildFile; fileRef = 914E38365E034D0D2874EAB4410B0ED0 /* LOTComposition.m */; }; + 48183C961E54E1B60039F121 /* CGGeometry+LOTAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 48183C941E54E1B60039F121 /* CGGeometry+LOTAdditions.h */; }; + 48183C971E54E1B60039F121 /* CGGeometry+LOTAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 48183C941E54E1B60039F121 /* CGGeometry+LOTAdditions.h */; }; + 48183C981E54E1B60039F121 /* CGGeometry+LOTAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 48183C951E54E1B60039F121 /* CGGeometry+LOTAdditions.m */; }; + 48183C991E54E1B60039F121 /* CGGeometry+LOTAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 48183C951E54E1B60039F121 /* CGGeometry+LOTAdditions.m */; }; 4833D2BD0666884F509A85C031D7CBCE /* LOTComposition.h in Headers */ = {isa = PBXBuildFile; fileRef = B758F16C1930B57D432706DF7B9D2107 /* LOTComposition.h */; settings = {ATTRIBUTES = (Project, ); }; }; 484FF8CA1E4A972500B2B4FF /* LOTStrokeShapeLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 484FF8C81E4A972500B2B4FF /* LOTStrokeShapeLayer.h */; }; 484FF8CB1E4A972500B2B4FF /* LOTStrokeShapeLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 484FF8C81E4A972500B2B4FF /* LOTStrokeShapeLayer.h */; }; @@ -155,7 +156,6 @@ BF971A24FED3B68FE4D1FD776BC47303 /* LOTAnimationTransitionController.m in Sources */ = {isa = PBXBuildFile; fileRef = AD20C5D921D9FA9DB42FDEAAD80BD9B9 /* LOTAnimationTransitionController.m */; }; C11C61F03C917D78AFA0838A8E4412F6 /* LOTAnimatablePointValue.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3C589944F8D998A78749A1AF85D8DE /* LOTAnimatablePointValue.m */; }; C2F8ACA3161511701D310AD830AB73DA /* LOTShapeStroke.m in Sources */ = {isa = PBXBuildFile; fileRef = 16C8676DB5D0B04ECB624FF8744D0C1D /* LOTShapeStroke.m */; }; - C78083529E6F254FA5A439BB838361A5 /* CGGeometryAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 82F6132D0F382F569E146FA58E4DAA27 /* CGGeometryAdditions.m */; }; C92D0AA32EE280340C0766FBA3C4F5B6 /* LOTAnimatableLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A356195F8E422F04DDBE0277E4B285C /* LOTAnimatableLayer.m */; }; CED532CCB58213D9CC1B20F9E02358A0 /* LOTShapeGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 08E2BE6E6F4E09DCAE63E77FA45E8D2F /* LOTShapeGroup.h */; settings = {ATTRIBUTES = (Project, ); }; }; CF2E359C8482BF80B812CA755D379321 /* LOTAnimatableScaleValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 3C037597573E9C79DE2ABBB5DEB7F38A /* LOTAnimatableScaleValue.h */; settings = {ATTRIBUTES = (Project, ); }; }; @@ -241,6 +241,8 @@ 3C037597573E9C79DE2ABBB5DEB7F38A /* LOTAnimatableScaleValue.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = LOTAnimatableScaleValue.h; sourceTree = ""; }; 3ED39BAEA78A76BB031647F4E01D9689 /* Pods-Lottie-Example-MacOS.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Pods-Lottie-Example-MacOS.modulemap"; sourceTree = ""; }; 3FC6C122778B882931A442F9B6AAE024 /* lottie-ios-OSX-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "lottie-ios-OSX-prefix.pch"; sourceTree = ""; }; + 48183C941E54E1B60039F121 /* CGGeometry+LOTAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CGGeometry+LOTAdditions.h"; sourceTree = ""; }; + 48183C951E54E1B60039F121 /* CGGeometry+LOTAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CGGeometry+LOTAdditions.m"; sourceTree = ""; }; 484FF8C81E4A972500B2B4FF /* LOTStrokeShapeLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LOTStrokeShapeLayer.h; sourceTree = ""; }; 484FF8C91E4A972500B2B4FF /* LOTStrokeShapeLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LOTStrokeShapeLayer.m; sourceTree = ""; }; 4897935C31F44A855C225490165F579E /* CAAnimationGroup+LOTAnimatableGroup.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "CAAnimationGroup+LOTAnimatableGroup.m"; sourceTree = ""; }; @@ -266,10 +268,8 @@ 7725F4F35EFB1A561204B8B714BF14FA /* UIColor+Expanded.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "UIColor+Expanded.h"; sourceTree = ""; }; 7A6381396C315D89301561EC79224990 /* CALayer+Compat.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "CALayer+Compat.h"; sourceTree = ""; }; 7B84DD8BA444B84A5807EA458734DA5D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; - 82F6132D0F382F569E146FA58E4DAA27 /* CGGeometryAdditions.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = CGGeometryAdditions.m; sourceTree = ""; }; 83C8E46C27F65CF9753008BA18A44A91 /* LOTGroupLayerView.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = LOTGroupLayerView.h; sourceTree = ""; }; 84A82B58FA427565C666E5DA0D725093 /* LOTAnimatableBoundsValue.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = LOTAnimatableBoundsValue.h; sourceTree = ""; }; - 853ADCB5AF0B129F0F8521140BB3F6B8 /* CGGeometryAdditions.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = CGGeometryAdditions.h; sourceTree = ""; }; 8592EA877C1B4E06F2DFBFDF38C1CBA7 /* LOTMaskLayer.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = LOTMaskLayer.m; sourceTree = ""; }; 882BD1ABCEEB35BB434E09E1341BED91 /* Lottie.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Lottie.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 8A157E1D06CC3E8A458366614657D561 /* LOTAnimationView.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = LOTAnimationView.m; sourceTree = ""; }; @@ -446,7 +446,7 @@ DC3B1FA61F43E8C516B69F77E9CAF1D6 /* UIColor.h */, 8D27B4F779C6777D529D7ECF8C2F7818 /* UIColor.m */, ); - path = "MacCompatability"; + path = MacCompatability; sourceTree = ""; }; 5C2E5B3228F4A33353B6DC6C3E4ACDA5 /* AnimationCache */ = { @@ -455,7 +455,7 @@ 262826A76F079A347BA24ABF06CDB0FE /* LOTAnimationCache.h */, 5B28A1060F4CA73B2C8DECA596DC1415 /* LOTAnimationCache.m */, ); - path = "AnimationCache"; + path = AnimationCache; sourceTree = ""; }; 679D0DF302A7EBDDA0D3C6B2BA14DC8A /* Extensions */ = { @@ -463,8 +463,8 @@ children = ( 7699768EF0DC404BD8D6AF609213BE75 /* CAAnimationGroup+LOTAnimatableGroup.h */, 4897935C31F44A855C225490165F579E /* CAAnimationGroup+LOTAnimatableGroup.m */, - 853ADCB5AF0B129F0F8521140BB3F6B8 /* CGGeometryAdditions.h */, - 82F6132D0F382F569E146FA58E4DAA27 /* CGGeometryAdditions.m */, + 48183C941E54E1B60039F121 /* CGGeometry+LOTAdditions.h */, + 48183C951E54E1B60039F121 /* CGGeometry+LOTAdditions.m */, 8E06AC3CC982685463EB8FB1A8A00077 /* LOTHelpers.h */, 7725F4F35EFB1A561204B8B714BF14FA /* UIColor+Expanded.h */, 9E30A18DA5453C1650631505E0326941 /* UIColor+Expanded.m */, @@ -512,7 +512,7 @@ 484FF8C81E4A972500B2B4FF /* LOTStrokeShapeLayer.h */, 484FF8C91E4A972500B2B4FF /* LOTStrokeShapeLayer.m */, ); - path = "AnimatableLayers"; + path = AnimatableLayers; sourceTree = ""; }; 717A3D55F0A42F0DD366468F205B030C /* PublicHeaders */ = { @@ -706,7 +706,6 @@ A972C8D4B5D0BFF794338049A47FBE1A /* CAAnimationGroup+LOTAnimatableGroup.h in Headers */, 5F18978641DA29CD188FBA1D8EB501D5 /* CADisplayLink.h in Headers */, 95F662708D1A26121B6D4E602187AAE6 /* CALayer+Compat.h in Headers */, - 0CABCE1BA137EC951B04F8765A3ECD2E /* CGGeometryAdditions.h in Headers */, 17C42E0EED16415A9EDD363DEEBCABDD /* LOTAnimatableBoundsValue.h in Headers */, 810EB908A3535240BDE4C77147744300 /* LOTAnimatableColorValue.h in Headers */, BF7CF85D9D53A2325472C9CB84D401A4 /* LOTAnimatableLayer.h in Headers */, @@ -729,6 +728,7 @@ 23FF5E1FEC9F357DEEC6BFE5563C10F1 /* LOTMask.h in Headers */, 7299688E73D2B61F3361281ACBB4660E /* LOTMaskLayer.h in Headers */, 579F11312EA02E2DCFF81BE25F51DB39 /* LOTModels.h in Headers */, + 48183C971E54E1B60039F121 /* CGGeometry+LOTAdditions.h in Headers */, 1B7AD1DB3B240B3F6075DAC7A2C60327 /* LOTPlatformCompat.h in Headers */, 9393029CAB8D0DCFBD598DCA8F9652CB /* LOTRectShapeLayer.h in Headers */, 43525BF925E577FA5BC55FA8722D3C95 /* LOTShapeCircle.h in Headers */, @@ -757,7 +757,6 @@ 68F736D1CD2598FFA36E68D13D886E38 /* CAAnimationGroup+LOTAnimatableGroup.h in Headers */, F796DAA7DD4E7F271892DC980D1FFE24 /* CADisplayLink.h in Headers */, B6A5941F7E8B53F1E4926FD7716A00DE /* CALayer+Compat.h in Headers */, - 308BAC9046FD2B69BB7CCDA6F24FE59D /* CGGeometryAdditions.h in Headers */, 1D1543E455046617A8F412994A6B8713 /* LOTAnimatableBoundsValue.h in Headers */, 96142EF4F16B59D098BD648927183FFA /* LOTAnimatableColorValue.h in Headers */, D7BA59A4D0507D575473765CF02F0233 /* LOTAnimatableLayer.h in Headers */, @@ -780,6 +779,7 @@ 2CDB9C2783AEFB59BD0E027E2E0F88A7 /* LOTMask.h in Headers */, 7EDB7B9FA909F0E056D34EEEFD73D9EF /* LOTMaskLayer.h in Headers */, E2D5868DEC6CBB929B419FB3285731B1 /* LOTModels.h in Headers */, + 48183C961E54E1B60039F121 /* CGGeometry+LOTAdditions.h in Headers */, 019EB390040200530FBD33CFCE1C6C0C /* LOTPlatformCompat.h in Headers */, FB9D8FF758399BF0DDE29DF9D14FD18C /* LOTRectShapeLayer.h in Headers */, F9FC80D505B823B40B2B00D5D3D070C6 /* LOTShapeCircle.h in Headers */, @@ -952,7 +952,6 @@ 1AF05E6A1ED488D8A4590E451D16DB25 /* CAAnimationGroup+LOTAnimatableGroup.m in Sources */, 38724389F4AF391B9BC43CD50AA3EDD8 /* CADisplayLink.m in Sources */, 0F981EA0F990063F90AB32883A53CE20 /* CALayer+Compat.m in Sources */, - C78083529E6F254FA5A439BB838361A5 /* CGGeometryAdditions.m in Sources */, 125FD7A203E94B904350E4DCF69758F0 /* LOTAnimatableBoundsValue.m in Sources */, 9B3E6A02A045DF4A5F215401E3334912 /* LOTAnimatableColorValue.m in Sources */, C92D0AA32EE280340C0766FBA3C4F5B6 /* LOTAnimatableLayer.m in Sources */, @@ -973,6 +972,7 @@ DBD9A18F3667D4871E60D8460D206F6C /* LOTMaskLayer.m in Sources */, BF134B98B1B9D10C25342E2C29FB8765 /* LOTRectShapeLayer.m in Sources */, FC2DFB5A3D8CA54CB00264F7DF5DBCA7 /* LOTShapeCircle.m in Sources */, + 48183C981E54E1B60039F121 /* CGGeometry+LOTAdditions.m in Sources */, 7979D3A6E47E7449AC865C57DD35F839 /* LOTShapeFill.m in Sources */, 1C1FD4859F03CD5975789890C67FDE5B /* LOTShapeGroup.m in Sources */, 4F0B2D6C49741327F6B439F355B73E51 /* LOTShapeLayerView.m in Sources */, @@ -1012,7 +1012,6 @@ 07DF80DAF9334BF948557F2B6E25CA41 /* CAAnimationGroup+LOTAnimatableGroup.m in Sources */, 03667BC5DD6C96DC5FA10669D8D1169C /* CADisplayLink.m in Sources */, 7EB6832366B45B6EA7B484FC55BD065C /* CALayer+Compat.m in Sources */, - 1C636B64825FE9F560CDFD9315069210 /* CGGeometryAdditions.m in Sources */, D7441019D83407B7975F2CD33EE1E55E /* LOTAnimatableBoundsValue.m in Sources */, 7AFD15F6190F7EADEA3CF258FF21D8D5 /* LOTAnimatableColorValue.m in Sources */, 15AC80C6C96763DFEEC790A9791E51E9 /* LOTAnimatableLayer.m in Sources */, @@ -1033,6 +1032,7 @@ 8BCEE8B56B5888414B337285A8A8A07C /* LOTMaskLayer.m in Sources */, ECFF0DF0D7D8168BC81B98D4FFE56BAE /* LOTRectShapeLayer.m in Sources */, DA138E1AC245BB30E51CE90933818034 /* LOTShapeCircle.m in Sources */, + 48183C991E54E1B60039F121 /* CGGeometry+LOTAdditions.m in Sources */, 15EF53F42565FBC7BBF78E742576D83E /* LOTShapeFill.m in Sources */, FCF6945890A6ECE3E662EAD107349713 /* LOTShapeGroup.m in Sources */, 0B29280A9ADDDD0EE1FA1575967AC5BD /* LOTShapeLayerView.m in Sources */, diff --git a/Lottie.xcodeproj/project.pbxproj b/Lottie.xcodeproj/project.pbxproj index 91f892017d..2a62603be8 100644 --- a/Lottie.xcodeproj/project.pbxproj +++ b/Lottie.xcodeproj/project.pbxproj @@ -8,6 +8,10 @@ /* Begin PBXBuildFile section */ 2DBA19324CDD83B5F0F115B8 /* LOTAnimationView_Compat.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DBA16351B4FA408937A16CE /* LOTAnimationView_Compat.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 48183C9C1E54E20B0039F121 /* CGGeometry+LOTAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 48183C9A1E54E20B0039F121 /* CGGeometry+LOTAdditions.h */; }; + 48183C9D1E54E20B0039F121 /* CGGeometry+LOTAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 48183C9A1E54E20B0039F121 /* CGGeometry+LOTAdditions.h */; }; + 48183C9E1E54E20B0039F121 /* CGGeometry+LOTAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 48183C9B1E54E20B0039F121 /* CGGeometry+LOTAdditions.m */; }; + 48183C9F1E54E20B0039F121 /* CGGeometry+LOTAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 48183C9B1E54E20B0039F121 /* CGGeometry+LOTAdditions.m */; }; 481A4A5B1E4A7885003CF62B /* LOTAnimatableLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 481A4A181E4A7885003CF62B /* LOTAnimatableLayer.h */; }; 481A4A5C1E4A7885003CF62B /* LOTAnimatableLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 481A4A181E4A7885003CF62B /* LOTAnimatableLayer.h */; }; 481A4A5D1E4A7885003CF62B /* LOTAnimatableLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 481A4A191E4A7885003CF62B /* LOTAnimatableLayer.m */; }; @@ -70,10 +74,6 @@ 481A4A961E4A7885003CF62B /* CAAnimationGroup+LOTAnimatableGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 481A4A381E4A7885003CF62B /* CAAnimationGroup+LOTAnimatableGroup.h */; }; 481A4A971E4A7885003CF62B /* CAAnimationGroup+LOTAnimatableGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = 481A4A391E4A7885003CF62B /* CAAnimationGroup+LOTAnimatableGroup.m */; }; 481A4A981E4A7885003CF62B /* CAAnimationGroup+LOTAnimatableGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = 481A4A391E4A7885003CF62B /* CAAnimationGroup+LOTAnimatableGroup.m */; }; - 481A4A991E4A7885003CF62B /* CGGeometryAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 481A4A3A1E4A7885003CF62B /* CGGeometryAdditions.h */; }; - 481A4A9A1E4A7885003CF62B /* CGGeometryAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 481A4A3A1E4A7885003CF62B /* CGGeometryAdditions.h */; }; - 481A4A9B1E4A7885003CF62B /* CGGeometryAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 481A4A3B1E4A7885003CF62B /* CGGeometryAdditions.m */; }; - 481A4A9C1E4A7885003CF62B /* CGGeometryAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 481A4A3B1E4A7885003CF62B /* CGGeometryAdditions.m */; }; 481A4A9D1E4A7885003CF62B /* LOTHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 481A4A3C1E4A7885003CF62B /* LOTHelpers.h */; }; 481A4A9E1E4A7885003CF62B /* LOTHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 481A4A3C1E4A7885003CF62B /* LOTHelpers.h */; }; 481A4A9F1E4A7885003CF62B /* UIColor+Expanded.h in Headers */ = {isa = PBXBuildFile; fileRef = 481A4A3D1E4A7885003CF62B /* UIColor+Expanded.h */; }; @@ -165,7 +165,6 @@ 84FE13041E4C1553009B157C /* LOTAnimatableShapeValue.m in Sources */ = {isa = PBXBuildFile; fileRef = 481A4A321E4A7885003CF62B /* LOTAnimatableShapeValue.m */; }; 84FE13051E4C1553009B157C /* LOTAnimationCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 481A4A361E4A7885003CF62B /* LOTAnimationCache.m */; }; 84FE13061E4C1553009B157C /* CAAnimationGroup+LOTAnimatableGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = 481A4A391E4A7885003CF62B /* CAAnimationGroup+LOTAnimatableGroup.m */; }; - 84FE13071E4C1553009B157C /* CGGeometryAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 481A4A3B1E4A7885003CF62B /* CGGeometryAdditions.m */; }; 84FE13081E4C1553009B157C /* UIColor+Expanded.m in Sources */ = {isa = PBXBuildFile; fileRef = 481A4A3E1E4A7885003CF62B /* UIColor+Expanded.m */; }; 84FE13091E4C1553009B157C /* LOTComposition.m in Sources */ = {isa = PBXBuildFile; fileRef = 481A4A411E4A7885003CF62B /* LOTComposition.m */; }; 84FE130A1E4C1553009B157C /* LOTLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 481A4A431E4A7885003CF62B /* LOTLayer.m */; }; @@ -208,6 +207,8 @@ /* Begin PBXFileReference section */ 2DBA16351B4FA408937A16CE /* LOTAnimationView_Compat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LOTAnimationView_Compat.h; sourceTree = ""; }; + 48183C9A1E54E20B0039F121 /* CGGeometry+LOTAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CGGeometry+LOTAdditions.h"; sourceTree = ""; }; + 48183C9B1E54E20B0039F121 /* CGGeometry+LOTAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CGGeometry+LOTAdditions.m"; sourceTree = ""; }; 481A4A181E4A7885003CF62B /* LOTAnimatableLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LOTAnimatableLayer.h; sourceTree = ""; }; 481A4A191E4A7885003CF62B /* LOTAnimatableLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LOTAnimatableLayer.m; sourceTree = ""; }; 481A4A1A1E4A7885003CF62B /* LOTEllipseShapeLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LOTEllipseShapeLayer.h; sourceTree = ""; }; @@ -239,8 +240,6 @@ 481A4A361E4A7885003CF62B /* LOTAnimationCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LOTAnimationCache.m; sourceTree = ""; }; 481A4A381E4A7885003CF62B /* CAAnimationGroup+LOTAnimatableGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CAAnimationGroup+LOTAnimatableGroup.h"; sourceTree = ""; }; 481A4A391E4A7885003CF62B /* CAAnimationGroup+LOTAnimatableGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CAAnimationGroup+LOTAnimatableGroup.m"; sourceTree = ""; }; - 481A4A3A1E4A7885003CF62B /* CGGeometryAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGGeometryAdditions.h; sourceTree = ""; }; - 481A4A3B1E4A7885003CF62B /* CGGeometryAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CGGeometryAdditions.m; sourceTree = ""; }; 481A4A3C1E4A7885003CF62B /* LOTHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LOTHelpers.h; sourceTree = ""; }; 481A4A3D1E4A7885003CF62B /* UIColor+Expanded.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+Expanded.h"; sourceTree = ""; }; 481A4A3E1E4A7885003CF62B /* UIColor+Expanded.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+Expanded.m"; sourceTree = ""; }; @@ -378,8 +377,8 @@ children = ( 481A4A381E4A7885003CF62B /* CAAnimationGroup+LOTAnimatableGroup.h */, 481A4A391E4A7885003CF62B /* CAAnimationGroup+LOTAnimatableGroup.m */, - 481A4A3A1E4A7885003CF62B /* CGGeometryAdditions.h */, - 481A4A3B1E4A7885003CF62B /* CGGeometryAdditions.m */, + 48183C9A1E54E20B0039F121 /* CGGeometry+LOTAdditions.h */, + 48183C9B1E54E20B0039F121 /* CGGeometry+LOTAdditions.m */, 481A4A3C1E4A7885003CF62B /* LOTHelpers.h */, 481A4A3D1E4A7885003CF62B /* UIColor+Expanded.h */, 481A4A3E1E4A7885003CF62B /* UIColor+Expanded.m */, @@ -513,6 +512,7 @@ 481A4AB51E4A7885003CF62B /* LOTShapeFill.h in Headers */, 481A4A6B1E4A7885003CF62B /* LOTMaskLayer.h in Headers */, 481A4AEE1E4A78A5003CF62B /* LOTPlatformCompat.h in Headers */, + 48183C9C1E54E20B0039F121 /* CGGeometry+LOTAdditions.h in Headers */, 481A4A8F1E4A7885003CF62B /* LOTAnimatableValue.h in Headers */, 481A4ABD1E4A7885003CF62B /* LOTShapePath.h in Headers */, 481A4A831E4A7885003CF62B /* LOTAnimatablePointValue.h in Headers */, @@ -526,7 +526,6 @@ 489F8E121E4CF3BE00F2DEB7 /* LOTStrokeShapeLayer.h in Headers */, 481A4A671E4A7885003CF62B /* LOTLayerView.h in Headers */, 481A4AC11E4A7885003CF62B /* LOTShapeRectangle.h in Headers */, - 481A4A991E4A7885003CF62B /* CGGeometryAdditions.h in Headers */, 481A4AC51E4A7885003CF62B /* LOTShapeStroke.h in Headers */, 481A4A911E4A7885003CF62B /* LOTAnimationCache.h in Headers */, 481A4A6F1E4A7885003CF62B /* LOTRectShapeLayer.h in Headers */, @@ -568,6 +567,7 @@ 481A4ACA1E4A7885003CF62B /* LOTShapeTransform.h in Headers */, 481A4AE51E4A78A0003CF62B /* CALayer+Compat.h in Headers */, 489F8E131E4CF3BE00F2DEB7 /* LOTStrokeShapeLayer.h in Headers */, + 48183C9D1E54E20B0039F121 /* CGGeometry+LOTAdditions.h in Headers */, 481A4A701E4A7885003CF62B /* LOTRectShapeLayer.h in Headers */, 481A4A7C1E4A7885003CF62B /* LOTAnimatableColorValue.h in Headers */, 481A4A6C1E4A7885003CF62B /* LOTMaskLayer.h in Headers */, @@ -578,7 +578,6 @@ 481A4AD61E4A7885003CF62B /* LOTAnimationView_Internal.h in Headers */, FA1F5AA11E42B52800FF36BF /* LOTAnimationView.h in Headers */, 481A4AC61E4A7885003CF62B /* LOTShapeStroke.h in Headers */, - 481A4A9A1E4A7885003CF62B /* CGGeometryAdditions.h in Headers */, 481A4AA41E4A7885003CF62B /* LOTComposition.h in Headers */, 481A4A801E4A7885003CF62B /* LOTAnimatableNumberValue.h in Headers */, 481A4ACE1E4A7885003CF62B /* LOTShapeTrimPath.h in Headers */, @@ -718,7 +717,6 @@ 481A4AA11E4A7885003CF62B /* UIColor+Expanded.m in Sources */, 481A4AA51E4A7885003CF62B /* LOTComposition.m in Sources */, 481A4A7D1E4A7885003CF62B /* LOTAnimatableColorValue.m in Sources */, - 481A4A9B1E4A7885003CF62B /* CGGeometryAdditions.m in Sources */, 481A4A651E4A7885003CF62B /* LOTGroupLayerView.m in Sources */, 481A4AB71E4A7885003CF62B /* LOTShapeFill.m in Sources */, 481A4A691E4A7885003CF62B /* LOTLayerView.m in Sources */, @@ -735,6 +733,7 @@ 481A4AB31E4A7885003CF62B /* LOTShapeCircle.m in Sources */, 481A4A711E4A7885003CF62B /* LOTRectShapeLayer.m in Sources */, 481A4A751E4A7885003CF62B /* LOTShapeLayerView.m in Sources */, + 48183C9E1E54E20B0039F121 /* CGGeometry+LOTAdditions.m in Sources */, 481A4ABF1E4A7885003CF62B /* LOTShapePath.m in Sources */, 481A4A611E4A7885003CF62B /* LOTEllipseShapeLayer.m in Sources */, 481A4A851E4A7885003CF62B /* LOTAnimatablePointValue.m in Sources */, @@ -763,7 +762,6 @@ 84FE13041E4C1553009B157C /* LOTAnimatableShapeValue.m in Sources */, 84FE13051E4C1553009B157C /* LOTAnimationCache.m in Sources */, 84FE13061E4C1553009B157C /* CAAnimationGroup+LOTAnimatableGroup.m in Sources */, - 84FE13071E4C1553009B157C /* CGGeometryAdditions.m in Sources */, 84FE13081E4C1553009B157C /* UIColor+Expanded.m in Sources */, 84FE13091E4C1553009B157C /* LOTComposition.m in Sources */, 84FE130A1E4C1553009B157C /* LOTLayer.m in Sources */, @@ -790,13 +788,13 @@ 481A4A6E1E4A7885003CF62B /* LOTMaskLayer.m in Sources */, 481A4A941E4A7885003CF62B /* LOTAnimationCache.m in Sources */, 481A4AD01E4A7885003CF62B /* LOTShapeTrimPath.m in Sources */, - 481A4A9C1E4A7885003CF62B /* CGGeometryAdditions.m in Sources */, 481A4AA61E4A7885003CF62B /* LOTComposition.m in Sources */, 481A4AC41E4A7885003CF62B /* LOTShapeRectangle.m in Sources */, 481A4ACC1E4A7885003CF62B /* LOTShapeTransform.m in Sources */, 481A4AB81E4A7885003CF62B /* LOTShapeFill.m in Sources */, 481A4AC01E4A7885003CF62B /* LOTShapePath.m in Sources */, 481A4A721E4A7885003CF62B /* LOTRectShapeLayer.m in Sources */, + 48183C9F1E54E20B0039F121 /* CGGeometry+LOTAdditions.m in Sources */, 481A4AAE1E4A7885003CF62B /* LOTMask.m in Sources */, 481A4A8E1E4A7885003CF62B /* LOTAnimatableShapeValue.m in Sources */, 481A4A5E1E4A7885003CF62B /* LOTAnimatableLayer.m in Sources */, diff --git a/lottie-ios/Classes/AnimatableLayers/LOTLayerView.m b/lottie-ios/Classes/AnimatableLayers/LOTLayerView.m index 22f01bed8d..95492aa4f2 100644 --- a/lottie-ios/Classes/AnimatableLayers/LOTLayerView.m +++ b/lottie-ios/Classes/AnimatableLayers/LOTLayerView.m @@ -13,7 +13,7 @@ #import "LOTGroupLayerView.h" #import "CAAnimationGroup+LOTAnimatableGroup.h" #import "LOTMaskLayer.h" -#import "CGGeometryAdditions.h" +#import "CGGeometry+LOTAdditions.h" @interface LOTParentLayer : LOTAnimatableLayer diff --git a/lottie-ios/Classes/AnimatableLayers/LOTRectShapeLayer.m b/lottie-ios/Classes/AnimatableLayers/LOTRectShapeLayer.m index 4b8bdfcd4d..c7e60c3fe9 100644 --- a/lottie-ios/Classes/AnimatableLayers/LOTRectShapeLayer.m +++ b/lottie-ios/Classes/AnimatableLayers/LOTRectShapeLayer.m @@ -84,8 +84,8 @@ - (void)_setPath { if (radius > 0) { point.x = point.x - radius; - [path1 addArcWithCenter:point radius:radius startAngle:DegreestoRadians(0) endAngle:DegreestoRadians(90) clockwise:YES]; - [path2 addArcWithCenter:point radius:radius startAngle:DegreestoRadians(0) endAngle:DegreestoRadians(90) clockwise:YES]; + [path1 addArcWithCenter:point radius:radius startAngle:LOT_DegreesToRadians(0) endAngle:LOT_DegreesToRadians(90) clockwise:YES]; + [path2 addArcWithCenter:point radius:radius startAngle:LOT_DegreesToRadians(0) endAngle:LOT_DegreesToRadians(90) clockwise:YES]; } point.x = CGRectGetMinX(rectFrame) + radius; @@ -95,8 +95,8 @@ - (void)_setPath { if (radius > 0) { point.y = point.y - radius; - [path1 addArcWithCenter:point radius:radius startAngle:DegreestoRadians(90) endAngle:DegreestoRadians(180) clockwise:YES]; - [path2 addArcWithCenter:point radius:radius startAngle:DegreestoRadians(90) endAngle:DegreestoRadians(180) clockwise:YES]; + [path1 addArcWithCenter:point radius:radius startAngle:LOT_DegreesToRadians(90) endAngle:LOT_DegreesToRadians(180) clockwise:YES]; + [path2 addArcWithCenter:point radius:radius startAngle:LOT_DegreesToRadians(90) endAngle:LOT_DegreesToRadians(180) clockwise:YES]; } point.x = CGRectGetMinX(rectFrame); @@ -106,8 +106,8 @@ - (void)_setPath { if (radius > 0) { point.x = point.x + radius; - [path1 addArcWithCenter:point radius:radius startAngle:DegreestoRadians(180) endAngle:DegreestoRadians(270) clockwise:YES]; - [path2 addArcWithCenter:point radius:radius startAngle:DegreestoRadians(180) endAngle:DegreestoRadians(270) clockwise:YES]; + [path1 addArcWithCenter:point radius:radius startAngle:LOT_DegreesToRadians(180) endAngle:LOT_DegreesToRadians(270) clockwise:YES]; + [path2 addArcWithCenter:point radius:radius startAngle:LOT_DegreesToRadians(180) endAngle:LOT_DegreesToRadians(270) clockwise:YES]; } point.x = CGRectGetMaxX(rectFrame) - radius; @@ -117,8 +117,8 @@ - (void)_setPath { if (radius > 0) { point.y = point.y + radius; - [path1 addArcWithCenter:point radius:radius startAngle:DegreestoRadians(270) endAngle:DegreestoRadians(360) clockwise:YES]; - [path2 addArcWithCenter:point radius:radius startAngle:DegreestoRadians(270) endAngle:DegreestoRadians(360) clockwise:YES]; + [path1 addArcWithCenter:point radius:radius startAngle:LOT_DegreesToRadians(270) endAngle:LOT_DegreesToRadians(360) clockwise:YES]; + [path2 addArcWithCenter:point radius:radius startAngle:LOT_DegreesToRadians(270) endAngle:LOT_DegreesToRadians(360) clockwise:YES]; } [path1 closePath]; [path2 closePath]; diff --git a/lottie-ios/Classes/AnimatableProperties/LOTAnimatableNumberValue.m b/lottie-ios/Classes/AnimatableProperties/LOTAnimatableNumberValue.m index f94565ed8c..d170817762 100644 --- a/lottie-ios/Classes/AnimatableProperties/LOTAnimatableNumberValue.m +++ b/lottie-ios/Classes/AnimatableProperties/LOTAnimatableNumberValue.m @@ -172,7 +172,7 @@ - (void)remapValuesFromMin:(NSNumber *)fromMin toMin:(NSNumber *)toMin toMax:(NSNumber *)toMax { [self remapValueWithBlock:^CGFloat(CGFloat inValue) { - return RemapValue(inValue, fromMin.floatValue, fromMax.floatValue, toMin.floatValue, toMax.floatValue); + return LOT_RemapValue(inValue, fromMin.floatValue, fromMax.floatValue, toMin.floatValue, toMax.floatValue); }]; } diff --git a/lottie-ios/Classes/AnimatableProperties/LOTAnimatablePointValue.m b/lottie-ios/Classes/AnimatableProperties/LOTAnimatablePointValue.m index 48d06764e8..75ae4148d0 100644 --- a/lottie-ios/Classes/AnimatableProperties/LOTAnimatablePointValue.m +++ b/lottie-ios/Classes/AnimatableProperties/LOTAnimatablePointValue.m @@ -8,7 +8,7 @@ #import "LOTPlatformCompat.h" #import "LOTAnimatablePointValue.h" -#import "CGGeometryAdditions.h" +#import "CGGeometry+LOTAdditions.h" @interface LOTAnimatablePointValue () @@ -129,8 +129,8 @@ - (void)_buildAnimationForKeyframes:(NSArray *)keyframes { } else { CGPoint inVertex = [self _pointFromValueArray:startPoint]; [motionPath addCurveToPoint:vertex - controlPoint1:CGPointAddedToPoint(inVertex, cp1) - controlPoint2:CGPointAddedToPoint(vertex, cp2)]; + controlPoint1:LOT_PointAddedToPoint(inVertex, cp1) + controlPoint2:LOT_PointAddedToPoint(vertex, cp2)]; } @@ -177,8 +177,8 @@ - (void)remapPointsFromBounds:(CGRect)frombounds toBounds:(CGRect)toBounds { NSMutableArray *newValues = [NSMutableArray array]; for (NSValue *pointValue in _pointKeyframes) { CGPoint oldPoint = pointValue.CGPointValue; - CGPoint newPoint = CGPointMake(RemapValue(oldPoint.x, frombounds.origin.x, frombounds.size.width, toBounds.origin.x, toBounds.size.width), - RemapValue(oldPoint.y, frombounds.origin.y, frombounds.size.height, toBounds.origin.y, toBounds.size.height)); + CGPoint newPoint = CGPointMake(LOT_RemapValue(oldPoint.x, frombounds.origin.x, frombounds.size.width, toBounds.origin.x, toBounds.size.width), + LOT_RemapValue(oldPoint.y, frombounds.origin.y, frombounds.size.height, toBounds.origin.y, toBounds.size.height)); [newValues addObject:[NSValue valueWithCGPoint:newPoint]]; } NSValue *firstPoint = newValues.firstObject; @@ -186,8 +186,8 @@ - (void)remapPointsFromBounds:(CGRect)frombounds toBounds:(CGRect)toBounds { _pointKeyframes = newValues; _animationPath = nil; } else { - CGPoint newPoint = CGPointMake(RemapValue(_initialPoint.x, frombounds.origin.x, frombounds.size.width, toBounds.origin.x, toBounds.size.width), - RemapValue(_initialPoint.y, frombounds.origin.y, frombounds.size.height, toBounds.origin.y, toBounds.size.height)); + CGPoint newPoint = CGPointMake(LOT_RemapValue(_initialPoint.x, frombounds.origin.x, frombounds.size.width, toBounds.origin.x, toBounds.size.width), + LOT_RemapValue(_initialPoint.y, frombounds.origin.y, frombounds.size.height, toBounds.origin.y, toBounds.size.height)); _initialPoint = newPoint; } } diff --git a/lottie-ios/Classes/AnimatableProperties/LOTAnimatableShapeValue.m b/lottie-ios/Classes/AnimatableProperties/LOTAnimatableShapeValue.m index c7f41b8e80..fab8c242b1 100644 --- a/lottie-ios/Classes/AnimatableProperties/LOTAnimatableShapeValue.m +++ b/lottie-ios/Classes/AnimatableProperties/LOTAnimatableShapeValue.m @@ -7,7 +7,7 @@ // #import "LOTAnimatableShapeValue.h" -#import "CGGeometryAdditions.h" +#import "CGGeometry+LOTAdditions.h" @interface LOTAnimatableShapeValue () @property (nonatomic, readonly) NSArray *shapeKeyframes; @@ -179,23 +179,23 @@ - (UIBezierPath *)_bezierShapeFromValue:(id)value closed:(BOOL)closedPath { for (int i = 1; i < pointsArray.count; i ++) { CGPoint vertex = [self _vertexAtIndex:i inArray:pointsArray]; CGPoint previousVertex = [self _vertexAtIndex:i - 1 inArray:pointsArray]; - CGPoint cp1 = CGPointAddedToPoint(previousVertex, [self _vertexAtIndex:i - 1 inArray:outTangents]); - CGPoint cp2 = CGPointAddedToPoint(vertex, [self _vertexAtIndex:i inArray:inTangents]); + CGPoint cp1 = LOT_PointAddedToPoint(previousVertex, [self _vertexAtIndex:i - 1 inArray:outTangents]); + CGPoint cp2 = LOT_PointAddedToPoint(vertex, [self _vertexAtIndex:i inArray:inTangents]); if (CGPointEqualToPoint(previousVertex, cp1) && CGPointEqualToPoint(vertex, cp2)) { // Straight Line - cp1 = CGPointByLerpingPoints(previousVertex, vertex, 0.01); - cp2 = CGPointByLerpingPoints(previousVertex, vertex, 0.99); + cp1 = LOT_PointByLerpingPoints(previousVertex, vertex, 0.01); + cp2 = LOT_PointByLerpingPoints(previousVertex, vertex, 0.99); } else { if (CGPointEqualToPoint(previousVertex, cp1)) { // Missing out tan - cp1 = CGPointByLerpingPoints(previousVertex, cp2, 0.01); + cp1 = LOT_PointByLerpingPoints(previousVertex, cp2, 0.01); } if (CGPointEqualToPoint(vertex, cp2)) { // Missing in tan - cp2 = CGPointByLerpingPoints(cp1, vertex, 0.99); + cp2 = LOT_PointByLerpingPoints(cp1, vertex, 0.99); } } @@ -207,22 +207,22 @@ - (UIBezierPath *)_bezierShapeFromValue:(id)value closed:(BOOL)closedPath { if (closedPath) { CGPoint vertex = [self _vertexAtIndex:0 inArray:pointsArray]; CGPoint previousVertex = [self _vertexAtIndex:pointsArray.count - 1 inArray:pointsArray]; - CGPoint cp1 = CGPointAddedToPoint(previousVertex, [self _vertexAtIndex:pointsArray.count - 1 inArray:outTangents]); - CGPoint cp2 = CGPointAddedToPoint(vertex, [self _vertexAtIndex:0 inArray:inTangents]); + CGPoint cp1 = LOT_PointAddedToPoint(previousVertex, [self _vertexAtIndex:pointsArray.count - 1 inArray:outTangents]); + CGPoint cp2 = LOT_PointAddedToPoint(vertex, [self _vertexAtIndex:0 inArray:inTangents]); if (CGPointEqualToPoint(previousVertex, cp1) && CGPointEqualToPoint(vertex, cp2)) { // Straight Line - cp1 = CGPointByLerpingPoints(previousVertex, vertex, 0.01); - cp2 = CGPointByLerpingPoints(previousVertex, vertex, 0.99); + cp1 = LOT_PointByLerpingPoints(previousVertex, vertex, 0.01); + cp2 = LOT_PointByLerpingPoints(previousVertex, vertex, 0.99); } else { if (CGPointEqualToPoint(previousVertex, cp1)) { // Missing out tan - cp1 = CGPointByLerpingPoints(previousVertex, cp2, 0.01); + cp1 = LOT_PointByLerpingPoints(previousVertex, cp2, 0.01); } if (CGPointEqualToPoint(vertex, cp2)) { // Missing in tan - cp2 = CGPointByLerpingPoints(cp1, vertex, 0.99); + cp2 = LOT_PointByLerpingPoints(cp1, vertex, 0.99); } } diff --git a/lottie-ios/Classes/Extensions/CGGeometry+LOTAdditions.h b/lottie-ios/Classes/Extensions/CGGeometry+LOTAdditions.h new file mode 100644 index 0000000000..4b6fc82a91 --- /dev/null +++ b/lottie-ios/Classes/Extensions/CGGeometry+LOTAdditions.h @@ -0,0 +1,89 @@ + +#import "LOTPlatformCompat.h" +#import +#import +#import +// +// Core Graphics Geometry Additions +// + +extern const CGSize CGSizeMax; + +CGRect LOT_RectIntegral(CGRect rect); + +// Centering + +// Returns a rectangle of the given size, centered at a point +CGRect LOT_RectCenteredAtPoint(CGPoint center, CGSize size, BOOL integral); + +// Returns the center point of a CGRect +CGPoint LOT_RectGetCenterPoint(CGRect rect); + +// Insetting + +// Inset the rectangle on a single edge +CGRect LOT_RectInsetLeft(CGRect rect, CGFloat inset); +CGRect LOT_RectInsetRight(CGRect rect, CGFloat inset); +CGRect LOT_RectInsetTop(CGRect rect, CGFloat inset); +CGRect LOT_RectInsetBottom(CGRect rect, CGFloat inset); + +// Inset the rectangle on two edges +CGRect LOT_RectInsetHorizontal(CGRect rect, CGFloat leftInset, CGFloat rightInset); +CGRect LOT_RectInsetVertical(CGRect rect, CGFloat topInset, CGFloat bottomInset); + +// Inset the rectangle on all edges +CGRect LOT_RectInsetAll(CGRect rect, CGFloat leftInset, CGFloat rightInset, CGFloat topInset, CGFloat bottomInset); + +// Framing + +// Returns a rectangle of size framed in the center of the given rectangle +CGRect LOT_RectFramedCenteredInRect(CGRect rect, CGSize size, BOOL integral); + +// Returns a rectangle of size framed in the given rectangle and inset +CGRect LOT_RectFramedLeftInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral); +CGRect LOT_RectFramedRightInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral); +CGRect LOT_RectFramedTopInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral); +CGRect LOT_RectFramedBottomInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral); + +CGRect LOT_RectFramedTopLeftInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral); +CGRect LOT_RectFramedTopRightInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral); +CGRect LOT_RectFramedBottomLeftInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral); +CGRect LOT_RectFramedBottomRightInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral); + +// Divides a rect into sections and returns the section at specified index + +CGRect LOT_RectDividedSection(CGRect rect, NSInteger sections, NSInteger index, CGRectEdge fromEdge); + +// Returns a rectangle of size attached to the given rectangle +CGRect LOT_RectAttachedLeftToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral); +CGRect LOT_RectAttachedRightToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral); +CGRect LOT_RectAttachedTopToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral); +CGRect LOT_RectAttachedBottomToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral); + +CGRect LOT_RectAttachedBottomLeftToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral); +CGRect LOT_RectAttachedBottomRightToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral); +CGRect LOT_RectAttachedTopRightToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral); +CGRect LOT_RectAttachedTopLeftToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral); + +// Combining +// Adds all values of the 2nd rect to the first rect +CGRect LOT_RectAddRect(CGRect rect, CGRect other); +CGRect LOT_RectAddPoint(CGRect rect, CGPoint point); +CGRect LOT_RectAddSize(CGRect rect, CGSize size); +CGRect LOT_RectBounded(CGRect rect); + +CGPoint LOT_PointAddedToPoint(CGPoint point1, CGPoint point2); + +CGRect LOT_RectSetHeight(CGRect rect, CGFloat height); + +CGFloat LOT_PointDistanceFromPoint(CGPoint point1, CGPoint point2); +CGFloat LOT_DegreesToRadians(CGFloat degrees); + +GLKMatrix4 LOT_GLKMatrix4FromCATransform(CATransform3D xform); + +CATransform3D LOT_CATransform3DFromGLKMatrix4(GLKMatrix4 xform); + +CATransform3D LOT_CATransform3DSlerpToTransform(CATransform3D fromXorm, CATransform3D toXform, CGFloat amount ); + +CGFloat LOT_RemapValue(CGFloat value, CGFloat low1, CGFloat high1, CGFloat low2, CGFloat high2 ); +CGPoint LOT_PointByLerpingPoints(CGPoint point1, CGPoint point2, CGFloat value); diff --git a/lottie-ios/Classes/Extensions/CGGeometryAdditions.m b/lottie-ios/Classes/Extensions/CGGeometry+LOTAdditions.m similarity index 60% rename from lottie-ios/Classes/Extensions/CGGeometryAdditions.m rename to lottie-ios/Classes/Extensions/CGGeometry+LOTAdditions.m index 9771b36df9..47c1e06283 100644 --- a/lottie-ios/Classes/Extensions/CGGeometryAdditions.m +++ b/lottie-ios/Classes/Extensions/CGGeometry+LOTAdditions.m @@ -1,5 +1,5 @@ -#import "CGGeometryAdditions.h" +#import "CGGeometry+LOTAdditions.h" const CGSize CGSizeMax = {CGFLOAT_MAX, CGFLOAT_MAX}; // @@ -8,8 +8,8 @@ // CGRectIntegral returns a rectangle with the smallest integer values for its origin and size that contains the source rectangle. // For a rect with .origin={5, 5.5}, .size=(10, 10), it will return .origin={5,5}, .size={10, 11}; -// BBRectIntegral will return {5,5}, {10, 10}. -CGRect BBRectIntegral(CGRect rect) { +// LOT_RectIntegral will return {5,5}, {10, 10}. +CGRect LOT_RectIntegral(CGRect rect) { rect.origin = CGPointMake(rintf(rect.origin.x), rintf(rect.origin.y)); rect.size = CGSizeMake(ceilf(rect.size.width), ceil(rect.size.height)); return rect; @@ -20,18 +20,18 @@ CGRect BBRectIntegral(CGRect rect) { // Returns a rectangle of the given size, centered at a point -CGRect CGRectCenteredAtPoint(CGPoint center, CGSize size, BOOL integral) { +CGRect LOT_RectCenteredAtPoint(CGPoint center, CGSize size, BOOL integral) { CGRect result; result.origin.x = center.x - 0.5f * size.width; result.origin.y = center.y - 0.5f * size.height; result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } // Returns the center point of a CGRect -CGPoint CGRectGetCenterPoint(CGRect rect) { +CGPoint LOT_RectGetCenterPoint(CGRect rect) { return CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); } @@ -40,37 +40,37 @@ CGPoint CGRectGetCenterPoint(CGRect rect) { // Inset the rectangle on a single edge -CGRect CGRectInsetLeft(CGRect rect, CGFloat inset) { +CGRect LOT_RectInsetLeft(CGRect rect, CGFloat inset) { rect.origin.x += inset; rect.size.width -= inset; return rect; } -CGRect CGRectInsetRight(CGRect rect, CGFloat inset) { +CGRect LOT_RectInsetRight(CGRect rect, CGFloat inset) { rect.size.width -= inset; return rect; } -CGRect CGRectInsetTop(CGRect rect, CGFloat inset) { +CGRect LOT_RectInsetTop(CGRect rect, CGFloat inset) { rect.origin.y += inset; rect.size.height -= inset; return rect; } -CGRect CGRectInsetBottom(CGRect rect, CGFloat inset) { +CGRect LOT_RectInsetBottom(CGRect rect, CGFloat inset) { rect.size.height -= inset; return rect; } // Inset the rectangle on two edges -CGRect CGRectInsetHorizontal(CGRect rect, CGFloat leftInset, CGFloat rightInset) { +CGRect LOT_RectInsetHorizontal(CGRect rect, CGFloat leftInset, CGFloat rightInset) { rect.origin.x += leftInset; rect.size.width -= (leftInset + rightInset); return rect; } -CGRect CGRectInsetVertical(CGRect rect, CGFloat topInset, CGFloat bottomInset) { +CGRect LOT_RectInsetVertical(CGRect rect, CGFloat topInset, CGFloat bottomInset) { rect.origin.y += topInset; rect.size.height -= (topInset + bottomInset); return rect; @@ -78,7 +78,7 @@ CGRect CGRectInsetVertical(CGRect rect, CGFloat topInset, CGFloat bottomInset) { // Inset the rectangle on all edges -CGRect CGRectInsetAll(CGRect rect, CGFloat leftInset, CGFloat rightInset, CGFloat topInset, CGFloat bottomInset) { +CGRect LOT_RectInsetAll(CGRect rect, CGFloat leftInset, CGFloat rightInset, CGFloat topInset, CGFloat bottomInset) { rect.origin.x += leftInset; rect.origin.y += topInset; rect.size.width -= (leftInset + rightInset); @@ -86,226 +86,188 @@ CGRect CGRectInsetAll(CGRect rect, CGFloat leftInset, CGFloat rightInset, CGFloa return rect; } -// Expand a size or rectangle by edge insets - -CGFloat UIEdgeInsetsExpandWidth(CGFloat width, UIEdgeInsets insets) { - return width + insets.left + insets.right; -} - -CGFloat UIEdgeInsetsExpandHeight(CGFloat height, UIEdgeInsets insets) { - return height + insets.top + insets.bottom; -} - -CGSize UIEdgeInsetsExpandSize(CGSize size, UIEdgeInsets insets) { - size.width += (insets.left + insets.right); - size.height += (insets.top + insets.bottom); - return size; -} - -CGSize UIEdgeInsetsContractWidth(CGSize size, UIEdgeInsets insets) { - size.width -= (insets.left + insets.right); - return size; -} - -CGSize UIEdgeInsetsContractHeight(CGSize size, UIEdgeInsets insets) { - size.height -= (insets.top + insets.bottom); - return size; -} - -CGSize UIEdgeInsetsContractSize(CGSize size, UIEdgeInsets insets) { - return UIEdgeInsetsContractHeight(UIEdgeInsetsContractWidth(size, insets), insets); -} - -CGRect UIEdgeInsetsExpandRect(CGRect rect, UIEdgeInsets insets) { - rect.origin.x -= insets.left; - rect.origin.y -= insets.top; - rect.size.width += (insets.left + insets.right); - rect.size.height += (insets.top + insets.bottom); - return rect; -} - // // Framing // Returns a rectangle of size framed in the center of the given rectangle -CGRect CGRectFramedCenteredInRect(CGRect rect, CGSize size, BOOL integral) { +CGRect LOT_RectFramedCenteredInRect(CGRect rect, CGSize size, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + rintf(0.5f * (rect.size.width - size.width)); result.origin.y = rect.origin.y + rintf(0.5f * (rect.size.height - size.height)); result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } // Returns a rectangle of size framed in the given rectangle and inset -CGRect CGRectFramedLeftInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral) { +CGRect LOT_RectFramedLeftInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + inset; result.origin.y = rect.origin.y + rintf(0.5f * (rect.size.height - size.height)); result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } -CGRect CGRectFramedRightInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral) { +CGRect LOT_RectFramedRightInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + rect.size.width - size.width - inset; result.origin.y = rect.origin.y + rintf(0.5f * (rect.size.height - size.height)); result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } -CGRect CGRectFramedTopInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral) { +CGRect LOT_RectFramedTopInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + rintf(0.5f * (rect.size.width - size.width)); result.origin.y = rect.origin.y + inset; result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } -CGRect CGRectFramedBottomInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral) { +CGRect LOT_RectFramedBottomInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + rintf(0.5f * (rect.size.width - size.width)); result.origin.y = rect.origin.y + rect.size.height - size.height - inset; result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } -CGRect CGRectFramedTopLeftInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral) { +CGRect LOT_RectFramedTopLeftInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + insetWidth; result.origin.y = rect.origin.y + insetHeight; result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } -CGRect CGRectFramedTopRightInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral) { +CGRect LOT_RectFramedTopRightInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + rect.size.width - size.width - insetWidth; result.origin.y = rect.origin.y + insetHeight; result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } -CGRect CGRectFramedBottomLeftInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral) { +CGRect LOT_RectFramedBottomLeftInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + insetWidth; result.origin.y = rect.origin.y + rect.size.height - size.height - insetHeight; result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } -CGRect CGRectFramedBottomRightInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral) { +CGRect LOT_RectFramedBottomRightInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + rect.size.width - size.width - insetWidth; result.origin.y = rect.origin.y + rect.size.height - size.height - insetHeight; result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } // Returns a rectangle of size attached to the given rectangle -CGRect CGRectAttachedLeftToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral) { +CGRect LOT_RectAttachedLeftToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral) { CGRect result; result.origin.x = rect.origin.x - size.width - margin; result.origin.y = rect.origin.y + rintf(0.5f * (rect.size.height - size.height)); result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } -CGRect CGRectAttachedRightToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral) { +CGRect LOT_RectAttachedRightToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + rect.size.width + margin; result.origin.y = rect.origin.y + rintf(0.5f * (rect.size.height - size.height)); result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } -CGRect CGRectAttachedTopToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral) { +CGRect LOT_RectAttachedTopToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + rintf(0.5f * (rect.size.width - size.width)); result.origin.y = rect.origin.y - size.height - margin; result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } -CGRect CGRectAttachedTopLeftToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral) { +CGRect LOT_RectAttachedTopLeftToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + marginWidth; result.origin.y = rect.origin.y - size.height - marginHeight; result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } -CGRect CGRectAttachedTopRightToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral) { +CGRect LOT_RectAttachedTopRightToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + rect.size.width - size.width - marginWidth; result.origin.y = rect.origin.y - rect.size.height - marginHeight; result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } -CGRect CGRectAttachedBottomToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral) { +CGRect LOT_RectAttachedBottomToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + rintf(0.5f * (rect.size.width - size.width)); result.origin.y = rect.origin.y + rect.size.height + margin; result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } -CGRect CGRectAttachedBottomLeftToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral) { +CGRect LOT_RectAttachedBottomLeftToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + marginWidth; result.origin.y = rect.origin.y + rect.size.height + marginHeight; result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } -CGRect CGRectAttachedBottomRightToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral) { +CGRect LOT_RectAttachedBottomRightToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral) { CGRect result; result.origin.x = rect.origin.x + rect.size.width - size.width - marginWidth; result.origin.y = rect.origin.y + rect.size.height + marginHeight; result.size = size; - if (integral) { result = BBRectIntegral(result); } + if (integral) { result = LOT_RectIntegral(result); } return result; } // Divides a rect into sections and returns the section at specified index -CGRect CGRectDividedSection(CGRect rect, NSInteger sections, NSInteger index, CGRectEdge fromEdge) { +CGRect LOT_RectDividedSection(CGRect rect, NSInteger sections, NSInteger index, CGRectEdge fromEdge) { if (sections == 0) { return CGRectZero; } @@ -321,50 +283,50 @@ CGRect CGRectDividedSection(CGRect rect, NSInteger sections, NSInteger index, CG } -CGRect CGRectAddRect(CGRect rect, CGRect other) { +CGRect LOT_RectAddRect(CGRect rect, CGRect other) { return CGRectMake(rect.origin.x + other.origin.x, rect.origin.y + other.origin.y, rect.size.width + other.size.width, rect.size.height + other.size.height); } -CGRect CGRectAddPoint(CGRect rect, CGPoint point) { +CGRect LOT_RectAddPoint(CGRect rect, CGPoint point) { return CGRectMake(rect.origin.x + point.x, rect.origin.y + point.y, rect.size.width, rect.size.height); } -CGRect CGRectAddSize(CGRect rect, CGSize size) { +CGRect LOT_RectAddSize(CGRect rect, CGSize size) { return CGRectMake(rect.origin.x, rect.origin.y, rect.size.width + size.width, rect.size.height + size.height); } -CGRect CGRectBounded(CGRect rect) { +CGRect LOT_RectBounded(CGRect rect) { CGRect returnRect = rect; returnRect.origin = CGPointZero; return returnRect; } -CGPoint CGPointAddedToPoint(CGPoint point1, CGPoint point2) { +CGPoint LOT_PointAddedToPoint(CGPoint point1, CGPoint point2) { CGPoint returnPoint = point1; returnPoint.x += point2.x; returnPoint.y += point2.y; return returnPoint; } -CGRect CGRectSetHeight(CGRect rect, CGFloat height) { +CGRect LOT_RectSetHeight(CGRect rect, CGFloat height) { return CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, height); } -CGFloat DegreestoRadians(CGFloat degrees) { +CGFloat LOT_DegreesToRadians(CGFloat degrees) { return degrees * M_PI / 180; } -GLKMatrix4 GLKMatrix4FromCATransform(CATransform3D xform) { +GLKMatrix4 LOT_GLKMatrix4FromCATransform(CATransform3D xform) { return GLKMatrix4Make(xform.m11, xform.m12, xform.m13, xform.m14, xform.m21, xform.m22, xform.m23, xform.m24, xform.m31, xform.m32, xform.m33, xform.m34, xform.m41, xform.m42, xform.m43, xform.m44); } -CATransform3D CATransform3DFromGLKMatrix4(GLKMatrix4 xform) { +CATransform3D LOT_CATransform3DFromGLKMatrix4(GLKMatrix4 xform) { CATransform3D newXform; newXform.m11 = xform.m00; newXform.m12 = xform.m01; @@ -385,13 +347,13 @@ CATransform3D CATransform3DFromGLKMatrix4(GLKMatrix4 xform) { return newXform; } -CATransform3D CATransform3DSlerpToTransform(CATransform3D fromXorm, CATransform3D toXform, CGFloat amount ){ +CATransform3D LOT_CATransform3DSlerpToTransform(CATransform3D fromXorm, CATransform3D toXform, CGFloat amount ){ // amount = MIN(MAX(0, amount), 1); if (amount == 0 || amount == 1) { return amount == 0 ? fromXorm : toXform; } - GLKMatrix4 xform1 = GLKMatrix4FromCATransform(fromXorm); - GLKMatrix4 xform2 = GLKMatrix4FromCATransform(toXform); + GLKMatrix4 xform1 = LOT_GLKMatrix4FromCATransform(fromXorm); + GLKMatrix4 xform2 = LOT_GLKMatrix4FromCATransform(toXform); GLKQuaternion q1 = GLKQuaternionMakeWithMatrix4(xform1); GLKQuaternion q2 = GLKQuaternionMakeWithMatrix4(xform2); GLKQuaternion r1 = GLKQuaternionSlerp(q1, q2, amount); @@ -403,39 +365,35 @@ CATransform3D CATransform3DSlerpToTransform(CATransform3D fromXorm, CATransform3 rX.m30 = r2.x; rX.m31 = r2.y; rX.m32 = r2.z; - return CATransform3DFromGLKMatrix4(rX); + return LOT_CATransform3DFromGLKMatrix4(rX); } -CGFloat CGPointDistanceFromPoint(CGPoint point1, CGPoint point2) { +CGFloat LOT_PointDistanceFromPoint(CGPoint point1, CGPoint point2) { CGFloat xDist = (point2.x - point1.x); CGFloat yDist = (point2.y - point1.y); CGFloat distance = sqrt((xDist * xDist) + (yDist * yDist)); return distance; } -CGFloat DegreesToRadians(CGFloat degrees) { - return ( ( degrees ) / 180.0 * M_PI ); -} - -CGFloat RemapValue(CGFloat value, CGFloat low1, CGFloat high1, CGFloat low2, CGFloat high2 ) { +CGFloat LOT_RemapValue(CGFloat value, CGFloat low1, CGFloat high1, CGFloat low2, CGFloat high2 ) { return low2 + (value - low1) * (high2 - low2) / (high1 - low1); } -CGPoint CGPointByLerpingPoints(CGPoint point1, CGPoint point2, CGFloat value) { +CGPoint LOT_PointByLerpingPoints(CGPoint point1, CGPoint point2, CGFloat value) { CGFloat xDiff = point2.x - point1.x; CGFloat yDiff = point2.y - point1.y; CGPoint transposed = CGPointMake(fabs(xDiff), fabs(yDiff)); CGPoint returnPoint; if (xDiff == 0 || yDiff == 0) { - returnPoint.x = xDiff == 0 ? point1.x : RemapValue(value, 0, 1, point1.x, point2.x); - returnPoint.y = yDiff == 0 ? point1.y : RemapValue(value, 0, 1, point1.y, point2.y); + returnPoint.x = xDiff == 0 ? point1.x : LOT_RemapValue(value, 0, 1, point1.x, point2.x); + returnPoint.y = yDiff == 0 ? point1.y : LOT_RemapValue(value, 0, 1, point1.y, point2.y); } else { CGFloat rx = transposed.x / transposed.y; - CGFloat yLerp = RemapValue(value, 0, 1, 0, transposed.y); + CGFloat yLerp = LOT_RemapValue(value, 0, 1, 0, transposed.y); CGFloat xLerp = yLerp * rx; CGPoint interpolatedPoint = CGPointMake(point2.x < point1.x ? xLerp * -1 : xLerp, point2.y < point1.y ? yLerp * -1 : yLerp); - returnPoint = CGPointAddedToPoint(point1, interpolatedPoint); + returnPoint = LOT_PointAddedToPoint(point1, interpolatedPoint); } return returnPoint; } diff --git a/lottie-ios/Classes/Extensions/CGGeometryAdditions.h b/lottie-ios/Classes/Extensions/CGGeometryAdditions.h deleted file mode 100644 index c94d82a738..0000000000 --- a/lottie-ios/Classes/Extensions/CGGeometryAdditions.h +++ /dev/null @@ -1,106 +0,0 @@ - -#import "LOTPlatformCompat.h" -#import -#import -#import -// -// Core Graphics Geometry Additions -// - -extern const CGSize CGSizeMax; - -CGRect BBRectIntegral(CGRect rect); - -// Centering - -// Returns a rectangle of the given size, centered at a point -CGRect CGRectCenteredAtPoint(CGPoint center, CGSize size, BOOL integral); - -// Returns the center point of a CGRect -CGPoint CGRectGetCenterPoint(CGRect rect); - -// Insetting - -// Inset the rectangle on a single edge -CGRect CGRectInsetLeft(CGRect rect, CGFloat inset); -CGRect CGRectInsetRight(CGRect rect, CGFloat inset); -CGRect CGRectInsetTop(CGRect rect, CGFloat inset); -CGRect CGRectInsetBottom(CGRect rect, CGFloat inset); - -// Inset the rectangle on two edges -CGRect CGRectInsetHorizontal(CGRect rect, CGFloat leftInset, CGFloat rightInset); -CGRect CGRectInsetVertical(CGRect rect, CGFloat topInset, CGFloat bottomInset); - -// Inset the rectangle on all edges -CGRect CGRectInsetAll(CGRect rect, CGFloat leftInset, CGFloat rightInset, CGFloat topInset, CGFloat bottomInset); - -// Expand a size or rectangle by edge insets -CGFloat UIEdgeInsetsExpandWidth(CGFloat width, UIEdgeInsets insets); -CGFloat UIEdgeInsetsExpandHeight(CGFloat height, UIEdgeInsets insets); -CGSize UIEdgeInsetsContractSize(CGSize size, UIEdgeInsets insets); - -CGSize UIEdgeInsetsContractWidth(CGSize size, UIEdgeInsets insets); -CGSize UIEdgeInsetsContractHeight(CGSize size, UIEdgeInsets insets); -CGSize UIEdgeInsetsExpandSize(CGSize size, UIEdgeInsets insets); - -CGRect UIEdgeInsetsExpandRect(CGRect rect, UIEdgeInsets insets); - -// Framing - -// Returns a rectangle of size framed in the center of the given rectangle -CGRect CGRectFramedCenteredInRect(CGRect rect, CGSize size, BOOL integral); - -// Returns a rectangle of size framed in the given rectangle and inset -CGRect CGRectFramedLeftInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral); -CGRect CGRectFramedRightInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral); -CGRect CGRectFramedTopInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral); -CGRect CGRectFramedBottomInRect(CGRect rect, CGSize size, CGFloat inset, BOOL integral); - -CGRect CGRectFramedTopLeftInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral); -CGRect CGRectFramedTopRightInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral); -CGRect CGRectFramedBottomLeftInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral); -CGRect CGRectFramedBottomRightInRect(CGRect rect, CGSize size, CGFloat insetWidth, CGFloat insetHeight, BOOL integral); - -// Divides a rect into sections and returns the section at specified index - -CGRect CGRectDividedSection(CGRect rect, NSInteger sections, NSInteger index, CGRectEdge fromEdge); - -// Returns a rectangle of size attached to the given rectangle -CGRect CGRectAttachedLeftToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral); -CGRect CGRectAttachedRightToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral); -CGRect CGRectAttachedTopToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral); -CGRect CGRectAttachedBottomToRect(CGRect rect, CGSize size, CGFloat margin, BOOL integral); - -CGRect CGRectAttachedBottomLeftToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral); -CGRect CGRectAttachedBottomRightToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral); -CGRect CGRectAttachedTopRightToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral); -CGRect CGRectAttachedTopLeftToRect(CGRect rect, CGSize size, CGFloat marginWidth, CGFloat marginHeight, BOOL integral); - -// Combining -// Adds all values of the 2nd rect to the first rect -CGRect CGRectAddRect(CGRect rect, CGRect other); -CGRect CGRectAddPoint(CGRect rect, CGPoint point); -CGRect CGRectAddSize(CGRect rect, CGSize size); -CGRect CGRectBounded(CGRect rect); - -CGPoint CGPointAddedToPoint(CGPoint point1, CGPoint point2); - -/** -* update the height property of a rect -* @return new rectangle with updated height -* */ -CGRect CGRectSetHeight(CGRect rect, CGFloat height); - -CGFloat CGPointDistanceFromPoint(CGPoint point1, CGPoint point2); -CGFloat DegreestoRadians(CGFloat degrees); - -GLKMatrix4 GLKMatrix4FromCATransform(CATransform3D xform); - -CATransform3D CATransform3DFromGLKMatrix4(GLKMatrix4 xform); - -CATransform3D CATransform3DSlerpToTransform(CATransform3D fromXorm, CATransform3D toXform, CGFloat amount ); - -CGFloat DegreesToRadians(CGFloat degrees); - -CGFloat RemapValue(CGFloat value, CGFloat low1, CGFloat high1, CGFloat low2, CGFloat high2 ); -CGPoint CGPointByLerpingPoints(CGPoint point1, CGPoint point2, CGFloat value); diff --git a/lottie-ios/Classes/Extensions/LOTHelpers.h b/lottie-ios/Classes/Extensions/LOTHelpers.h index cde1153608..b89539d044 100644 --- a/lottie-ios/Classes/Extensions/LOTHelpers.h +++ b/lottie-ios/Classes/Extensions/LOTHelpers.h @@ -10,6 +10,6 @@ #define LOTHelpers_h #import "UIColor+Expanded.h" -#import "CGGeometryAdditions.h" +#import "CGGeometry+LOTAdditions.h" #endif /* LOTHelpers_h */ diff --git a/lottie-ios/Classes/Models/LOTLayer.m b/lottie-ios/Classes/Models/LOTLayer.m index c6fc0e4c2f..b39a038c1b 100644 --- a/lottie-ios/Classes/Models/LOTLayer.m +++ b/lottie-ios/Classes/Models/LOTLayer.m @@ -65,7 +65,7 @@ - (void)_mapFromJSON:(NSDictionary *)jsonDictionary fromComposition:(LOTComposit if (rotation) { _rotation = [[LOTAnimatableNumberValue alloc] initWithNumberValues:rotation frameRate:_framerate]; [_rotation remapValueWithBlock:^CGFloat(CGFloat inValue) { - return DegreesToRadians(inValue); + return LOT_DegreesToRadians(inValue); }]; } diff --git a/lottie-ios/Classes/Models/LOTShapeTransform.m b/lottie-ios/Classes/Models/LOTShapeTransform.m index 30bf21b018..37f678be80 100644 --- a/lottie-ios/Classes/Models/LOTShapeTransform.m +++ b/lottie-ios/Classes/Models/LOTShapeTransform.m @@ -57,7 +57,7 @@ - (void)_mapFromJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameR if (rotation) { _rotation = [[LOTAnimatableNumberValue alloc] initWithNumberValues:rotation frameRate:frameRate]; [_rotation remapValueWithBlock:^CGFloat(CGFloat inValue) { - return DegreesToRadians(inValue); + return LOT_DegreesToRadians(inValue); }]; } diff --git a/lottie-ios/Classes/Private/LOTAnimationView.m b/lottie-ios/Classes/Private/LOTAnimationView.m index a1d1389d84..9e7fc76984 100644 --- a/lottie-ios/Classes/Private/LOTAnimationView.m +++ b/lottie-ios/Classes/Private/LOTAnimationView.m @@ -514,21 +514,6 @@ - (CGFloat)animationDuration { # pragma mark - Overrides -- (void)didMoveToWindow { - [super didMoveToWindow]; - [_animationState setNeedsAnimationUpdate]; -} - -- (void)didMoveToSuperview { - [super didMoveToSuperview]; - [_animationState setNeedsAnimationUpdate]; -} - -- (void)removeFromSuperview { - [self pause]; - [super removeFromSuperview]; -} - #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR #define LOTViewContentMode UIViewContentMode @@ -546,6 +531,21 @@ - (void)removeFromSuperview { #define LOTViewContentModeBottomLeft UIViewContentModeBottomLeft #define LOTViewContentModeBottomRight UIViewContentModeBottomRight +- (void)didMoveToWindow { + [super didMoveToWindow]; + [_animationState setNeedsAnimationUpdate]; +} + +- (void)didMoveToSuperview { + [super didMoveToSuperview]; + [_animationState setNeedsAnimationUpdate]; +} + +- (void)removeFromSuperview { + [self pause]; + [super removeFromSuperview]; +} + - (void)setContentMode:(LOTViewContentMode)contentMode { [super setContentMode:contentMode]; [self setNeedsLayout]; @@ -592,7 +592,7 @@ - (void)_layout { return; } - CGPoint centerPoint = CGRectGetCenterPoint(self.bounds); + CGPoint centerPoint = LOT_RectGetCenterPoint(self.bounds); CATransform3D xform; if (self.contentMode == LOTViewContentModeScaleToFill) {