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.

27 lines
592B

  1. #include <app/MultiLightWidget.hpp>
  2. #include <color.hpp>
  3. namespace rack {
  4. namespace app {
  5. void MultiLightWidget::addBaseColor(NVGcolor baseColor) {
  6. baseColors.push_back(baseColor);
  7. }
  8. void MultiLightWidget::setBrightnesses(const std::vector<float>& brightnesses) {
  9. assert(brightnesses.size() == baseColors.size());
  10. color = nvgRGBAf(0, 0, 0, 0);
  11. for (size_t i = 0; i < baseColors.size(); i++) {
  12. NVGcolor c = baseColors[i];
  13. c.a *= math::clamp(brightnesses[i], 0.f, 1.f);
  14. color = color::screen(color, c);
  15. }
  16. color = color::clamp(color);
  17. }
  18. } // namespace app
  19. } // namespace rack