From f18067ff83e8989f80c7f521c40e6fcb5fa8b451 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 29 Sep 2021 15:53:06 +0200 Subject: spline: make sure zeros stay zeros Issue: #1341 --- spline/spline.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spline/spline.cpp b/spline/spline.cpp index 917300c2..7017c93e 100644 --- a/spline/spline.cpp +++ b/spline/spline.cpp @@ -249,6 +249,17 @@ void spline::update_interp_data() const last = data[i]; } + // make sure empty places stay empty (see #1341) + if (auto it = std::find_if(list.cbegin(), list.cend(), + [](QPointF x) { return x.x() >= 1e-6 && x.y() >= 1e-6; }); + it != list.cend() && it != list.cbegin()) + { + it--; + unsigned max = std::clamp((unsigned)iround(it->x() * c), 0u, value_count-1); + + for (unsigned x = 0; x < max; x++) + data[x] = 0; + } #ifdef __clang__ # pragma clang diagnostic pop #endif -- cgit v1.2.3