summaryrefslogtreecommitdiff
path: root/libs/canvas
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-06-04 06:40:59 +1000
committernick_m <mainsbridge@gmail.com>2016-06-04 06:40:59 +1000
commit1eb8216408b4684b9f93c90b30ac3adee0724d15 (patch)
tree94c2553947791b924752602c8fb85747e2e14105 /libs/canvas
parenta98015e11a87000202d76e6660d4195768598932 (diff)
More FramedCurve render work
- draw last point correctly if applicable - comment intent.
Diffstat (limited to 'libs/canvas')
-rw-r--r--libs/canvas/framed_curve.cc36
1 files changed, 20 insertions, 16 deletions
diff --git a/libs/canvas/framed_curve.cc b/libs/canvas/framed_curve.cc
index 6cb2aa9d18..c539a50150 100644
--- a/libs/canvas/framed_curve.cc
+++ b/libs/canvas/framed_curve.cc
@@ -201,21 +201,26 @@ FramedCurve::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) c
}
}
- /* a redraw may have been requested between the last sample and the last point.*/
+ const Duple first_sample = Duple (samples[left].x, samples[left].y);
- const Duple first_point = Duple (samples[left].x, samples[left].y);
- Duple last_point = Duple (samples[right].x, samples[right].y);
+ /* move to the first sample's x and the draw height */
+ window_space = item_to_window (Duple (first_sample.x, draw.height()));
+ context->move_to (window_space.x, window_space.y);
- if (draw.x1 > last_point.x) {
- last_point = Duple (_points.back().x, _points.back().y);
+ /* draw line to first sample and then between samples */
+ for (uint32_t idx = left; idx <= right; ++idx) {
+ window_space = item_to_window (Duple (samples[idx].x, samples[idx].y), false);
+ context->line_to (window_space.x, window_space.y);
}
- window_space = item_to_window (first_point);
- context->move_to (window_space.x, window_space.y);
+ /* a redraw may have been requested between the last sample and the last point.
+ if so, draw a line to the last _point.
+ */
+ Duple last_sample = Duple (samples[right].x, samples[right].y);
- /* draw line between samples */
- for (uint32_t idx = left + 1; idx <= right; ++idx) {
- window_space = item_to_window (Duple (samples[idx].x, samples[idx].y), false);
+ if (draw.x1 > last_sample.x) {
+ last_sample = Duple (_points.back().x, _points.back().y);
+ window_space = item_to_window (last_sample, false);
context->line_to (window_space.x, window_space.y);
}
@@ -225,21 +230,20 @@ FramedCurve::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) c
break;
case Inside:
context->stroke_preserve ();
-
- window_space = item_to_window (Duple (last_point.x, draw.height()));
+ /* close the frame, possibly using the last _point's x rather than samples[right].x */
+ window_space = item_to_window (Duple (last_sample.x, draw.height()));
context->line_to (window_space.x, window_space.y);
- window_space = item_to_window (Duple (first_point.x, draw.height()));
+ window_space = item_to_window (Duple (first_sample.x, draw.height()));
context->line_to (window_space.x, window_space.y);
-
context->close_path();
setup_fill_context(context);
context->fill ();
break;
case Outside:
context->stroke_preserve ();
- window_space = item_to_window (last_point);
+ window_space = item_to_window (last_sample);
context->line_to (window_space.x, window_space.y);
- window_space = item_to_window (first_point);
+ window_space = item_to_window (first_sample);
context->line_to (window_space.x, window_space.y);
context->close_path();
setup_fill_context(context);