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.

31 lines
716B

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