FORUMS: list search recent posts

# Flowing Layers Expression?

FAQ   •   VIEW ALL
 Flowing Layers Expression? on Mar 19, 2014 at 5:13:45 pm

Long time lurker, first time poster.

I was looking to recreate a video effect I saw at the Cleveland Museum of Art with either a plugin or expressions and was hoping someone would know of something I could use. The effect can be seen here in this fairly crappy youtube clip starting at around 11 seconds:

The effect is that multiple layers are moving across the screen, and when something is highlighted and scaled up, all the rest of the layers flow around it and then back to their original positions. Any ideas?

--
End transmission.

 Re: Flowing Layers Expression?on Mar 26, 2014 at 2:01:06 pm

So to get this done, I figured I'd break the animation into two separate expressions: one for position and one for scale. Using the Colin Braley repel expression as a base, this is what I came up with for scale:

```avoidSca = thisComp.layer("Avoid Me").scale; avoidPos = thisComp.layer("Avoid Me").position; minDistance = thisComp.layer("Scale Controls").effect("min distance")("Slider"); //minimum distance to begin scaling //-- sca = length ( avoidSca ); pos = position - avoidPos scaMin = mul(scale,.3) distance = length( pos ); scaDif = ease(sca, 433, 174, scale, scaMin); displaceAmt = ease( distance , minDistance, 0 , scaDif , scale);```
This assumes that "avoid me" has a starting scale value of 100%, but then the objects around it don't start to scale down until "avoid me" scales up.

I was thinking of using his return to original position expression to reposition the layers, but I really only want the layers to move out of the way on the y axis only. Any ideas on how to configure this so it only writes to the y value of the layer?

```avoidPos = thisComp.layer("Avoid Me").position; maxDisplacement = 85; //maximum amount to move the layer minDistance = 50; //minimum distance to begin displacing at //-- vec = avoidPos - position; directionVec = normalize( vec ); distance = length( vec ); displaceAmt = ease( distance , 0 , minDistance , 0, maxDisplacement ); displacementVec = displaceAmt * directionVec; position + displacementVec ```

Thanks!

--
End transmission.

 Re: Flowing Layers Expression?on Mar 26, 2014 at 6:34:00 pm

Well this is what I ended up coming up with. The "avoid me" layer is only moving along the x axis, so all the layers simply look at whether they are above or below to determine which way they travel round. Just posting my code here in case it helps someone else.

```avoidPos = thisComp.layer("Avoid Me").position; avoidSca = thisComp.layer("Avoid Me").scale; maxDisplacement = thisComp.layer("Position Controls").effect("max disp")("Slider"); //maximum amount to move the layer minDistance = thisComp.layer("Position Controls").effect("min distance")("Slider"); //minimum distance to begin displacing at //-- vec = position - avoidPos; direction = normalize (vec); yvec = length ( vec ); if ( direction[1] >= 0 ){ yfinal = ease(yvec, minDistance , 0 , value[1]+maxDisplacement, value[1]); } else { yfinal = ease(yvec, minDistance , 0 , value[1]-maxDisplacement, value[1]); } [value[0],yfinal,value[2]]```

--
End transmission.