Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expression to invert the opacity of a layer based on another

  • Expression to invert the opacity of a layer based on another

    Posted by Chris Huggett on September 26, 2007 at 3:14 pm

    Hi guys

    Im pulling my hair out at what should be a simple expression but no matter how hard i think, i just can’t get my head around it and need some help please.

    I have a layer (layer 1)that has to have its opacity at 100% throughout the comp. At certain times during my comp, another layer (layer 2) has it opacity at 100. This layer has markers on it that represent opacity at 100%. At all other times its at 0%. So what I need is layer 1 to be 0% at the markers or similarly, when that layer is at 100%. So basically it just needs to invert.

    At the moment my expression is linked to layer 2s opacity +100

    This should be simple but i can’t figure it out.

    Thanks for your help

    Mike Clasby replied 18 years, 7 months ago 3 Members · 5 Replies
  • 5 Replies
  • Steve Roberts

    September 26, 2007 at 3:31 pm

    If A=100, B=0.
    If B=0, A=100.
    Assuming … if A=25, B=75, if A=85, B=15.

    Therefore A+B=100
    … and B=100-A.

  • Chris Huggett

    September 26, 2007 at 3:33 pm

    Hi Dave

    For a number of reasons really. Im trying to get more into expressions and the more i do the more i learn. it keeps my comp nice and neat and manageable and in my comp, i have a layer with nearly 85 markers. At every marker, i need layer 1s opacity to be at 0%. Although your solution is a very good one, id rather avoid it.

    As it turns out, i stepped away from my machine, had a coffee and came back and it came to me. All i had to do was to multiply the opacity by -1 the add 100. It works just fine now.

    Thanks for your reply though. I appreciate all help on this great resource, the Cow.

    Chris

  • Steve Roberts

    September 26, 2007 at 4:14 pm

    (-1*a)+100 is the same as 100-a, no? 😉

  • Mike Clasby

    September 26, 2007 at 4:22 pm

    This If statement seems to do what you want, on the other layer’s Opacity:

    op = thisComp.layer(“2s”).opacity;
    if (op < 100) 100 else 0 Assuming the contolling layer is named "2s". Dan explains if statements here: https://www.motionscript.com/mastering-expressions/language-beginning-4.html

    So anytime layer 2s’s opacity drops below 100, the layer with the expression’s opacity will be 100. If layer 2s is at 100, the other layer will be at 0.

  • Mike Clasby

    September 26, 2007 at 4:30 pm

    This linear interpolation on Opacity, does the same thing:

    op = thisComp.layer(“2s”).opacity;
    linear(op, 0, 100, 100, 0)

    Well, it’s not really the same thing, it gives you the inverse opacity of layer 2s. It just says as the opacity of 2s (op) changes from 0 to 100, change the opacity of this layer from 100 to 0.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy