mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
Use std::min and std::max
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "plot_store.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace Matplotlib {
|
||||
|
||||
@@ -160,15 +161,12 @@ void PlotStore::addLabel(mp_obj_t x, mp_obj_t y, mp_obj_t string) {
|
||||
|
||||
// Axes
|
||||
|
||||
static inline float minFloat(float x, float y) { return x < y ? x : y; }
|
||||
static inline float maxFloat(float x, float y) { return x > y ? x : y; }
|
||||
|
||||
void updateRange(float * xMin, float * xMax, float * yMin, float * yMax, float x, float y) {
|
||||
if (!std::isnan(x) && !std::isinf(x) && !std::isnan(y) && !std::isinf(y)) {
|
||||
*xMin = minFloat(*xMin, x);
|
||||
*xMax = maxFloat(*xMax, x);
|
||||
*yMin = minFloat(*yMin, y);
|
||||
*yMax = maxFloat(*yMax, y);
|
||||
*xMin = std::min(*xMin, x);
|
||||
*xMax = std::max(*xMax, x);
|
||||
*yMin = std::min(*yMin, y);
|
||||
*yMax = std::max(*yMax, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "plot_view.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace Matplotlib {
|
||||
|
||||
@@ -52,7 +53,6 @@ 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 {
|
||||
KDCoordinate left = std::round(floatToPixel(Axis::Horizontal, rect.left()));
|
||||
KDCoordinate right = std::round(floatToPixel(Axis::Horizontal, rect.right()));
|
||||
@@ -61,7 +61,7 @@ void PlotView::traceRect(KDContext * ctx, KDRect r, PlotStore::Rect rect) const
|
||||
KDRect pixelRect(
|
||||
left,
|
||||
top,
|
||||
maxKDCoordinate(right - left, 1), // Rectangle should at least be visible
|
||||
std::max(right - left, 1), // Rectangle should at least be visible
|
||||
bottom - top
|
||||
);
|
||||
ctx->fillRect(pixelRect, rect.color());
|
||||
|
||||
Reference in New Issue
Block a user