[cairo] Variable width strokes

Carl Worth cworth at east.isi.edu
Thu Mar 18 11:17:07 PST 2004

On Feb 19, Seth Nickell wrote:
 > Cairo's strokes render quite pleasingly, but as far as I can tell, you
 > cannot vary line width mid-stroke. Breaking pen input into line segments
 > and rendering each line segment as a separate stroke in order to allow
 > each segment to have a different line width will not look very nice ;-)
 > Am I missing something or am I hitting a limitation of Cairo's
 > path/stroke API?

No, you're not missing anything. Right now, to do what you want you
would need to compute the outline of the shape you want and fill that,
(and no, this is likely not trivial).

I've had the idea of variable-width strokes at the back of my mind for
some time. A somewhat related idea would be to allow more general pen
shapes, (other than the currently supported ellipses).

The current implementation could handle general pens quite easily, but
it would take a bit of work to make it handle pens than changed,
(width or shape), along the path.

The other trick to solve involves the semantics of the API. Currently,
cairo_set_line_width has no effect but to set a parameter in the
graphics state that is not examined until the next call to

So, even if we don't implement variable-width strokes right away, it
might be worth coming up with a plan so that they could be introduced
later without forcing an incompatible change in API semantics.


More information about the cairo mailing list