LOTShapeStar.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // LOTShapeStar.m
  3. // Lottie
  4. //
  5. // Created by brandon_withrow on 7/27/17.
  6. // Copyright © 2017 Airbnb. All rights reserved.
  7. //
  8. #import "LOTShapeStar.h"
  9. @implementation LOTShapeStar
  10. - (instancetype)initWithJSON:(NSDictionary *)jsonDictionary {
  11. self = [super init];
  12. if (self) {
  13. [self _mapFromJSON:jsonDictionary];
  14. }
  15. return self;
  16. }
  17. - (void)_mapFromJSON:(NSDictionary *)jsonDictionary {
  18. if (jsonDictionary[@"nm"] ) {
  19. _keyname = [jsonDictionary[@"nm"] copy];
  20. }
  21. NSDictionary *outerRadius = jsonDictionary[@"or"];
  22. if (outerRadius) {
  23. _outerRadius = [[LOTKeyframeGroup alloc] initWithData:outerRadius];
  24. }
  25. NSDictionary *outerRoundness = jsonDictionary[@"os"];
  26. if (outerRoundness) {
  27. _outerRoundness = [[LOTKeyframeGroup alloc] initWithData:outerRoundness];
  28. }
  29. NSDictionary *innerRadius = jsonDictionary[@"ir"];
  30. if (innerRadius) {
  31. _innerRadius = [[LOTKeyframeGroup alloc] initWithData:innerRadius];
  32. }
  33. NSDictionary *innerRoundness = jsonDictionary[@"is"];
  34. if (innerRoundness) {
  35. _innerRoundness = [[LOTKeyframeGroup alloc] initWithData:innerRoundness];
  36. }
  37. NSDictionary *position = jsonDictionary[@"p"];
  38. if (position) {
  39. _position = [[LOTKeyframeGroup alloc] initWithData:position];
  40. }
  41. NSDictionary *numberOfPoints = jsonDictionary[@"pt"];
  42. if (numberOfPoints) {
  43. _numberOfPoints = [[LOTKeyframeGroup alloc] initWithData:numberOfPoints];
  44. }
  45. NSDictionary *rotation = jsonDictionary[@"r"];
  46. if (rotation) {
  47. _rotation = [[LOTKeyframeGroup alloc] initWithData:rotation];
  48. }
  49. NSNumber *type = jsonDictionary[@"sy"];
  50. _type = type.integerValue;
  51. }
  52. @end