Help with image effect
Alex Tweedly
alex at tweedly.net
Sun Oct 23 14:50:46 EDT 2005
I want a nice, simple (?) visual effect:
I have two images (which may be different sizes), and I want to swap
them over (such that each one stretches or shrinks to occupy the space
previously taken up by the other one).
I thought this would be simple ... loop some number of times, adjusting
the "rect" of each image - then find a suitable "wait" value to slow it
down.
In fact, it is unbearably slow - even for medium sized images (320*240
swapping with a 320*480) each step is clearly visible.
For 2 images of 160*120 it's almost a smooth animation - I'm not sure if
it's just that they are smaller sizes, or if it's the fact that the
sizes remain the same. (all on medium laptop - Pentium P4 2.8G with
low-end ATI graphics)
It does look OK on a top of the range Pentium laptop with ATI92xx
graphics (my wife needs high-end hardware to play Sims :-), but that's
not exactly typical hardware yet.
Is there some other way I should be approaching this ?
> on imageSwap pImg1, pImg2, pNumber
> local r1, r2
> local dtlx, dtly, dbrx, dbry
>
> if paramCount() < 3 then
> put 20 into pNumber
> end if
>
> put the rect of img pImg1 into r1
> put the rect of img pImg2 into r2
>
> put (item 1 of r2 - item 1 of r1)/20 into dtlx
> put (item 2 of r2 - item 2 of r1)/20 into dtly
> put (item 3 of r2 - item 3 of r1)/20 into dbrx
> put (item 4 of r2 - item 4 of r1)/20 into dbry
>
> repeat with i = 1 to pNumber
> set the rect of img pImg1 to trunc(item 1 of r1 + i*dtlx),
> trunc(item 2 of r1 + i*dtly), trunc(item 3 of r1 + i*dbrx), trunc(item
> 4 of r1 + i*dbry)
> set the rect of img pImg2 to trunc(item 1 of r2 - i*dtlx),
> trunc(item 2 of r2 - i*dtly), trunc(item 3 of r2 - i*dbrx), trunc(item
> 4 of r2 - i*dbry)
> end repeat
> end imageSwap
Thanks,
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.361 / Virus Database: 267.12.4/146 - Release Date: 21/10/2005
More information about the use-livecode
mailing list