You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

color.hpp 580B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include "util/math.hpp"
  3. #include "nanovg.h"
  4. namespace rack {
  5. inline NVGcolor colorClip(NVGcolor a) {
  6. for (int i = 0; i < 4; i++)
  7. a.rgba[i] = clamp(a.rgba[i], 0.f, 1.f);
  8. return a;
  9. }
  10. inline NVGcolor colorMinus(NVGcolor a, NVGcolor b) {
  11. for (int i = 0; i < 4; i++)
  12. a.rgba[i] -= b.rgba[i];
  13. return a;
  14. }
  15. inline NVGcolor colorPlus(NVGcolor a, NVGcolor b) {
  16. for (int i = 0; i < 4; i++)
  17. a.rgba[i] += b.rgba[i];
  18. return a;
  19. }
  20. inline NVGcolor colorMult(NVGcolor a, float x) {
  21. for (int i = 0; i < 4; i++)
  22. a.rgba[i] *= x;
  23. return a;
  24. }
  25. } // namespace rack