Highlighted

## Opposite expression

Community Beginner ,
May 04, 2020

Copy link to clipboard

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

Community Beginner
| Community Beginner

Thanks. going to try this today

TOPICS
Expressions

Views

321

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

## Opposite expression

Community Beginner ,
May 04, 2020

Copy link to clipboard

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

Community Beginner
| Community Beginner

Thanks. going to try this today

TOPICS
Expressions

Views

322

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 0
3 Replies 3
Guide ,
May 04, 2020

Copy link to clipboard

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 0
Adobe Community Professional ,
May 04, 2020

Copy link to clipboard

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
May 04, 2020 0
Community Beginner ,
May 12, 2020

Copy link to clipboard

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
May 12, 2020 0