From d6fdb2a2c16d7232ba39671ed2b6a0aaf7731b36 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 30 Mar 2020 21:50:24 -0400 Subject: [PATCH] Remove LightWidget halo. Decrease default CircularShadow opacity slightly. Render shadow with hard edges by default. --- src/app/CircularShadow.cpp | 14 ++++++++++---- src/app/LightWidget.cpp | 26 ++++++++++++++------------ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/app/CircularShadow.cpp b/src/app/CircularShadow.cpp index 56846777..fd9d0ca0 100644 --- a/src/app/CircularShadow.cpp +++ b/src/app/CircularShadow.cpp @@ -14,14 +14,20 @@ void CircularShadow::draw(const DrawArgs& args) { if (opacity <= 0.0) return; - nvgBeginPath(args.vg); - nvgRect(args.vg, -blurRadius, -blurRadius, box.size.x + 2 * blurRadius, box.size.y + 2 * blurRadius); math::Vec center = box.size.div(2.0); float radius = center.x; NVGcolor icol = nvgRGBAf(0.0, 0.0, 0.0, opacity); NVGcolor ocol = nvgRGBAf(0.0, 0.0, 0.0, 0.0); - NVGpaint paint = nvgRadialGradient(args.vg, center.x, center.y, radius - blurRadius, radius, icol, ocol); - nvgFillPaint(args.vg, paint); + nvgBeginPath(args.vg); + if (blurRadius > 0.0) { + nvgRect(args.vg, -blurRadius, -blurRadius, box.size.x + 2 * blurRadius, box.size.y + 2 * blurRadius); + NVGpaint paint = nvgRadialGradient(args.vg, center.x, center.y, radius - blurRadius, radius, icol, ocol); + nvgFillPaint(args.vg, paint); + } + else { + nvgCircle(args.vg, center.x, center.y, radius); + nvgFillColor(args.vg, icol); + } nvgFill(args.vg); } diff --git a/src/app/LightWidget.cpp b/src/app/LightWidget.cpp index 3df6dce8..518b78c8 100644 --- a/src/app/LightWidget.cpp +++ b/src/app/LightWidget.cpp @@ -38,19 +38,21 @@ void LightWidget::drawLight(const DrawArgs& args) { } void LightWidget::drawHalo(const DrawArgs& args) { - float radius = std::min(box.size.x, box.size.y) / 2.0; - float oradius = 4.0 * radius; + // Halo is now deprecated - nvgBeginPath(args.vg); - nvgRect(args.vg, radius - oradius, radius - oradius, 2 * oradius, 2 * oradius); - - NVGpaint paint; - NVGcolor icol = color::mult(color, 0.07); - NVGcolor ocol = nvgRGB(0, 0, 0); - paint = nvgRadialGradient(args.vg, radius, radius, radius, oradius, icol, ocol); - nvgFillPaint(args.vg, paint); - nvgGlobalCompositeOperation(args.vg, NVG_LIGHTER); - nvgFill(args.vg); + // float radius = std::min(box.size.x, box.size.y) / 2.0; + // float oradius = 4.0 * radius; + + // nvgBeginPath(args.vg); + // nvgRect(args.vg, radius - oradius, radius - oradius, 2 * oradius, 2 * oradius); + + // NVGpaint paint; + // NVGcolor icol = color::mult(color, 0.04); + // NVGcolor ocol = nvgRGB(0, 0, 0); + // paint = nvgRadialGradient(args.vg, radius, radius, radius, oradius, icol, ocol); + // nvgFillPaint(args.vg, paint); + // nvgGlobalCompositeOperation(args.vg, NVG_LIGHTER); + // nvgFill(args.vg); }