easing_test.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  4. */
  5. #include "test.h"
  6. #include <bx/easing.h>
  7. #include <bx/file.h>
  8. TEST_CASE("easing", "")
  9. {
  10. bx::WriterI* writer = bx::getNullOut();
  11. for (uint32_t ee = 0; ee < bx::Easing::Count; ++ee)
  12. {
  13. bx::writePrintf(writer, "\n\n%d\n", ee);
  14. const bx::EaseFn easing = bx::getEaseFunc(bx::Easing::Enum(ee) );
  15. const int32_t nx = 64;
  16. const int32_t ny = 10;
  17. bx::writePrintf(writer, "\t/// ^\n");
  18. for (int32_t yy = ny+4; yy >= -5; --yy)
  19. {
  20. const float ys = float(yy )/float(ny);
  21. const float ye = float(yy+1.0)/float(ny);
  22. bx::writePrintf(writer, "\t/// %c", yy != 0 ? '|' : '+');
  23. for (int32_t xx = 0; xx < nx; ++xx)
  24. {
  25. int32_t jj = 0;
  26. for (; jj < 10; ++jj)
  27. {
  28. const float tt = float(xx*10+jj)/10.0f/float(nx);
  29. const float vv = easing(tt);
  30. if (vv >= ys
  31. && vv < ye)
  32. {
  33. bx::writePrintf(writer, "*");
  34. break;
  35. }
  36. }
  37. if (jj == 10)
  38. {
  39. bx::writePrintf(writer, "%c", yy != 0 ? ' ' : '-');
  40. }
  41. }
  42. bx::writePrintf(writer, "%s\n", yy != 0 ? "" : ">");
  43. }
  44. }
  45. }