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.

49 lines
1004B

  1. #include "app.hpp"
  2. namespace rack {
  3. void LightWidget::draw(NVGcontext *vg) {
  4. float radius = box.size.x / 2.0;
  5. float oradius = radius + 15.0;
  6. color.r = clampf(color.r, 0.0, 1.0);
  7. color.g = clampf(color.g, 0.0, 1.0);
  8. color.b = clampf(color.b, 0.0, 1.0);
  9. color.a = clampf(color.a, 0.0, 1.0);
  10. // Solid
  11. nvgBeginPath(vg);
  12. nvgCircle(vg, radius, radius, radius);
  13. nvgFillColor(vg, bgColor);
  14. nvgFill(vg);
  15. // Border
  16. nvgStrokeWidth(vg, 1.0);
  17. NVGcolor borderColor = bgColor;
  18. borderColor.a *= 0.5;
  19. nvgStrokeColor(vg, borderColor);
  20. nvgStroke(vg);
  21. // Inner glow
  22. nvgGlobalCompositeOperation(vg, NVG_LIGHTER);
  23. nvgFillColor(vg, color);
  24. nvgFill(vg);
  25. // Outer glow
  26. nvgBeginPath(vg);
  27. nvgRect(vg, radius - oradius, radius - oradius, 2*oradius, 2*oradius);
  28. NVGpaint paint;
  29. NVGcolor icol = color;
  30. icol.a *= 0.10;
  31. NVGcolor ocol = color;
  32. ocol.a = 0.0;
  33. paint = nvgRadialGradient(vg, radius, radius, radius, oradius, icol, ocol);
  34. nvgFillPaint(vg, paint);
  35. nvgFill(vg);
  36. }
  37. } // namespace rack