[cairo] simple surface size question
Dan McMahill
dan at mcmahill.net
Mon Jan 19 19:37:34 PST 2009
Hello,
I'm new to cairo and am finishing up a cairo driver for pstoedit and had
a question. To test out the generated code, I'm doing something like this:
main()
{
cairo_surface_t *cs;
cairo_t *cr;
cs = cairo_pdf_surface_create("myfile.pdf", SIZEX, SIZEY);
cr = render_page_1(cs);
cairo_show_page(cr);
cairo_destroy(cr);
}
and the render_page_1() function is the generated code coming out of
pstoedit
cairo_t *render_page1(cairo_surface_t *cs)
{
cairo_t *cr;
cr = cairo_create(cs);
// now there are lots of calls like
// cairo_moveto(), cairo_line_to(), cairo_stroke(), etc
return cr;
}
It seems I have a chicken and egg problem. In main() I set the size of
my surface. But I don't *know* what my size really is yet. That
depends on all the drawing that was done in render_page_1() and that
came out of my pstoedit driver.
How do I handle not knowing the x/y limits of my drawing up front? In
fact, unless I do something drastic to the pstoedit driver, I might even
have negative x and y coordinates in my cairo calls. Is that even
allowed (negative coordinates)?
Thanks
-Dan
More information about the cairo
mailing list