Skip to main content
Participant
May 4, 2020
Answered

Opposite expression

  • May 4, 2020
  • 2 replies
  • 2422 views

Hi All,

New to exploring simple expressions and a bit stuck.
I know I can use this expression to mimic a different layer's movement:

thisComp.layer("flat earthers").transform.scale

 

What do I need to add to this expression to make it do the opposite movement? As one layer grows the other shrinks.

 

Thanks,

 

Alec

This topic has been closed for replies.
Correct answer alec

Thanks. going to try this today

 

2 replies

Community Expert
May 4, 2020

Martin's expression will set the scale of the layer with the expression to zero when the target (flat earthers) layer is at 100%. If you want to maintain the original scale of both layers you need to divide the target layer's scale by 100.  For example, if you had two rectangles making up a bar chart and both layers made up the entire bar, then adding this expression to the slave layer would keep the total width of the bar the same while changing the ratio between the two layers:

 

// Constant Width for both layers
target = thisComp.layer("Target").scale / 100;
[value[0] / target[0], value[1]]

 

This would be very useful if you were creating an animated chart showing believers vs non-believers as part of the total population.

 

If you want to keep the total area of both layers the same just modify the last line like this:

 

//Constant area for both layers
target = thisComp.layer("Target").scale / 100;
[value[0] / target[0], value[1] / target[1]]

 

alecAuthorCorrect answer
Participant
May 12, 2020

Thanks. going to try this today

 

Martin_Ritter
Legend
May 4, 2020

In a basic layout, you can just subtract the other layers scale from the current scale:

 

//assuming the layer scale is 100 by default

100 - thisComp.layer("flat earthers").transform.scale;

 

Example results:

flat earthers scale = 100    target layer scale = 0

flat earthers scale = 75      target layer scale = 25

flat earthers scale = 5        target layer scale = 95

 

*Martin