[cairo] Projective transformation demo program

Bryce Harrington bryce at osg.samsung.com
Fri Nov 28 20:47:07 PST 2014


Attached is transquare.c, a demo of various types of transformations
including projective transformations (using the patches posted today).
A screenshot of the demo is attached as well.

You can compile this example against stock cairo using the following
commandline:

    gcc transquare.c -o transquare \
        $(pkg-config --cflags --libs gtk+-2.0 cairo)
    ./transquare

Notice that with this, the rotational example works fine.

After patching Cairo with the projective transformation patchset and
installing (e.g. to /usr/local), you can build the demo like this:

    gcc transquare.c -DWITH_PROJECTIVE -o transquare  \
    	$(pkg-config --cflags --libs gtk+-2.0 cairo)
    ./transquare

(I'd recommend doing a 'make uninstall' on cairo after finishing the
build.)

As you can see from the screenshot, the rotation transformation is buggy
here.  I'm not even sure how to best describe it, but it's rotating the
points in a heavily distorted way, as though there are stray elements in
the matrix.  I'm sure I'm missing something simple but I've
doublechecked the math and am a bit stymied, so I'm posting on list in
hopes a second pair of eyes will spot where the error is.

Bryce
-------------- next part --------------
A non-text attachment was scrubbed...
Name: projective-transform.png
Type: image/png
Size: 50592 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20141128/c917751e/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: transquare.c
Type: text/x-csrc
Size: 13423 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20141128/c917751e/attachment-0001.c>


More information about the cairo mailing list