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.

47 lines
913B

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