• Opposite expression

Opposite expression

Community Beginner ,
May 04, 2020 May 04, 2020

Copied

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

TOPICS
Expressions

Views

803

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Community Beginner , May 12, 2020 May 12, 2020
Thanks. going to try this today

Likes

5 Replies 5
Mentor ,
May 04, 2020 May 04, 2020

Copied

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

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 04, 2020 May 04, 2020

Copied

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

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
May 12, 2020 May 12, 2020

Copied

Thanks. going to try this today

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Apr 14, 2022 Apr 14, 2022

Copied

Hi,

Have found this expression very useful, however it only scales the width. What if I have a 2 squares. The Master and the child. They are both at 100% scale to begin with. So as I scale up the Master the child copy scales down whilst maintaning its correct proportions. And then when I scale back down the Master to 100% the child scales back up to 100%

Have attached a screen grab of what I am trying to achieve.

many thanks

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Apr 14, 2022 Apr 14, 2022

Copied

LATEST

Hi,

Have found this expression very useful, however it only scales the width. What if I have a 2 squares. The Master and the child. They are both at 100% scale to begin with. So as I scale up the Master the child copy scales down whilst maintaning its correct proportions. And then when I scale back down the Master to 100% the child scales back up to 100%

Have attached a screen grab of what I am trying to achieve.

many thanks

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources
Troubleshooting FAQs
After Effects Community Recap
Getting started with After Effects