Info on drawing curves with Cairo can be found here.
A four point Bezier curve looks like this:
cairo_curve_to
takes the current pen position for p0
and its arguments are the next 3 points.
So you could make cairo_curve_to
draw a straight line by passing the same point for each argument. This is kinda wasteful but not a serious issue for you probably.
It looks like if you pass the end position for both arguments of _line_from_to
it will degenerate to drawing a straight line, as you want. e.g. if the call to that function was _line_from_to(cr, &x, &y, x2, y2)
change it to _line_from_to(cr, &x2, &y2, x2, y2)
.
Alternatively, change the code for _line_from_to
to be
static void
_line_from_to ( cairo_t *cr,
gfloat *xs,
gfloat *ys,
gfloat xf,
gfloat yf)
{
cairo_line_to (cr, xf, yf);
*xs = xf;
*ys = yf;
}
If you want more info on cairo_curve_to
, see this example.