transform

Mon, 02 Oct 2006 22:05:43 -0700

affine transforms for twin

Well, getting the basic drawing stuff done in twin was good fun, and I learned a lot about the algorithms we're already using in cairo to do path stroking. But, a PostScript-ish API without affine transforms is like pie without the crust -- tasty, but lacking substance.

Given that our target platform doesn't support floating point numbers, I couldn't just use those for the twin API. Instead, I'm using 16.16 fixed point numbers. That doesn't provide a huge dynamic range, but it should make "reasonable" drawings possible. Those 16.16 values are run through a 3x2 matrix and converted to the 12.4 fixed point values use in the rendering layer. I still need to figure out what to do with out of range values. Ideally, I could clip lines to the bounds of the coordinate space and preserve (approximate) slopes. That may be more work that it's worth for this system; time will tell.

Given affine transforms, all of the usual 2D drawing tricks are now possible. As text is just strokes, even that can be transformed without problem.

One remaining issue is to re-implement the text snapping code under the transformations. I'm not quite sure how I'm supposed to do that though, I'd like to figure out some reasonable invarients so that text doesn't look too funky.