Saturday, February 27, 2010

Completed the code for arbitrary rotation of a gnocl::pixBuf.

Finished adding the arbitrary rotation command. I had some issues but this wasn't incorporating the code, that was achieved earlier, but it was over wether or not to replace the buffer for the rotate object with a new buffer, or simply to create a new rotated buffer. In the end I settled for the latter choice. This would allow for any simple undo/redo operation under script control. The rotation is achieved using code taken from the zfuncs library from Kornelix -thanks. There is one option in the code that does the actual turn, acolor. The code comments don't make it abundantly clear what is happening but I provided support for it anyway. Its a nice fast routine, a much better alternative than using Imagick. Apart from rotation of colour information, the function also creates an alpha channel. Here's a snippet from the test script:

set pb5 [gnocl::pixBuf load "vyrnwy.png"]

set pb6 [$pb5 rotate \
   -angle 30 \
   -aColor 255]

gnocl::window \
   -child [gnocl::image \
   -image "%?$pb6"] -onDelete {exit}

No comments: