[cairo] Cairo is non-deterministic?

Dirk Schönberger dirk.schoenberger at sz-online.de
Tue Jan 3 13:56:21 PST 2006


> > void create_star (int numsides)
> > {
> >   moveto (0, 1)
> >    for (int i=0; i<numsides; i++)
> >   {
> >     rotate(360/numsides)
> >      lineto (0, 1)
> >    }
> > }
...
> > gsave
> > create_star (10)
> > fill_and_stroke_path
> > grestore

> That still doesn't change the fact create_start is modifying the CTM
> in a way that will be visible to the caller. Imagine a family of
> path-creating functions that append shapes to the current path (at the
> origin, say). A use of the functions might look something like:

> gsave
> create_star (10)
> moveto (x, y)
> create_moon
> fill_and_stroke_path
> grestore

> So what needs to be avoided here is "leaking" CTM modifications from
> create_star to create_moon. In general, with the PostScript model, the
> way to avoid leaking gstate modifications is with gsave/grestore. But
> that's not an option for path-creating functions.

With avoiding "leaking" CTM modifictaions you mean that I could write
create_star like the following

void create_star (int numsides)
{
   gsave
   moveto (0, 1)
   for (int i=0; i<numsides; i++)
   {
     rotate(360/numsides)
     lineto (0, 1)
   }
  grestore
}

which should work in Cairo and PDF, but not in Postscript?

Regards
Dirk



More information about the cairo mailing list