diff options
Diffstat (limited to 'spline')
-rw-r--r-- | spline/spline-widget.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp index 0dfac0e9..f56522bd 100644 --- a/spline/spline-widget.cpp +++ b/spline/spline-widget.cpp @@ -204,18 +204,22 @@ void spline_widget::drawFunction() : QPointF{max_x_pixel, val.y()}; }; - for (double k = 0; k < maxx; k += step*3) // NOLINT - { - const auto next_1 = config->get_value_no_save(k + step*1); - const auto next_2 = config->get_value_no_save(k + step*2); - const auto next_3 = config->get_value_no_save(k + step*3); + const auto fn = [&] (double k) { + const auto next_1 = config->get_value_no_save(k + step*1); + const auto next_2 = config->get_value_no_save(k + step*2); + const auto next_3 = config->get_value_no_save(k + step*3); - QPointF b(clamp(point_to_pixel({k + step*1, next_1}))), - c(clamp(point_to_pixel({k + step*2, next_2}))), - d(clamp(point_to_pixel({k + step*3, next_3}))); + QPointF b(clamp(point_to_pixel({k + step*1, next_1}))), + c(clamp(point_to_pixel({k + step*2, next_2}))), + d(clamp(point_to_pixel({k + step*3, next_3}))); - path.cubicTo(b, c, d); - } + path.cubicTo(b, c, d); + }; + + for (double k = 0; k < maxx; k += step*3) // NOLINT + fn(k); + + fn(maxx); painter.drawPath(path); #else |