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.

44 lines
845B

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