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.

62 lines
1.3KB

  1. #include <app/LightWidget.hpp>
  2. #include <color.hpp>
  3. namespace rack {
  4. namespace app {
  5. void LightWidget::draw(const DrawArgs& args) {
  6. drawLight(args);
  7. drawHalo(args);
  8. TransparentWidget::draw(args);
  9. }
  10. void LightWidget::drawLight(const DrawArgs& args) {
  11. float radius = std::min(box.size.x, box.size.y) / 2.0;
  12. nvgBeginPath(args.vg);
  13. nvgCircle(args.vg, radius, radius, radius);
  14. // Background
  15. if (bgColor.a > 0.0) {
  16. nvgFillColor(args.vg, bgColor);
  17. nvgFill(args.vg);
  18. }
  19. // Foreground
  20. if (color.a > 0.0) {
  21. nvgFillColor(args.vg, color);
  22. nvgFill(args.vg);
  23. }
  24. // Border
  25. if (borderColor.a > 0.0) {
  26. nvgStrokeWidth(args.vg, 0.5);
  27. nvgStrokeColor(args.vg, borderColor);
  28. nvgStroke(args.vg);
  29. }
  30. }
  31. void LightWidget::drawHalo(const DrawArgs& args) {
  32. // Halo is now deprecated
  33. // float radius = std::min(box.size.x, box.size.y) / 2.0;
  34. // float oradius = 4.0 * radius;
  35. // nvgBeginPath(args.vg);
  36. // nvgRect(args.vg, radius - oradius, radius - oradius, 2 * oradius, 2 * oradius);
  37. // NVGpaint paint;
  38. // NVGcolor icol = color::mult(color, 0.04);
  39. // NVGcolor ocol = nvgRGB(0, 0, 0);
  40. // paint = nvgRadialGradient(args.vg, radius, radius, radius, oradius, icol, ocol);
  41. // nvgFillPaint(args.vg, paint);
  42. // nvgGlobalCompositeOperation(args.vg, NVG_LIGHTER);
  43. // nvgFill(args.vg);
  44. }
  45. } // namespace app
  46. } // namespace rack