LOTBlockCallback.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. //
  2. // LOTBlockCallback.h
  3. // Lottie
  4. //
  5. // Created by brandon_withrow on 12/15/17.
  6. // Copyright © 2017 Airbnb. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <CoreGraphics/CoreGraphics.h>
  10. #import "LOTValueDelegate.h"
  11. /*!
  12. @brief A block that is used to change a Color value at keytime, the block is called continuously for a keypath while the animation plays.
  13. @param currentFrame The current frame of the animation in the parent compositions time space.
  14. @param startKeyFrame When the block is called, startFrame is the most recent keyframe for the keypath in relation to the current time.
  15. @param endKeyFrame When the block is called, endFrame is the next keyframe for the keypath in relation to the current time.
  16. @param interpolatedProgress A value from 0-1 that represents the current progress between keyframes. It respects the keyframes current easing curves.
  17. @param startColor The color from the previous keyframe in relation to the current time.
  18. @param endColor The color from the next keyframe in relation to the current time.
  19. @param interpolatedColor The color interpolated at the current time between startColor and endColor. This represents the keypaths current color for the current time.
  20. @return CGColorRef the color to set the keypath node for the current frame
  21. */
  22. typedef CGColorRef _Nonnull (^LOTColorValueCallbackBlock)(CGFloat currentFrame,
  23. CGFloat startKeyFrame,
  24. CGFloat endKeyFrame,
  25. CGFloat interpolatedProgress,
  26. CGColorRef _Nullable startColor,
  27. CGColorRef _Nullable endColor,
  28. CGColorRef _Nullable interpolatedColor);
  29. /*!
  30. @brief A block that is used to change a Number value at keytime, the block is called continuously for a keypath while the animation plays.
  31. @param currentFrame The current frame of the animation in the parent compositions time space.
  32. @param startKeyFrame When the block is called, startFrame is the most recent keyframe for the keypath in relation to the current time.
  33. @param endKeyFrame When the block is called, endFrame is the next keyframe for the keypath in relation to the current time.
  34. @param interpolatedProgress A value from 0-1 that represents the current progress between keyframes. It respects the keyframes current easing curves.
  35. @param startValue The Number from the previous keyframe in relation to the current time.
  36. @param endValue The Number from the next keyframe in relation to the current time.
  37. @param interpolatedValue The Number interpolated at the current time between startValue and endValue. This represents the keypaths current Number for the current time.
  38. @return CGFloat the number to set the keypath node for the current frame
  39. */
  40. typedef CGFloat (^LOTNumberValueCallbackBlock)(CGFloat currentFrame,
  41. CGFloat startKeyFrame,
  42. CGFloat endKeyFrame,
  43. CGFloat interpolatedProgress,
  44. CGFloat startValue,
  45. CGFloat endValue,
  46. CGFloat interpolatedValue);
  47. /*!
  48. @brief A block that is used to change a Point value at keytime, the block is called continuously for a keypath while the animation plays.
  49. @param currentFrame The current frame of the animation in the parent compositions time space.
  50. @param startKeyFrame When the block is called, startFrame is the most recent keyframe for the keypath in relation to the current time.
  51. @param endKeyFrame When the block is called, endFrame is the next keyframe for the keypath in relation to the current time.
  52. @param interpolatedProgress A value from 0-1 that represents the current progress between keyframes. It respects the keyframes current easing curves.
  53. @param startPoint The Point from the previous keyframe in relation to the current time.
  54. @param endPoint The Point from the next keyframe in relation to the current time.
  55. @param interpolatedPoint The Point interpolated at the current time between startPoint and endPoint. This represents the keypaths current Point for the current time.
  56. @return CGPoint the point to set the keypath node for the current frame.
  57. */
  58. typedef CGPoint (^LOTPointValueCallbackBlock)(CGFloat currentFrame,
  59. CGFloat startKeyFrame,
  60. CGFloat endKeyFrame,
  61. CGFloat interpolatedProgress,
  62. CGPoint startPoint,
  63. CGPoint endPoint,
  64. CGPoint interpolatedPoint);
  65. /*!
  66. @brief A block that is used to change a Size value at keytime, the block is called continuously for a keypath while the animation plays.
  67. @param currentFrame The current frame of the animation in the parent compositions time space.
  68. @param startKeyFrame When the block is called, startFrame is the most recent keyframe for the keypath in relation to the current time.
  69. @param endKeyFrame When the block is called, endFrame is the next keyframe for the keypath in relation to the current time.
  70. @param interpolatedProgress A value from 0-1 that represents the current progress between keyframes. It respects the keyframes current easing curves.
  71. @param startSize The Size from the previous keyframe in relation to the current time.
  72. @param endSize The Size from the next keyframe in relation to the current time.
  73. @param interpolatedSize The Size interpolated at the current time between startSize and endSize. This represents the keypaths current Size for the current time.
  74. @return CGSize the size to set the keypath node for the current frame.
  75. */
  76. typedef CGSize (^LOTSizeValueCallbackBlock)(CGFloat currentFrame,
  77. CGFloat startKeyFrame,
  78. CGFloat endKeyFrame,
  79. CGFloat interpolatedProgress,
  80. CGSize startSize,
  81. CGSize endSize,
  82. CGSize interpolatedSize);
  83. /*!
  84. @brief A block that is used to change a Path value at keytime, the block is called continuously for a keypath while the animation plays.
  85. @param currentFrame The current frame of the animation in the parent compositions time space.
  86. @param startKeyFrame When the block is called, startFrame is the most recent keyframe for the keypath in relation to the current time.
  87. @param endKeyFrame When the block is called, endFrame is the next keyframe for the keypath in relation to the current time.
  88. @param interpolatedProgress A value from 0-1 that represents the current progress between keyframes. It respects the keyframes current easing curves.
  89. @return UIBezierPath the path to set the keypath node for the current frame.
  90. */
  91. typedef CGPathRef _Nonnull (^LOTPathValueCallbackBlock)(CGFloat currentFrame,
  92. CGFloat startKeyFrame,
  93. CGFloat endKeyFrame,
  94. CGFloat interpolatedProgress);
  95. /*!
  96. @brief LOTColorValueCallback is wrapper around a LOTColorValueCallbackBlock. This block can be used in conjunction with LOTAnimationView setValueDelegate:forKeypath to dynamically change an animation's color keypath at runtime.
  97. */
  98. @interface LOTColorBlockCallback : NSObject <LOTColorValueDelegate>
  99. + (instancetype _Nonnull)withBlock:(LOTColorValueCallbackBlock _Nonnull )block NS_SWIFT_NAME(init(block:));
  100. @property (nonatomic, copy, nonnull) LOTColorValueCallbackBlock callback;
  101. @end
  102. /*!
  103. @brief LOTNumberValueCallback is wrapper around a LOTNumberValueCallbackBlock. This block can be used in conjunction with LOTAnimationView setValueDelegate:forKeypath to dynamically change an animation's number keypath at runtime.
  104. */
  105. @interface LOTNumberBlockCallback : NSObject <LOTNumberValueDelegate>
  106. + (instancetype _Nonnull)withBlock:(LOTNumberValueCallbackBlock _Nonnull)block NS_SWIFT_NAME(init(block:));
  107. @property (nonatomic, copy, nonnull) LOTNumberValueCallbackBlock callback;
  108. @end
  109. /*!
  110. @brief LOTPointValueCallback is wrapper around a LOTPointValueCallbackBlock. This block can be used in conjunction with LOTAnimationView setValueDelegate:forKeypath to dynamically change an animation's point keypath at runtime.
  111. */
  112. @interface LOTPointBlockCallback : NSObject <LOTPointValueDelegate>
  113. + (instancetype _Nonnull)withBlock:(LOTPointValueCallbackBlock _Nonnull)block NS_SWIFT_NAME(init(block:));
  114. @property (nonatomic, copy, nonnull) LOTPointValueCallbackBlock callback;
  115. @end
  116. /*!
  117. @brief LOTSizeValueCallback is wrapper around a LOTSizeValueCallbackBlock. This block can be used in conjunction with LOTAnimationView setValueDelegate:forKeypath to dynamically change an animation's size keypath at runtime.
  118. */
  119. @interface LOTSizeBlockCallback : NSObject <LOTSizeValueDelegate>
  120. + (instancetype _Nonnull)withBlock:(LOTSizeValueCallbackBlock _Nonnull)block NS_SWIFT_NAME(init(block:));
  121. @property (nonatomic, copy, nonnull) LOTSizeValueCallbackBlock callback;
  122. @end
  123. /*!
  124. @brief LOTPathValueCallback is wrapper around a LOTPathValueCallbackBlock. This block can be used in conjunction with LOTAnimationView setValueDelegate:forKeypath to dynamically change an animation's path keypath at runtime.
  125. */
  126. @interface LOTPathBlockCallback : NSObject <LOTPathValueDelegate>
  127. + (instancetype _Nonnull)withBlock:(LOTPathValueCallbackBlock _Nonnull)block NS_SWIFT_NAME(init(block:));
  128. @property (nonatomic, copy, nonnull) LOTPathValueCallbackBlock callback;
  129. @end