Caricature challenge

Ken Ray kray at sonsothunder.com
Mon Dec 17 10:46:47 EST 2007


On Sun, 16 Dec 2007 18:36:22 -0800, Randall Lee Reetz wrote:

> In supercard, if you set the "picturedata" of a polygon to an image's 
> path on disc, that image assumes the dimentions of the rectangle that 
> defines the smallest rectangle within which the polygon would fit.  

> Reshape the polygon and the image rectangle stretches likewise to fit 
> the new outer bounds of the new shaped polygon.  So, the image is 
> warped in height and width to fit the polygon, which isnt as good as 
> warping to fit the non-linear angular distotion of it's bounds as 
> might be achieved with the use of a quad, but in light of performance 
> it is in fact fast to fake this same overall effect through a grid of 
> interleaved triangles (so long as your grid is sufficiently fine).  I 
> found that the eye is pretty forgiving with image montage of fairly 
> low fedelity.
> 
> Will someone do a quick trial with this pattern property and apply an 
> image to the content of a polygon to see if there is in fact no easy 
> way to make sure that the applied image always stretches in x and y 
> to fit the exact outer width and height of the polygon holding it?

I tried that, and there's no *easy* way AFAICT. The only thing I could 
think of would be to make it a multi-step process:

1) Take the original image (img "orig"), duplicate it (img "dupe") and 
lock its loc.
2) Set the rect of "dupe" to the same size as the polygon
3) Make a new image object (img "stretch") that has the same size as 
the copy.
4) Set the imageData of the "stretch" to the imageData of "dupe"
5) Set the backgroundPattern of the polygon to "stretch"

This of course couldn't happen dynamically in real time without 
stuttering, etc., especially on larger images. I miss SuperCard's 
manipulation of pictureData in Revolution (you can do all sorts of 
other things too like setting offsets, magnification etc.) - it would 
be a great addition to Rev...


Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/



More information about the use-livecode mailing list