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.

29 lines
624B

  1. #include "app.hpp"
  2. namespace rack {
  3. CircularShadow::CircularShadow() {
  4. blurRadius = 0;
  5. opacity = 0.15;
  6. }
  7. void CircularShadow::draw(NVGcontext *vg) {
  8. if (opacity <= 0.0)
  9. return;
  10. nvgBeginPath(vg);
  11. nvgRect(vg, -blurRadius, -blurRadius, box.size.x + 2*blurRadius, box.size.y + 2*blurRadius);
  12. Vec center = box.size.div(2.0);
  13. float radius = center.x;
  14. NVGcolor icol = nvgRGBAf(0.0, 0.0, 0.0, opacity);
  15. NVGcolor ocol = nvgRGBAf(0.0, 0.0, 0.0, 0.0);
  16. NVGpaint paint = nvgRadialGradient(vg, center.x, center.y, radius - blurRadius, radius, icol, ocol);
  17. nvgFillPaint(vg, paint);
  18. nvgFill(vg);
  19. }
  20. } // namespace rack