[cairo] New query functions: cairo_current_path, cairo_current_path_flat
Bill Spitzak
spitzak at d2.com
Wed Feb 18 18:38:16 PST 2004
All sounds reasonable to me. I did not know this could be used to extract the
shape out of glyphs, which does make a big difference and is a reason to be
able to get the curves from a path.
It's possible that a better programming interface would be to allocate a big
array that the caller is supposed to free, filled in with a fixed-size
structure for each segment. This would avoid most of the problems with
multithreading or changing the path that you were worried about, and allow
the calling program to examine the data without putting all it's local
variables in a structure. This is also much faster than the overhead of a
call per segment. Instead of making this big enough for a curveto, you
instead turn curveto into 3 entries, this would also have the advantage that
code that did not expect a curveto would "sort of" work and draw along the
tangent vectors as though they were the path:
struct {
int id;
double x,y;
} CairoPathSegment;
enum { // values for id
// zero is reserved
CAIRO_LINETO = 1,
CAIRO_MOVETO,
CAIRO_CURVETO1,
CAIRO_CURVETO2,
CAIRO_CURVETO3,
CAIRO_CLOSEPATH
};
CairoPathSegment* cairo_getpath(state, int* put_length_here);
Because of alignment, the id may take the same space as a double. If this is
a problem, perhaps 2 arrays can be returned, one with id's and the other with
x/y pairs. Or 3 can be returned, with id's, x, and y in different arrays.
On Wednesday 18 February 2004 10:35 am, Keith Packard wrote:
> Around 10 o'clock on Feb 18, Bill Spitzak wrote:
> > It seems to me that only the "flattened" version is really needed:
>
> It is possible that most application uses will want the flattened version,
> however, flattening the path discards information; as Carl said,
> reconstructing the path from the flattened version may result in
> rasterization which exceeds the specified error bounds, while
> reconstructing the path from the canonical version will not....
--
,~,~,~,~ ~ ~ ~ ~
/\_ _|_========___ Bill Spitzak
~~~/\/\\~~~~~~\____________/~~~~~~~~ spitzak at d2.com
More information about the cairo
mailing list