+ double x;
+ double y;
+
+ context->save ();
+ context->rectangle (area.x0, area.y0, area.width(),area.height());
+ context->clip ();
+
+ setup_outline_context (context);
+
+ if (_points.size() == 2) {
+
+ /* straight line */
+
+ Duple window_space;
+
+ window_space = item_to_window (_points.front());
+ context->move_to (window_space.x, window_space.y);
+ window_space = item_to_window (_points.back());
+ context->line_to (window_space.x, window_space.y);
+
+ } else {
+
+ /* curve of at least 3 points */
+
+ const double xfront = _points.front().x;
+ const double xextent = _points.back().x - xfront;
+
+ /* move through points to find the first one inside the
+ * rendering area
+ */
+
+ Points::const_iterator edge = _points.end();
+ bool edge_found = false;
+
+ for (Points::const_iterator p = _points.begin(); p != _points.end(); ++p) {
+ Duple w (item_to_window (Duple ((*p).x, 0.0)));
+ if (w.x >= area.x0) {
+ edge_found = true;
+ break;
+ }
+ edge = p;
+
+ }
+
+ if (edge == _points.end()) {
+ if (edge_found) {
+ edge = _points.begin();
+ } else {
+ return;
+ }
+ }
+
+ std::cerr << "Start drawing " << distance (_points.begin(), edge) << " into points\n";
+
+ x = (*edge).x;
+ y = map_value (0.0);
+
+ Duple window_space = item_to_window (Duple (x, y));
+ context->move_to (window_space.x, window_space.y);
+
+ /* if the extent of this curve (in pixels) is small, then we don't need
+ * many segments.
+ */
+
+ uint32_t nsegs = area.width();
+ double last_x = 0;
+ double xoffset = (x-xfront)/xextent;
+
+ // std::cerr << " draw " << nsegs << " segments\n";
+
+ for (uint32_t n = 1; n < nsegs; ++n) {
+
+ /* compute item space x coordinate of the start of this segment */
+
+ x = xoffset + (n / (double) nsegs);
+ y = map_value (x);
+
+ x += xfront + (xextent * x);
+
+ // std::cerr << "hspan @ " << x << ' ' << x - last_x << std::endl;
+ last_x = x;
+
+ window_space = item_to_window (Duple (x, y));
+ context->line_to (window_space.x, window_space.y);
+
+ if (window_space.x > area.x1) {
+ /* we're done - the last point was outside the redraw area along the x-axis */
+ break;
+ }
+ }