Help with image effect

2005-10-23 Thread Alex Tweedly


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

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Help with image effect

2005-10-23 Thread Scott Rossi
Recently, Alex Tweedly  wrote:

> 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 ?


Without seeing exactly what you're doing, I'll go out on a limb and guess
that yes, the images are too large for Rev to really do this smoothly.  If
Rev had some kind of direct-to-screen option, this might be doable, but the
images are probably a bit large for Rev to do natively. Three suggestions:

1) If possible, map the images down to 8 bit color, no transparency.  The
fewer calculations Rev has to do to render the image/s on the card, the
faster the transition can be.

2) If possible, don't do a "real" scaling effect.  Instead, create the
in-between frames in advance and show those, for example, as icons of a
button.  But again, given the size of the image, the delay between image
updates may still be too great, and of course, you probably want to do this
on-the-fly with any given images.

I just realized you mentioned Windows platform, so QT effects are probably
out.  But FWIW, I've seen the QT effects do blend/dissolve effects very
quickly, though I'm pretty sure the advanced ones are limited to OSX.

Sorry the above isn't much help.

Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
-
E: [EMAIL PROTECTED]
W: http://www.tactilemedia.com

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


RE: Help with image effect

2005-10-23 Thread MisterX
Alex, 

Great effect!!!

Strange, my portable PC 1.6Ghz is faster than my 3Ghz PC ;)

3Ghz = smooth transition
1.6Ghz = instantaneous...

what you could do is test the function to see how much time it takes.
Given that, increment or decrement the number of transitions...

Also a percentage increase in size may look smoother but that's just
a habit and it may slow down things...

Last bit, that would be cool, is to switch layers so that the zoomed
image becomes the top image in the middle of the transition ;)

cheers
Xavier

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Alex Tweedly
> Sent: Sunday, October 23, 2005 8:51 PM
> To: How to use Revolution
> Subject: Help with image effect
> 
> 
> 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
> 
> ___
> use-revolution mailing list
> use-revolution@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage 
> your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


RE: Help with image effect

2005-10-24 Thread MisterX
 slower draw = laag...

so how do you optimise this? You play the animation once to get the
cpu/refresh speed at a number of pnumber draws - which is equal to a number
of milliseconds... so the rest is drawing only within the number of cycles
you need to. So for 24 fps, you send a draw or wait for the number of
milliseconds to draw or (if millisecond mod (fps+-tolerance) is not your
redraw speed, then DRAW... 

Major tip: Don’t check for x more milliseconds after last redraw to draw,
check to the "time" to draw... This is the milliseconds mod drawtimeinFPM
(frames per ms).

Putting this into practice is the next step... which I leave as exercise...
for the cunning scripter... but it's not hard

repeat wathever
  wait x mod milliseconds
  change things timefactor by pnumber
  draw next step
end repeat

BTW, this is dear to my animation routine in MoireX Volume 2 - the rev
screen saver...

http://www.monsieurx.com/modules.php?name=News&file=article&sid=160

but how many poligons can you get to move smoothly?

adding rotation ideas? swap and twist the object's rects? what if the
control is a movie and it's playing? ;)

anyone think rev should support opengl? How far can Rev take multimedia with
a simple idea?

cheers
Xavier
http://monsieurx.com/taoo

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of MisterX
> Sent: Monday, October 24, 2005 7:04 AM
> To: 'How to use Revolution'
> Subject: RE: Help with image effect
> 
> Alex, 
> 
> Great effect!!!
> 
> Strange, my portable PC 1.6Ghz is faster than my 3Ghz PC ;)
> 
> 3Ghz = smooth transition
> 1.6Ghz = instantaneous...
> 
> what you could do is test the function to see how much time it takes.
> Given that, increment or decrement the number of transitions...
> 
> Also a percentage increase in size may look smoother but 
> that's just a habit and it may slow down things...
> 
> Last bit, that would be cool, is to switch layers so that the 
> zoomed image becomes the top image in the middle of the transition ;)
> 
> cheers
> Xavier
> 
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Alex 
> > Tweedly
> > Sent: Sunday, October 23, 2005 8:51 PM
> > To: How to use Revolution
> > Subject: Help with image effect
> > 
> > 
> > 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,
> &g

Re: Help with image effect

2005-10-24 Thread Alex Tweedly

MisterX wrote:


Alex

Here's the new script I made - note that now it's TAOO style ;)
It applies to any control's rect... And it swaps layers at some
point.
 


I like it - almost !

I'm not sure it's safe to swap the layers of an arbitrary control, just 
because you're changing its position - doesn't that affect the tab order 
for focusable controls.


In my specific case, what I'm actually doing is raising the layer of the 
two images I'm swapping to the top (otherwise they flicker in and out of 
view as the pass behind / in front of the other intervening images. 
(Think "jigsaw puzzle").



What's TAOO about this handler? It handles any occasion! It was
improved, it's shared among the community for more ideas!

 


Thanks!


anyone think rev should support opengl? How far can Rev take multimedia with
a simple idea?

 

I think OpenGL would be good  though I struggle to do much exciting 
stuff with images (far less sound and video), so I'm not sure I'd be 
able to make good use of it - but I'd sure like to have the chance.


--
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.5/147 - Release Date: 24/10/2005

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Help with image effect

2005-10-24 Thread Alex Tweedly

Scott Rossi wrote:


Without seeing exactly what you're doing, I'll go out on a limb and guess

that yes, the images are too large for Rev to really do this smoothly.  If
Rev had some kind of direct-to-screen option, this might be doable, but the
images are probably a bit large for Rev to do natively. Three suggestions:

 

Thanks Scott - that gave me the confidence that I'm not missing anything 
too obvious, so I pressed ahead.



1) If possible, map the images down to 8 bit color, no transparency.  The
fewer calculations Rev has to do to render the image/s on the card, the
faster the transition can be.

2) If possible, don't do a "real" scaling effect.  Instead, create the
in-between frames in advance and show those, for example, as icons of a
button.  But again, given the size of the image, the delay between image
updates may still be too great, and of course, you probably want to do this
on-the-fly with any given images.
 

You're right - arbitrary images (sections from an entire image supplied 
by the user).


I've simply limited the max size of any image that I am trying to 
animate. The user can always override my choices and make bigger 
sections - and choose whether to disable the animation feature.



--
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.5/147 - Release Date: 24/10/2005

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Help with image effect

2005-10-25 Thread Alex Tweedly

MisterX wrote:


Alex

Here's the new script I made - note that now it's TAOO style ;)
It applies to any control's rect... And it swaps layers at some
point.
The third parameter is a bit improved and the layer switch couldn't
be smarter - no detection needed however it will switch one image's 
layer above anything else... That can be changed correctly with a 
bit more scripting...


 

I've changed this (hopefully improved it) some more, so here it is back 
to add to your library.


I've made the movement more "natural", and I've added a couple of more 
parameters to support that.


The objects now accelerate from rest up to a "turnover" point, and then 
decelerate to a stop.


on imageSwap pObj1, pObj2, pNumber, pTurnover, pTime

pNumber : number of steps to make the move
pTurnover : number of steps of acceleration (remainder are deceleration)
pTime : number of msec between each step (assuming hw can keep up)

for my jigsaw puzzle game, I'll set the turnover at around 3/4 of the 
total - so the pieces speed up and then screech into place just in time :-)


(note it puts the moving objects on the top layers - up to you whether 
to do that or swap their layers).



on mouseUp
 imageswap the long name of img 1, the long name of img 2,fld 1
end mouseUp

 



on imageSwap pObj1, pObj2, pNumber, pTurnover, pTime
   local r1, r2
   local dtlx, dtly, dbrx, dbry
   local tDecc, tRemain
   local tLast
   
   if paramCount() < 3 or pNumber is not a number or pNumber < 3  then

   put 20 into pNumber
   end if
  
   if paramCount() < 4 or pTurnover is not a number or pTurnover > 
pNumber  then

   put pNumber / 2 into pTurnover
   end if
  
   if paramCount() < 5 or pTime is not a number  then

   put 72 into pTime
   end if
  
   set the layer of pObj1 to the number of layers on this card + 1

   set the layer of pObj2 to the number of layers on this card + 1
   
   put the rect of pObj1 into r1

   put the rect of pObj2 into r2
   
   -- Accelerate from rest until pTurnover, then decelerate to stop at 
pNumber
  
  
   -- assume acc = 1, so decc can be calculated

   --   v-turn = acc * turnover =  decc * remaining time
   put (pNumber - pTurnover) into tRemain
   put pTurnover / tRemain into tDecc
  
   -- now calculate distance
   put 0.5  * pTurnover^2 + pTurnover * tRemain  - 0.5 * tDecc * 
tRemain^2 into tDelta
 
   put (item 1 of r2 - item 1 of r1)/tDelta into dtlx

   put (item 2 of r2 - item 2 of r1)/tDelta into dtly
   put (item 3 of r2 - item 3 of r1)/tDelta into dbrx
   put (item 4 of r2 - item 4 of r1)/tDelta into dbry
   
   put 0 into N

   put the millisecs into tLast
   repeat with i = 1 to pNumber
   if i <= pTurnover then
   put 0.5 *  i^2   into N
   else
   put 0.5 *  pTurnover^2 + pTurnover*(i-pTurnover) - ( 0.5 * 
tDecc * (pTurnover-i)^2 )  into N

   end if
   set the rect of pObj1 to trunc(item 1 of r1 + N*dtlx), 
trunc(item 2 of r1 + N*dtly), trunc(item 3 of r1 + N*dbrx), trunc(item 4 
of r1 + N*dbry)
   set the rect of pObj2 to trunc(item 1 of r2 - N*dtlx), 
trunc(item 2 of r2 - N*dtly), trunc(item 3 of r2 - N*dbrx), trunc(item 4 
of r2 - N*dbry)

   if the millisecs < tLast + pTime then
   wait (tLast + pTime - the millisecs) milliseconds with messages
   put the millisecs into tLast
   end if
   end repeat
   
end imageSwap


--
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.5/148 - Release Date: 25/10/2005

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution