From ce33faad11e9a97d75c8b8f74667b351afbe2562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 30 Mar 2020 16:17:44 +0200 Subject: [PATCH] [python] matplotlib: PlotView: rectangle are always visible despite the pixel width --- python/port/mod/matplotlib/pyplot/plot_view.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/port/mod/matplotlib/pyplot/plot_view.cpp b/python/port/mod/matplotlib/pyplot/plot_view.cpp index f56b918b1..d55034be5 100644 --- a/python/port/mod/matplotlib/pyplot/plot_view.cpp +++ b/python/port/mod/matplotlib/pyplot/plot_view.cpp @@ -52,11 +52,12 @@ void PlotView::traceSegment(KDContext * ctx, KDRect r, PlotStore::Segment segmen } } +static inline KDCoordinate maxKDCoordinate(KDCoordinate x, KDCoordinate y) { return x > y ? x : y; } void PlotView::traceRect(KDContext * ctx, KDRect r, PlotStore::Rect rect) const { KDRect pixelRect( floatToPixel(Axis::Horizontal, rect.x()), floatToPixel(Axis::Vertical, rect.y()), - rect.width() / pixelWidth(), + maxKDCoordinate(rect.width() / pixelWidth(), 1), // Rectangle should at least be visible rect.height() / pixelHeight() ); ctx->fillRect(pixelRect, rect.color());