LOTArrayInterpolator.m 916 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // LOTArrayInterpolator.m
  3. // Lottie
  4. //
  5. // Created by brandon_withrow on 7/27/17.
  6. // Copyright © 2017 Airbnb. All rights reserved.
  7. //
  8. #import "LOTArrayInterpolator.h"
  9. #import "CGGeometry+LOTAdditions.h"
  10. @implementation LOTArrayInterpolator
  11. - (NSArray *)numberArrayForFrame:(NSNumber *)frame {
  12. CGFloat progress = [self progressForFrame:frame];
  13. if (progress == 0) {
  14. return self.leadingKeyframe.arrayValue;
  15. }
  16. if (progress == 1) {
  17. return self.trailingKeyframe.arrayValue;
  18. }
  19. NSMutableArray *returnArray = [NSMutableArray array];
  20. for (int i = 0; i < self.leadingKeyframe.arrayValue.count; i ++) {
  21. CGFloat from = [(NSNumber *)self.leadingKeyframe.arrayValue[i] floatValue];
  22. CGFloat to = [(NSNumber *)self.trailingKeyframe.arrayValue[i] floatValue];
  23. CGFloat value = LOT_RemapValue(progress, 0, 1, from, to);
  24. [returnArray addObject:@(value)];
  25. }
  26. return returnArray;
  27. }
  28. @end