[cairo] API Shakeup: cairo_current_matrix

Carl Worth cworth at cworth.org
Wed Mar 2 04:23:44 PST 2005


On Tue, 01 Mar 2005 18:47:03 -0500, Carl Worth wrote:
> But I don't have any better proposal for ordering the members of the
> structure.

I take that back now, (a good night's sleep can make everything seem
more clear). So, now I'll shoot some holes in the arguments I gave
last night.

I had argued that users should initialize the matrix by member
names. This does allow the user to prefer either column-vector order,
(showing a translate by (3,5) matrix in the examples):

	cairo_matrix_t m;
	m.xx = 1.0; m.xy = 0.0; m.x0 = 3.0;
	m.yx = 0.0; m.yy = 1.0; m.y0 = 5.0;

or row-vector order:

	cairo_matrix_t m;
	m.xx = 1.0; m.yx = 0.0;
	m.xy = 0.0; m.yy = 1.0;
	m.x0 = 3.0; m.y0 = 5.0;

But both those work independent of the order we choose for the
structure members. Telling users to just not use structure
initialization doesn't seem like it's going to work. People are going
to want to do it. So, there, we can choose to support either
column-vector order:

	cairo_matrix_t m = { 1.0, 0.0, 3.0,
			     0.0, 1.0, 5.0 };

or row-vector order:

	cairo_matrix_t m = { 1.0, 0.0,
			     0.0, 1.0,
			     3.0, 5.0 };

but we don't get to support both simultaneously of course.

And the order I proposed before doesn't support either. It's a
confusing order with no easy-to-remember rule, (which is the kind of
thing I want to keep out of cairo).

So, I now propose supporting the column-vector order within the
structure. My complaint about separating x0/y0 is dealt with by
judicious use of white space:

	typedef struct _cairo_matrix {
	    double xx; double xy; double x0;
	    double yx; double yy; double y0;
	} cairo_matrix_t;

The other arguments I had put forth were regarding compatibility with
other library matrix structures. As far as the 4-element matrix
structures in freetype and fontconfig, we still have member-name
compatibility which is probably the most important.

With this proposal, we will be incompatible with pango's 6-element
matrix order. But, it occurs to me that even if the order were the
same, the two would not be compatible anyway since pango and cairo use
different rotation conventions, (in cairo a positive angle rotates
from the direction of the positive X axis toward the positive Y axis,
while in pango a positive angle rotates counterclockwise).

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050302/e048e11e/attachment.pgp


More information about the cairo mailing list