[python] matplotlib: PlotView: improve rect drawing (use round instead

of truncating pixelFloat
This commit is contained in:
Émilie Feral
2020-03-30 17:04:50 +02:00
parent b3b6565410
commit 84bc46ca8c

View File

@@ -55,10 +55,10 @@ 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()),
maxKDCoordinate(rect.width() / pixelWidth(), 1), // Rectangle should at least be visible
rect.height() / pixelHeight()
std::round(floatToPixel(Axis::Horizontal, rect.x())),
std::round(floatToPixel(Axis::Vertical, rect.y())),
maxKDCoordinate(std::round(rect.width() / pixelWidth()), 1), // Rectangle should at least be visible
std::round(rect.height() / pixelHeight())
);
ctx->fillRect(pixelRect, rect.color());
}