mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Reorganized Project Changed Namescape
This commit is contained in:
parent
c5ee28dedd
commit
b79d34bd40
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,4 +8,5 @@ UserInterfaceState.xcuserstate
|
||||
xample/lottie-ios.xcodeproj/xcuserdata
|
||||
Lottie.xcodeproj/xcuserdata/
|
||||
Example/lottie-ios.xcworkspace/xcuserdata/
|
||||
Example/lottie-ios.xcodeproj/xcuserdata/
|
||||
.idea/
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
@interface ViewController ()
|
||||
|
||||
@property (nonatomic, strong) LAAnimationView *lottieLogo;
|
||||
@property (nonatomic, strong) LOTAnimationView *lottieLogo;
|
||||
|
||||
@end
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
self.lottieLogo = [LAAnimationView animationNamed:@"LottieLogo1"];
|
||||
self.lottieLogo.contentMode = LAViewContentModeScaleAspectFill;
|
||||
self.lottieLogo = [LOTAnimationView animationNamed:@"LottieLogo1"];
|
||||
self.lottieLogo.contentMode = LOTViewContentModeScaleAspectFill;
|
||||
self.lottieLogo.frame = self.view.bounds;
|
||||
self.lottieLogo.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
||||
|
||||
|
1111
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
1111
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
File diff suppressed because it is too large
Load Diff
@ -10,9 +10,9 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#import "LAAnimationTransitionController.h"
|
||||
#import "LAAnimationView.h"
|
||||
#import "LAAnimationView_Compat.h"
|
||||
#import "LOTAnimationTransitionController.h"
|
||||
#import "LOTAnimationView.h"
|
||||
#import "LOTAnimationView_Compat.h"
|
||||
#import "Lottie.h"
|
||||
|
||||
FOUNDATION_EXPORT double LottieVersionNumber;
|
||||
|
@ -10,9 +10,9 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#import "LAAnimationTransitionController.h"
|
||||
#import "LAAnimationView.h"
|
||||
#import "LAAnimationView_Compat.h"
|
||||
#import "LOTAnimationTransitionController.h"
|
||||
#import "LOTAnimationView.h"
|
||||
#import "LOTAnimationView_Compat.h"
|
||||
#import "Lottie.h"
|
||||
|
||||
FOUNDATION_EXPORT double LottieVersionNumber;
|
||||
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>lottie-ios-Example.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
<dict>
|
||||
<key>6003F589195388D20070C39A</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>6003F5AD195388D20070C39A</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
@ -18,7 +18,7 @@
|
||||
@end
|
||||
|
||||
@implementation LACharacterCell {
|
||||
LAAnimationView *animationView_;
|
||||
LOTAnimationView *animationView_;
|
||||
NSString *character_;
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@
|
||||
return;
|
||||
}
|
||||
character_ = sanitizedCharacter;
|
||||
LAAnimationView *animationView = [LAAnimationView animationNamed:sanitizedCharacter];
|
||||
LOTAnimationView *animationView = [LOTAnimationView animationNamed:sanitizedCharacter];
|
||||
animationView_ = animationView;
|
||||
animationView_.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.contentView addSubview:animationView_];
|
||||
|
@ -22,7 +22,7 @@ typedef enum : NSUInteger {
|
||||
@property (nonatomic, assign) ViewBackgroundColor currentBGColor;
|
||||
@property (nonatomic, strong) UIToolbar *toolbar;
|
||||
@property (nonatomic, strong) UISlider *slider;
|
||||
@property (nonatomic, strong) LAAnimationView *laAnimation;
|
||||
@property (nonatomic, strong) LOTAnimationView *laAnimation;
|
||||
|
||||
@end
|
||||
|
||||
@ -186,7 +186,7 @@ typedef enum : NSUInteger {
|
||||
self.laAnimation = nil;
|
||||
[self resetAllButtons];
|
||||
|
||||
self.laAnimation = [[LAAnimationView alloc] initWithContentsOfURL:[NSURL URLWithString:URL]];
|
||||
self.laAnimation = [[LOTAnimationView alloc] initWithContentsOfURL:[NSURL URLWithString:URL]];
|
||||
self.laAnimation.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.view addSubview:self.laAnimation];
|
||||
[self.view setNeedsLayout];
|
||||
@ -197,7 +197,7 @@ typedef enum : NSUInteger {
|
||||
self.laAnimation = nil;
|
||||
[self resetAllButtons];
|
||||
|
||||
self.laAnimation = [LAAnimationView animationNamed:named];
|
||||
self.laAnimation = [LOTAnimationView animationNamed:named];
|
||||
self.laAnimation.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.view addSubview:self.laAnimation];
|
||||
[self.view setNeedsLayout];
|
||||
|
@ -129,14 +129,14 @@
|
||||
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
|
||||
presentingController:(UIViewController *)presenting
|
||||
sourceController:(UIViewController *)source {
|
||||
LAAnimationTransitionController *animationController = [[LAAnimationTransitionController alloc] initWithAnimationNamed:@"vcTransition1"
|
||||
LOTAnimationTransitionController *animationController = [[LOTAnimationTransitionController alloc] initWithAnimationNamed:@"vcTransition1"
|
||||
fromLayerNamed:@"outLayer"
|
||||
toLayerNamed:@"inLayer"];
|
||||
return animationController;
|
||||
}
|
||||
|
||||
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
|
||||
LAAnimationTransitionController *animationController = [[LAAnimationTransitionController alloc] initWithAnimationNamed:@"vcTransition2"
|
||||
LOTAnimationTransitionController *animationController = [[LOTAnimationTransitionController alloc] initWithAnimationNamed:@"vcTransition2"
|
||||
fromLayerNamed:@"outLayer"
|
||||
toLayerNamed:@"inLayer"];
|
||||
return animationController;
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
@interface LottieRootViewController () <UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic, strong) LAAnimationView *lottieLogo;
|
||||
@property (nonatomic, strong) LOTAnimationView *lottieLogo;
|
||||
@property (nonatomic, strong) UIButton *lottieButton;
|
||||
@property (nonatomic, strong) UITableView *tableView;
|
||||
@property (nonatomic, strong) NSArray *tableViewItems;
|
||||
@ -23,7 +23,7 @@
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[self _buildDataSource];
|
||||
self.lottieLogo = [LAAnimationView animationNamed:@"LottieLogo1"];
|
||||
self.lottieLogo = [LOTAnimationView animationNamed:@"LottieLogo1"];
|
||||
self.lottieLogo.contentMode = UIViewContentModeScaleAspectFill;
|
||||
[self.view addSubview:self.lottieLogo];
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,7 @@
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "62CA59B71E3C173B002D7188"
|
||||
BuildableName = "Lottie.framework"
|
||||
BlueprintName = "Lottie"
|
||||
BlueprintName = "Lottie_iOS"
|
||||
ReferencedContainer = "container:Lottie.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
@ -47,7 +47,7 @@
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "62CA59B71E3C173B002D7188"
|
||||
BuildableName = "Lottie.framework"
|
||||
BlueprintName = "Lottie"
|
||||
BlueprintName = "Lottie_iOS"
|
||||
ReferencedContainer = "container:Lottie.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
@ -65,7 +65,7 @@
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "62CA59B71E3C173B002D7188"
|
||||
BuildableName = "Lottie.framework"
|
||||
BlueprintName = "Lottie"
|
||||
BlueprintName = "Lottie_iOS"
|
||||
ReferencedContainer = "container:Lottie.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LAAnimatableLayer.h
|
||||
// LOTAnimatableLayer.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/21/16.
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
@interface LAAnimatableLayer : CALayer
|
||||
@interface LOTAnimatableLayer : CALayer
|
||||
|
||||
- (instancetype)initWithDuration:(NSTimeInterval)duration NS_DESIGNATED_INITIALIZER;
|
||||
|
@ -1,14 +1,14 @@
|
||||
//
|
||||
// LAAnimatableLayer.m
|
||||
// LOTAnimatableLayer.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/21/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAAnimatableLayer.h"
|
||||
#import "LOTAnimatableLayer.h"
|
||||
|
||||
@implementation LAAnimatableLayer
|
||||
@implementation LOTAnimatableLayer
|
||||
|
||||
- (instancetype)initWithDuration:(NSTimeInterval)duration {
|
||||
self = [super init];
|
21
lottie-ios/Classes/Animatable Layers/LOTEllipseShapeLayer.h
Normal file
21
lottie-ios/Classes/Animatable Layers/LOTEllipseShapeLayer.h
Normal file
@ -0,0 +1,21 @@
|
||||
//
|
||||
// LOTEllipseShapeLayer.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/26/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LOTAnimatableLayer.h"
|
||||
#import "LOTModels.h"
|
||||
|
||||
@interface LOTEllipseShapeLayer : LOTAnimatableLayer
|
||||
|
||||
- (instancetype)initWithEllipseShape:(LOTShapeCircle *)circleShape
|
||||
fill:(LOTShapeFill *)fill
|
||||
stroke:(LOTShapeStroke *)stroke
|
||||
trim:(LOTShapeTrimPath *)trim
|
||||
transform:(LOTShapeTransform *)transform
|
||||
withDuration:(NSTimeInterval)duration;
|
||||
|
||||
@end
|
@ -1,33 +1,33 @@
|
||||
//
|
||||
// LAEllipseShapeLayer.m
|
||||
// LOTEllipseShapeLayer.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/26/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAEllipseShapeLayer.h"
|
||||
#import "CAAnimationGroup+LAAnimatableGroup.h"
|
||||
#import "LOTEllipseShapeLayer.h"
|
||||
#import "CAAnimationGroup+LOTAnimatableGroup.h"
|
||||
|
||||
const CGFloat kEllipseControlPointPercentage = 0.55228;
|
||||
|
||||
@interface LACircleShapeLayer : CAShapeLayer
|
||||
@interface LOTCircleShapeLayer : CAShapeLayer
|
||||
|
||||
@property (nonatomic) CGPoint circlePosition;
|
||||
@property (nonatomic) CGPoint circleSize;
|
||||
|
||||
@end
|
||||
|
||||
@implementation LACircleShapeLayer
|
||||
@implementation LOTCircleShapeLayer
|
||||
|
||||
@dynamic circleSize;
|
||||
@dynamic circlePosition;
|
||||
|
||||
-(id)initWithLayer:(id)layer {
|
||||
if( ( self = [super initWithLayer:layer] ) ) {
|
||||
if ([layer isKindOfClass:[LACircleShapeLayer class]]) {
|
||||
self.circleSize = ((LACircleShapeLayer *)layer).circleSize;
|
||||
self.circlePosition = ((LACircleShapeLayer *)layer).circlePosition;
|
||||
if ([layer isKindOfClass:[LOTCircleShapeLayer class]]) {
|
||||
self.circleSize = ((LOTCircleShapeLayer *)layer).circleSize;
|
||||
self.circlePosition = ((LOTCircleShapeLayer *)layer).circlePosition;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
@ -54,7 +54,7 @@ const CGFloat kEllipseControlPointPercentage = 0.55228;
|
||||
}
|
||||
|
||||
- (void)_setPath {
|
||||
LACircleShapeLayer *presentationCircle = (LACircleShapeLayer *)self.presentationLayer;
|
||||
LOTCircleShapeLayer *presentationCircle = (LOTCircleShapeLayer *)self.presentationLayer;
|
||||
if (presentationCircle == nil) {
|
||||
presentationCircle = self;
|
||||
}
|
||||
@ -88,26 +88,26 @@ const CGFloat kEllipseControlPointPercentage = 0.55228;
|
||||
|
||||
@end
|
||||
|
||||
@implementation LAEllipseShapeLayer {
|
||||
LAShapeTransform *_transform;
|
||||
LAShapeStroke *_stroke;
|
||||
LAShapeFill *_fill;
|
||||
LAShapeCircle *_circle;
|
||||
LAShapeTrimPath *_trim;
|
||||
@implementation LOTEllipseShapeLayer {
|
||||
LOTShapeTransform *_transform;
|
||||
LOTShapeStroke *_stroke;
|
||||
LOTShapeFill *_fill;
|
||||
LOTShapeCircle *_circle;
|
||||
LOTShapeTrimPath *_trim;
|
||||
|
||||
LACircleShapeLayer *_fillLayer;
|
||||
LACircleShapeLayer *_strokeLayer;
|
||||
LOTCircleShapeLayer *_fillLayer;
|
||||
LOTCircleShapeLayer *_strokeLayer;
|
||||
|
||||
CAAnimationGroup *_animation;
|
||||
CAAnimationGroup *_strokeAnimation;
|
||||
CAAnimationGroup *_fillAnimation;
|
||||
}
|
||||
|
||||
- (instancetype)initWithEllipseShape:(LAShapeCircle *)circleShape
|
||||
fill:(LAShapeFill *)fill
|
||||
stroke:(LAShapeStroke *)stroke
|
||||
trim:(LAShapeTrimPath *)trim
|
||||
transform:(LAShapeTransform *)transform
|
||||
- (instancetype)initWithEllipseShape:(LOTShapeCircle *)circleShape
|
||||
fill:(LOTShapeFill *)fill
|
||||
stroke:(LOTShapeStroke *)stroke
|
||||
trim:(LOTShapeTrimPath *)trim
|
||||
transform:(LOTShapeTransform *)transform
|
||||
withDuration:(NSTimeInterval)duration {
|
||||
self = [super initWithDuration:duration];
|
||||
if (self) {
|
||||
@ -126,7 +126,7 @@ const CGFloat kEllipseControlPointPercentage = 0.55228;
|
||||
self.sublayerTransform = CATransform3DMakeRotation(_transform.rotation.initialValue.floatValue, 0, 0, 1);
|
||||
|
||||
if (fill) {
|
||||
_fillLayer = [LACircleShapeLayer new];
|
||||
_fillLayer = [LOTCircleShapeLayer new];
|
||||
_fillLayer.allowsEdgeAntialiasing = YES;
|
||||
_fillLayer.fillColor = _fill.color.initialColor.CGColor;
|
||||
_fillLayer.opacity = _fill.opacity.initialValue.floatValue;
|
||||
@ -136,7 +136,7 @@ const CGFloat kEllipseControlPointPercentage = 0.55228;
|
||||
}
|
||||
|
||||
if (stroke) {
|
||||
_strokeLayer = [LACircleShapeLayer new];
|
||||
_strokeLayer = [LOTCircleShapeLayer new];
|
||||
_strokeLayer.allowsEdgeAntialiasing = YES;
|
||||
_strokeLayer.strokeColor = _stroke.color.initialColor.CGColor;
|
||||
_strokeLayer.opacity = _stroke.opacity.initialValue.floatValue;
|
||||
@ -144,17 +144,17 @@ const CGFloat kEllipseControlPointPercentage = 0.55228;
|
||||
_strokeLayer.fillColor = nil;
|
||||
_strokeLayer.backgroundColor = nil;
|
||||
_strokeLayer.lineDashPattern = _stroke.lineDashPattern;
|
||||
_strokeLayer.lineCap = _stroke.capType == LALineCapTypeRound ? kCALineCapRound : kCALineCapButt;
|
||||
_strokeLayer.lineCap = _stroke.capType == LOTLineCapTypeRound ? kCALineCapRound : kCALineCapButt;
|
||||
_strokeLayer.circlePosition = circleShape.position.initialPoint;
|
||||
_strokeLayer.circleSize = circleShape.size.initialPoint;
|
||||
switch (_stroke.joinType) {
|
||||
case LALineJoinTypeBevel:
|
||||
case LOTLineJoinTypeBevel:
|
||||
_strokeLayer.lineJoin = kCALineJoinBevel;
|
||||
break;
|
||||
case LALineJoinTypeMiter:
|
||||
case LOTLineJoinTypeMiter:
|
||||
_strokeLayer.lineJoin = kCALineJoinMiter;
|
||||
break;
|
||||
case LALineJoinTypeRound:
|
||||
case LOTLineJoinTypeRound:
|
||||
_strokeLayer.lineJoin = kCALineJoinRound;
|
||||
break;
|
||||
default:
|
||||
@ -175,7 +175,7 @@ const CGFloat kEllipseControlPointPercentage = 0.55228;
|
||||
|
||||
- (void)_buildAnimation {
|
||||
if (_transform) {
|
||||
_animation = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:@{@"opacity" : _transform.opacity,
|
||||
_animation = [CAAnimationGroup LOT_animationGroupForAnimatablePropertiesWithKeyPaths:@{@"opacity" : _transform.opacity,
|
||||
@"position" : _transform.position,
|
||||
@"anchorPoint" : _transform.anchor,
|
||||
@"transform" : _transform.scale,
|
||||
@ -193,13 +193,13 @@ const CGFloat kEllipseControlPointPercentage = 0.55228;
|
||||
properties[@"strokeStart"] = _trim.start;
|
||||
properties[@"strokeEnd"] = _trim.end;
|
||||
}
|
||||
_strokeAnimation = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:properties];
|
||||
_strokeAnimation = [CAAnimationGroup LOT_animationGroupForAnimatablePropertiesWithKeyPaths:properties];
|
||||
[_strokeLayer addAnimation:_strokeAnimation forKey:@""];
|
||||
|
||||
}
|
||||
|
||||
if (_fill) {
|
||||
_fillAnimation = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:@{@"fillColor" : _fill.color,
|
||||
_fillAnimation = [CAAnimationGroup LOT_animationGroupForAnimatablePropertiesWithKeyPaths:@{@"fillColor" : _fill.color,
|
||||
@"opacity" : _fill.opacity,
|
||||
@"circlePosition" : _circle.position,
|
||||
@"circleSize" : _circle.size}];
|
31
lottie-ios/Classes/Animatable Layers/LOTGroupLayerView.h
Normal file
31
lottie-ios/Classes/Animatable Layers/LOTGroupLayerView.h
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// LOTGroupLayerView.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/14/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import "LOTAnimatableLayer.h"
|
||||
|
||||
@class LOTShapeGroup;
|
||||
@class LOTShapeTransform;
|
||||
@class LOTShapeFill;
|
||||
@class LOTShapeStroke;
|
||||
@class LOTShapeTrimPath;
|
||||
|
||||
@interface LOTGroupLayerView : LOTAnimatableLayer
|
||||
|
||||
- (instancetype)initWithShapeGroup:(LOTShapeGroup *)shapeGroup
|
||||
transform:(LOTShapeTransform *)previousTransform
|
||||
fill:(LOTShapeFill *)previousFill
|
||||
stroke:(LOTShapeStroke *)previousStroke
|
||||
trimPath:(LOTShapeTrimPath *)previousTrimPath
|
||||
withDuration:(NSTimeInterval)duration;
|
||||
|
||||
@property (nonatomic, readonly) LOTShapeGroup *shapeGroup;
|
||||
@property (nonatomic, readonly) LOTShapeTransform *shapeTransform;
|
||||
@property (nonatomic, assign) BOOL debugModeOn;
|
||||
|
||||
@end
|
@ -1,29 +1,29 @@
|
||||
//
|
||||
// LAGroupLayerView.m
|
||||
// LOTGroupLayerView.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/14/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAGroupLayerView.h"
|
||||
#import "LAShapeLayerView.h"
|
||||
#import "LARectShapeLayer.h"
|
||||
#import "LAEllipseShapeLayer.h"
|
||||
#import "LOTGroupLayerView.h"
|
||||
#import "LOTShapeLayerView.h"
|
||||
#import "LOTRectShapeLayer.h"
|
||||
#import "LOTEllipseShapeLayer.h"
|
||||
|
||||
#import "CAAnimationGroup+LAAnimatableGroup.h"
|
||||
#import "CAAnimationGroup+LOTAnimatableGroup.h"
|
||||
|
||||
@implementation LAGroupLayerView {
|
||||
NSArray<LAGroupLayerView *> *_groupLayers;
|
||||
NSArray<LAShapeLayerView *> *_shapeLayers;
|
||||
@implementation LOTGroupLayerView {
|
||||
NSArray<LOTGroupLayerView *> *_groupLayers;
|
||||
NSArray<LOTShapeLayerView *> *_shapeLayers;
|
||||
CAAnimationGroup *_animation;
|
||||
}
|
||||
|
||||
- (instancetype)initWithShapeGroup:(LAShapeGroup *)shapeGroup
|
||||
transform:(LAShapeTransform *)previousTransform
|
||||
fill:(LAShapeFill *)previousFill
|
||||
stroke:(LAShapeStroke *)previousStroke
|
||||
trimPath:(LAShapeTrimPath *)previousTrimPath
|
||||
- (instancetype)initWithShapeGroup:(LOTShapeGroup *)shapeGroup
|
||||
transform:(LOTShapeTransform *)previousTransform
|
||||
fill:(LOTShapeFill *)previousFill
|
||||
stroke:(LOTShapeStroke *)previousStroke
|
||||
trimPath:(LOTShapeTrimPath *)previousTrimPath
|
||||
withDuration:(NSTimeInterval)duration {
|
||||
self = [super initWithDuration:duration];
|
||||
if (self) {
|
||||
@ -34,9 +34,9 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)_setupShapeGroupWithFill:(LAShapeFill *)previousFill
|
||||
stroke:(LAShapeStroke *)previousStroke
|
||||
trimPath:(LAShapeTrimPath *)previousTrimPath {
|
||||
- (void)_setupShapeGroupWithFill:(LOTShapeFill *)previousFill
|
||||
stroke:(LOTShapeStroke *)previousStroke
|
||||
trimPath:(LOTShapeTrimPath *)previousTrimPath {
|
||||
if (_shapeTransform) {
|
||||
self.frame = _shapeTransform.compBounds;
|
||||
self.anchorPoint = _shapeTransform.anchor.initialPoint;
|
||||
@ -49,26 +49,26 @@
|
||||
NSArray *groupItems = _shapeGroup.items;
|
||||
NSArray *reversedItems = [[groupItems reverseObjectEnumerator] allObjects];
|
||||
|
||||
LAShapeFill *currentFill = previousFill;
|
||||
LAShapeStroke *currentStroke = previousStroke;
|
||||
LAShapeTransform *currentTransform;
|
||||
LAShapeTrimPath *currentTrim = previousTrimPath;
|
||||
LOTShapeFill *currentFill = previousFill;
|
||||
LOTShapeStroke *currentStroke = previousStroke;
|
||||
LOTShapeTransform *currentTransform;
|
||||
LOTShapeTrimPath *currentTrim = previousTrimPath;
|
||||
|
||||
NSMutableArray *shapeLayers = [NSMutableArray array];
|
||||
NSMutableArray *groupLayers = [NSMutableArray array];
|
||||
|
||||
for (id item in reversedItems) {
|
||||
if ([item isKindOfClass:[LAShapeTransform class]]) {
|
||||
if ([item isKindOfClass:[LOTShapeTransform class]]) {
|
||||
currentTransform = item;
|
||||
} else if ([item isKindOfClass:[LAShapeStroke class]]) {
|
||||
} else if ([item isKindOfClass:[LOTShapeStroke class]]) {
|
||||
currentStroke = item;
|
||||
} else if ([item isKindOfClass:[LAShapeFill class]]) {
|
||||
} else if ([item isKindOfClass:[LOTShapeFill class]]) {
|
||||
currentFill = item;
|
||||
} else if ([item isKindOfClass:[LAShapeTrimPath class]]) {
|
||||
} else if ([item isKindOfClass:[LOTShapeTrimPath class]]) {
|
||||
currentTrim = item;
|
||||
} else if ([item isKindOfClass:[LAShapePath class]]) {
|
||||
LAShapePath *shapePath = (LAShapePath *)item;
|
||||
LAShapeLayerView *shapeLayer = [[LAShapeLayerView alloc] initWithShape:shapePath
|
||||
} else if ([item isKindOfClass:[LOTShapePath class]]) {
|
||||
LOTShapePath *shapePath = (LOTShapePath *)item;
|
||||
LOTShapeLayerView *shapeLayer = [[LOTShapeLayerView alloc] initWithShape:shapePath
|
||||
fill:currentFill
|
||||
stroke:currentStroke
|
||||
trim:currentTrim
|
||||
@ -76,18 +76,18 @@
|
||||
withDuration:self.laAnimationDuration];
|
||||
[shapeLayers addObject:shapeLayer];
|
||||
[self addSublayer:shapeLayer];
|
||||
} else if ([item isKindOfClass:[LAShapeRectangle class]]) {
|
||||
LAShapeRectangle *shapeRect = (LAShapeRectangle *)item;
|
||||
LARectShapeLayer *shapeLayer = [[LARectShapeLayer alloc] initWithRectShape:shapeRect
|
||||
} else if ([item isKindOfClass:[LOTShapeRectangle class]]) {
|
||||
LOTShapeRectangle *shapeRect = (LOTShapeRectangle *)item;
|
||||
LOTRectShapeLayer *shapeLayer = [[LOTRectShapeLayer alloc] initWithRectShape:shapeRect
|
||||
fill:currentFill
|
||||
stroke:currentStroke
|
||||
transform:currentTransform
|
||||
withDuration:self.laAnimationDuration];
|
||||
[shapeLayers addObject:shapeLayer];
|
||||
[self addSublayer:shapeLayer];
|
||||
} else if ([item isKindOfClass:[LAShapeCircle class]]) {
|
||||
LAShapeCircle *shapeCircle = (LAShapeCircle *)item;
|
||||
LAEllipseShapeLayer *shapeLayer = [[LAEllipseShapeLayer alloc] initWithEllipseShape:shapeCircle
|
||||
} else if ([item isKindOfClass:[LOTShapeCircle class]]) {
|
||||
LOTShapeCircle *shapeCircle = (LOTShapeCircle *)item;
|
||||
LOTEllipseShapeLayer *shapeLayer = [[LOTEllipseShapeLayer alloc] initWithEllipseShape:shapeCircle
|
||||
fill:currentFill
|
||||
stroke:currentStroke
|
||||
trim:currentTrim
|
||||
@ -95,9 +95,9 @@
|
||||
withDuration:self.laAnimationDuration];
|
||||
[shapeLayers addObject:shapeLayer];
|
||||
[self addSublayer:shapeLayer];
|
||||
} else if ([item isKindOfClass:[LAShapeGroup class]]) {
|
||||
LAShapeGroup *shapeGroup = (LAShapeGroup *)item;
|
||||
LAGroupLayerView *groupLayer = [[LAGroupLayerView alloc] initWithShapeGroup:shapeGroup
|
||||
} else if ([item isKindOfClass:[LOTShapeGroup class]]) {
|
||||
LOTShapeGroup *shapeGroup = (LOTShapeGroup *)item;
|
||||
LOTGroupLayerView *groupLayer = [[LOTGroupLayerView alloc] initWithShapeGroup:shapeGroup
|
||||
transform:currentTransform
|
||||
fill:currentFill
|
||||
stroke:currentStroke
|
||||
@ -115,7 +115,7 @@
|
||||
|
||||
- (void)_buildAnimation {
|
||||
if (_shapeTransform) {
|
||||
_animation = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:@{@"opacity" : _shapeTransform.opacity,
|
||||
_animation = [CAAnimationGroup LOT_animationGroupForAnimatablePropertiesWithKeyPaths:@{@"opacity" : _shapeTransform.opacity,
|
||||
@"position" : _shapeTransform.position,
|
||||
@"anchorPoint" : _shapeTransform.anchor,
|
||||
@"transform" : _shapeTransform.scale,
|
21
lottie-ios/Classes/Animatable Layers/LOTLayerView.h
Normal file
21
lottie-ios/Classes/Animatable Layers/LOTLayerView.h
Normal file
@ -0,0 +1,21 @@
|
||||
//
|
||||
// LOTLayerView.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/14/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LOTPlatformCompat.h"
|
||||
#import "LOTAnimatableLayer.h"
|
||||
|
||||
#import "LOTModels.h"
|
||||
|
||||
@interface LOTLayerView : LOTAnimatableLayer
|
||||
|
||||
- (instancetype)initWithModel:(LOTLayer *)model inComposition:(LOTComposition *)comp;
|
||||
|
||||
@property (nonatomic, readonly) LOTLayer *layerModel;
|
||||
@property (nonatomic, assign) BOOL debugModeOn;
|
||||
|
||||
@end
|
@ -1,32 +1,32 @@
|
||||
//
|
||||
// LALayerView.m
|
||||
// LOTLayerView.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/14/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LALayerView.h"
|
||||
#import "LAShapeLayerView.h"
|
||||
#import "LARectShapeLayer.h"
|
||||
#import "LAEllipseShapeLayer.h"
|
||||
#import "LAGroupLayerView.h"
|
||||
#import "CAAnimationGroup+LAAnimatableGroup.h"
|
||||
#import "LAMaskLayer.h"
|
||||
#import "LOTLayerView.h"
|
||||
#import "LOTShapeLayerView.h"
|
||||
#import "LOTRectShapeLayer.h"
|
||||
#import "LOTEllipseShapeLayer.h"
|
||||
#import "LOTGroupLayerView.h"
|
||||
#import "CAAnimationGroup+LOTAnimatableGroup.h"
|
||||
#import "LOTMaskLayer.h"
|
||||
#import "CGGeometryAdditions.h"
|
||||
|
||||
@interface LAParentLayer : LAAnimatableLayer
|
||||
@interface LOTParentLayer : LOTAnimatableLayer
|
||||
|
||||
- (instancetype)initWithParentModel:(LALayer *)parent inComposition:(LAComposition *)comp;
|
||||
- (instancetype)initWithParentModel:(LOTLayer *)parent inComposition:(LOTComposition *)comp;
|
||||
|
||||
@end
|
||||
|
||||
@implementation LAParentLayer {
|
||||
LALayer *_parentModel;
|
||||
@implementation LOTParentLayer {
|
||||
LOTLayer *_parentModel;
|
||||
CAAnimationGroup *_animation;
|
||||
}
|
||||
|
||||
- (instancetype)initWithParentModel:(LALayer *)parent inComposition:(LAComposition *)comp {
|
||||
- (instancetype)initWithParentModel:(LOTLayer *)parent inComposition:(LOTComposition *)comp {
|
||||
self = [super initWithDuration:comp.timeDuration];
|
||||
if (self) {
|
||||
self.bounds = parent.compBounds;
|
||||
@ -45,7 +45,7 @@
|
||||
}
|
||||
|
||||
- (void)_buildAnimations {
|
||||
_animation = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:@{@"position" : _parentModel.position,
|
||||
_animation = [CAAnimationGroup LOT_animationGroupForAnimatablePropertiesWithKeyPaths:@{@"position" : _parentModel.position,
|
||||
@"anchorPoint" : _parentModel.anchor,
|
||||
@"transform" : _parentModel.scale,
|
||||
@"sublayerTransform.rotation" : _parentModel.rotation}];
|
||||
@ -54,18 +54,18 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation LALayerView {
|
||||
NSArray<LAGroupLayerView *> *_shapeLayers;
|
||||
@implementation LOTLayerView {
|
||||
NSArray<LOTGroupLayerView *> *_shapeLayers;
|
||||
CALayer *_childContainerLayer;
|
||||
CALayer *_rotationLayer;
|
||||
CAAnimationGroup *_animation;
|
||||
CAKeyframeAnimation *_inOutAnimation;
|
||||
NSArray<LAParentLayer *> *_parentLayers;
|
||||
LAComposition *_composition;
|
||||
LAMaskLayer *_maskLayer;
|
||||
NSArray<LOTParentLayer *> *_parentLayers;
|
||||
LOTComposition *_composition;
|
||||
LOTMaskLayer *_maskLayer;
|
||||
}
|
||||
|
||||
- (instancetype)initWithModel:(LALayer *)model inComposition:(LAComposition *)comp {
|
||||
- (instancetype)initWithModel:(LOTLayer *)model inComposition:(LOTComposition *)comp {
|
||||
self = [super initWithDuration:comp.timeDuration];
|
||||
if (self) {
|
||||
_layerModel = model;
|
||||
@ -84,7 +84,7 @@
|
||||
_childContainerLayer.bounds = self.bounds;
|
||||
_childContainerLayer.backgroundColor = _layerModel.solidColor.CGColor;
|
||||
|
||||
if (_layerModel.layerType == LALayerTypeSolid) {
|
||||
if (_layerModel.layerType == LOTLayerTypeSolid) {
|
||||
_childContainerLayer.bounds = CGRectMake(0, 0, _layerModel.solidWidth.floatValue, _layerModel.solidHeight.floatValue);
|
||||
_childContainerLayer.backgroundColor = nil;
|
||||
_childContainerLayer.masksToBounds = NO;
|
||||
@ -101,8 +101,8 @@
|
||||
NSMutableArray *parentLayers = [NSMutableArray array];
|
||||
if (parentID) {
|
||||
while (parentID != nil) {
|
||||
LALayer *parentModel = [_composition layerModelForID:parentID];
|
||||
LAParentLayer *parentLayer = [[LAParentLayer alloc] initWithParentModel:parentModel inComposition:_composition];
|
||||
LOTLayer *parentModel = [_composition layerModelForID:parentID];
|
||||
LOTParentLayer *parentLayer = [[LOTParentLayer alloc] initWithParentModel:parentModel inComposition:_composition];
|
||||
[parentLayer addSublayer:currentChild];
|
||||
[parentLayers addObject:parentLayer];
|
||||
currentChild = parentLayer;
|
||||
@ -123,16 +123,16 @@
|
||||
|
||||
NSArray *groupItems = _layerModel.shapes;
|
||||
NSArray *reversedItems = [[groupItems reverseObjectEnumerator] allObjects];
|
||||
LAShapeTransform *currentTransform = [LAShapeTransform transformIdentityWithCompBounds:_composition.compBounds];
|
||||
LAShapeTrimPath *currentTrimPath = nil;
|
||||
LAShapeFill *currentFill = nil;
|
||||
LAShapeStroke *currentStroke = nil;
|
||||
LOTShapeTransform *currentTransform = [LOTShapeTransform transformIdentityWithCompBounds:_composition.compBounds];
|
||||
LOTShapeTrimPath *currentTrimPath = nil;
|
||||
LOTShapeFill *currentFill = nil;
|
||||
LOTShapeStroke *currentStroke = nil;
|
||||
|
||||
NSMutableArray *shapeLayers = [NSMutableArray array];
|
||||
|
||||
for (id item in reversedItems) {
|
||||
if ([item isKindOfClass:[LAShapeGroup class]]) {
|
||||
LAGroupLayerView *groupLayer = [[LAGroupLayerView alloc] initWithShapeGroup:(LAShapeGroup *)item
|
||||
if ([item isKindOfClass:[LOTShapeGroup class]]) {
|
||||
LOTGroupLayerView *groupLayer = [[LOTGroupLayerView alloc] initWithShapeGroup:(LOTShapeGroup *)item
|
||||
transform:currentTransform
|
||||
fill:currentFill
|
||||
stroke:currentStroke
|
||||
@ -140,9 +140,9 @@
|
||||
withDuration:self.laAnimationDuration];
|
||||
[_childContainerLayer addSublayer:groupLayer];
|
||||
[shapeLayers addObject:groupLayer];
|
||||
} else if ([item isKindOfClass:[LAShapePath class]]) {
|
||||
LAShapePath *shapePath = (LAShapePath *)item;
|
||||
LAShapeLayerView *shapeLayer = [[LAShapeLayerView alloc] initWithShape:shapePath
|
||||
} else if ([item isKindOfClass:[LOTShapePath class]]) {
|
||||
LOTShapePath *shapePath = (LOTShapePath *)item;
|
||||
LOTShapeLayerView *shapeLayer = [[LOTShapeLayerView alloc] initWithShape:shapePath
|
||||
fill:currentFill
|
||||
stroke:currentStroke
|
||||
trim:currentTrimPath
|
||||
@ -150,18 +150,18 @@
|
||||
withDuration:self.laAnimationDuration];
|
||||
[shapeLayers addObject:shapeLayer];
|
||||
[_childContainerLayer addSublayer:shapeLayer];
|
||||
} else if ([item isKindOfClass:[LAShapeRectangle class]]) {
|
||||
LAShapeRectangle *shapeRect = (LAShapeRectangle *)item;
|
||||
LARectShapeLayer *shapeLayer = [[LARectShapeLayer alloc] initWithRectShape:shapeRect
|
||||
} else if ([item isKindOfClass:[LOTShapeRectangle class]]) {
|
||||
LOTShapeRectangle *shapeRect = (LOTShapeRectangle *)item;
|
||||
LOTRectShapeLayer *shapeLayer = [[LOTRectShapeLayer alloc] initWithRectShape:shapeRect
|
||||
fill:currentFill
|
||||
stroke:currentStroke
|
||||
transform:currentTransform
|
||||
withDuration:self.laAnimationDuration];
|
||||
[shapeLayers addObject:shapeLayer];
|
||||
[_childContainerLayer addSublayer:shapeLayer];
|
||||
} else if ([item isKindOfClass:[LAShapeCircle class]]) {
|
||||
LAShapeCircle *shapeCircle = (LAShapeCircle *)item;
|
||||
LAEllipseShapeLayer *shapeLayer = [[LAEllipseShapeLayer alloc] initWithEllipseShape:shapeCircle
|
||||
} else if ([item isKindOfClass:[LOTShapeCircle class]]) {
|
||||
LOTShapeCircle *shapeCircle = (LOTShapeCircle *)item;
|
||||
LOTEllipseShapeLayer *shapeLayer = [[LOTEllipseShapeLayer alloc] initWithEllipseShape:shapeCircle
|
||||
fill:currentFill
|
||||
stroke:currentStroke
|
||||
trim:currentTrimPath
|
||||
@ -169,21 +169,21 @@
|
||||
withDuration:self.laAnimationDuration];
|
||||
[shapeLayers addObject:shapeLayer];
|
||||
[_childContainerLayer addSublayer:shapeLayer];
|
||||
} else if ([item isKindOfClass:[LAShapeTransform class]]) {
|
||||
currentTransform = (LAShapeTransform *)item;
|
||||
} else if ([item isKindOfClass:[LAShapeFill class]]) {
|
||||
currentFill = (LAShapeFill *)item;
|
||||
} else if ([item isKindOfClass:[LAShapeTrimPath class]]) {
|
||||
currentTrimPath = (LAShapeTrimPath *)item;
|
||||
} else if ([item isKindOfClass:[LAShapeStroke class]]) {
|
||||
currentStroke = (LAShapeStroke *)item;
|
||||
} else if ([item isKindOfClass:[LOTShapeTransform class]]) {
|
||||
currentTransform = (LOTShapeTransform *)item;
|
||||
} else if ([item isKindOfClass:[LOTShapeFill class]]) {
|
||||
currentFill = (LOTShapeFill *)item;
|
||||
} else if ([item isKindOfClass:[LOTShapeTrimPath class]]) {
|
||||
currentTrimPath = (LOTShapeTrimPath *)item;
|
||||
} else if ([item isKindOfClass:[LOTShapeStroke class]]) {
|
||||
currentStroke = (LOTShapeStroke *)item;
|
||||
}
|
||||
}
|
||||
|
||||
_shapeLayers = shapeLayers;
|
||||
|
||||
if (_layerModel.masks) {
|
||||
_maskLayer = [[LAMaskLayer alloc] initWithMasks:_layerModel.masks inComposition:_composition];
|
||||
_maskLayer = [[LOTMaskLayer alloc] initWithMasks:_layerModel.masks inComposition:_composition];
|
||||
_childContainerLayer.mask = _maskLayer;
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@
|
||||
}
|
||||
|
||||
|
||||
_animation = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:keypaths];
|
||||
_animation = [CAAnimationGroup LOT_animationGroupForAnimatablePropertiesWithKeyPaths:keypaths];
|
||||
|
||||
if (_animation) {
|
||||
[_childContainerLayer addAnimation:_animation forKey:@"LottieAnimation"];
|
||||
@ -249,7 +249,7 @@
|
||||
self.borderWidth = debugModeOn ? 2 : 0;
|
||||
self.backgroundColor = debugModeOn ? [[UIColor blueColor] colorWithAlphaComponent:0.2].CGColor : [UIColor clearColor].CGColor;
|
||||
|
||||
for (LAGroupLayerView *group in _shapeLayers) {
|
||||
for (LOTGroupLayerView *group in _shapeLayers) {
|
||||
group.debugModeOn = debugModeOn;
|
||||
}
|
||||
}
|
19
lottie-ios/Classes/Animatable Layers/LOTMaskLayer.h
Normal file
19
lottie-ios/Classes/Animatable Layers/LOTMaskLayer.h
Normal file
@ -0,0 +1,19 @@
|
||||
//
|
||||
// LOTMaskLayer.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/22/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LOTAnimatableLayer.h"
|
||||
#import "LOTModels.h"
|
||||
|
||||
@interface LOTMaskLayer : LOTAnimatableLayer
|
||||
|
||||
- (instancetype)initWithMasks:(NSArray<LOTMask *> *)masks inComposition:(LOTComposition *)comp;
|
||||
|
||||
@property (nonatomic, readonly) NSArray<LOTMask *> *masks;
|
||||
|
||||
|
||||
@end
|
@ -1,20 +1,20 @@
|
||||
//
|
||||
// LAMaskLayer.m
|
||||
// LOTMaskLayer.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/22/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAMaskLayer.h"
|
||||
#import "CAAnimationGroup+LAAnimatableGroup.h"
|
||||
#import "LOTMaskLayer.h"
|
||||
#import "CAAnimationGroup+LOTAnimatableGroup.h"
|
||||
|
||||
@implementation LAMaskLayer {
|
||||
LAComposition *_composition;
|
||||
@implementation LOTMaskLayer {
|
||||
LOTComposition *_composition;
|
||||
NSArray *_maskLayers;
|
||||
}
|
||||
|
||||
- (instancetype)initWithMasks:(NSArray<LAMask *> *)masks inComposition:(LAComposition *)comp {
|
||||
- (instancetype)initWithMasks:(NSArray<LOTMask *> *)masks inComposition:(LOTComposition *)comp {
|
||||
self = [super initWithDuration:comp.timeDuration];
|
||||
if (self) {
|
||||
_masks = masks;
|
||||
@ -27,13 +27,13 @@
|
||||
- (void)_setupViewFromModel {
|
||||
NSMutableArray *maskLayers = [NSMutableArray array];
|
||||
|
||||
for (LAMask *mask in _masks) {
|
||||
for (LOTMask *mask in _masks) {
|
||||
CAShapeLayer *maskLayer = [CAShapeLayer new];
|
||||
maskLayer.path = mask.maskPath.initialShape.CGPath;
|
||||
maskLayer.fillColor = [UIColor whiteColor].CGColor;
|
||||
maskLayer.opacity = mask.opacity.initialValue.floatValue;
|
||||
[self addSublayer:maskLayer];
|
||||
CAAnimationGroup *animGroup = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:@{@"opacity" : mask.opacity,
|
||||
CAAnimationGroup *animGroup = [CAAnimationGroup LOT_animationGroupForAnimatablePropertiesWithKeyPaths:@{@"opacity" : mask.opacity,
|
||||
@"path" : mask.maskPath}];
|
||||
if (animGroup) {
|
||||
[maskLayer addAnimation:animGroup forKey:@""];
|
21
lottie-ios/Classes/Animatable Layers/LOTRectShapeLayer.h
Normal file
21
lottie-ios/Classes/Animatable Layers/LOTRectShapeLayer.h
Normal file
@ -0,0 +1,21 @@
|
||||
//
|
||||
// LOTRectShapeLayer.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/20/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import "LOTModels.h"
|
||||
#import "LOTAnimatableLayer.h"
|
||||
|
||||
@interface LOTRectShapeLayer : LOTAnimatableLayer
|
||||
|
||||
- (instancetype)initWithRectShape:(LOTShapeRectangle *)rectShape
|
||||
fill:(LOTShapeFill *)fill
|
||||
stroke:(LOTShapeStroke *)stroke
|
||||
transform:(LOTShapeTransform *)transform
|
||||
withDuration:(NSTimeInterval)duration;
|
||||
|
||||
@end
|
@ -1,16 +1,16 @@
|
||||
//
|
||||
// LARectShapeLayer.m
|
||||
// LOTRectShapeLayer.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/20/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LARectShapeLayer.h"
|
||||
#import "LAPlatformCompat.h"
|
||||
#import "CAAnimationGroup+LAAnimatableGroup.h"
|
||||
#import "LOTRectShapeLayer.h"
|
||||
#import "LOTPlatformCompat.h"
|
||||
#import "CAAnimationGroup+LOTAnimatableGroup.h"
|
||||
|
||||
@interface LARoundRectLayer : CAShapeLayer
|
||||
@interface LOTRoundRectLayer : CAShapeLayer
|
||||
|
||||
@property (nonatomic) CGPoint rectPosition;
|
||||
@property (nonatomic) CGPoint rectSize;
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation LARoundRectLayer
|
||||
@implementation LOTRoundRectLayer
|
||||
|
||||
@dynamic rectPosition;
|
||||
@dynamic rectSize;
|
||||
@ -26,10 +26,10 @@
|
||||
|
||||
-(id)initWithLayer:(id)layer {
|
||||
if( ( self = [super initWithLayer:layer] ) ) {
|
||||
if ([layer isKindOfClass:[LARoundRectLayer class]]) {
|
||||
self.rectSize = ((LARoundRectLayer *)layer).rectSize;
|
||||
self.rectPosition = ((LARoundRectLayer *)layer).rectPosition;
|
||||
self.rectCornerRadius = ((LARoundRectLayer *)layer).rectCornerRadius;
|
||||
if ([layer isKindOfClass:[LOTRoundRectLayer class]]) {
|
||||
self.rectSize = ((LOTRoundRectLayer *)layer).rectSize;
|
||||
self.rectPosition = ((LOTRoundRectLayer *)layer).rectPosition;
|
||||
self.rectCornerRadius = ((LOTRoundRectLayer *)layer).rectCornerRadius;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
@ -56,7 +56,7 @@
|
||||
}
|
||||
|
||||
- (void)_setPath {
|
||||
LARoundRectLayer *presentationRect = (LARoundRectLayer *)self.presentationLayer;
|
||||
LOTRoundRectLayer *presentationRect = (LOTRoundRectLayer *)self.presentationLayer;
|
||||
if (presentationRect == nil) {
|
||||
presentationRect = self;
|
||||
}
|
||||
@ -75,24 +75,24 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation LARectShapeLayer {
|
||||
LAShapeTransform *_transform;
|
||||
LAShapeStroke *_stroke;
|
||||
LAShapeFill *_fill;
|
||||
LAShapeRectangle *_rectangle;
|
||||
@implementation LOTRectShapeLayer {
|
||||
LOTShapeTransform *_transform;
|
||||
LOTShapeStroke *_stroke;
|
||||
LOTShapeFill *_fill;
|
||||
LOTShapeRectangle *_rectangle;
|
||||
|
||||
LARoundRectLayer *_fillLayer;
|
||||
LARoundRectLayer *_strokeLayer;
|
||||
LOTRoundRectLayer *_fillLayer;
|
||||
LOTRoundRectLayer *_strokeLayer;
|
||||
|
||||
CAAnimationGroup *_animation;
|
||||
CAAnimationGroup *_strokeAnimation;
|
||||
CAAnimationGroup *_fillAnimation;
|
||||
}
|
||||
|
||||
- (instancetype)initWithRectShape:(LAShapeRectangle *)rectShape
|
||||
fill:(LAShapeFill *)fill
|
||||
stroke:(LAShapeStroke *)stroke
|
||||
transform:(LAShapeTransform *)transform
|
||||
- (instancetype)initWithRectShape:(LOTShapeRectangle *)rectShape
|
||||
fill:(LOTShapeFill *)fill
|
||||
stroke:(LOTShapeStroke *)stroke
|
||||
transform:(LOTShapeTransform *)transform
|
||||
withDuration:(NSTimeInterval)duration {
|
||||
self = [super initWithDuration:duration];
|
||||
if (self) {
|
||||
@ -110,7 +110,7 @@
|
||||
self.sublayerTransform = CATransform3DMakeRotation(_transform.rotation.initialValue.floatValue, 0, 0, 1);
|
||||
|
||||
if (fill) {
|
||||
_fillLayer = [LARoundRectLayer layer];
|
||||
_fillLayer = [LOTRoundRectLayer layer];
|
||||
_fillLayer.allowsEdgeAntialiasing = YES;
|
||||
_fillLayer.fillColor = _fill.color.initialColor.CGColor;
|
||||
_fillLayer.opacity = _fill.opacity.initialValue.floatValue;
|
||||
@ -121,7 +121,7 @@
|
||||
}
|
||||
|
||||
if (stroke) {
|
||||
_strokeLayer = [LARoundRectLayer layer];
|
||||
_strokeLayer = [LOTRoundRectLayer layer];
|
||||
_strokeLayer.allowsEdgeAntialiasing = YES;
|
||||
_strokeLayer.strokeColor = _stroke.color.initialColor.CGColor;
|
||||
_strokeLayer.opacity = _stroke.opacity.initialValue.floatValue;
|
||||
@ -129,18 +129,18 @@
|
||||
_strokeLayer.fillColor = nil;
|
||||
_strokeLayer.backgroundColor = nil;
|
||||
_strokeLayer.lineDashPattern = _stroke.lineDashPattern;
|
||||
_strokeLayer.lineCap = _stroke.capType == LALineCapTypeRound ? kCALineCapRound : kCALineCapButt;
|
||||
_strokeLayer.lineCap = _stroke.capType == LOTLineCapTypeRound ? kCALineCapRound : kCALineCapButt;
|
||||
_strokeLayer.rectCornerRadius = rectShape.cornerRadius.initialValue.floatValue;
|
||||
_strokeLayer.rectSize = rectShape.size.initialPoint;
|
||||
_strokeLayer.rectPosition = rectShape.position.initialPoint;
|
||||
switch (_stroke.joinType) {
|
||||
case LALineJoinTypeBevel:
|
||||
case LOTLineJoinTypeBevel:
|
||||
_strokeLayer.lineJoin = kCALineJoinBevel;
|
||||
break;
|
||||
case LALineJoinTypeMiter:
|
||||
case LOTLineJoinTypeMiter:
|
||||
_strokeLayer.lineJoin = kCALineJoinMiter;
|
||||
break;
|
||||
case LALineJoinTypeRound:
|
||||
case LOTLineJoinTypeRound:
|
||||
_strokeLayer.lineJoin = kCALineJoinRound;
|
||||
break;
|
||||
default:
|
||||
@ -161,7 +161,7 @@
|
||||
|
||||
- (void)_buildAnimation {
|
||||
if (_transform) {
|
||||
_animation = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:@{@"opacity" : _transform.opacity,
|
||||
_animation = [CAAnimationGroup LOT_animationGroupForAnimatablePropertiesWithKeyPaths:@{@"opacity" : _transform.opacity,
|
||||
@"position" : _transform.position,
|
||||
@"anchorPoint" : _transform.anchor,
|
||||
@"transform" : _transform.scale,
|
||||
@ -170,7 +170,7 @@
|
||||
}
|
||||
|
||||
if (_stroke) {
|
||||
_strokeAnimation = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:@{@"strokeColor" : _stroke.color,
|
||||
_strokeAnimation = [CAAnimationGroup LOT_animationGroupForAnimatablePropertiesWithKeyPaths:@{@"strokeColor" : _stroke.color,
|
||||
@"opacity" : _stroke.opacity,
|
||||
@"lineWidth" : _stroke.width,
|
||||
@"rectSize" : _rectangle.size,
|
||||
@ -181,7 +181,7 @@
|
||||
}
|
||||
|
||||
if (_fill) {
|
||||
_fillAnimation = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:@{@"fillColor" : _fill.color,
|
||||
_fillAnimation = [CAAnimationGroup LOT_animationGroupForAnimatablePropertiesWithKeyPaths:@{@"fillColor" : _fill.color,
|
||||
@"opacity" : _fill.opacity,
|
||||
@"rectSize" : _rectangle.size,
|
||||
@"rectPosition" : _rectangle.position,
|
21
lottie-ios/Classes/Animatable Layers/LOTShapeLayerView.h
Normal file
21
lottie-ios/Classes/Animatable Layers/LOTShapeLayerView.h
Normal file
@ -0,0 +1,21 @@
|
||||
//
|
||||
// LOTShapeLayerView.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 7/13/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LOTAnimatableLayer.h"
|
||||
#import "LOTModels.h"
|
||||
|
||||
@interface LOTShapeLayerView : LOTAnimatableLayer
|
||||
|
||||
- (instancetype)initWithShape:(LOTShapePath *)shape
|
||||
fill:(LOTShapeFill *)fill
|
||||
stroke:(LOTShapeStroke *)stroke
|
||||
trim:(LOTShapeTrimPath *)trim
|
||||
transform:(LOTShapeTransform *)transform
|
||||
withDuration:(NSTimeInterval)duration;
|
||||
|
||||
@end
|
@ -1,20 +1,20 @@
|
||||
//
|
||||
// LAShapeLayerView.m
|
||||
// LOTShapeLayerView.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 7/13/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAShapeLayerView.h"
|
||||
#import "CAAnimationGroup+LAAnimatableGroup.h"
|
||||
#import "LOTShapeLayerView.h"
|
||||
#import "CAAnimationGroup+LOTAnimatableGroup.h"
|
||||
|
||||
@implementation LAShapeLayerView {
|
||||
LAShapeTransform *_transform;
|
||||
LAShapeStroke *_stroke;
|
||||
LAShapeFill *_fill;
|
||||
LAShapePath *_path;
|
||||
LAShapeTrimPath *_trim;
|
||||
@implementation LOTShapeLayerView {
|
||||
LOTShapeTransform *_transform;
|
||||
LOTShapeStroke *_stroke;
|
||||
LOTShapeFill *_fill;
|
||||
LOTShapePath *_path;
|
||||
LOTShapeTrimPath *_trim;
|
||||
|
||||
CAShapeLayer *_fillLayer;
|
||||
CAShapeLayer *_strokeLayer;
|
||||
@ -24,11 +24,11 @@
|
||||
CAAnimationGroup *_fillAnimation;
|
||||
}
|
||||
|
||||
- (instancetype)initWithShape:(LAShapePath *)shape
|
||||
fill:(LAShapeFill *)fill
|
||||
stroke:(LAShapeStroke *)stroke
|
||||
trim:(LAShapeTrimPath *)trim
|
||||
transform:(LAShapeTransform *)transform
|
||||
- (instancetype)initWithShape:(LOTShapePath *)shape
|
||||
fill:(LOTShapeFill *)fill
|
||||
stroke:(LOTShapeStroke *)stroke
|
||||
trim:(LOTShapeTrimPath *)trim
|
||||
transform:(LOTShapeTransform *)transform
|
||||
withDuration:(NSTimeInterval)duration {
|
||||
self = [super initWithDuration:duration];
|
||||
if (self) {
|
||||
@ -63,15 +63,15 @@
|
||||
_strokeLayer.opacity = _stroke.opacity.initialValue.floatValue;
|
||||
_strokeLayer.lineWidth = _stroke.width.initialValue.floatValue;
|
||||
_strokeLayer.lineDashPattern = _stroke.lineDashPattern;
|
||||
_strokeLayer.lineCap = _stroke.capType == LALineCapTypeRound ? kCALineCapRound : kCALineCapButt;
|
||||
_strokeLayer.lineCap = _stroke.capType == LOTLineCapTypeRound ? kCALineCapRound : kCALineCapButt;
|
||||
switch (_stroke.joinType) {
|
||||
case LALineJoinTypeBevel:
|
||||
case LOTLineJoinTypeBevel:
|
||||
_strokeLayer.lineJoin = kCALineJoinBevel;
|
||||
break;
|
||||
case LALineJoinTypeMiter:
|
||||
case LOTLineJoinTypeMiter:
|
||||
_strokeLayer.lineJoin = kCALineJoinMiter;
|
||||
break;
|
||||
case LALineJoinTypeRound:
|
||||
case LOTLineJoinTypeRound:
|
||||
_strokeLayer.lineJoin = kCALineJoinRound;
|
||||
break;
|
||||
default:
|
||||
@ -93,7 +93,7 @@
|
||||
|
||||
- (void)_buildAnimation {
|
||||
if (_transform) {
|
||||
_animation = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:@{@"opacity" : _transform.opacity,
|
||||
_animation = [CAAnimationGroup LOT_animationGroupForAnimatablePropertiesWithKeyPaths:@{@"opacity" : _transform.opacity,
|
||||
@"position" : _transform.position,
|
||||
@"anchorPoint" : _transform.anchor,
|
||||
@"transform" : _transform.scale,
|
||||
@ -110,12 +110,12 @@
|
||||
properties[@"strokeStart"] = _trim.start;
|
||||
properties[@"strokeEnd"] = _trim.end;
|
||||
}
|
||||
_strokeAnimation = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:properties];
|
||||
_strokeAnimation = [CAAnimationGroup LOT_animationGroupForAnimatablePropertiesWithKeyPaths:properties];
|
||||
[_strokeLayer addAnimation:_strokeAnimation forKey:@""];
|
||||
}
|
||||
|
||||
if (_fill) {
|
||||
_fillAnimation = [CAAnimationGroup animationGroupForAnimatablePropertiesWithKeyPaths:@{@"fillColor" : _fill.color,
|
||||
_fillAnimation = [CAAnimationGroup LOT_animationGroupForAnimatablePropertiesWithKeyPaths:@{@"fillColor" : _fill.color,
|
||||
@"opacity" : _fill.opacity,
|
||||
@"path" : _path.shapePath}];
|
||||
[_fillLayer addAnimation:_fillAnimation forKey:@""];
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LAAnimatableBoundsValue.h
|
||||
// LOTAnimatableBoundsValue.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/20/16.
|
||||
@ -8,9 +8,9 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import "LAAnimatableValue.h"
|
||||
#import "LOTAnimatableValue.h"
|
||||
|
||||
@interface LAAnimatableBoundsValue : NSObject <LAAnimatableValue>
|
||||
@interface LOTAnimatableBoundsValue : NSObject <LOTAnimatableValue>
|
||||
|
||||
- (instancetype)initWithSizeValues:(NSDictionary *)sizeValue frameRate:(NSNumber *)frameRate;
|
||||
|
@ -1,15 +1,15 @@
|
||||
//
|
||||
// LAAnimatableBoundsValue.m
|
||||
// LOTAnimatableBoundsValue.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/20/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAPlatformCompat.h"
|
||||
#import "LAAnimatableBoundsValue.h"
|
||||
#import "LOTPlatformCompat.h"
|
||||
#import "LOTAnimatableBoundsValue.h"
|
||||
|
||||
@interface LAAnimatableBoundsValue ()
|
||||
@interface LOTAnimatableBoundsValue ()
|
||||
|
||||
@property (nonatomic, readonly) NSArray *boundsKeyframes;
|
||||
@property (nonatomic, readonly) NSArray<NSNumber *> *keyTimes;
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation LAAnimatableBoundsValue
|
||||
@implementation LOTAnimatableBoundsValue
|
||||
|
||||
- (instancetype)initWithSizeValues:(NSDictionary *)sizeValue frameRate:(NSNumber *)frameRate {
|
||||
self = [super init];
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LAAnimatableColorValue.h
|
||||
// LOTAnimatableColorValue.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 6/23/16.
|
||||
@ -8,10 +8,10 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import "LAAnimatableValue.h"
|
||||
#import "LAPlatformCompat.h"
|
||||
#import "LOTAnimatableValue.h"
|
||||
#import "LOTPlatformCompat.h"
|
||||
|
||||
@interface LAAnimatableColorValue : NSObject <LAAnimatableValue>
|
||||
@interface LOTAnimatableColorValue : NSObject <LOTAnimatableValue>
|
||||
|
||||
- (instancetype)initWithColorValues:(NSDictionary *)colorValues frameRate:(NSNumber *)frameRate;
|
||||
|
@ -1,14 +1,14 @@
|
||||
//
|
||||
// LAAnimatableColorValue.m
|
||||
// LOTAnimatableColorValue.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 6/23/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAAnimatableColorValue.h"
|
||||
#import "LOTAnimatableColorValue.h"
|
||||
|
||||
@interface LAAnimatableColorValue ()
|
||||
@interface LOTAnimatableColorValue ()
|
||||
|
||||
@property (nonatomic, readonly) NSArray *colorKeyframes;
|
||||
@property (nonatomic, readonly) NSArray<NSNumber *> *keyTimes;
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation LAAnimatableColorValue
|
||||
@implementation LOTAnimatableColorValue
|
||||
|
||||
- (instancetype)initWithColorValues:(NSDictionary *)colorValues frameRate:(NSNumber *)frameRate {
|
||||
self = [super init];
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LAAnimatableNumberValue.h
|
||||
// LOTAnimatableNumberValue.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 6/23/16.
|
||||
@ -8,9 +8,9 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
#import "LAAnimatableValue.h"
|
||||
#import "LOTAnimatableValue.h"
|
||||
|
||||
@interface LAAnimatableNumberValue : NSObject <LAAnimatableValue>
|
||||
@interface LOTAnimatableNumberValue : NSObject <LOTAnimatableValue>
|
||||
|
||||
- (instancetype)initWithNumberValues:(NSDictionary *)numberValues frameRate:(NSNumber *)frameRate;
|
||||
- (void)remapValuesFromMin:(NSNumber *)fromMin
|
@ -1,15 +1,15 @@
|
||||
//
|
||||
// LAAnimatableNumberValue.m
|
||||
// LOTAnimatableNumberValue.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 6/23/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAAnimatableNumberValue.h"
|
||||
#import "LAHelpers.h"
|
||||
#import "LOTAnimatableNumberValue.h"
|
||||
#import "LOTHelpers.h"
|
||||
|
||||
@interface LAAnimatableNumberValue ()
|
||||
@interface LOTAnimatableNumberValue ()
|
||||
|
||||
@property (nonatomic, readonly) NSArray<NSNumber *> *valueKeyframes;
|
||||
@property (nonatomic, readonly) NSArray<NSNumber *> *keyTimes;
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation LAAnimatableNumberValue
|
||||
@implementation LOTAnimatableNumberValue
|
||||
|
||||
- (instancetype)initWithNumberValues:(NSDictionary *)numberValues frameRate:(NSNumber *)frameRate {
|
||||
self = [super init];
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LAAnimatablePointValue.h
|
||||
// LOTAnimatablePointValue.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 6/23/16.
|
||||
@ -8,9 +8,9 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
#import "LAAnimatableValue.h"
|
||||
#import "LOTAnimatableValue.h"
|
||||
|
||||
@interface LAAnimatablePointValue : NSObject <LAAnimatableValue>
|
||||
@interface LOTAnimatablePointValue : NSObject <LOTAnimatableValue>
|
||||
|
||||
- (instancetype)initWithPointValues:(NSDictionary *)pointValues frameRate:(NSNumber *)frameRate;
|
||||
- (void)remapPointsFromBounds:(CGRect)frombounds toBounds:(CGRect)toBounds;
|
@ -1,16 +1,16 @@
|
||||
//
|
||||
// LAAnimatablePointValue.m
|
||||
// LOTAnimatablePointValue.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 6/23/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAPlatformCompat.h"
|
||||
#import "LAAnimatablePointValue.h"
|
||||
#import "LOTPlatformCompat.h"
|
||||
#import "LOTAnimatablePointValue.h"
|
||||
#import "CGGeometryAdditions.h"
|
||||
|
||||
@interface LAAnimatablePointValue ()
|
||||
@interface LOTAnimatablePointValue ()
|
||||
|
||||
@property (nonatomic, readonly) UIBezierPath *animationPath;
|
||||
@property (nonatomic, readonly) NSArray<NSValue *> *pointKeyframes;
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation LAAnimatablePointValue
|
||||
@implementation LOTAnimatablePointValue
|
||||
|
||||
- (instancetype)initWithPointValues:(NSDictionary *)pointValues frameRate:(NSNumber *)frameRate {
|
||||
self = [super init];
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LAAnimatableScaleValue.h
|
||||
// LOTAnimatableScaleValue.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/11/16.
|
||||
@ -7,9 +7,9 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "LAAnimatableValue.h"
|
||||
#import "LOTAnimatableValue.h"
|
||||
|
||||
@interface LAAnimatableScaleValue : NSObject <LAAnimatableValue>
|
||||
@interface LOTAnimatableScaleValue : NSObject <LOTAnimatableValue>
|
||||
|
||||
- (instancetype)initWithScaleValues:(NSDictionary *)scaleValues frameRate:(NSNumber *)frameRate;
|
||||
|
@ -1,14 +1,14 @@
|
||||
//
|
||||
// LAAnimatableScaleValue.m
|
||||
// LOTAnimatableScaleValue.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/11/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAAnimatableScaleValue.h"
|
||||
#import "LOTAnimatableScaleValue.h"
|
||||
|
||||
@interface LAAnimatableScaleValue ()
|
||||
@interface LOTAnimatableScaleValue ()
|
||||
|
||||
@property (nonatomic, readonly) NSArray<NSValue *> *scaleKeyframes;
|
||||
@property (nonatomic, readonly) NSArray<NSNumber *> *keyTimes;
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation LAAnimatableScaleValue
|
||||
@implementation LOTAnimatableScaleValue
|
||||
|
||||
- (instancetype)initWithScaleValues:(NSDictionary *)scaleValues frameRate:(NSNumber *)frameRate {
|
||||
self = [super init];
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LAAnimatableShapeValue.h
|
||||
// LOTAnimatableShapeValue.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 6/23/16.
|
||||
@ -7,10 +7,10 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "LAPlatformCompat.h"
|
||||
#import "LAAnimatableValue.h"
|
||||
#import "LOTPlatformCompat.h"
|
||||
#import "LOTAnimatableValue.h"
|
||||
|
||||
@interface LAAnimatableShapeValue : NSObject <LAAnimatableValue>
|
||||
@interface LOTAnimatableShapeValue : NSObject <LOTAnimatableValue>
|
||||
|
||||
- (instancetype)initWithShapeValues:(NSDictionary *)shapeValues frameRate:(NSNumber *)frameRate closed:(BOOL)closed;
|
||||
|
@ -1,14 +1,14 @@
|
||||
//
|
||||
// LAAnimatableShapeValue.m
|
||||
// LOTAnimatableShapeValue.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 6/23/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAAnimatableShapeValue.h"
|
||||
#import "LOTAnimatableShapeValue.h"
|
||||
#import "CGGeometryAdditions.h"
|
||||
@interface LAAnimatableShapeValue ()
|
||||
@interface LOTAnimatableShapeValue ()
|
||||
|
||||
@property (nonatomic, readonly) NSArray *shapeKeyframes;
|
||||
@property (nonatomic, readonly) NSArray<NSNumber *> *keyTimes;
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation LAAnimatableShapeValue
|
||||
@implementation LOTAnimatableShapeValue
|
||||
|
||||
- (instancetype)initWithShapeValues:(NSDictionary *)shapeValues frameRate:(NSNumber *)frameRate closed:(BOOL)closed {
|
||||
self = [super init];
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LAAnimatableValue.h
|
||||
// LOTAnimatableValue.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/19/16.
|
||||
@ -9,7 +9,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
@protocol LAAnimatableValue <NSObject>
|
||||
@protocol LOTAnimatableValue <NSObject>
|
||||
|
||||
- (CAKeyframeAnimation *)animationForKeyPath:(NSString *)keypath;
|
||||
- (BOOL)hasAnimation;
|
20
lottie-ios/Classes/Animation Cache/LOTAnimationCache.h
Normal file
20
lottie-ios/Classes/Animation Cache/LOTAnimationCache.h
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// LOTAnimationCache.h
|
||||
// Lottie
|
||||
//
|
||||
// Created by Brandon Withrow on 1/9/17.
|
||||
// Copyright © 2017 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class LOTComposition;
|
||||
|
||||
@interface LOTAnimationCache : NSObject
|
||||
|
||||
+ (instancetype)sharedCache;
|
||||
|
||||
- (void)addAnimation:(LOTComposition *)animation forKey:(NSString *)key;
|
||||
- (LOTComposition *)animationForKey:(NSString *)key;
|
||||
|
||||
@end
|
@ -1,22 +1,22 @@
|
||||
//
|
||||
// LAAnimationCache.m
|
||||
// LOTAnimationCache.m
|
||||
// Lottie
|
||||
//
|
||||
// Created by Brandon Withrow on 1/9/17.
|
||||
// Copyright © 2017 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAAnimationCache.h"
|
||||
#import "LOTAnimationCache.h"
|
||||
|
||||
const NSInteger kLACacheSize = 50;
|
||||
const NSInteger kLOTCacheSize = 50;
|
||||
|
||||
@implementation LAAnimationCache {
|
||||
@implementation LOTAnimationCache {
|
||||
NSMutableDictionary *animationsCache_;
|
||||
NSMutableArray *lruOrderArray_;
|
||||
}
|
||||
|
||||
+ (instancetype)sharedCache {
|
||||
static LAAnimationCache *sharedCache = nil;
|
||||
static LOTAnimationCache *sharedCache = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedCache = [[self alloc] init];
|
||||
@ -33,8 +33,8 @@ const NSInteger kLACacheSize = 50;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)addAnimation:(LAComposition *)animation forKey:(NSString *)key {
|
||||
if (lruOrderArray_.count >= kLACacheSize) {
|
||||
- (void)addAnimation:(LOTComposition *)animation forKey:(NSString *)key {
|
||||
if (lruOrderArray_.count >= kLOTCacheSize) {
|
||||
NSString *oldKey = lruOrderArray_[0];
|
||||
[animationsCache_ removeObjectForKey:oldKey];
|
||||
[lruOrderArray_ removeObject:oldKey];
|
||||
@ -44,8 +44,8 @@ const NSInteger kLACacheSize = 50;
|
||||
[animationsCache_ setObject:animation forKey:key];
|
||||
}
|
||||
|
||||
- (LAComposition *)animationForKey:(NSString *)key {
|
||||
LAComposition *animation = [animationsCache_ objectForKey:key];
|
||||
- (LOTComposition *)animationForKey:(NSString *)key {
|
||||
LOTComposition *animation = [animationsCache_ objectForKey:key];
|
||||
[lruOrderArray_ removeObject:key];
|
||||
[lruOrderArray_ addObject:key];
|
||||
return animation;
|
@ -1,16 +0,0 @@
|
||||
//
|
||||
// CAAnimationGroup+LAAnimatableGroup.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/19/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import "LAAnimatableValue.h"
|
||||
|
||||
@interface CAAnimationGroup (LAAnimatableGroup)
|
||||
|
||||
+ (nullable CAAnimationGroup *)animationGroupForAnimatablePropertiesWithKeyPaths:(nonnull NSDictionary<NSString *, id<LAAnimatableValue>> *)properties;
|
||||
|
||||
@end
|
@ -0,0 +1,16 @@
|
||||
//
|
||||
// CAAnimationGroup+LOTAnimatableGroup.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/19/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import "LOTAnimatableValue.h"
|
||||
|
||||
@interface CAAnimationGroup (LOTAnimatableGroup)
|
||||
|
||||
+ (nullable CAAnimationGroup *)LOT_animationGroupForAnimatablePropertiesWithKeyPaths:(nonnull NSDictionary<NSString *, id<LOTAnimatableValue>> *)properties;
|
||||
|
||||
@end
|
@ -1,20 +1,20 @@
|
||||
//
|
||||
// CAAnimationGroup+LAAnimatableGroup.m
|
||||
// CAAnimationGroup+LOTAnimatableGroup.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/19/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "CAAnimationGroup+LAAnimatableGroup.h"
|
||||
#import "CAAnimationGroup+LOTAnimatableGroup.h"
|
||||
|
||||
@implementation CAAnimationGroup (LAAnimatableGroup)
|
||||
@implementation CAAnimationGroup (LOTAnimatableGroup)
|
||||
|
||||
+ (nullable CAAnimationGroup *)animationGroupForAnimatablePropertiesWithKeyPaths:(nonnull NSDictionary<NSString *, id<LAAnimatableValue>> *)properties {
|
||||
+ (nullable CAAnimationGroup *)LOT_animationGroupForAnimatablePropertiesWithKeyPaths:(nonnull NSDictionary<NSString *, id<LOTAnimatableValue>> *)properties {
|
||||
NSMutableArray *animations = [NSMutableArray array];
|
||||
NSTimeInterval animduration = 0;
|
||||
for (NSString *keyPath in properties.allKeys) {
|
||||
id <LAAnimatableValue>property = properties[keyPath];
|
||||
id <LOTAnimatableValue>property = properties[keyPath];
|
||||
if ([property hasAnimation]) {
|
||||
CAKeyframeAnimation *animation = [property animationForKeyPath:keyPath];
|
||||
[animations addObject:animation];
|
@ -1,5 +1,5 @@
|
||||
|
||||
#import "LAPlatformCompat.h"
|
||||
#import "LOTPlatformCompat.h"
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
#import <GLKit/GLKMathTypes.h>
|
||||
#import <GLKit/GLKit.h>
|
@ -1,15 +1,15 @@
|
||||
//
|
||||
// LAHelpers.h
|
||||
// LOTHelpers.h
|
||||
// Lottie
|
||||
//
|
||||
// Created by Brandon Withrow on 7/28/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef LAHelpers_h
|
||||
#define LAHelpers_h
|
||||
#ifndef LOTHelpers_h
|
||||
#define LOTHelpers_h
|
||||
|
||||
#import "UIColor+Expanded.h"
|
||||
#import "CGGeometryAdditions.h"
|
||||
|
||||
#endif /* LAHelpers_h */
|
||||
#endif /* LOTHelpers_h */
|
51
lottie-ios/Classes/Extensions/UIColor+Expanded.h
Normal file
51
lottie-ios/Classes/Extensions/UIColor+Expanded.h
Normal file
@ -0,0 +1,51 @@
|
||||
#import "LOTPlatformCompat.h"
|
||||
|
||||
// From http://github.com/ars/uicolor-utilities
|
||||
#define CLAMP(val,min,max) MIN(MAX(val,min),max)
|
||||
|
||||
@interface UIColor (UIColor_Expanded)
|
||||
@property (nonatomic, readonly) CGColorSpaceModel colorSpaceModel;
|
||||
@property (nonatomic, readonly) BOOL canProvideRGBComponents;
|
||||
@property (nonatomic, readonly) CGFloat red; // Only valid if canProvideRGBComponents is YES
|
||||
@property (nonatomic, readonly) CGFloat green; // Only valid if canProvideRGBComponents is YES
|
||||
@property (nonatomic, readonly) CGFloat blue; // Only valid if canProvideRGBComponents is YES
|
||||
@property (nonatomic, readonly) CGFloat white; // Only valid if colorSpaceModel == kCGColorSpaceModelMonochrome
|
||||
@property (nonatomic, readonly) CGFloat alpha;
|
||||
@property (nonatomic, readonly) UInt32 rgbHex;
|
||||
|
||||
- (NSString *)LOT_colorSpaceString;
|
||||
|
||||
- (NSArray *)LOT_arrayFromRGBAComponents;
|
||||
|
||||
- (BOOL)LOT_red:(CGFloat *)r green:(CGFloat *)g blue:(CGFloat *)b alpha:(CGFloat *)a;
|
||||
|
||||
- (UIColor *)LOT_colorByLuminanceMapping;
|
||||
|
||||
- (UIColor *)LOT_colorByMultiplyingByRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
|
||||
- (UIColor *) LOT_colorByAddingRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
|
||||
- (UIColor *) LOT_colorByLighteningToRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
|
||||
- (UIColor *) LOT_colorByDarkeningToRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
|
||||
|
||||
- (UIColor *)LOT_colorByMultiplyingBy:(CGFloat)f;
|
||||
- (UIColor *) LOT_colorByAdding:(CGFloat)f;
|
||||
- (UIColor *) LOT_colorByLighteningTo:(CGFloat)f;
|
||||
- (UIColor *) LOT_colorByDarkeningTo:(CGFloat)f;
|
||||
|
||||
- (UIColor *)LOT_colorByMultiplyingByColor:(UIColor *)color;
|
||||
- (UIColor *) LOT_colorByAddingColor:(UIColor *)color;
|
||||
- (UIColor *) LOT_colorByLighteningToColor:(UIColor *)color;
|
||||
- (UIColor *) LOT_colorByDarkeningToColor:(UIColor *)color;
|
||||
|
||||
- (NSString *)LOT_stringFromColor;
|
||||
- (NSString *)LOT_hexStringValue;
|
||||
|
||||
+ (UIColor *)LOT_randomColor;
|
||||
+ (UIColor *)LOT_colorWithString:(NSString *)stringToConvert;
|
||||
+ (UIColor *)LOT_colorWithRGBHex:(UInt32)hex;
|
||||
+ (UIColor *)LOT_colorWithHexString:(NSString *)stringToConvert;
|
||||
|
||||
+ (UIColor *)LOT_colorWithName:(NSString *)cssColorName;
|
||||
|
||||
+ (UIColor *)LOT_colorByLerpingFromColor:(UIColor *)fromColor toColor:(UIColor *)toColor amount:(CGFloat)amount;
|
||||
|
||||
@end
|
@ -31,7 +31,7 @@
|
||||
};
|
||||
*/
|
||||
|
||||
// Static cache of looked up color names. Used with +colorWithName:
|
||||
// Static cache of looked up color names. Used with +LOT_colorWithName:
|
||||
static NSMutableDictionary *colorNameCache = nil;
|
||||
|
||||
@interface UIColor (UIColor_Expanded_Support)
|
||||
@ -46,7 +46,7 @@ static NSMutableDictionary *colorNameCache = nil;
|
||||
return CGColorSpaceGetModel(CGColorGetColorSpace(self.CGColor));
|
||||
}
|
||||
|
||||
- (NSString *)colorSpaceString {
|
||||
- (NSString *)LOT_colorSpaceString {
|
||||
switch (self.colorSpaceModel) {
|
||||
case kCGColorSpaceModelUnknown:
|
||||
return @"kCGColorSpaceModelUnknown";
|
||||
@ -79,11 +79,11 @@ static NSMutableDictionary *colorNameCache = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)arrayFromRGBAComponents {
|
||||
NSAssert(self.canProvideRGBComponents, @"Must be an RGB color to use -arrayFromRGBAComponents");
|
||||
- (NSArray *)LOT_arrayFromRGBAComponents {
|
||||
NSAssert(self.canProvideRGBComponents, @"Must be an RGB color to use -LOT_arrayFromRGBAComponents");
|
||||
|
||||
CGFloat r,g,b,a;
|
||||
if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
if (![self LOT_red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
|
||||
return [NSArray arrayWithObjects:
|
||||
[NSNumber numberWithFloat:r],
|
||||
@ -93,7 +93,7 @@ static NSMutableDictionary *colorNameCache = nil;
|
||||
nil];
|
||||
}
|
||||
|
||||
- (BOOL)red:(CGFloat *)red green:(CGFloat *)green blue:(CGFloat *)blue alpha:(CGFloat *)alpha {
|
||||
- (BOOL)LOT_red:(CGFloat *)red green:(CGFloat *)green blue:(CGFloat *)blue alpha:(CGFloat *)alpha {
|
||||
const CGFloat *components = CGColorGetComponents(self.CGColor);
|
||||
|
||||
CGFloat r,g,b,a;
|
||||
@ -155,7 +155,7 @@ static NSMutableDictionary *colorNameCache = nil;
|
||||
NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use rgbHex");
|
||||
|
||||
CGFloat r,g,b,a;
|
||||
if (![self red:&r green:&g blue:&b alpha:&a]) return 0;
|
||||
if (![self LOT_red:&r green:&g blue:&b alpha:&a]) return 0;
|
||||
|
||||
r = MIN(MAX(self.red, 0.0f), 1.0f);
|
||||
g = MIN(MAX(self.green, 0.0f), 1.0f);
|
||||
@ -168,11 +168,11 @@ static NSMutableDictionary *colorNameCache = nil;
|
||||
|
||||
#pragma mark Arithmetic operations
|
||||
|
||||
- (UIColor *)colorByLuminanceMapping {
|
||||
- (UIColor *)LOT_colorByLuminanceMapping {
|
||||
NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
|
||||
|
||||
CGFloat r,g,b,a;
|
||||
if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
if (![self LOT_red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
|
||||
// http://en.wikipedia.org/wiki/Luma_(video)
|
||||
// Y = 0.2126 R + 0.7152 G + 0.0722 B
|
||||
@ -181,11 +181,11 @@ static NSMutableDictionary *colorNameCache = nil;
|
||||
|
||||
}
|
||||
|
||||
- (UIColor *)colorByMultiplyingByRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha {
|
||||
- (UIColor *)LOT_colorByMultiplyingByRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha {
|
||||
NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
|
||||
|
||||
CGFloat r,g,b,a;
|
||||
if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
if (![self LOT_red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
|
||||
return [UIColor colorWithRed:MAX(0.0, MIN(1.0, r * red))
|
||||
green:MAX(0.0, MIN(1.0, g * green))
|
||||
@ -193,11 +193,11 @@ static NSMutableDictionary *colorNameCache = nil;
|
||||
alpha:MAX(0.0, MIN(1.0, a * alpha))];
|
||||
}
|
||||
|
||||
- (UIColor *)colorByAddingRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha {
|
||||
- (UIColor *)LOT_colorByAddingRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha {
|
||||
NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
|
||||
|
||||
CGFloat r,g,b,a;
|
||||
if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
if (![self LOT_red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
|
||||
return [UIColor colorWithRed:MAX(0.0, MIN(1.0, r + red))
|
||||
green:MAX(0.0, MIN(1.0, g + green))
|
||||
@ -205,11 +205,11 @@ static NSMutableDictionary *colorNameCache = nil;
|
||||
alpha:MAX(0.0, MIN(1.0, a + alpha))];
|
||||
}
|
||||
|
||||
- (UIColor *)colorByLighteningToRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha {
|
||||
- (UIColor *)LOT_colorByLighteningToRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha {
|
||||
NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
|
||||
|
||||
CGFloat r,g,b,a;
|
||||
if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
if (![self LOT_red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
|
||||
return [UIColor colorWithRed:MAX(r, red)
|
||||
green:MAX(g, green)
|
||||
@ -217,11 +217,11 @@ static NSMutableDictionary *colorNameCache = nil;
|
||||
alpha:MAX(a, alpha)];
|
||||
}
|
||||
|
||||
- (UIColor *)colorByDarkeningToRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha {
|
||||
- (UIColor *)LOT_colorByDarkeningToRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha {
|
||||
NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
|
||||
|
||||
CGFloat r,g,b,a;
|
||||
if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
if (![self LOT_red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
|
||||
return [UIColor colorWithRed:MIN(r, red)
|
||||
green:MIN(g, green)
|
||||
@ -229,62 +229,62 @@ static NSMutableDictionary *colorNameCache = nil;
|
||||
alpha:MIN(a, alpha)];
|
||||
}
|
||||
|
||||
- (UIColor *)colorByMultiplyingBy:(CGFloat)f {
|
||||
return [self colorByMultiplyingByRed:f green:f blue:f alpha:1.0f];
|
||||
- (UIColor *)LOT_colorByMultiplyingBy:(CGFloat)f {
|
||||
return [self LOT_colorByMultiplyingByRed:f green:f blue:f alpha:1.0f];
|
||||
}
|
||||
|
||||
- (UIColor *)colorByAdding:(CGFloat)f {
|
||||
return [self colorByMultiplyingByRed:f green:f blue:f alpha:0.0f];
|
||||
- (UIColor *)LOT_colorByAdding:(CGFloat)f {
|
||||
return [self LOT_colorByMultiplyingByRed:f green:f blue:f alpha:0.0f];
|
||||
}
|
||||
|
||||
- (UIColor *)colorByLighteningTo:(CGFloat)f {
|
||||
return [self colorByLighteningToRed:f green:f blue:f alpha:0.0f];
|
||||
- (UIColor *)LOT_colorByLighteningTo:(CGFloat)f {
|
||||
return [self LOT_colorByLighteningToRed:f green:f blue:f alpha:0.0f];
|
||||
}
|
||||
|
||||
- (UIColor *)colorByDarkeningTo:(CGFloat)f {
|
||||
return [self colorByDarkeningToRed:f green:f blue:f alpha:1.0f];
|
||||
- (UIColor *)LOT_colorByDarkeningTo:(CGFloat)f {
|
||||
return [self LOT_colorByDarkeningToRed:f green:f blue:f alpha:1.0f];
|
||||
}
|
||||
|
||||
- (UIColor *)colorByMultiplyingByColor:(UIColor *)color {
|
||||
- (UIColor *)LOT_colorByMultiplyingByColor:(UIColor *)color {
|
||||
NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
|
||||
|
||||
CGFloat r,g,b,a;
|
||||
if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
if (![self LOT_red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
|
||||
return [self colorByMultiplyingByRed:r green:g blue:b alpha:1.0f];
|
||||
return [self LOT_colorByMultiplyingByRed:r green:g blue:b alpha:1.0f];
|
||||
}
|
||||
|
||||
- (UIColor *)colorByAddingColor:(UIColor *)color {
|
||||
- (UIColor *)LOT_colorByAddingColor:(UIColor *)color {
|
||||
NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
|
||||
|
||||
CGFloat r,g,b,a;
|
||||
if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
if (![self LOT_red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
|
||||
return [self colorByAddingRed:r green:g blue:b alpha:0.0f];
|
||||
return [self LOT_colorByAddingRed:r green:g blue:b alpha:0.0f];
|
||||
}
|
||||
|
||||
- (UIColor *)colorByLighteningToColor:(UIColor *)color {
|
||||
- (UIColor *)LOT_colorByLighteningToColor:(UIColor *)color {
|
||||
NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
|
||||
|
||||
CGFloat r,g,b,a;
|
||||
if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
if (![self LOT_red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
|
||||
return [self colorByLighteningToRed:r green:g blue:b alpha:0.0f];
|
||||
return [self LOT_colorByLighteningToRed:r green:g blue:b alpha:0.0f];
|
||||
}
|
||||
|
||||
- (UIColor *)colorByDarkeningToColor:(UIColor *)color {
|
||||
- (UIColor *)LOT_colorByDarkeningToColor:(UIColor *)color {
|
||||
NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
|
||||
|
||||
CGFloat r,g,b,a;
|
||||
if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
if (![self LOT_red:&r green:&g blue:&b alpha:&a]) return nil;
|
||||
|
||||
return [self colorByDarkeningToRed:r green:g blue:b alpha:1.0f];
|
||||
return [self LOT_colorByDarkeningToRed:r green:g blue:b alpha:1.0f];
|
||||
}
|
||||
|
||||
#pragma mark String utilities
|
||||
|
||||
- (NSString *)stringFromColor {
|
||||
NSAssert(self.canProvideRGBComponents, @"Must be an RGB color to use -stringFromColor");
|
||||
- (NSString *)LOT_stringFromColor {
|
||||
NSAssert(self.canProvideRGBComponents, @"Must be an RGB color to use -LOT_stringFromColor");
|
||||
NSString *result;
|
||||
switch (self.colorSpaceModel) {
|
||||
case kCGColorSpaceModelRGB:
|
||||
@ -299,11 +299,11 @@ static NSMutableDictionary *colorNameCache = nil;
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSString *)hexStringValue {
|
||||
- (NSString *)LOT_hexStringValue {
|
||||
return [NSString stringWithFormat:@"%0.6X", (unsigned int)self.rgbHex];
|
||||
}
|
||||
|
||||
+ (UIColor *)colorWithString:(NSString *)stringToConvert {
|
||||
+ (UIColor *)LOT_colorWithString:(NSString *)stringToConvert {
|
||||
NSScanner *scanner = [NSScanner scannerWithString:stringToConvert];
|
||||
if (![scanner scanString:@"{" intoString:NULL]) return nil;
|
||||
const NSUInteger kMaxComponents = 4;
|
||||
@ -338,14 +338,14 @@ static NSMutableDictionary *colorNameCache = nil;
|
||||
|
||||
#pragma mark Class methods
|
||||
|
||||
+ (UIColor *)randomColor {
|
||||
+ (UIColor *)LOT_randomColor {
|
||||
return [UIColor colorWithRed:(CGFloat)random() / (CGFloat)RAND_MAX
|
||||
green:(CGFloat)random() / (CGFloat)RAND_MAX
|
||||
blue:(CGFloat)random() / (CGFloat)RAND_MAX
|
||||
alpha:1.0f];
|
||||
}
|
||||
|
||||
+ (UIColor *)colorWithRGBHex:(UInt32)hex {
|
||||
+ (UIColor *)LOT_colorWithRGBHex:(UInt32)hex {
|
||||
int r = (hex >> 16) & 0xFF;
|
||||
int g = (hex >> 8) & 0xFF;
|
||||
int b = (hex) & 0xFF;
|
||||
@ -356,18 +356,18 @@ static NSMutableDictionary *colorNameCache = nil;
|
||||
alpha:1.0f];
|
||||
}
|
||||
|
||||
// Returns a UIColor by scanning the string for a hex number and passing that to +[UIColor colorWithRGBHex:]
|
||||
// Returns a UIColor by scanning the string for a hex number and passing that to +[UIColor LOT_colorWithRGBHex:]
|
||||
// Skips any leading whitespace and ignores any trailing characters
|
||||
+ (UIColor *)colorWithHexString:(NSString *)stringToConvert {
|
||||
+ (UIColor *)LOT_colorWithHexString:(NSString *)stringToConvert {
|
||||
NSString *strippedString = [stringToConvert stringByReplacingOccurrencesOfString:@"#" withString:@""];
|
||||
NSScanner *scanner = [NSScanner scannerWithString:strippedString];
|
||||
unsigned hexNum;
|
||||
if (![scanner scanHexInt:&hexNum]) return nil;
|
||||
return [UIColor colorWithRGBHex:hexNum];
|
||||
return [UIColor LOT_colorWithRGBHex:hexNum];
|
||||
}
|
||||
|
||||
// Lookup a color using css 3/svg color name
|
||||
+ (UIColor *)colorWithName:(NSString *)cssColorName {
|
||||
+ (UIColor *)LOT_colorWithName:(NSString *)cssColorName {
|
||||
UIColor *color;
|
||||
@synchronized(colorNameCache) {
|
||||
// Look for the color in the cache
|
||||
@ -389,7 +389,7 @@ static NSMutableDictionary *colorNameCache = nil;
|
||||
return color;
|
||||
}
|
||||
|
||||
+ (UIColor *)colorByLerpingFromColor:(UIColor *)fromColor toColor:(UIColor *)toColor amount:(CGFloat)amount {
|
||||
+ (UIColor *)LOT_colorByLerpingFromColor:(UIColor *)fromColor toColor:(UIColor *)toColor amount:(CGFloat)amount {
|
||||
NSAssert((toColor != nil && fromColor != nil), @"Passing Nil Color");
|
||||
amount = CLAMP(amount, 0.f, 1.f);
|
||||
const CGFloat *fromComponents = CGColorGetComponents(fromColor.CGColor);
|
||||
@ -474,7 +474,7 @@ static const char *colorNameDB = ","
|
||||
const char *after = found + strlen(searchString);
|
||||
int hex;
|
||||
if (sscanf(after, "%x", &hex) == 1) {
|
||||
result = [self colorWithRGBHex:hex];
|
||||
result = [self LOT_colorWithRGBHex:hex];
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
//
|
||||
// LAAnimationCache.h
|
||||
// Lottie
|
||||
//
|
||||
// Created by Brandon Withrow on 1/9/17.
|
||||
// Copyright © 2017 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class LAComposition;
|
||||
|
||||
@interface LAAnimationCache : NSObject
|
||||
|
||||
+ (instancetype)sharedCache;
|
||||
|
||||
- (void)addAnimation:(LAComposition *)animation forKey:(NSString *)key;
|
||||
- (LAComposition *)animationForKey:(NSString *)key;
|
||||
|
||||
@end
|
@ -1,21 +0,0 @@
|
||||
//
|
||||
// LAEllipseShapeLayer.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/26/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAAnimatableLayer.h"
|
||||
#import "LAModels.h"
|
||||
|
||||
@interface LAEllipseShapeLayer : LAAnimatableLayer
|
||||
|
||||
- (instancetype)initWithEllipseShape:(LAShapeCircle *)circleShape
|
||||
fill:(LAShapeFill *)fill
|
||||
stroke:(LAShapeStroke *)stroke
|
||||
trim:(LAShapeTrimPath *)trim
|
||||
transform:(LAShapeTransform *)transform
|
||||
withDuration:(NSTimeInterval)duration;
|
||||
|
||||
@end
|
@ -1,31 +0,0 @@
|
||||
//
|
||||
// LAGroupLayerView.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/14/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import "LAAnimatableLayer.h"
|
||||
|
||||
@class LAShapeGroup;
|
||||
@class LAShapeTransform;
|
||||
@class LAShapeFill;
|
||||
@class LAShapeStroke;
|
||||
@class LAShapeTrimPath;
|
||||
|
||||
@interface LAGroupLayerView : LAAnimatableLayer
|
||||
|
||||
- (instancetype)initWithShapeGroup:(LAShapeGroup *)shapeGroup
|
||||
transform:(LAShapeTransform *)previousTransform
|
||||
fill:(LAShapeFill *)previousFill
|
||||
stroke:(LAShapeStroke *)previousStroke
|
||||
trimPath:(LAShapeTrimPath *)previousTrimPath
|
||||
withDuration:(NSTimeInterval)duration;
|
||||
|
||||
@property (nonatomic, readonly) LAShapeGroup *shapeGroup;
|
||||
@property (nonatomic, readonly) LAShapeTransform *shapeTransform;
|
||||
@property (nonatomic, assign) BOOL debugModeOn;
|
||||
|
||||
@end
|
@ -1,74 +0,0 @@
|
||||
//
|
||||
// LALayer.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/14/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "LAPlatformCompat.h"
|
||||
|
||||
@class LAShapeGroup;
|
||||
@class LAMask;
|
||||
@class LAAnimatableColorValue;
|
||||
@class LAAnimatablePointValue;
|
||||
@class LAAnimatableNumberValue;
|
||||
@class LAAnimatableScaleValue;
|
||||
@class LAComposition;
|
||||
|
||||
typedef enum : NSInteger {
|
||||
LALayerTypeNone,
|
||||
LALayerTypeSolid,
|
||||
LALayerTypeUnknown,
|
||||
LALayerTypeNull,
|
||||
LALayerTypeShape
|
||||
} LALayerType;
|
||||
|
||||
typedef enum : NSInteger {
|
||||
LAMatteTypeNone,
|
||||
LAMatteTypeAdd,
|
||||
LAMatteTypeInvert,
|
||||
LALayerTypeUknown
|
||||
} LAMatteType;
|
||||
|
||||
@interface LALayer : NSObject
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary fromComposition:(LAComposition *)composition;
|
||||
|
||||
@property (nonatomic, readonly) NSString *layerName;
|
||||
@property (nonatomic, readonly) NSNumber *layerID;
|
||||
@property (nonatomic, readonly) LALayerType layerType;
|
||||
@property (nonatomic, readonly) NSNumber *parentID;
|
||||
@property (nonatomic, readonly) NSNumber *inFrame;
|
||||
@property (nonatomic, readonly) NSNumber *outFrame;
|
||||
@property (nonatomic, readonly) CGRect compBounds;
|
||||
@property (nonatomic, readonly) NSNumber *framerate;
|
||||
|
||||
@property (nonatomic, readonly) NSArray<LAShapeGroup *> *shapes;
|
||||
@property (nonatomic, readonly) NSArray<LAMask *> *masks;
|
||||
|
||||
@property (nonatomic, readonly) NSNumber *solidWidth;
|
||||
@property (nonatomic, readonly) NSNumber *solidHeight;
|
||||
@property (nonatomic, readonly) UIColor *solidColor;
|
||||
|
||||
@property (nonatomic, readonly) LAAnimatableNumberValue *opacity;
|
||||
@property (nonatomic, readonly) LAAnimatableNumberValue *rotation;
|
||||
@property (nonatomic, readonly) LAAnimatablePointValue *position;
|
||||
|
||||
@property (nonatomic, readonly) LAAnimatableNumberValue *positionX;
|
||||
@property (nonatomic, readonly) LAAnimatableNumberValue *positionY;
|
||||
|
||||
@property (nonatomic, readonly) LAAnimatablePointValue *anchor;
|
||||
@property (nonatomic, readonly) LAAnimatableScaleValue *scale;
|
||||
|
||||
@property (nonatomic, readonly) BOOL hasOutAnimation;
|
||||
@property (nonatomic, readonly) BOOL hasInAnimation;
|
||||
@property (nonatomic, readonly) BOOL hasInOutAnimation;
|
||||
@property (nonatomic, readonly) NSArray *inOutKeyframes;
|
||||
@property (nonatomic, readonly) NSArray *inOutKeyTimes;
|
||||
@property (nonatomic, readonly) NSTimeInterval compDuration;
|
||||
|
||||
@property (nonatomic, readonly) LAMatteType matteType;
|
||||
|
||||
@end
|
@ -1,21 +0,0 @@
|
||||
//
|
||||
// LALayerView.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/14/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAPlatformCompat.h"
|
||||
#import "LAAnimatableLayer.h"
|
||||
|
||||
#import "LAModels.h"
|
||||
|
||||
@interface LALayerView : LAAnimatableLayer
|
||||
|
||||
- (instancetype)initWithModel:(LALayer *)model inComposition:(LAComposition *)comp;
|
||||
|
||||
@property (nonatomic, readonly) LALayer *layerModel;
|
||||
@property (nonatomic, assign) BOOL debugModeOn;
|
||||
|
||||
@end
|
@ -1,30 +0,0 @@
|
||||
//
|
||||
// LAMask.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/14/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@class LAAnimatableShapeValue;
|
||||
@class LAAnimatableNumberValue;
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
LAMaskModeAdd,
|
||||
LAMaskModeSubtract,
|
||||
LAMaskModeIntersect,
|
||||
LAMaskModeUnknown
|
||||
} LAMaskMode;
|
||||
|
||||
@interface LAMask : NSObject
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate;
|
||||
|
||||
@property (nonatomic, readonly) BOOL closed;
|
||||
@property (nonatomic, readonly) BOOL inverted;
|
||||
@property (nonatomic, readonly) LAMaskMode maskMode;
|
||||
@property (nonatomic, readonly) LAAnimatableShapeValue *maskPath;
|
||||
@property (nonatomic, readonly) LAAnimatableNumberValue *opacity;
|
||||
|
||||
@end
|
@ -1,19 +0,0 @@
|
||||
//
|
||||
// LAMaskLayer.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/22/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAAnimatableLayer.h"
|
||||
#import "LAModels.h"
|
||||
|
||||
@interface LAMaskLayer : LAAnimatableLayer
|
||||
|
||||
- (instancetype)initWithMasks:(NSArray<LAMask *> *)masks inComposition:(LAComposition *)comp;
|
||||
|
||||
@property (nonatomic, readonly) NSArray<LAMask *> *masks;
|
||||
|
||||
|
||||
@end
|
@ -1,32 +0,0 @@
|
||||
//
|
||||
// LAModels.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef LAModels_h
|
||||
#define LAModels_h
|
||||
|
||||
#import "CAAnimationGroup+LAAnimatableGroup.h"
|
||||
#import "LAAnimatableBoundsValue.h"
|
||||
#import "LAAnimatableColorValue.h"
|
||||
#import "LAAnimatableNumberValue.h"
|
||||
#import "LAAnimatablePointValue.h"
|
||||
#import "LAAnimatableScaleValue.h"
|
||||
#import "LAAnimatableShapeValue.h"
|
||||
#import "LAAnimatableValue.h"
|
||||
#import "LAComposition.h"
|
||||
#import "LALayer.h"
|
||||
#import "LAMask.h"
|
||||
#import "LAShapeCircle.h"
|
||||
#import "LAShapeFill.h"
|
||||
#import "LAShapeGroup.h"
|
||||
#import "LAShapePath.h"
|
||||
#import "LAShapeRectangle.h"
|
||||
#import "LAShapeStroke.h"
|
||||
#import "LAShapeTransform.h"
|
||||
#import "LAShapeTrimPath.h"
|
||||
|
||||
#endif /* LAModels_h */
|
@ -1,21 +0,0 @@
|
||||
//
|
||||
// LARectShapeLayer.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/20/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import "LAModels.h"
|
||||
#import "LAAnimatableLayer.h"
|
||||
|
||||
@interface LARectShapeLayer : LAAnimatableLayer
|
||||
|
||||
- (instancetype)initWithRectShape:(LAShapeRectangle *)rectShape
|
||||
fill:(LAShapeFill *)fill
|
||||
stroke:(LAShapeStroke *)stroke
|
||||
transform:(LAShapeTransform *)transform
|
||||
withDuration:(NSTimeInterval)duration;
|
||||
|
||||
@end
|
@ -1,21 +0,0 @@
|
||||
//
|
||||
// LAShapeLayerView.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 7/13/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAAnimatableLayer.h"
|
||||
#import "LAModels.h"
|
||||
|
||||
@interface LAShapeLayerView : LAAnimatableLayer
|
||||
|
||||
- (instancetype)initWithShape:(LAShapePath *)shape
|
||||
fill:(LAShapeFill *)fill
|
||||
stroke:(LAShapeStroke *)stroke
|
||||
trim:(LAShapeTrimPath *)trim
|
||||
transform:(LAShapeTransform *)transform
|
||||
withDuration:(NSTimeInterval)duration;
|
||||
|
||||
@end
|
@ -1,22 +0,0 @@
|
||||
//
|
||||
// LAShapeRectangle.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@class LAAnimatableBoundsValue;
|
||||
@class LAAnimatablePointValue;
|
||||
@class LAAnimatableNumberValue;
|
||||
|
||||
@interface LAShapeRectangle : NSObject
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate;
|
||||
|
||||
@property (nonatomic, readonly) LAAnimatablePointValue *position;
|
||||
@property (nonatomic, readonly) LAAnimatablePointValue *size;
|
||||
@property (nonatomic, readonly) LAAnimatableNumberValue *cornerRadius;
|
||||
|
||||
@end
|
@ -1,39 +0,0 @@
|
||||
//
|
||||
// LAShapeStroke.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class LAAnimatableColorValue;
|
||||
@class LAAnimatableNumberValue;
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
LALineCapTypeButt,
|
||||
LALineCapTypeRound,
|
||||
LALineCapTypeUnknown
|
||||
} LALineCapType;
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
LALineJoinTypeMiter,
|
||||
LALineJoinTypeRound,
|
||||
LALineJoinTypeBevel
|
||||
} LALineJoinType;
|
||||
|
||||
@interface LAShapeStroke : NSObject
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate;
|
||||
|
||||
@property (nonatomic, readonly) BOOL fillEnabled;
|
||||
@property (nonatomic, readonly) LAAnimatableColorValue *color;
|
||||
@property (nonatomic, readonly) LAAnimatableNumberValue *opacity;
|
||||
@property (nonatomic, readonly) LAAnimatableNumberValue *width;
|
||||
@property (nonatomic, readonly) LALineCapType capType;
|
||||
@property (nonatomic, readonly) LALineJoinType joinType;
|
||||
|
||||
@property (nonatomic, readonly) NSArray *lineDashPattern;
|
||||
|
||||
@end
|
@ -1,29 +0,0 @@
|
||||
//
|
||||
// LAShapeTransform.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
|
||||
@class LAAnimatableNumberValue;
|
||||
@class LAAnimatablePointValue;
|
||||
@class LAAnimatableScaleValue;
|
||||
|
||||
@interface LAShapeTransform : NSObject
|
||||
|
||||
+ (instancetype)transformIdentityWithCompBounds:(CGRect)compBounds;
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate compBounds:(CGRect)compBounds;
|
||||
|
||||
@property (nonatomic, readonly) CGRect compBounds;
|
||||
@property (nonatomic, readonly) LAAnimatablePointValue *position;
|
||||
@property (nonatomic, readonly) LAAnimatablePointValue *anchor;
|
||||
@property (nonatomic, readonly) LAAnimatableScaleValue *scale;
|
||||
@property (nonatomic, readonly) LAAnimatableNumberValue *rotation;
|
||||
@property (nonatomic, readonly) LAAnimatableNumberValue *opacity;
|
||||
|
||||
@end
|
@ -1,19 +0,0 @@
|
||||
//
|
||||
// LAShapeTrimPath.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/26/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@class LAAnimatableNumberValue;
|
||||
|
||||
@interface LAShapeTrimPath : NSObject
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate;
|
||||
|
||||
@property (nonatomic, readonly) LAAnimatableNumberValue *start;
|
||||
@property (nonatomic, readonly) LAAnimatableNumberValue *end;
|
||||
@property (nonatomic, readonly) LAAnimatableNumberValue *offset;
|
||||
@end
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LAScene.h
|
||||
// LOTScene.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/14/15.
|
||||
@ -9,19 +9,19 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
|
||||
@class LALayer;
|
||||
@class LOTLayer;
|
||||
|
||||
@interface LAComposition : NSObject
|
||||
@interface LOTComposition : NSObject
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary;
|
||||
|
||||
@property (nonatomic, readonly) NSArray <LALayer *> *layers;
|
||||
@property (nonatomic, readonly) NSArray <LOTLayer *> *layers;
|
||||
@property (nonatomic, readonly) CGRect compBounds;
|
||||
@property (nonatomic, readonly) NSNumber *startFrame;
|
||||
@property (nonatomic, readonly) NSNumber *endFrame;
|
||||
@property (nonatomic, readonly) NSNumber *framerate;
|
||||
@property (nonatomic, readonly) NSTimeInterval timeDuration;
|
||||
|
||||
- (LALayer *)layerModelForID:(NSNumber *)layerID;
|
||||
- (LOTLayer *)layerModelForID:(NSNumber *)layerID;
|
||||
|
||||
@end
|
@ -1,15 +1,15 @@
|
||||
//
|
||||
// LAScene.m
|
||||
// LOTScene.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/14/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAComposition.h"
|
||||
#import "LALayer.h"
|
||||
#import "LOTComposition.h"
|
||||
#import "LOTLayer.h"
|
||||
|
||||
@implementation LAComposition {
|
||||
@implementation LOTComposition {
|
||||
NSDictionary *_modelMap;
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
NSMutableDictionary *modelMap = [NSMutableDictionary dictionary];
|
||||
|
||||
for (NSDictionary *layerJSON in layersJSON) {
|
||||
LALayer *layer = [[LALayer alloc] initWithJSON:layerJSON fromComposition:self];
|
||||
LOTLayer *layer = [[LOTLayer alloc] initWithJSON:layerJSON fromComposition:self];
|
||||
[layers addObject:layer];
|
||||
modelMap[layer.layerID] = layer;
|
||||
}
|
||||
@ -53,7 +53,7 @@
|
||||
_layers = layers;
|
||||
}
|
||||
|
||||
- (LALayer *)layerModelForID:(NSNumber *)layerID {
|
||||
- (LOTLayer *)layerModelForID:(NSNumber *)layerID {
|
||||
return _modelMap[layerID];
|
||||
}
|
||||
|
74
lottie-ios/Classes/Models/LOTLayer.h
Normal file
74
lottie-ios/Classes/Models/LOTLayer.h
Normal file
@ -0,0 +1,74 @@
|
||||
//
|
||||
// LOTLayer.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/14/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "LOTPlatformCompat.h"
|
||||
|
||||
@class LOTShapeGroup;
|
||||
@class LOTMask;
|
||||
@class LOTAnimatableColorValue;
|
||||
@class LOTAnimatablePointValue;
|
||||
@class LOTAnimatableNumberValue;
|
||||
@class LOTAnimatableScaleValue;
|
||||
@class LOTComposition;
|
||||
|
||||
typedef enum : NSInteger {
|
||||
LOTLayerTypeNone,
|
||||
LOTLayerTypeSolid,
|
||||
LOTLayerTypeUnknown,
|
||||
LOTLayerTypeNull,
|
||||
LOTLayerTypeShape
|
||||
} LOTLayerType;
|
||||
|
||||
typedef enum : NSInteger {
|
||||
LOTMatteTypeNone,
|
||||
LOTMatteTypeAdd,
|
||||
LOTMatteTypeInvert,
|
||||
LOTLayerTypeUknown
|
||||
} LOTMatteType;
|
||||
|
||||
@interface LOTLayer : NSObject
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary fromComposition:(LOTComposition *)composition;
|
||||
|
||||
@property (nonatomic, readonly) NSString *layerName;
|
||||
@property (nonatomic, readonly) NSNumber *layerID;
|
||||
@property (nonatomic, readonly) LOTLayerType layerType;
|
||||
@property (nonatomic, readonly) NSNumber *parentID;
|
||||
@property (nonatomic, readonly) NSNumber *inFrame;
|
||||
@property (nonatomic, readonly) NSNumber *outFrame;
|
||||
@property (nonatomic, readonly) CGRect compBounds;
|
||||
@property (nonatomic, readonly) NSNumber *framerate;
|
||||
|
||||
@property (nonatomic, readonly) NSArray<LOTShapeGroup *> *shapes;
|
||||
@property (nonatomic, readonly) NSArray<LOTMask *> *masks;
|
||||
|
||||
@property (nonatomic, readonly) NSNumber *solidWidth;
|
||||
@property (nonatomic, readonly) NSNumber *solidHeight;
|
||||
@property (nonatomic, readonly) UIColor *solidColor;
|
||||
|
||||
@property (nonatomic, readonly) LOTAnimatableNumberValue *opacity;
|
||||
@property (nonatomic, readonly) LOTAnimatableNumberValue *rotation;
|
||||
@property (nonatomic, readonly) LOTAnimatablePointValue *position;
|
||||
|
||||
@property (nonatomic, readonly) LOTAnimatableNumberValue *positionX;
|
||||
@property (nonatomic, readonly) LOTAnimatableNumberValue *positionY;
|
||||
|
||||
@property (nonatomic, readonly) LOTAnimatablePointValue *anchor;
|
||||
@property (nonatomic, readonly) LOTAnimatableScaleValue *scale;
|
||||
|
||||
@property (nonatomic, readonly) BOOL hasOutAnimation;
|
||||
@property (nonatomic, readonly) BOOL hasInAnimation;
|
||||
@property (nonatomic, readonly) BOOL hasInOutAnimation;
|
||||
@property (nonatomic, readonly) NSArray *inOutKeyframes;
|
||||
@property (nonatomic, readonly) NSArray *inOutKeyTimes;
|
||||
@property (nonatomic, readonly) NSTimeInterval compDuration;
|
||||
|
||||
@property (nonatomic, readonly) LOTMatteType matteType;
|
||||
|
||||
@end
|
@ -1,24 +1,24 @@
|
||||
//
|
||||
// LALayer.m
|
||||
// LOTLayer.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/14/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LALayer.h"
|
||||
#import "LAAnimatableColorValue.h"
|
||||
#import "LAAnimatablePointValue.h"
|
||||
#import "LAAnimatableNumberValue.h"
|
||||
#import "LAAnimatableScaleValue.h"
|
||||
#import "LAShapeGroup.h"
|
||||
#import "LAComposition.h"
|
||||
#import "LAHelpers.h"
|
||||
#import "LAMask.h"
|
||||
#import "LOTLayer.h"
|
||||
#import "LOTAnimatableColorValue.h"
|
||||
#import "LOTAnimatablePointValue.h"
|
||||
#import "LOTAnimatableNumberValue.h"
|
||||
#import "LOTAnimatableScaleValue.h"
|
||||
#import "LOTShapeGroup.h"
|
||||
#import "LOTComposition.h"
|
||||
#import "LOTHelpers.h"
|
||||
#import "LOTMask.h"
|
||||
|
||||
@implementation LALayer
|
||||
@implementation LOTLayer
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary fromComposition:(LAComposition *)composition {
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary fromComposition:(LOTComposition *)composition {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
[self _mapFromJSON:jsonDictionary fromComposition:composition];
|
||||
@ -26,35 +26,35 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)_mapFromJSON:(NSDictionary *)jsonDictionary fromComposition:(LAComposition *)composition {
|
||||
- (void)_mapFromJSON:(NSDictionary *)jsonDictionary fromComposition:(LOTComposition *)composition {
|
||||
_layerName = [jsonDictionary[@"nm"] copy];
|
||||
_layerID = [jsonDictionary[@"ind"] copy];
|
||||
_compBounds = composition.compBounds;
|
||||
_framerate = composition.framerate;
|
||||
|
||||
NSNumber *layerType = jsonDictionary[@"ty"];
|
||||
if (layerType.integerValue <= LALayerTypeShape) {
|
||||
if (layerType.integerValue <= LOTLayerTypeShape) {
|
||||
_layerType = layerType.integerValue;
|
||||
} else {
|
||||
_layerType = LALayerTypeUnknown;
|
||||
_layerType = LOTLayerTypeUnknown;
|
||||
}
|
||||
|
||||
_parentID = [jsonDictionary[@"parent"] copy];
|
||||
_inFrame = [jsonDictionary[@"ip"] copy];
|
||||
_outFrame = [jsonDictionary[@"op"] copy];
|
||||
|
||||
if (_layerType == LALayerTypeSolid) {
|
||||
if (_layerType == LOTLayerTypeSolid) {
|
||||
_solidWidth = jsonDictionary[@"sw"];
|
||||
_solidHeight = jsonDictionary[@"sh"];
|
||||
_compBounds = CGRectMake(0, 0, _solidWidth.floatValue, _solidHeight.floatValue);
|
||||
NSString *solidColor = jsonDictionary[@"sc"];
|
||||
_solidColor = [UIColor colorWithHexString:solidColor];
|
||||
_solidColor = [UIColor LOT_colorWithHexString:solidColor];
|
||||
}
|
||||
NSDictionary *ks = jsonDictionary[@"ks"];
|
||||
|
||||
NSDictionary *opacity = ks[@"o"];
|
||||
if (opacity) {
|
||||
_opacity = [[LAAnimatableNumberValue alloc] initWithNumberValues:opacity frameRate:_framerate];
|
||||
_opacity = [[LOTAnimatableNumberValue alloc] initWithNumberValues:opacity frameRate:_framerate];
|
||||
[_opacity remapValuesFromMin:@0 fromMax:@100 toMin:@0 toMax:@1];
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@
|
||||
rotation = ks[@"rz"];
|
||||
}
|
||||
if (rotation) {
|
||||
_rotation = [[LAAnimatableNumberValue alloc] initWithNumberValues:rotation frameRate:_framerate];
|
||||
_rotation = [[LOTAnimatableNumberValue alloc] initWithNumberValues:rotation frameRate:_framerate];
|
||||
[_rotation remapValueWithBlock:^CGFloat(CGFloat inValue) {
|
||||
return DegreesToRadians(inValue);
|
||||
}];
|
||||
@ -72,22 +72,22 @@
|
||||
NSDictionary *position = ks[@"p"];
|
||||
if ([position[@"s"] boolValue]) {
|
||||
// Seperate dimensions
|
||||
_positionX = [[LAAnimatableNumberValue alloc] initWithNumberValues:position[@"x"] frameRate:_framerate];
|
||||
_positionY = [[LAAnimatableNumberValue alloc] initWithNumberValues:position[@"y"] frameRate:_framerate];
|
||||
_positionX = [[LOTAnimatableNumberValue alloc] initWithNumberValues:position[@"x"] frameRate:_framerate];
|
||||
_positionY = [[LOTAnimatableNumberValue alloc] initWithNumberValues:position[@"y"] frameRate:_framerate];
|
||||
} else {
|
||||
_position = [[LAAnimatablePointValue alloc] initWithPointValues:position frameRate:_framerate];
|
||||
_position = [[LOTAnimatablePointValue alloc] initWithPointValues:position frameRate:_framerate];
|
||||
}
|
||||
|
||||
NSDictionary *anchor = ks[@"a"];
|
||||
if (anchor) {
|
||||
_anchor = [[LAAnimatablePointValue alloc] initWithPointValues:anchor frameRate:_framerate];
|
||||
_anchor = [[LOTAnimatablePointValue alloc] initWithPointValues:anchor frameRate:_framerate];
|
||||
[_anchor remapPointsFromBounds:_compBounds toBounds:CGRectMake(0, 0, 1, 1)];
|
||||
_anchor.usePathAnimation = NO;
|
||||
}
|
||||
|
||||
NSDictionary *scale = ks[@"s"];
|
||||
if (scale) {
|
||||
_scale = [[LAAnimatableScaleValue alloc] initWithScaleValues:scale frameRate:_framerate];
|
||||
_scale = [[LOTAnimatableScaleValue alloc] initWithScaleValues:scale frameRate:_framerate];
|
||||
}
|
||||
|
||||
_matteType = [jsonDictionary[@"tt"] integerValue];
|
||||
@ -95,14 +95,14 @@
|
||||
|
||||
NSMutableArray *masks = [NSMutableArray array];
|
||||
for (NSDictionary *maskJSON in jsonDictionary[@"masksProperties"]) {
|
||||
LAMask *mask = [[LAMask alloc] initWithJSON:maskJSON frameRate:_framerate];
|
||||
LOTMask *mask = [[LOTMask alloc] initWithJSON:maskJSON frameRate:_framerate];
|
||||
[masks addObject:mask];
|
||||
}
|
||||
_masks = masks.count ? masks : nil;
|
||||
|
||||
NSMutableArray *shapes = [NSMutableArray array];
|
||||
for (NSDictionary *shapeJSON in jsonDictionary[@"shapes"]) {
|
||||
id shapeItem = [LAShapeGroup shapeItemWithJSON:shapeJSON frameRate:_framerate compBounds:_compBounds];
|
||||
id shapeItem = [LOTShapeGroup shapeItemWithJSON:shapeJSON frameRate:_framerate compBounds:_compBounds];
|
||||
if (shapeItem) {
|
||||
[shapes addObject:shapeItem];
|
||||
}
|
30
lottie-ios/Classes/Models/LOTMask.h
Normal file
30
lottie-ios/Classes/Models/LOTMask.h
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// LOTMask.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/14/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@class LOTAnimatableShapeValue;
|
||||
@class LOTAnimatableNumberValue;
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
LOTMaskModeAdd,
|
||||
LOTMaskModeSubtract,
|
||||
LOTMaskModeIntersect,
|
||||
LOTMaskModeUnknown
|
||||
} LOTMaskMode;
|
||||
|
||||
@interface LOTMask : NSObject
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate;
|
||||
|
||||
@property (nonatomic, readonly) BOOL closed;
|
||||
@property (nonatomic, readonly) BOOL inverted;
|
||||
@property (nonatomic, readonly) LOTMaskMode maskMode;
|
||||
@property (nonatomic, readonly) LOTAnimatableShapeValue *maskPath;
|
||||
@property (nonatomic, readonly) LOTAnimatableNumberValue *opacity;
|
||||
|
||||
@end
|
@ -1,16 +1,16 @@
|
||||
//
|
||||
// LAMask.m
|
||||
// LOTMask.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/14/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAMask.h"
|
||||
#import "LAAnimatableShapeValue.h"
|
||||
#import "LAAnimatableNumberValue.h"
|
||||
#import "LOTMask.h"
|
||||
#import "LOTAnimatableShapeValue.h"
|
||||
#import "LOTAnimatableNumberValue.h"
|
||||
|
||||
@implementation LAMask
|
||||
@implementation LOTMask
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate {
|
||||
self = [super init];
|
||||
@ -29,23 +29,23 @@
|
||||
|
||||
NSString *mode = jsonDictionary[@"mode"];
|
||||
if ([mode isEqualToString:@"a"]) {
|
||||
_maskMode = LAMaskModeAdd;
|
||||
_maskMode = LOTMaskModeAdd;
|
||||
} else if ([mode isEqualToString:@"s"]) {
|
||||
_maskMode = LAMaskModeSubtract;
|
||||
_maskMode = LOTMaskModeSubtract;
|
||||
} else if ([mode isEqualToString:@"i"]) {
|
||||
_maskMode = LAMaskModeIntersect;
|
||||
_maskMode = LOTMaskModeIntersect;
|
||||
} else {
|
||||
_maskMode = LAMaskModeUnknown;
|
||||
_maskMode = LOTMaskModeUnknown;
|
||||
}
|
||||
|
||||
NSDictionary *maskshape = jsonDictionary[@"pt"];
|
||||
if (maskshape) {
|
||||
_maskPath = [[LAAnimatableShapeValue alloc] initWithShapeValues:maskshape frameRate:frameRate closed:_closed];
|
||||
_maskPath = [[LOTAnimatableShapeValue alloc] initWithShapeValues:maskshape frameRate:frameRate closed:_closed];
|
||||
}
|
||||
|
||||
NSDictionary *opacity = jsonDictionary[@"o"];
|
||||
if (opacity) {
|
||||
_opacity = [[LAAnimatableNumberValue alloc] initWithNumberValues:opacity frameRate:frameRate];
|
||||
_opacity = [[LOTAnimatableNumberValue alloc] initWithNumberValues:opacity frameRate:frameRate];
|
||||
[_opacity remapValuesFromMin:@0 fromMax:@100 toMin:@0 toMax:@1];
|
||||
}
|
||||
}
|
32
lottie-ios/Classes/Models/LOTModels.h
Normal file
32
lottie-ios/Classes/Models/LOTModels.h
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// LOTModels.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef LOTModels_h
|
||||
#define LOTModels_h
|
||||
|
||||
#import "CAAnimationGroup+LOTAnimatableGroup.h"
|
||||
#import "LOTAnimatableBoundsValue.h"
|
||||
#import "LOTAnimatableColorValue.h"
|
||||
#import "LOTAnimatableNumberValue.h"
|
||||
#import "LOTAnimatablePointValue.h"
|
||||
#import "LOTAnimatableScaleValue.h"
|
||||
#import "LOTAnimatableShapeValue.h"
|
||||
#import "LOTAnimatableValue.h"
|
||||
#import "LOTComposition.h"
|
||||
#import "LOTLayer.h"
|
||||
#import "LOTMask.h"
|
||||
#import "LOTShapeCircle.h"
|
||||
#import "LOTShapeFill.h"
|
||||
#import "LOTShapeGroup.h"
|
||||
#import "LOTShapePath.h"
|
||||
#import "LOTShapeRectangle.h"
|
||||
#import "LOTShapeStroke.h"
|
||||
#import "LOTShapeTransform.h"
|
||||
#import "LOTShapeTrimPath.h"
|
||||
|
||||
#endif /* LOTModels_h */
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LAShapeCircle.h
|
||||
// LOTShapeCircle.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
@ -7,14 +7,14 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@class LAAnimatablePointValue;
|
||||
@class LAAnimatableScaleValue;
|
||||
@class LOTAnimatablePointValue;
|
||||
@class LOTAnimatableScaleValue;
|
||||
|
||||
@interface LAShapeCircle : NSObject
|
||||
@interface LOTShapeCircle : NSObject
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate;
|
||||
|
||||
@property (nonatomic, readonly) LAAnimatablePointValue *position;
|
||||
@property (nonatomic, readonly) LAAnimatablePointValue *size;
|
||||
@property (nonatomic, readonly) LOTAnimatablePointValue *position;
|
||||
@property (nonatomic, readonly) LOTAnimatablePointValue *size;
|
||||
|
||||
@end
|
@ -1,16 +1,16 @@
|
||||
//
|
||||
// LAShapeCircle.m
|
||||
// LOTShapeCircle.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAShapeCircle.h"
|
||||
#import "LAAnimatablePointValue.h"
|
||||
#import "LAAnimatableScaleValue.h"
|
||||
#import "LOTShapeCircle.h"
|
||||
#import "LOTAnimatablePointValue.h"
|
||||
#import "LOTAnimatableScaleValue.h"
|
||||
|
||||
@implementation LAShapeCircle
|
||||
@implementation LOTShapeCircle
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate {
|
||||
self = [super init];
|
||||
@ -23,13 +23,13 @@
|
||||
- (void)_mapFromJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate {
|
||||
NSDictionary *position = jsonDictionary[@"p"];
|
||||
if (position) {
|
||||
_position = [[LAAnimatablePointValue alloc] initWithPointValues:position frameRate:frameRate];
|
||||
_position = [[LOTAnimatablePointValue alloc] initWithPointValues:position frameRate:frameRate];
|
||||
_position.usePathAnimation = NO;
|
||||
}
|
||||
|
||||
NSDictionary *size= jsonDictionary[@"s"];
|
||||
if (size) {
|
||||
_size = [[LAAnimatablePointValue alloc] initWithPointValues:size frameRate:frameRate];
|
||||
_size = [[LOTAnimatablePointValue alloc] initWithPointValues:size frameRate:frameRate];
|
||||
_size.usePathAnimation = NO;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LAShapeFill.h
|
||||
// LOTShapeFill.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
@ -8,15 +8,15 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class LAAnimatableColorValue;
|
||||
@class LAAnimatableNumberValue;
|
||||
@class LOTAnimatableColorValue;
|
||||
@class LOTAnimatableNumberValue;
|
||||
|
||||
@interface LAShapeFill : NSObject
|
||||
@interface LOTShapeFill : NSObject
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate;
|
||||
|
||||
@property (nonatomic, readonly) BOOL fillEnabled;
|
||||
@property (nonatomic, readonly) LAAnimatableColorValue *color;
|
||||
@property (nonatomic, readonly) LAAnimatableNumberValue *opacity;
|
||||
@property (nonatomic, readonly) LOTAnimatableColorValue *color;
|
||||
@property (nonatomic, readonly) LOTAnimatableNumberValue *opacity;
|
||||
|
||||
@end
|
@ -1,16 +1,16 @@
|
||||
//
|
||||
// LAShapeFill.m
|
||||
// LOTShapeFill.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAShapeFill.h"
|
||||
#import "LAAnimatableNumberValue.h"
|
||||
#import "LAAnimatableColorValue.h"
|
||||
#import "LOTShapeFill.h"
|
||||
#import "LOTAnimatableNumberValue.h"
|
||||
#import "LOTAnimatableColorValue.h"
|
||||
|
||||
@implementation LAShapeFill
|
||||
@implementation LOTShapeFill
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate {
|
||||
self = [super init];
|
||||
@ -23,12 +23,12 @@
|
||||
- (void)_mapFromJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate {
|
||||
NSDictionary *color = jsonDictionary[@"c"];
|
||||
if (color) {
|
||||
_color = [[LAAnimatableColorValue alloc] initWithColorValues:color frameRate:frameRate];
|
||||
_color = [[LOTAnimatableColorValue alloc] initWithColorValues:color frameRate:frameRate];
|
||||
}
|
||||
|
||||
NSDictionary *opacity = jsonDictionary[@"o"];
|
||||
if (opacity) {
|
||||
_opacity = [[LAAnimatableNumberValue alloc] initWithNumberValues:opacity frameRate:frameRate];
|
||||
_opacity = [[LOTAnimatableNumberValue alloc] initWithNumberValues:opacity frameRate:frameRate];
|
||||
[_opacity remapValuesFromMin:@0 fromMax:@100 toMin:@0 toMax:@1];
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LAShape.h
|
||||
// LOTShape.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/14/15.
|
||||
@ -9,7 +9,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
|
||||
@interface LAShapeGroup : NSObject
|
||||
@interface LOTShapeGroup : NSObject
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate compBounds:(CGRect)compBounds;
|
||||
|
@ -1,21 +1,21 @@
|
||||
//
|
||||
// LAShape.m
|
||||
// LOTShape.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/14/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAShapeGroup.h"
|
||||
#import "LAShapeFill.h"
|
||||
#import "LAShapePath.h"
|
||||
#import "LAShapeCircle.h"
|
||||
#import "LAShapeStroke.h"
|
||||
#import "LAShapeTransform.h"
|
||||
#import "LAShapeRectangle.h"
|
||||
#import "LAShapeTrimPath.h"
|
||||
#import "LOTShapeGroup.h"
|
||||
#import "LOTShapeFill.h"
|
||||
#import "LOTShapePath.h"
|
||||
#import "LOTShapeCircle.h"
|
||||
#import "LOTShapeStroke.h"
|
||||
#import "LOTShapeTransform.h"
|
||||
#import "LOTShapeRectangle.h"
|
||||
#import "LOTShapeTrimPath.h"
|
||||
|
||||
@implementation LAShapeGroup
|
||||
@implementation LOTShapeGroup
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate compBounds:(CGRect)compBounds {
|
||||
self = [super init];
|
||||
@ -29,7 +29,7 @@
|
||||
NSArray *itemsJSON = jsonDictionary[@"it"];
|
||||
NSMutableArray *items = [NSMutableArray array];
|
||||
for (NSDictionary *itemJSON in itemsJSON) {
|
||||
id newItem = [LAShapeGroup shapeItemWithJSON:itemJSON frameRate:frameRate compBounds:compBounds];
|
||||
id newItem = [LOTShapeGroup shapeItemWithJSON:itemJSON frameRate:frameRate compBounds:compBounds];
|
||||
if (newItem) {
|
||||
[items addObject:newItem];
|
||||
}
|
||||
@ -40,28 +40,28 @@
|
||||
+ (id)shapeItemWithJSON:(NSDictionary *)itemJSON frameRate:(NSNumber *)frameRate compBounds:(CGRect)compBounds {
|
||||
NSString *type = itemJSON[@"ty"];
|
||||
if ([type isEqualToString:@"gr"]) {
|
||||
LAShapeGroup *group = [[LAShapeGroup alloc] initWithJSON:itemJSON frameRate:frameRate compBounds:compBounds];
|
||||
LOTShapeGroup *group = [[LOTShapeGroup alloc] initWithJSON:itemJSON frameRate:frameRate compBounds:compBounds];
|
||||
return group;
|
||||
} else if ([type isEqualToString:@"st"]) {
|
||||
LAShapeStroke *stroke = [[LAShapeStroke alloc] initWithJSON:itemJSON frameRate:frameRate];
|
||||
LOTShapeStroke *stroke = [[LOTShapeStroke alloc] initWithJSON:itemJSON frameRate:frameRate];
|
||||
return stroke;
|
||||
} else if ([type isEqualToString:@"fl"]) {
|
||||
LAShapeFill *fill = [[LAShapeFill alloc] initWithJSON:itemJSON frameRate:frameRate];
|
||||
LOTShapeFill *fill = [[LOTShapeFill alloc] initWithJSON:itemJSON frameRate:frameRate];
|
||||
return fill;
|
||||
} else if ([type isEqualToString:@"tr"]) {
|
||||
LAShapeTransform *transform = [[LAShapeTransform alloc] initWithJSON:itemJSON frameRate:frameRate compBounds:compBounds];
|
||||
LOTShapeTransform *transform = [[LOTShapeTransform alloc] initWithJSON:itemJSON frameRate:frameRate compBounds:compBounds];
|
||||
return transform;
|
||||
} else if ([type isEqualToString:@"sh"]) {
|
||||
LAShapePath *path = [[LAShapePath alloc] initWithJSON:itemJSON frameRate:frameRate];
|
||||
LOTShapePath *path = [[LOTShapePath alloc] initWithJSON:itemJSON frameRate:frameRate];
|
||||
return path;
|
||||
} else if ([type isEqualToString:@"el"]) {
|
||||
LAShapeCircle *circle = [[LAShapeCircle alloc] initWithJSON:itemJSON frameRate:frameRate];
|
||||
LOTShapeCircle *circle = [[LOTShapeCircle alloc] initWithJSON:itemJSON frameRate:frameRate];
|
||||
return circle;
|
||||
} else if ([type isEqualToString:@"rc"]) {
|
||||
LAShapeRectangle *rectangle = [[LAShapeRectangle alloc] initWithJSON:itemJSON frameRate:frameRate];
|
||||
LOTShapeRectangle *rectangle = [[LOTShapeRectangle alloc] initWithJSON:itemJSON frameRate:frameRate];
|
||||
return rectangle;
|
||||
} else if ([type isEqualToString:@"tm"]) {
|
||||
LAShapeTrimPath *trim = [[LAShapeTrimPath alloc] initWithJSON:itemJSON frameRate:frameRate];
|
||||
LOTShapeTrimPath *trim = [[LOTShapeTrimPath alloc] initWithJSON:itemJSON frameRate:frameRate];
|
||||
return trim;
|
||||
}
|
||||
return nil;
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LAShapePath.h
|
||||
// LOTShapePath.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
@ -8,14 +8,14 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class LAAnimatableShapeValue;
|
||||
@class LOTAnimatableShapeValue;
|
||||
|
||||
@interface LAShapePath : NSObject
|
||||
@interface LOTShapePath : NSObject
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate;
|
||||
|
||||
@property (nonatomic, readonly) BOOL closed;
|
||||
@property (nonatomic, readonly) NSNumber *index;
|
||||
@property (nonatomic, readonly) LAAnimatableShapeValue *shapePath;
|
||||
@property (nonatomic, readonly) LOTAnimatableShapeValue *shapePath;
|
||||
|
||||
@end
|
@ -1,15 +1,15 @@
|
||||
//
|
||||
// LAShapePath.m
|
||||
// LOTShapePath.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAShapePath.h"
|
||||
#import "LAAnimatableShapeValue.h"
|
||||
#import "LOTShapePath.h"
|
||||
#import "LOTAnimatableShapeValue.h"
|
||||
|
||||
@implementation LAShapePath
|
||||
@implementation LOTShapePath
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate {
|
||||
self = [super init];
|
||||
@ -24,7 +24,7 @@
|
||||
_closed = [jsonDictionary[@"closed"] boolValue];
|
||||
NSDictionary *shape = jsonDictionary[@"ks"];
|
||||
if (shape) {
|
||||
_shapePath = [[LAAnimatableShapeValue alloc] initWithShapeValues:shape frameRate:frameRate closed:_closed];
|
||||
_shapePath = [[LOTAnimatableShapeValue alloc] initWithShapeValues:shape frameRate:frameRate closed:_closed];
|
||||
}
|
||||
}
|
||||
|
22
lottie-ios/Classes/Models/LOTShapeRectangle.h
Normal file
22
lottie-ios/Classes/Models/LOTShapeRectangle.h
Normal file
@ -0,0 +1,22 @@
|
||||
//
|
||||
// LOTShapeRectangle.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@class LOTAnimatableBoundsValue;
|
||||
@class LOTAnimatablePointValue;
|
||||
@class LOTAnimatableNumberValue;
|
||||
|
||||
@interface LOTShapeRectangle : NSObject
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate;
|
||||
|
||||
@property (nonatomic, readonly) LOTAnimatablePointValue *position;
|
||||
@property (nonatomic, readonly) LOTAnimatablePointValue *size;
|
||||
@property (nonatomic, readonly) LOTAnimatableNumberValue *cornerRadius;
|
||||
|
||||
@end
|
@ -1,17 +1,17 @@
|
||||
//
|
||||
// LAShapeRectangle.m
|
||||
// LOTShapeRectangle.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAShapeRectangle.h"
|
||||
#import "LAAnimatableBoundsValue.h"
|
||||
#import "LAAnimatablePointValue.h"
|
||||
#import "LAAnimatableNumberValue.h"
|
||||
#import "LOTShapeRectangle.h"
|
||||
#import "LOTAnimatableBoundsValue.h"
|
||||
#import "LOTAnimatablePointValue.h"
|
||||
#import "LOTAnimatableNumberValue.h"
|
||||
|
||||
@implementation LAShapeRectangle
|
||||
@implementation LOTShapeRectangle
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate {
|
||||
self = [super init];
|
||||
@ -24,18 +24,18 @@
|
||||
- (void)_mapFromJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate {
|
||||
NSDictionary *position = jsonDictionary[@"p"];
|
||||
if (position) {
|
||||
_position = [[LAAnimatablePointValue alloc] initWithPointValues:position frameRate:frameRate];
|
||||
_position = [[LOTAnimatablePointValue alloc] initWithPointValues:position frameRate:frameRate];
|
||||
_position.usePathAnimation = NO;
|
||||
}
|
||||
|
||||
NSDictionary *cornerRadius = jsonDictionary[@"r"];
|
||||
if (cornerRadius) {
|
||||
_cornerRadius = [[LAAnimatableNumberValue alloc] initWithNumberValues:cornerRadius frameRate:frameRate];
|
||||
_cornerRadius = [[LOTAnimatableNumberValue alloc] initWithNumberValues:cornerRadius frameRate:frameRate];
|
||||
}
|
||||
|
||||
NSDictionary *size = jsonDictionary[@"s"];
|
||||
if (size) {
|
||||
_size = [[LAAnimatablePointValue alloc] initWithPointValues:size frameRate:frameRate];
|
||||
_size = [[LOTAnimatablePointValue alloc] initWithPointValues:size frameRate:frameRate];
|
||||
}
|
||||
}
|
||||
|
39
lottie-ios/Classes/Models/LOTShapeStroke.h
Normal file
39
lottie-ios/Classes/Models/LOTShapeStroke.h
Normal file
@ -0,0 +1,39 @@
|
||||
//
|
||||
// LOTShapeStroke.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class LOTAnimatableColorValue;
|
||||
@class LOTAnimatableNumberValue;
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
LOTLineCapTypeButt,
|
||||
LOTLineCapTypeRound,
|
||||
LOTLineCapTypeUnknown
|
||||
} LOTLineCapType;
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
LOTLineJoinTypeMiter,
|
||||
LOTLineJoinTypeRound,
|
||||
LOTLineJoinTypeBevel
|
||||
} LOTLineJoinType;
|
||||
|
||||
@interface LOTShapeStroke : NSObject
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate;
|
||||
|
||||
@property (nonatomic, readonly) BOOL fillEnabled;
|
||||
@property (nonatomic, readonly) LOTAnimatableColorValue *color;
|
||||
@property (nonatomic, readonly) LOTAnimatableNumberValue *opacity;
|
||||
@property (nonatomic, readonly) LOTAnimatableNumberValue *width;
|
||||
@property (nonatomic, readonly) LOTLineCapType capType;
|
||||
@property (nonatomic, readonly) LOTLineJoinType joinType;
|
||||
|
||||
@property (nonatomic, readonly) NSArray *lineDashPattern;
|
||||
|
||||
@end
|
@ -1,16 +1,16 @@
|
||||
//
|
||||
// LAShapeStroke.m
|
||||
// LOTShapeStroke.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAShapeStroke.h"
|
||||
#import "LAAnimatableNumberValue.h"
|
||||
#import "LAAnimatableColorValue.h"
|
||||
#import "LOTShapeStroke.h"
|
||||
#import "LOTAnimatableNumberValue.h"
|
||||
#import "LOTAnimatableColorValue.h"
|
||||
|
||||
@implementation LAShapeStroke
|
||||
@implementation LOTShapeStroke
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate {
|
||||
self = [super init];
|
||||
@ -23,17 +23,17 @@
|
||||
- (void)_mapFromJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate {
|
||||
NSDictionary *color = jsonDictionary[@"c"];
|
||||
if (color) {
|
||||
_color = [[LAAnimatableColorValue alloc] initWithColorValues:color frameRate:frameRate];
|
||||
_color = [[LOTAnimatableColorValue alloc] initWithColorValues:color frameRate:frameRate];
|
||||
}
|
||||
|
||||
NSDictionary *width = jsonDictionary[@"w"];
|
||||
if (width) {
|
||||
_width = [[LAAnimatableNumberValue alloc] initWithNumberValues:width frameRate:frameRate];
|
||||
_width = [[LOTAnimatableNumberValue alloc] initWithNumberValues:width frameRate:frameRate];
|
||||
}
|
||||
|
||||
NSDictionary *opacity = jsonDictionary[@"o"];
|
||||
if (opacity) {
|
||||
_opacity = [[LAAnimatableNumberValue alloc] initWithNumberValues:opacity frameRate:frameRate];
|
||||
_opacity = [[LOTAnimatableNumberValue alloc] initWithNumberValues:opacity frameRate:frameRate];
|
||||
[_opacity remapValuesFromMin:@0 fromMax:@100 toMin:@0 toMax:@1];
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@
|
||||
continue;
|
||||
}
|
||||
NSDictionary *value = dash[@"v"];
|
||||
LAAnimatableNumberValue *numberValue = [[LAAnimatableNumberValue alloc] initWithNumberValues:value frameRate:frameRate];
|
||||
LOTAnimatableNumberValue *numberValue = [[LOTAnimatableNumberValue alloc] initWithNumberValues:value frameRate:frameRate];
|
||||
[dashPattern addObject:[numberValue.initialValue copy]];
|
||||
}
|
||||
_lineDashPattern = dashPattern;
|
29
lottie-ios/Classes/Models/LOTShapeTransform.h
Normal file
29
lottie-ios/Classes/Models/LOTShapeTransform.h
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// LOTShapeTransform.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
|
||||
@class LOTAnimatableNumberValue;
|
||||
@class LOTAnimatablePointValue;
|
||||
@class LOTAnimatableScaleValue;
|
||||
|
||||
@interface LOTShapeTransform : NSObject
|
||||
|
||||
+ (instancetype)transformIdentityWithCompBounds:(CGRect)compBounds;
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate compBounds:(CGRect)compBounds;
|
||||
|
||||
@property (nonatomic, readonly) CGRect compBounds;
|
||||
@property (nonatomic, readonly) LOTAnimatablePointValue *position;
|
||||
@property (nonatomic, readonly) LOTAnimatablePointValue *anchor;
|
||||
@property (nonatomic, readonly) LOTAnimatableScaleValue *scale;
|
||||
@property (nonatomic, readonly) LOTAnimatableNumberValue *rotation;
|
||||
@property (nonatomic, readonly) LOTAnimatableNumberValue *opacity;
|
||||
|
||||
@end
|
@ -1,18 +1,18 @@
|
||||
//
|
||||
// LAShapeTransform.m
|
||||
// LOTShapeTransform.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/15/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAShapeTransform.h"
|
||||
#import "LAAnimatableNumberValue.h"
|
||||
#import "LAAnimatablePointValue.h"
|
||||
#import "LAAnimatableScaleValue.h"
|
||||
#import "LAHelpers.h"
|
||||
#import "LOTShapeTransform.h"
|
||||
#import "LOTAnimatableNumberValue.h"
|
||||
#import "LOTAnimatablePointValue.h"
|
||||
#import "LOTAnimatableScaleValue.h"
|
||||
#import "LOTHelpers.h"
|
||||
|
||||
@implementation LAShapeTransform
|
||||
@implementation LOTShapeTransform
|
||||
|
||||
+ (instancetype)transformIdentityWithCompBounds:(CGRect)compBounds {
|
||||
NSDictionary *transformIdentity = @{@"p" : @{@"k" : @[@0, @0]},
|
||||
@ -22,7 +22,7 @@
|
||||
@"o" : @{@"k" : @[@100]}};
|
||||
|
||||
|
||||
return [[LAShapeTransform alloc] initWithJSON:transformIdentity frameRate:@60 compBounds:compBounds];
|
||||
return [[LOTShapeTransform alloc] initWithJSON:transformIdentity frameRate:@60 compBounds:compBounds];
|
||||
}
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate compBounds:(CGRect)compBounds {
|
||||
@ -38,24 +38,24 @@
|
||||
|
||||
NSDictionary *position = jsonDictionary[@"p"];
|
||||
if (position) {
|
||||
_position = [[LAAnimatablePointValue alloc] initWithPointValues:position frameRate:frameRate];
|
||||
_position = [[LOTAnimatablePointValue alloc] initWithPointValues:position frameRate:frameRate];
|
||||
}
|
||||
|
||||
NSDictionary *anchor = jsonDictionary[@"a"];
|
||||
if (anchor) {
|
||||
_anchor = [[LAAnimatablePointValue alloc] initWithPointValues:anchor frameRate:frameRate];
|
||||
_anchor = [[LOTAnimatablePointValue alloc] initWithPointValues:anchor frameRate:frameRate];
|
||||
[_anchor remapPointsFromBounds:compBounds toBounds:CGRectMake(0, 0, 1, 1)];
|
||||
_anchor.usePathAnimation = NO;
|
||||
}
|
||||
|
||||
NSDictionary *scale = jsonDictionary[@"s"];
|
||||
if (scale) {
|
||||
_scale = [[LAAnimatableScaleValue alloc] initWithScaleValues:scale frameRate:frameRate];
|
||||
_scale = [[LOTAnimatableScaleValue alloc] initWithScaleValues:scale frameRate:frameRate];
|
||||
}
|
||||
|
||||
NSDictionary *rotation = jsonDictionary[@"r"];
|
||||
if (rotation) {
|
||||
_rotation = [[LAAnimatableNumberValue alloc] initWithNumberValues:rotation frameRate:frameRate];
|
||||
_rotation = [[LOTAnimatableNumberValue alloc] initWithNumberValues:rotation frameRate:frameRate];
|
||||
[_rotation remapValueWithBlock:^CGFloat(CGFloat inValue) {
|
||||
return DegreesToRadians(inValue);
|
||||
}];
|
||||
@ -63,13 +63,13 @@
|
||||
|
||||
NSDictionary *opacity = jsonDictionary[@"o"];
|
||||
if (opacity) {
|
||||
_opacity = [[LAAnimatableNumberValue alloc] initWithNumberValues:opacity frameRate:frameRate];
|
||||
_opacity = [[LOTAnimatableNumberValue alloc] initWithNumberValues:opacity frameRate:frameRate];
|
||||
[_opacity remapValuesFromMin:@0 fromMax:@100 toMin:@0 toMax:@1];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
return [NSString stringWithFormat:@"LAShapeTransform \"Position: %@ Anchor: %@ Scale: %@ Rotation: %@ Opacity: %@\"", _position.description, _anchor.description, _scale.description, _rotation.description, _opacity.description];
|
||||
return [NSString stringWithFormat:@"LOTShapeTransform \"Position: %@ Anchor: %@ Scale: %@ Rotation: %@ Opacity: %@\"", _position.description, _anchor.description, _scale.description, _rotation.description, _opacity.description];
|
||||
}
|
||||
|
||||
@end
|
19
lottie-ios/Classes/Models/LOTShapeTrimPath.h
Normal file
19
lottie-ios/Classes/Models/LOTShapeTrimPath.h
Normal file
@ -0,0 +1,19 @@
|
||||
//
|
||||
// LOTShapeTrimPath.h
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/26/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@class LOTAnimatableNumberValue;
|
||||
|
||||
@interface LOTShapeTrimPath : NSObject
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate;
|
||||
|
||||
@property (nonatomic, readonly) LOTAnimatableNumberValue *start;
|
||||
@property (nonatomic, readonly) LOTAnimatableNumberValue *end;
|
||||
@property (nonatomic, readonly) LOTAnimatableNumberValue *offset;
|
||||
@end
|
@ -1,15 +1,15 @@
|
||||
//
|
||||
// LAShapeTrimPath.m
|
||||
// LOTShapeTrimPath.m
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by brandon_withrow on 7/26/16.
|
||||
// Copyright © 2016 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAShapeTrimPath.h"
|
||||
#import "LAAnimatableNumberValue.h"
|
||||
#import "LOTShapeTrimPath.h"
|
||||
#import "LOTAnimatableNumberValue.h"
|
||||
|
||||
@implementation LAShapeTrimPath
|
||||
@implementation LOTShapeTrimPath
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate {
|
||||
self = [super init];
|
||||
@ -22,19 +22,19 @@
|
||||
- (void)_mapFromJSON:(NSDictionary *)jsonDictionary frameRate:(NSNumber *)frameRate {
|
||||
NSDictionary *start = jsonDictionary[@"s"];
|
||||
if (start) {
|
||||
_start = [[LAAnimatableNumberValue alloc] initWithNumberValues:start frameRate:frameRate];
|
||||
_start = [[LOTAnimatableNumberValue alloc] initWithNumberValues:start frameRate:frameRate];
|
||||
[_start remapValuesFromMin:@0 fromMax:@100 toMin:@0 toMax:@1];
|
||||
}
|
||||
|
||||
NSDictionary *end = jsonDictionary[@"e"];
|
||||
if (end) {
|
||||
_end = [[LAAnimatableNumberValue alloc] initWithNumberValues:end frameRate:frameRate];
|
||||
_end = [[LOTAnimatableNumberValue alloc] initWithNumberValues:end frameRate:frameRate];
|
||||
[_end remapValuesFromMin:@0 fromMax:@100 toMin:@0 toMax:@1];
|
||||
}
|
||||
|
||||
NSDictionary *offset = jsonDictionary[@"o"];
|
||||
if (offset) {
|
||||
_offset = [[LAAnimatableNumberValue alloc] initWithNumberValues:offset frameRate:frameRate];
|
||||
_offset = [[LOTAnimatableNumberValue alloc] initWithNumberValues:offset frameRate:frameRate];
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
//
|
||||
// LAPlatformCompat.h
|
||||
// LOTPlatformCompat.h
|
||||
// Lottie
|
||||
//
|
||||
// Created by Oleksii Pavlovskyi on 2/2/17.
|
||||
// Copyright (c) 2017 Airbnb. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef LAPlatformCompat_h
|
||||
#define LAPlatformCompat_h
|
||||
#ifndef LOTPlatformCompat_h
|
||||
#define LOTPlatformCompat_h
|
||||
|
||||
#import "TargetConditionals.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LAAnimationTransitionController.m
|
||||
// LOTAnimationTransitionController.m
|
||||
// Lottie
|
||||
//
|
||||
// Created by Brandon Withrow on 1/18/17.
|
||||
@ -8,11 +8,11 @@
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
|
||||
#import "LAAnimationTransitionController.h"
|
||||
#import "LAAnimationView.h"
|
||||
#import "LOTAnimationTransitionController.h"
|
||||
#import "LOTAnimationView.h"
|
||||
|
||||
@implementation LAAnimationTransitionController {
|
||||
LAAnimationView *tranistionAnimationView_;
|
||||
@implementation LOTAnimationTransitionController {
|
||||
LOTAnimationView *tranistionAnimationView_;
|
||||
NSString *fromLayerName_;
|
||||
NSString *toLayerName_;
|
||||
}
|
||||
@ -22,7 +22,7 @@
|
||||
toLayerNamed:(NSString *)toLayer {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
tranistionAnimationView_ = [LAAnimationView animationNamed:animation];
|
||||
tranistionAnimationView_ = [LOTAnimationView animationNamed:animation];
|
||||
fromLayerName_ = fromLayer;
|
||||
toLayerName_ = toLayer;
|
||||
}
|
@ -1,22 +1,22 @@
|
||||
//
|
||||
// LAAnimationView
|
||||
// LOTAnimationView
|
||||
// LottieAnimator
|
||||
//
|
||||
// Created by Brandon Withrow on 12/14/15.
|
||||
// Copyright © 2015 Brandon Withrow. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LAAnimationView.h"
|
||||
#import "LAPlatformCompat.h"
|
||||
#import "LALayerView.h"
|
||||
#import "LAModels.h"
|
||||
#import "LAHelpers.h"
|
||||
#import "LAAnimationView_Internal.h"
|
||||
#import "LAAnimationCache.h"
|
||||
#import "LOTAnimationView.h"
|
||||
#import "LOTPlatformCompat.h"
|
||||
#import "LOTLayerView.h"
|
||||
#import "LOTModels.h"
|
||||
#import "LOTHelpers.h"
|
||||
#import "LOTAnimationView_Internal.h"
|
||||
#import "LOTAnimationCache.h"
|
||||
|
||||
const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
|
||||
@implementation LAAnimationState {
|
||||
@implementation LOTAnimationState {
|
||||
BOOL _animationIsPlaying;
|
||||
BOOL _playFromBeginning;
|
||||
CFTimeInterval _previousLocalTime;
|
||||
@ -147,25 +147,25 @@ const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
|
||||
- (void)logStats:(NSString *)logName {
|
||||
CFTimeInterval localTime = [_layer convertTime:CACurrentMediaTime() fromLayer:nil];
|
||||
NSLog(@"LAAnimationState %@ || Is Playing %@ || Duration %f || Speed %lf || Progress %lf || Local Time %lf || ",
|
||||
NSLog(@"LOTAnimationState %@ || Is Playing %@ || Duration %f || Speed %lf || Progress %lf || Local Time %lf || ",
|
||||
logName, (_animationIsPlaying ? @"YES" : @"NO"), self.animationDuration, _layer.speed, self.animatedProgress, localTime);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface LACustomChild : NSObject
|
||||
@interface LOTCustomChild : NSObject
|
||||
|
||||
@property (nonatomic, strong) LAView *childView;
|
||||
@property (nonatomic, weak) LALayerView *layer;
|
||||
@property (nonatomic, assign) LAConstraintType constraint;
|
||||
@property (nonatomic, strong) LOTView *childView;
|
||||
@property (nonatomic, weak) LOTLayerView *layer;
|
||||
@property (nonatomic, assign) LOTConstraintType constraint;
|
||||
|
||||
@end
|
||||
|
||||
@implementation LACustomChild
|
||||
@implementation LOTCustomChild
|
||||
|
||||
@end
|
||||
|
||||
@implementation LAAnimationView {
|
||||
@implementation LOTAnimationView {
|
||||
NSDictionary *_layerMap;
|
||||
NSDictionary *_layerNameMap;
|
||||
NSMutableArray *_customLayers;
|
||||
@ -180,9 +180,9 @@ const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
NSArray *components = [animationName componentsSeparatedByString:@"."];
|
||||
animationName = components.firstObject;
|
||||
|
||||
LAComposition *comp = [[LAAnimationCache sharedCache] animationForKey:animationName];
|
||||
LOTComposition *comp = [[LOTAnimationCache sharedCache] animationForKey:animationName];
|
||||
if (comp) {
|
||||
return [[LAAnimationView alloc] initWithModel:comp];
|
||||
return [[LOTAnimationView alloc] initWithModel:comp];
|
||||
}
|
||||
|
||||
NSError *error;
|
||||
@ -191,28 +191,28 @@ const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
NSDictionary *JSONObject = jsonData ? [NSJSONSerialization JSONObjectWithData:jsonData
|
||||
options:0 error:&error] : nil;
|
||||
if (JSONObject && !error) {
|
||||
LAComposition *laScene = [[LAComposition alloc] initWithJSON:JSONObject];
|
||||
[[LAAnimationCache sharedCache] addAnimation:laScene forKey:animationName];
|
||||
return [[LAAnimationView alloc] initWithModel:laScene];
|
||||
LOTComposition *laScene = [[LOTComposition alloc] initWithJSON:JSONObject];
|
||||
[[LOTAnimationCache sharedCache] addAnimation:laScene forKey:animationName];
|
||||
return [[LOTAnimationView alloc] initWithModel:laScene];
|
||||
}
|
||||
|
||||
return [[LAAnimationView alloc] initWithModel:nil];
|
||||
return [[LOTAnimationView alloc] initWithModel:nil];
|
||||
}
|
||||
|
||||
+ (instancetype)animationFromJSON:(NSDictionary *)animationJSON {
|
||||
LAComposition *laScene = [[LAComposition alloc] initWithJSON:animationJSON];
|
||||
return [[LAAnimationView alloc] initWithModel:laScene];
|
||||
LOTComposition *laScene = [[LOTComposition alloc] initWithJSON:animationJSON];
|
||||
return [[LOTAnimationView alloc] initWithModel:laScene];
|
||||
}
|
||||
|
||||
- (instancetype)initWithContentsOfURL:(NSURL *)url {
|
||||
self = [super initWithFrame:CGRectZero];
|
||||
if (self) {
|
||||
LAComposition *laScene = [[LAAnimationCache sharedCache] animationForKey:url.absoluteString];
|
||||
LOTComposition *laScene = [[LOTAnimationCache sharedCache] animationForKey:url.absoluteString];
|
||||
if (laScene) {
|
||||
[self _initializeAnimationContainer];
|
||||
[self _setupWithSceneModel:laScene restoreAnimationState:NO];
|
||||
} else {
|
||||
_animationState = [[LAAnimationState alloc] initWithDuration:singleFrameTimeValue layer:nil];
|
||||
_animationState = [[LOTAnimationState alloc] initWithDuration:singleFrameTimeValue layer:nil];
|
||||
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
|
||||
NSData *animationData = [NSData dataWithContentsOfURL:url];
|
||||
if (!animationData) {
|
||||
@ -225,9 +225,9 @@ const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
return;
|
||||
}
|
||||
|
||||
LAComposition *laScene = [[LAComposition alloc] initWithJSON:animationJSON];
|
||||
LOTComposition *laScene = [[LOTComposition alloc] initWithJSON:animationJSON];
|
||||
dispatch_async(dispatch_get_main_queue(), ^(void){
|
||||
[[LAAnimationCache sharedCache] addAnimation:laScene forKey:url.absoluteString];
|
||||
[[LOTAnimationCache sharedCache] addAnimation:laScene forKey:url.absoluteString];
|
||||
[self _initializeAnimationContainer];
|
||||
[self _setupWithSceneModel:laScene restoreAnimationState:YES];
|
||||
});
|
||||
@ -237,7 +237,7 @@ const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithModel:(LAComposition *)model {
|
||||
- (instancetype)initWithModel:(LOTComposition *)model {
|
||||
self = [super initWithFrame:model.compBounds];
|
||||
if (self) {
|
||||
[self _initializeAnimationContainer];
|
||||
@ -268,11 +268,11 @@ const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
|
||||
#endif
|
||||
|
||||
- (void)_setupWithSceneModel:(LAComposition *)model restoreAnimationState:(BOOL)restoreAnimation {
|
||||
- (void)_setupWithSceneModel:(LOTComposition *)model restoreAnimationState:(BOOL)restoreAnimation {
|
||||
_sceneModel = model;
|
||||
[self _buildSubviewsFromModel];
|
||||
LAAnimationState *oldState = _animationState;
|
||||
_animationState = [[LAAnimationState alloc] initWithDuration:_sceneModel.timeDuration layer:_animationContainer];
|
||||
LOTAnimationState *oldState = _animationState;
|
||||
_animationState = [[LOTAnimationState alloc] initWithDuration:_sceneModel.timeDuration layer:_animationContainer];
|
||||
|
||||
if (restoreAnimation && oldState) {
|
||||
[self setLoopAnimation:oldState.loopAnimation];
|
||||
@ -290,7 +290,7 @@ const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
|
||||
- (void)_buildSubviewsFromModel {
|
||||
if (_customLayers) {
|
||||
for (LACustomChild *child in _customLayers) {
|
||||
for (LOTCustomChild *child in _customLayers) {
|
||||
[child.childView.layer removeFromSuperlayer];
|
||||
}
|
||||
_customLayers = nil;
|
||||
@ -314,16 +314,16 @@ const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
|
||||
NSArray *reversedItems = [[_sceneModel.layers reverseObjectEnumerator] allObjects];
|
||||
|
||||
LALayerView *maskedLayer = nil;
|
||||
for (LALayer *layer in reversedItems) {
|
||||
LALayerView *layerView = [[LALayerView alloc] initWithModel:layer inComposition:_sceneModel];
|
||||
LOTLayerView *maskedLayer = nil;
|
||||
for (LOTLayer *layer in reversedItems) {
|
||||
LOTLayerView *layerView = [[LOTLayerView alloc] initWithModel:layer inComposition:_sceneModel];
|
||||
layerMap[layer.layerID] = layerView;
|
||||
layerNameMap[layer.layerName] = layerView;
|
||||
if (maskedLayer) {
|
||||
maskedLayer.mask = layerView;
|
||||
maskedLayer = nil;
|
||||
} else {
|
||||
if (layer.matteType == LAMatteTypeAdd) {
|
||||
if (layer.matteType == LOTMatteTypeAdd) {
|
||||
maskedLayer = layerView;
|
||||
}
|
||||
[_animationContainer addSublayer:layerView];
|
||||
@ -338,12 +338,12 @@ const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
return;
|
||||
}
|
||||
|
||||
for (LACustomChild *child in _customLayers) {
|
||||
for (LOTCustomChild *child in _customLayers) {
|
||||
switch (child.constraint) {
|
||||
case LAConstraintTypeAlignToLayer:
|
||||
case LOTConstraintTypeAlignToLayer:
|
||||
child.childView.frame = child.layer.bounds;
|
||||
break;
|
||||
case LAConstraintTypeAlignToBounds: {
|
||||
case LOTConstraintTypeAlignToBounds: {
|
||||
CGRect selfBounds = _animationContainer.frame;
|
||||
CGRect convertedBounds = [child.childView.layer.superlayer convertRect:selfBounds fromLayer:self.layer];
|
||||
child.childView.layer.frame = convertedBounds;
|
||||
@ -360,7 +360,7 @@ const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
[self playWithCompletion:nil];
|
||||
}
|
||||
|
||||
- (void)playWithCompletion:(LAAnimationCompletionBlock)completion {
|
||||
- (void)playWithCompletion:(LOTAnimationCompletionBlock)completion {
|
||||
if (completion) {
|
||||
self.completionBlock = completion;
|
||||
}
|
||||
@ -390,11 +390,11 @@ const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addSubview:(LAView *)view
|
||||
- (void)addSubview:(LOTView *)view
|
||||
toLayerNamed:(NSString *)layer {
|
||||
LAConstraintType constraint = LAConstraintTypeAlignToBounds;
|
||||
LALayerView *layerObject = _layerNameMap[layer];
|
||||
LACustomChild *newChild = [[LACustomChild alloc] init];
|
||||
LOTConstraintType constraint = LOTConstraintTypeAlignToBounds;
|
||||
LOTLayerView *layerObject = _layerNameMap[layer];
|
||||
LOTCustomChild *newChild = [[LOTCustomChild alloc] init];
|
||||
newChild.constraint = constraint;
|
||||
newChild.childView = view;
|
||||
|
||||
@ -502,22 +502,22 @@ const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
|
||||
#define LAViewContentMode UIViewContentMode
|
||||
#define LAViewContentModeScaleToFill UIViewContentModeScaleToFill
|
||||
#define LAViewContentModeScaleAspectFit UIViewContentModeScaleAspectFit
|
||||
#define LAViewContentModeScaleAspectFill UIViewContentModeScaleAspectFill
|
||||
#define LAViewContentModeRedraw UIViewContentModeRedraw
|
||||
#define LAViewContentModeCenter UIViewContentModeCenter
|
||||
#define LAViewContentModeTop UIViewContentModeTop
|
||||
#define LAViewContentModeBottom UIViewContentModeBottom
|
||||
#define LAViewContentModeLeft UIViewContentModeLeft
|
||||
#define LAViewContentModeRight UIViewContentModeRight
|
||||
#define LAViewContentModeTopLeft UIViewContentModeTopLeft
|
||||
#define LAViewContentModeTopRight UIViewContentModeTopRight
|
||||
#define LAViewContentModeBottomLeft UIViewContentModeBottomLeft
|
||||
#define LAViewContentModeBottomRight UIViewContentModeBottomRight
|
||||
#define LOTViewContentMode UIViewContentMode
|
||||
#define LOTViewContentModeScaleToFill UIViewContentModeScaleToFill
|
||||
#define LOTViewContentModeScaleAspectFit UIViewContentModeScaleAspectFit
|
||||
#define LOTViewContentModeScaleAspectFill UIViewContentModeScaleAspectFill
|
||||
#define LOTViewContentModeRedraw UIViewContentModeRedraw
|
||||
#define LOTViewContentModeCenter UIViewContentModeCenter
|
||||
#define LOTViewContentModeTop UIViewContentModeTop
|
||||
#define LOTViewContentModeBottom UIViewContentModeBottom
|
||||
#define LOTViewContentModeLeft UIViewContentModeLeft
|
||||
#define LOTViewContentModeRight UIViewContentModeRight
|
||||
#define LOTViewContentModeTopLeft UIViewContentModeTopLeft
|
||||
#define LOTViewContentModeTopRight UIViewContentModeTopRight
|
||||
#define LOTViewContentModeBottomLeft UIViewContentModeBottomLeft
|
||||
#define LOTViewContentModeBottomRight UIViewContentModeBottomRight
|
||||
|
||||
- (void)setContentMode:(LAViewContentMode)contentMode {
|
||||
- (void)setContentMode:(LOTViewContentMode)contentMode {
|
||||
[super setContentMode:contentMode];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
@ -529,7 +529,7 @@ const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
|
||||
#else
|
||||
|
||||
- (void)setContentMode:(LAViewContentMode)contentMode {
|
||||
- (void)setContentMode:(LOTViewContentMode)contentMode {
|
||||
_contentMode = contentMode;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
@ -562,11 +562,11 @@ const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
CGPoint centerPoint = CGRectGetCenterPoint(self.bounds);
|
||||
CATransform3D xform;
|
||||
|
||||
if (self.contentMode == LAViewContentModeScaleToFill) {
|
||||
if (self.contentMode == LOTViewContentModeScaleToFill) {
|
||||
CGSize scaleSize = CGSizeMake(self.bounds.size.width / self.sceneModel.compBounds.size.width,
|
||||
self.bounds.size.height / self.sceneModel.compBounds.size.height);
|
||||
xform = CATransform3DMakeScale(scaleSize.width, scaleSize.height, 1);
|
||||
} else if (self.contentMode == LAViewContentModeScaleAspectFit) {
|
||||
} else if (self.contentMode == LOTViewContentModeScaleAspectFit) {
|
||||
CGFloat compAspect = self.sceneModel.compBounds.size.width / self.sceneModel.compBounds.size.height;
|
||||
CGFloat viewAspect = self.bounds.size.width / self.bounds.size.height;
|
||||
BOOL scaleWidth = compAspect > viewAspect;
|
||||
@ -574,7 +574,7 @@ const NSTimeInterval singleFrameTimeValue = 1.0 / 60.0;
|
||||
CGFloat compDimension = scaleWidth ? self.sceneModel.compBounds.size.width : self.sceneModel.compBounds.size.height;
|
||||
CGFloat scale = dominantDimension / compDimension;
|
||||
xform = CATransform3DMakeScale(scale, scale, 1);
|
||||
} else if (self.contentMode == LAViewContentModeScaleAspectFill) {
|
||||
} else if (self.contentMode == LOTViewContentModeScaleAspectFill) {
|
||||
CGFloat compAspect = self.sceneModel.compBounds.size.width / self.sceneModel.compBounds.size.height;
|
||||
CGFloat viewAspect = self.bounds.size.width / self.bounds.size.height;
|
||||
BOOL scaleWidth = compAspect < viewAspect;
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// LAAnimationView_Internal.h
|
||||
// LOTAnimationView_Internal.h
|
||||
// Lottie
|
||||
//
|
||||
// Created by Brandon Withrow on 12/7/16.
|
||||
@ -7,12 +7,12 @@
|
||||
//
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
LAConstraintTypeAlignToBounds,
|
||||
LAConstraintTypeAlignToLayer,
|
||||
LAConstraintTypeNone
|
||||
} LAConstraintType;
|
||||
LOTConstraintTypeAlignToBounds,
|
||||
LOTConstraintTypeAlignToLayer,
|
||||
LOTConstraintTypeNone
|
||||
} LOTConstraintType;
|
||||
|
||||
@interface LAAnimationState : NSObject
|
||||
@interface LOTAnimationState : NSObject
|
||||
|
||||
- (_Nonnull instancetype)initWithDuration:(CGFloat)duration layer:( CALayer * _Nullable)layer;
|
||||
|
||||
@ -33,10 +33,10 @@ typedef enum : NSUInteger {
|
||||
|
||||
@end
|
||||
|
||||
@interface LAAnimationView ()
|
||||
@interface LOTAnimationView ()
|
||||
|
||||
@property (nonatomic, readonly) LAComposition * _Nonnull sceneModel;
|
||||
@property (nonatomic, strong) LAAnimationState *_Nonnull animationState;
|
||||
@property (nonatomic, copy, nullable) LAAnimationCompletionBlock completionBlock;
|
||||
@property (nonatomic, readonly) LOTComposition * _Nonnull sceneModel;
|
||||
@property (nonatomic, strong) LOTAnimationState *_Nonnull animationState;
|
||||
@property (nonatomic, copy, nullable) LOTAnimationCompletionBlock completionBlock;
|
||||
|
||||
@end
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user