From d1f93268482a37747ccc09d8c7c8f229acd6bafd Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 21 Jun 2021 20:59:50 -0400 Subject: [PATCH] Fix center of light halo for non-square LightWidgets. --- src/app/LightWidget.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/LightWidget.cpp b/src/app/LightWidget.cpp index 2b316aed..d59a549f 100644 --- a/src/app/LightWidget.cpp +++ b/src/app/LightWidget.cpp @@ -69,15 +69,16 @@ void LightWidget::drawHalo(const DrawArgs& args) { if (color.r == 0.f && color.g == 0.f && color.b == 0.f) return; + math::Vec c = box.size.div(2); float radius = std::min(box.size.x, box.size.y) / 2.0; float oradius = radius + std::min(radius * 4.f, 15.f); nvgBeginPath(args.vg); - nvgRect(args.vg, radius - oradius, radius - oradius, 2 * oradius, 2 * oradius); + nvgRect(args.vg, c.x - oradius, c.y - oradius, 2 * oradius, 2 * oradius); NVGcolor icol = color::mult(color, halo); NVGcolor ocol = nvgRGBA(0, 0, 0, 0); - NVGpaint paint = nvgRadialGradient(args.vg, radius, radius, radius, oradius, icol, ocol); + NVGpaint paint = nvgRadialGradient(args.vg, c.x, c.y, radius, oradius, icol, ocol); nvgFillPaint(args.vg, paint); nvgFill(args.vg); }