[Xr] Xr API comments

Carl Worth cworth at east.isi.edu
Mon May 26 05:44:50 PDT 2003

On May 23, Soorya Kuloor wrote:
 > After using the Xr API for a while, here are some thoughts:

Thanks Soorya. Feedback from those with experience is quite needed
right now.

 > * XrSave() and XrRestore() function names are a bit confusing. XrPush()
 > and XrPop() may be better names?. Other libraries seem to use the
 > push/pop names (Eclipse draw2d, Java2D).

Save/restore come from PostScript and we've been trying to avoid
gratuitous inconsistency with PostScript.

On the other hand, I do want to add back the functions for drawing to
a temporary surface. The current proposed names for those are
XrPushGroup/XrPopGroup. So for internal consistency it may make sense
to switch to XrPush/XrPop as well.

 > * Are there any plans to provide 'higher level' shape related functions
 > in Xr API, such as drawing ellipses, curves and rectangles?

I recently added a convenience function for adding a rectangle to the
current path.

I do want to add arc functions as well. I posted a proposal some time
ago on the old render at xfree86.org list. Looks like there's an archival
copy of the message here:


I still feel pretty good about the XrArc, XrArcNegative, and XrArcTo
API proposed there.

The only remaining problem is that I need an implementation that can
break an elliptical arc into a sufficient number of cubic splines so
that the splines approximate the arc within a specified tolerance
value. Any help or pointers here would be most appreciated.

 > I am specifically talking about shapes that are supported by SVG,
 > such as arcs, ellipses, rounded rectangles. Xr already has
 > 'path'.

Xr will remain more like PostScript rather than SVG in that everything
is a path and the only way to draw is with XrStroke or XrFill.

The proposal above adds circular arcs. Transforms can be used to get
elliptical arcs. I haven't planned to add rounded rectangles, but the
XrArcTo function should make it quite easy to construct these
"manually" outside of Xr.

 > I had to dig them out of libxsvg and copy them over into my
 > code. Some of the shapes such as arcs are really complex.

Yes. The only reason I haven't copied the libxsvg version into Xr is
that it doesn't satisfy the "within a specified tolerance" constraint
I mentioned above.


Carl Worth                                        
USC Information Sciences Institute                      cworth at isi.edu

More information about the cairo mailing list