From e8a844d2e443fd4a5d07ef7654741e8322742d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 10 Jan 2018 17:05:49 +0100 Subject: [PATCH] [apps] Shared: In CurveView::drawCurve: compare pixels coordinate instead of float to avoid white pixels between the area under the curve and the cursor --- apps/shared/curve_view.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/shared/curve_view.cpp b/apps/shared/curve_view.cpp index 7b1daa12a..7bf55f141 100644 --- a/apps/shared/curve_view.cpp +++ b/apps/shared/curve_view.cpp @@ -307,6 +307,10 @@ void CurveView::drawCurve(KDContext * ctx, KDRect rect, EvaluateModelWithParamet float xStep = (xMax-xMin)/resolution(); float rectMin = pixelToFloat(Axis::Horizontal, rect.left() - k_externRectMargin); float rectMax = pixelToFloat(Axis::Horizontal, rect.right() + k_externRectMargin); + + float pixelColorLowerBound = std::round(floatToPixel(Axis::Horizontal, colorLowerBound)); + float pixelColorUpperBound = std::round(floatToPixel(Axis::Horizontal, colorUpperBound)); + for (float x = rectMin; x < rectMax; x += xStep) { /* When |rectMin| >> xStep, rectMin + xStep = rectMin. In that case, quit * the infinite loop. */ @@ -319,7 +323,7 @@ void CurveView::drawCurve(KDContext * ctx, KDRect rect, EvaluateModelWithParamet } float pxf = floatToPixel(Axis::Horizontal, x); float pyf = floatToPixel(Axis::Vertical, y); - if (colorUnderCurve && x > colorLowerBound && x < colorUpperBound) { + if (colorUnderCurve && pxf > pixelColorLowerBound && pxf < pixelColorUpperBound) { KDRect colorRect((int)pxf, std::round(pyf), 1, floatToPixel(Axis::Vertical, 0.0f) - std::round(pyf)); if (floatToPixel(Axis::Vertical, 0.0f) < std::round(pyf)) { colorRect = KDRect((int)pxf, floatToPixel(Axis::Vertical, 0.0f), 1, std::round(pyf) - floatToPixel(Axis::Vertical, 0.0f));