LOTValueDelegate.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // LOTValueDelegate.h
  3. // Lottie
  4. //
  5. // Created by brandon_withrow on 1/5/18.
  6. // Copyright © 2018 Airbnb. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <CoreGraphics/CoreGraphics.h>
  10. /*!
  11. @brief LOTValueDelegate is not intended to be used directly. It is used for type safety.
  12. @discussion LOTValueDelegates are used to dynamically change animation data at runtime. A delegate is set for a keypath, defined by LOTKeypath. While the animation is running the delegate is asked for the value for the keypath at each frame of the animation. The delegate is given the computed animation value for the the current frame. See LOTKeypath and the setValueDelegate:forKeypath method on LOTAnimationView.
  13. Prebuild delegates can be found in LOTBlockCallback, LOTInterpolatorCallback, and LOTValueCallback. These delegates allow direct setting and driving of an animated value.
  14. See LOTColorValueDelegate, LOTNumberValueDelegate, LOTPointValueDelegate, LOTSizeValueDelegate, LOTPathValueDelegate.
  15. */
  16. @protocol LOTValueDelegate <NSObject>
  17. @end
  18. @protocol LOTColorValueDelegate <LOTValueDelegate>
  19. @required
  20. /*!
  21. @brief LOTColorValueDelegate is called at runtime to override the color value of a property in a LOTAnimation. The property is defined by at LOTKeypath. The delegate is set via setValueDelegate:forKeypath on LOTAnimationView.
  22. @discussion LOTValueDelegates are used to dynamically change animation data at runtime. A delegate is set for a keypath, defined by LOTKeypath. While the animation is running the delegate is asked for the value for the keypath at each frame of the animation. The delegate is given the computed animation value for the the current frame. See LOTKeypath and the setValueDelegate:forKeypath method on LOTAnimationView.
  23. @param currentFrame The current frame of the animation in the parent compositions time space.
  24. @param startKeyframe When the block is called, startFrame is the most recent keyframe for the keypath in relation to the current time.
  25. @param endKeyframe When the block is called, endFrame is the next keyframe for the keypath in relation to the current time.
  26. @param interpolatedProgress A value from 0-1 that represents the current progress between keyframes. It respects the keyframes current easing curves.
  27. @param startColor The color from the previous keyframe in relation to the current time.
  28. @param endColor The color from the next keyframe in relation to the current time.
  29. @param interpolatedColor The color interpolated at the current time between startColor and endColor. This represents the keypaths current color for the current time.
  30. @return CGColorRef the color to set the keypath node for the current frame
  31. */
  32. - (CGColorRef)colorForFrame:(CGFloat)currentFrame
  33. startKeyframe:(CGFloat)startKeyframe
  34. endKeyframe:(CGFloat)endKeyframe
  35. interpolatedProgress:(CGFloat)interpolatedProgress
  36. startColor:(CGColorRef)startColor
  37. endColor:(CGColorRef)endColor
  38. currentColor:(CGColorRef)interpolatedColor;
  39. @end
  40. @protocol LOTNumberValueDelegate <LOTValueDelegate>
  41. @required
  42. /*!
  43. @brief LOTNumberValueDelegate is called at runtime to override the number value of a property in a LOTAnimation. The property is defined by at LOTKeypath. The delegate is set via setValueDelegate:forKeypath on LOTAnimationView.
  44. @discussion LOTValueDelegates are used to dynamically change animation data at runtime. A delegate is set for a keypath, defined by LOTKeypath. While the animation is running the delegate is asked for the value for the keypath at each frame of the animation. The delegate is given the computed animation value for the the current frame. See LOTKeypath and the setValueDelegate:forKeypath method on LOTAnimationView.
  45. @param currentFrame The current frame of the animation in the parent compositions time space.
  46. @param startKeyframe When the block is called, startFrame is the most recent keyframe for the keypath in relation to the current time.
  47. @param endKeyframe When the block is called, endFrame is the next keyframe for the keypath in relation to the current time.
  48. @param interpolatedProgress A value from 0-1 that represents the current progress between keyframes. It respects the keyframes current easing curves.
  49. @param startValue The number from the previous keyframe in relation to the current time.
  50. @param endValue The number from the next keyframe in relation to the current time.
  51. @param interpolatedValue The number interpolated at the current time between startNumber and endNumber. This represents the keypaths current number for the current time.
  52. @return CGFloat the number to set the keypath node for the current frame
  53. */
  54. - (CGFloat)floatValueForFrame:(CGFloat)currentFrame
  55. startKeyframe:(CGFloat)startKeyframe
  56. endKeyframe:(CGFloat)endKeyframe
  57. interpolatedProgress:(CGFloat)interpolatedProgress
  58. startValue:(CGFloat)startValue
  59. endValue:(CGFloat)endValue
  60. currentValue:(CGFloat)interpolatedValue;
  61. @end
  62. @protocol LOTPointValueDelegate <LOTValueDelegate>
  63. @required
  64. /*!
  65. @brief LOTPointValueDelegate is called at runtime to override the point value of a property in a LOTAnimation. The property is defined by at LOTKeypath. The delegate is set via setValueDelegate:forKeypath on LOTAnimationView.
  66. @discussion LOTValueDelegates are used to dynamically change animation data at runtime. A delegate is set for a keypath, defined by LOTKeypath. While the animation is running the delegate is asked for the value for the keypath at each frame of the animation. The delegate is given the computed animation value for the the current frame. See LOTKeypath and the setValueDelegate:forKeypath method on LOTAnimationView.
  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 startPoint The point from the previous keyframe in relation to the current time.
  72. @param endPoint The point from the next keyframe in relation to the current time.
  73. @param interpolatedPoint The point interpolated at the current time between startPoint and endPoint. This represents the keypaths current point for the current time.
  74. @return CGPoint the point to set the keypath node for the current frame
  75. */
  76. - (CGPoint)pointForFrame:(CGFloat)currentFrame
  77. startKeyframe:(CGFloat)startKeyframe
  78. endKeyframe:(CGFloat)endKeyframe
  79. interpolatedProgress:(CGFloat)interpolatedProgress
  80. startPoint:(CGPoint)startPoint
  81. endPoint:(CGPoint)endPoint
  82. currentPoint:(CGPoint)interpolatedPoint;
  83. @end
  84. @protocol LOTSizeValueDelegate <LOTValueDelegate>
  85. @required
  86. /*!
  87. @brief LOTSizeValueDelegate is called at runtime to override the size value of a property in a LOTAnimation. The property is defined by at LOTKeypath. The delegate is set via setValueDelegate:forKeypath on LOTAnimationView.
  88. @discussion LOTValueDelegates are used to dynamically change animation data at runtime. A delegate is set for a keypath, defined by LOTKeypath. While the animation is running the delegate is asked for the value for the keypath at each frame of the animation. The delegate is given the computed animation value for the the current frame. See LOTKeypath and the setValueDelegate:forKeypath method on LOTAnimationView.
  89. @param currentFrame The current frame of the animation in the parent compositions time space.
  90. @param startKeyframe When the block is called, startFrame is the most recent keyframe for the keypath in relation to the current time.
  91. @param endKeyframe When the block is called, endFrame is the next keyframe for the keypath in relation to the current time.
  92. @param interpolatedProgress A value from 0-1 that represents the current progress between keyframes. It respects the keyframes current easing curves.
  93. @param startSize The size from the previous keyframe in relation to the current time.
  94. @param endSize The size from the next keyframe in relation to the current time.
  95. @param interpolatedSize The size interpolated at the current time between startSize and endSize. This represents the keypaths current size for the current time.
  96. @return CGSize the size to set the keypath node for the current frame
  97. */
  98. - (CGSize)sizeForFrame:(CGFloat)currentFrame
  99. startKeyframe:(CGFloat)startKeyframe
  100. endKeyframe:(CGFloat)endKeyframe
  101. interpolatedProgress:(CGFloat)interpolatedProgress
  102. startSize:(CGSize)startSize
  103. endSize:(CGSize)endSize
  104. currentSize:(CGSize)interpolatedSize;
  105. @end
  106. @protocol LOTPathValueDelegate <LOTValueDelegate>
  107. @required
  108. /*!
  109. @brief LOTPathValueDelegate is called at runtime to override the path value of a property in a LOTAnimation. The property is defined by at LOTKeypath. The delegate is set via setValueDelegate:forKeypath on LOTAnimationView.
  110. @discussion LOTValueDelegates are used to dynamically change animation data at runtime. A delegate is set for a keypath, defined by LOTKeypath. While the animation is running the delegate is asked for the value for the keypath at each frame of the animation. The delegate is given the computed animation value for the the current frame. See LOTKeypath and the setValueDelegate:forKeypath method on LOTAnimationView.
  111. @param currentFrame The current frame of the animation in the parent compositions time space.
  112. @param startKeyframe When the block is called, startFrame is the most recent keyframe for the keypath in relation to the current time.
  113. @param endKeyframe When the block is called, endFrame is the next keyframe for the keypath in relation to the current time.
  114. @param interpolatedProgress A value from 0-1 that represents the current progress between keyframes. It respects the keyframes current easing curves.
  115. @return CGPathRef the path to set the keypath node for the current frame
  116. */
  117. - (CGPathRef)pathForFrame:(CGFloat)currentFrame
  118. startKeyframe:(CGFloat)startKeyframe
  119. endKeyframe:(CGFloat)endKeyframe
  120. interpolatedProgress:(CGFloat)interpolatedProgress;
  121. @end