fork download
  1. //Convience functions that scale the result for you, scaling both the duration and the value.
  2. float ScaledEase(const EaseFunction &easeFunction, float currentTime, float startPos, float stopPos, float startTime, float stopTime)
  3. {
  4. //Get the range of the values.
  5. float timeRange = (stopTime - startTime);
  6.  
  7. //Adjust the position from (begin, end) to (0, range), and convert to float.
  8. float adjustedTime = (currentTime - startTime);
  9.  
  10. //Convert to the (0.0f, 1.0f) scale.
  11. adjustedTime /= timeRange;
  12.  
  13. //Calculate the current position in the easing function, after adjusting 'currentTime' to the range (0.0 - 1.0).
  14. float easePos = easeFunction(adjustedTime);
  15.  
  16. //Get the range to convert the ease into.
  17. float distanceRange = (stopPos - startPos);
  18.  
  19. //Calculate and return the result.
  20. return (distanceRange * easePos) + startPos;
  21. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty