[cairo] Stroking the Inside Only of a Polygon

Nigel Tao nigel.tao at myrealbox.com
Sun Dec 4 21:00:05 PST 2005

Hiya.  I've been playing around with map data, and I want to somehow
highlight a selected region.  So I stroke over it in a bright, partially
transparent red:

I was wondering - is it possible to somehow stroke only the "inside" of
the polygon so that it doesn't bleed over the edge?  I'm imagining
something like what the game Civilization does to mark territorial
borders: http://www.sg.hu/kep/2005_05/civ4.jpg  It's a little hard to
see, but the yellow/brown border actually follows the river, mostly.

Would it be sane (and efficient) to clip to my polygon before stroking?
If I wanted to do this for hundreds of such regions on my screen?

Inkscape can perform an "Inset".  Would it be better to take my path,
inset it by w/2 (using the same code from... livarot?), and then stroke
it by width w?

Any other ideas?  For bonus points, can I also fade out my stroke with a
gradient that's stronger closer to the path and weaker further away, a
la the Civilization screenshot?  Or am I going to have to stroke twice
with low alphas, say, once with a small width and once with a large


More information about the cairo mailing list