[cairo] Stroking the Inside Only of a Polygon

Vladimir Vukicevic vladimirv at gmail.com
Sun Dec 4 22:37:44 PST 2005


It sounds like you came up with a number of possible solutions
yourself... clipping to the polygon would be the most correct
solution; doing an inset would also be an option.  I don't think you
can reproduce the gradient easily; the gradient in the screenshot is
always perpendicular to the path, and cairo doesn't have a gradient
fill of that type (though it would be nice if it did).  Doing two
separate strokes might be the easiest thing to do there, but it won't
reproduce the look exactly.

It would be worth trying each solution to see which gives you the look
you want and/or performance..

    - Vlad

On 12/4/05, Nigel Tao <nigel.tao at myrealbox.com> wrote:
> 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:
> http://browserbookapp.sourceforge.net/misc/boundaries.png
> 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
> width?
> tia,
> Nigel.
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo

More information about the cairo mailing list