easing.cpp 332 B

123456789101112131415161718192021
  1. #include "easing.h"
  2. float lerp(float a, float b, float r)
  3. {
  4. return a * (1 - r) + b * r;
  5. }
  6. float linearRemap(float val, float fromMin, float fromMax, float toMin, float toMax)
  7. {
  8. float rez = val;
  9. rez -= fromMin;
  10. rez /= (fromMax - fromMin);
  11. //rez is between 0 and 1 now
  12. rez *= (toMax - toMin);
  13. rez += toMin;
  14. return rez;
  15. }