|
This is a quick little demo that takes an image and does some neat warping
animation on the screen with it. I was using this as a handy way to test and
iron out bugs in a function I recently wrote. The function can read a polygon
from a source image, and draw its contents to another polygon in another image.
What makes it so useful is that those polygons do not have to be identical.
I have already used it to implement a blitting function with transformations
that is much faster than the one I wrote in college. It does have a few limitations.
For one thing, although the polygons in use do not have to be the same shape, they
do need to have an equal number of defining points (for instance, you could copy
between any two triangles, but not from a triangle to a square). This could
actually be changed if necessary, but I do not consider it so for now. The other
(more significant) limit is that the polygon to which it's drawing must be convex
(although the one from which it's reading does not need to be). That too could
be avoided, but doing so would slow the function down. This demo is always drawing
to a rectangle (the whole window), but is reading from a polygon that is transforming.
The file linked at the top contains the source code and a make
file, having been written to work on the GNU/Linux platform. A good friend of
mine was kind enough to compile this on his Windows machine for me, so if you're
using Windows and would like to see the program in action, you can download it
in this zip file.
|