12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- //
- // LOTShapeFill.m
- // LottieAnimator
- //
- // Created by Brandon Withrow on 12/15/15.
- // Copyright © 2015 Brandon Withrow. All rights reserved.
- //
- #import "LOTShapeFill.h"
- #import "CGGeometry+LOTAdditions.h"
- @implementation LOTShapeFill
- - (instancetype)initWithJSON:(NSDictionary *)jsonDictionary {
- self = [super init];
- if (self) {
- [self _mapFromJSON:jsonDictionary];
- }
- return self;
- }
- - (void)_mapFromJSON:(NSDictionary *)jsonDictionary {
-
- if (jsonDictionary[@"nm"] ) {
- _keyname = [jsonDictionary[@"nm"] copy];
- }
-
- NSDictionary *color = jsonDictionary[@"c"];
- if (color) {
- _color = [[LOTKeyframeGroup alloc] initWithData:color];
- }
-
- NSDictionary *opacity = jsonDictionary[@"o"];
- if (opacity) {
- _opacity = [[LOTKeyframeGroup alloc] initWithData:opacity];
- [_opacity remapKeyframesWithBlock:^CGFloat(CGFloat inValue) {
- return LOT_RemapValue(inValue, 0, 100, 0, 1);
- }];
- }
-
- NSNumber *evenOdd = jsonDictionary[@"r"];
- if (evenOdd.integerValue == 2) {
- _evenOddFillRule = YES;
- } else {
- _evenOddFillRule = NO;
- }
-
- NSNumber *fillEnabled = jsonDictionary[@"fillEnabled"];
- _fillEnabled = fillEnabled.boolValue;
- }
- @end
|