mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps] Add a method draw segment to draw curve view
Change-Id: I770cf498ecb58a0d12a4019278ef4e536cad2401
This commit is contained in:
@@ -118,6 +118,28 @@ void CurveView::drawLine(KDContext * ctx, KDRect rect, Axis axis, float coordina
|
||||
}
|
||||
}
|
||||
|
||||
void CurveView::drawSegment(KDContext * ctx, KDRect rect, Axis axis, float coordinate, float lowerBound, float upperBound, KDColor color, KDCoordinate thickness) const {
|
||||
KDRect lineRect = KDRectZero;
|
||||
switch(axis) {
|
||||
// WARNING TODO: anti-aliasing?
|
||||
case Axis::Horizontal:
|
||||
lineRect = KDRect(
|
||||
floorf(floatToPixel(Axis::Horizontal, lowerBound)), floatToPixel(Axis::Vertical, coordinate),
|
||||
ceilf(floatToPixel(Axis::Horizontal, upperBound) - floatToPixel(Axis::Horizontal, lowerBound)), thickness
|
||||
);
|
||||
break;
|
||||
case Axis::Vertical:
|
||||
lineRect = KDRect(
|
||||
floatToPixel(Axis::Horizontal, coordinate), floorf(floatToPixel(Axis::Vertical, upperBound)),
|
||||
thickness, ceilf(floatToPixel(Axis::Vertical, lowerBound) - floatToPixel(Axis::Vertical, upperBound))
|
||||
);
|
||||
break;
|
||||
}
|
||||
if (rect.intersects(lineRect)) {
|
||||
ctx->fillRect(lineRect, color);
|
||||
}
|
||||
}
|
||||
|
||||
void CurveView::drawAxes(Axis axis, KDContext * ctx, KDRect rect) const {
|
||||
drawLine(ctx, rect, axis, 0.0f, k_axisColor, 2);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ protected:
|
||||
float floatToPixel(Axis axis, float f) const;
|
||||
void drawLine(KDContext * ctx, KDRect rect, Axis axis,
|
||||
float coordinate, KDColor color, KDCoordinate thickness = 1) const;
|
||||
void drawSegment(KDContext * ctx, KDRect rect, Axis axis,
|
||||
float coordinate, float lowerBound, float upperBound,
|
||||
KDColor color, KDCoordinate thickness = 1) const;
|
||||
void drawAxes(Axis axis, KDContext * ctx, KDRect rect) const;
|
||||
void drawCurve(void * curve, KDColor color, KDContext * ctx, KDRect rect, bool colorUnderCurve = false, float colorLowerBound = 0.0f, float colorUpperBound = 0.0f, bool continuously = false) const;
|
||||
void drawDiscreteHistogram(KDColor color, KDContext * ctx, KDRect rect, bool colorHighlightBin = false, KDColor highlightColor = KDColorBlack, float colorLowerBound = 0.0f, float colorUpperBound = 0.0f) const;
|
||||
|
||||
Reference in New Issue
Block a user