Hi,

lambda (aka anonymous, locally-defined function) is your friend:

fadeIn(image1,
  lambda: hold(dur=5000,
    lambda: crossfade(image1, image2, dur=2000,
      lambda: hold(dur=5000))))

Also, have a look at the libavg test infrastructure:

  src/test/testcase.py, AVGTestCase.start() and .nextAction()

start() takes a list of python functions and calls one each time
nextAction() is called.

Cheers,

  Uli


Frederik Elwert wrote:
> Hello!
> 
> I'm currently using libavg for creating a kind of enhanced slideshow,
> without interactivity. Now one thing I'm struggling with is the callback
> based approach of libavg. This is of course very valuable when creating
> interactive applications, where several things can run simultaneously.
> When creating an animation sequence, this adds some kind of overhead.
> 
> Let's say I want to create a simple photo slideshow that has a crossfade
> of two images and shows each image for a given time. Therefore, I
> created some custom functions that use libavg's API internally. Now I'd
> like to be able to do something like this:
> 
>         fadeIn(image1)
>         hold(dur=5000)
>         crossfade(image1, image2, dur=2000)
>         hold(dur=5000)
> 
> But since all animations are non-blocking, I have to do something like
> this:
> 
>         def step1():
>                 fadeIn(image1, onStop=step2)
>                 
>         def step2():
>                 hold(dur=5000, onStop=step3)
>                 
>         def step3():
>                 crossfade(image1, image2, dur=2000, onStop=step4)
>                 
>         def step4():
>                 hold(dur=5000)
>                 
> Now this is of course much less convenient. So have I totally overseen
> something, is there an easier way to create sequential animations with
> libavg? I thought about at least using time.sleep() instead of
> avg.Player.setTimeout() to get a blocking hold function, but I have the
> impression that time.sleep() is much less exact than using libavg's
> infrastructure.
> 
> If anyone has suggestions to make this kind of work easier, I'd be very
> glad.
> 
> Thanks,
> Frederik

-- 
Any technology distinguishable from magic is insufficiently advanced.

Ulrich von Zadow | +49-172-7872715
Jabber: [EMAIL PROTECTED]
Skype: uzadow

_______________________________________________
libavg-users mailing list
[email protected]
https://mail.datenhain.de/mailman/listinfo/libavg-users

Reply via email to