[cairo] libpixman - libpixregion, libic and slim merged; cairo built with it
spitzak at d2.com
Tue Dec 9 14:43:23 PST 2003
On Tuesday 09 December 2003 01:45 pm, Keith Packard wrote:
> 'box' objects contain x1,y1 -> x2,y2 values, 'rectangles' contain x,y
> width,height values. Doing that consistently will at least avoid driving
> me insane.
> I don't know which interface to prefer for external use. Internally,
> boxes are *way* easier to do computations with because the values are
> independent, but I realize that many existing external interfaces have
> rectangles for some reason.
Despite the fact that it will break *my own* code, I would recommend the
two-point version of boxes. The same form of boxes should be used
*everywhere*, meaning inside the cairo implementation and also in the public
Two points are more easily be intersected, unioned, transformed by orthogonal
transforms, and converted to line segments. It can define a "winding
direction" with (x1>x2)!=(y1>y2) which transforms correctly, this is
necessary for non-zero-winding-rule regions.
Much software disagrees with what negative width or height means (reflected
rectangles, zero, or is width unsigned?). Therefore it may be best to avoid
width/height so that nobody makes incorrect assumptions about it.
Although width/height has a history in X, Mac and Windows users are quite
used to the xy-pair (unfortunately they call it left, bottom, right, top,
which implies a direction, we must make it clear that these are two points).
So this will not alienate as many programmers as you may think.
C++ and many other languages provide the inline methods needed so that asking
for the width and height of a box is no harder to write than getting the
,~,~,~,~ ~ ~ ~ ~
/\_ _|_========___ Bill Spitzak
~~~/\/\\~~~~~~\____________/~~~~~~~~ spitzak at d2.com
More information about the cairo