LOTShapeFill.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // LOTShapeFill.m
  3. // LottieAnimator
  4. //
  5. // Created by Brandon Withrow on 12/15/15.
  6. // Copyright © 2015 Brandon Withrow. All rights reserved.
  7. //
  8. #import "LOTShapeFill.h"
  9. #import "CGGeometry+LOTAdditions.h"
  10. @implementation LOTShapeFill
  11. - (instancetype)initWithJSON:(NSDictionary *)jsonDictionary {
  12. self = [super init];
  13. if (self) {
  14. [self _mapFromJSON:jsonDictionary];
  15. }
  16. return self;
  17. }
  18. - (void)_mapFromJSON:(NSDictionary *)jsonDictionary {
  19. if (jsonDictionary[@"nm"] ) {
  20. _keyname = [jsonDictionary[@"nm"] copy];
  21. }
  22. NSDictionary *color = jsonDictionary[@"c"];
  23. if (color) {
  24. _color = [[LOTKeyframeGroup alloc] initWithData:color];
  25. }
  26. NSDictionary *opacity = jsonDictionary[@"o"];
  27. if (opacity) {
  28. _opacity = [[LOTKeyframeGroup alloc] initWithData:opacity];
  29. [_opacity remapKeyframesWithBlock:^CGFloat(CGFloat inValue) {
  30. return LOT_RemapValue(inValue, 0, 100, 0, 1);
  31. }];
  32. }
  33. NSNumber *evenOdd = jsonDictionary[@"r"];
  34. if (evenOdd.integerValue == 2) {
  35. _evenOddFillRule = YES;
  36. } else {
  37. _evenOddFillRule = NO;
  38. }
  39. NSNumber *fillEnabled = jsonDictionary[@"fillEnabled"];
  40. _fillEnabled = fillEnabled.boolValue;
  41. }
  42. @end