[cairo] Drawing a thick path sans stroke()

donn donn.ingle at gmail.com
Fri Feb 19 11:24:57 PST 2010


On 19/02/2010 19:45, Carl Worth wrote:
> It sounds like what you want is to be able to take some path in cairo,
> and from it compute a new path for which cairo_fill() will produce the
> same result as cairo_stroke() would on the original path.
>
> Is that it?
Zigactly...ish -- I need it to fill the shape that the stroke would have 
outlined. In Inkscape it's called "Stroke to Path". If you draw a line 
(open or closed), give it a large border-size (say 80px) and then 
"stroke to path" you get a shape that is filled looking the same as 
before, except it's no longer a "line" but a "path". The terminology 
gets all kinds of messy between ui-land and cairo-speak.
* Reading that again, it does seem exactly what you said.

The problem is that I am working with Clutter and need an algorithm to 
use with their cairo-like cogl path API, since they can't draw lines 
greater than 1px. (And their stroke() segfaults randomly.)
However, I have come a way since my post and I have the start of a 'good 
enough' solution which I will post when I get it working.

> If so, the API we have envisioned for this operation (since long ago) is
> called cairo_stroke_to_path. And you're in luck, because Jeff Muizelaar
> has recently been doing implementation of exactly this function.
:D I dig me some Cairo.

Shooting for the Moon... are there any API's for things like:
1. Adding nodes into a given cairo_path_data_t (given two nodes within 
it) * by nodes I mean array indexes.

2. Joining two (or more) cairo_path_data_t's into one union

3. Subtracting cairo_path_data_t's (taking bites out.)

4. (Nice to have) A way to get an array of points along a 
cairo_path_data_t in such a way that they are all spread evenly (and can 
be made more or less dense) along the length.

5. (Controversial) A quick n' dirty cairo_path_data_t to SVG and back 
again.
This was raised a year or so ago, and parsing the array is how I do it 
now, but a fast C func to zip back and forth would be very handy.
I also realize that RSVG draws SVG. It just seem that SVG and Cairo are 
so close to one-another that it *feels* like RSVG should be part of 
Cairo and that the SVG surface should be easier to use (spit out svg to 
a string). I dunno. No flames intended -- my brain is an odd thing :)

Basically I am thinking like Inkscape but coding in cairo.

Perhaps a support library for this kind of specific path/svg la-de-dah 
(points 1 to 4) exists? Or maybe it could be a handy tool to write.

Thanks Carl,
\d
-- 
Fonty Python and Things! -- http://otherwise.relics.co.za/wiki/Software


More information about the cairo mailing list