Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Expression for Inverse Opacity Scaling

Explorer ,
Oct 19, 2022 Oct 19, 2022

Hey there everyone,

 

I currently have two layers:

 

One layer is a shape layer with a slider control, and the other layer is a solid with an effect on it. I'm wondering if there's an expression wherein as I incrase the value of the slider (0-100) the value of the opacity increases wherein when the slider is at 100, the opacity of the layer with an effect on it is at 0, or when the slider is at 0, the opacity of the layer with an effect is at 100. 

 

The reason for this is I'm planning on pairing the slider control layer to a master slider control that increases the values of a whole bunch of different effects wherein as I increase the master control all the different effects slowly reveal themselves. 

 

Thank you

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

correct answers 1 Correct answer

Community Expert , Oct 19, 2022 Oct 19, 2022

There are two ways to approach this. The first is to attach the slider to the master layer's opacity and then attach the opacity of the layer below to the opacity of the master with this expression:

 

t = thisComp.layer("Master Layer").transform.opacity;
100 - t

 

If the master layer is at 100%, the other layer will be at 0%.

 

The other way to do this would be to tie the Opacity of both layers to the slider with two different expressions:

 

// Master layer opacity
t = effect("Master Opacity")("
...
Translate
Community Expert ,
Oct 19, 2022 Oct 19, 2022

There are two ways to approach this. The first is to attach the slider to the master layer's opacity and then attach the opacity of the layer below to the opacity of the master with this expression:

 

t = thisComp.layer("Master Layer").transform.opacity;
100 - t

 

If the master layer is at 100%, the other layer will be at 0%.

 

The other way to do this would be to tie the Opacity of both layers to the slider with two different expressions:

 

// Master layer opacity
t = effect("Master Opacity")("Slider");
t = linear(t, 0, 100, 0, 100);


// Follow layer opacity
t = thisComp.layer("Master Layer").effect("Master Opacity")("Slider");
linear(t, 0, 100, 100, 0)

 

I prefer the first method, and I use the Linear method for the second so no out-of-range values will be sent to Opacity.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 26, 2022 Oct 26, 2022
LATEST

Hey there Rick,

 

Thank you very much for both these options, I went with the first and it worked perfectly! 

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