example slideshow expression
Hi,
I recently wrote a (simple) expression for generating a slideshow of images, and I thought I'd post it here. It's very basic, it just slides the images in (& out) from (& to) the left, top, right, bottom, again the left and so on. To use it, place the images on different tracks and assign the expression to the position property of the tracks. The duration of the tracks should equal (tscrollin + thold + tscrollout). You'd probably also want to make sure tscrollin == tscrollout == the overlap between the tracks. For instance, with tscrollin = tscrollout = 1 s and thold = 4 s, make the duration of your images 6 s, and the overlap between them 1 s. So image1 starts at 0 & ends at 6, image2 starts at 5 & ends at 11, and so on. I hope this might be useful to somebody somehow and I'd be happy to elaborate if necessary.
w = this_comp.width;
h = this_comp.height;
// timing
tstart = start_time;
tscrollin = 1.0;
thold = 4.0;
tscrollout = 1.0;
// positioning
// p1 -> pc (scrollin); pc (hold); pc -> p2 (scrollout)
pcx = w/2; pcy = h/2; // center position
if((index % 4) == 0)
{ p1x = w/2 + w; p1y = h/2;
p2x = w/2; p2y = h/2 - h;
else
{ if((index % 4) == 1)
{ p1x = w/2; p1y = h/2 + h;
p2x = w/2 + w; p2y = h/2;
else
{ if((index % 4) == 2)
{ p1x = w/2 - w; p1y = h/2;
p2x = w/2; p2y = h/2 + h;
else
{ p1x = w/2; p1y = h/2 - h;
p2x = w/2 - w; p2y = h/2;
ctime = time;
ctime -= tstart;
if(ctime < 0)
{ mypos = [p1x, p1y];
else
{ if(ctime < tscrollin)
{ fac = Math.sin(0.5*Math.PI*ctime/tscrollin);
fac *= fac;
mypos = [((1.0 - fac)*p1x + fac*pcx), ((1.0 - fac)*p1y + fac*pcy)];
else
{ ctime -= tscrollin;
if(ctime < thold)
{ mypos = [pcx, pcy];
else
{ ctime -= thold;
if(ctime < tscrollout)
{ fac = Math.sin(0.5*Math.PI*ctime/tscrollout);
fac *= fac;
mypos = [((1.0 - fac)*pcx + fac*p2x), ((1.0 - fac)*pcy + fac*p2y)];
else
{ mypos = [p2x, p2y];
mypos
Posting-Information:
Date: Tue, 9 Sep 2003 17:49:16 -0700