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.

43 lines
856B

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