Question

I'm currently trying to modify Avant Window Navigator's "Lucido mode" code in order to replace the separator's/s' curves with diagonal lines.

The part of the (Cairo) code that governs the curviness is present from lines 330 to 334 in the following file on GitHub: link

{ /* Oblique */
  gfloat xm = ( *xs + xf ) / 2.0;
  cairo_curve_to (cr, xm, *ys, xm, yf, xf, yf);
}

In order to make the goal easier to understand, here is an image of what AWN Lucido looks like right now and what I want it to look like:

Example

I would be very grateful if anyone could help me with getting the code right to make the separator a straight, diagonal line.

Thank you very much for your time :)

Was it helpful?

Solution

Info on drawing curves with Cairo can be found here.

A four point Bezier curve looks like this:

enter image description here

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top