Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Linking Fill Color to Rotation

  • Linking Fill Color to Rotation

    Posted by Nick Adcock on May 3, 2010 at 9:22 pm

    I need to create a simple expression that links the fill of a layer to its rotation. I have many layers that all need to turn from white to different shade of blue as they turn. The don’t need to turn gradually just change at the 90 degree mark so when they flip over they are the blue color. So the color can turn on and off.

    Thanks in advance.

    Dan Ebberts replied 12 years, 5 months ago 4 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    May 3, 2010 at 9:51 pm

    Play around with this fill color expression:

    color1 = [255,255,255,255]; // white + alpha
    color2 = [87,110,163,255]; // shade of blue + alpha
    r = transform.rotation;
    if (r > 90) color2/255 else color1/255

    Dan

  • Nick Adcock

    May 4, 2010 at 2:06 pm

    Thank you Dan and thank you for monitoring these boards like you do and being so damn good at actionscript.

    I did a slight mod for the y rotation and different rotation values but it worked perfectly.

    color1 = [255,255,255,255]; // white + alpha
    color2 = [87,110,163,255]; // shade of blue + alpha
    r = transform.yRotation;
    if (r < -90) color2/255 else color1/255

  • Joel Young

    April 1, 2011 at 1:52 pm

    I’m trying something similar to this, but I want the color to be driven by the value of a text layer. I’m going for a conditional statement, but even when I simplify it I am not getting the desired results. It seems to just return the value of the first if statement no matter what.

    color1 = [255,255,255,255];
    color2 = [0,255,0,255]; // Green
    color3 = [255,0,0,255]; // Red

    c = thisComp.layer("Text1").text.sourceText;

    if (c = "Green")
    color2/255;
    else if (c = "Red")
    color3/255;
    else
    color1/255;

  • Dan Ebberts

    April 1, 2011 at 3:27 pm

    In your if statements, change “=” to “==”.

    Dan

  • Joel Young

    April 1, 2011 at 4:09 pm

    Works perfect. Thank you very much for showing me ==, now the search results show a lot more information.

  • Evan Hancock

    November 28, 2013 at 5:45 am

    Hi there,

    I know this thread is quite old but had a question in regards to the following expression.

    What do I add or replace to the expression to fade to from color 1 to color 2?

    color1 = [255,255,255,255]; // white + alpha
    color2 = [87,110,163,255]; // shade of blue + alpha
    r = transform.rotation;
    if (r > 90) color2/255 else color1/255

  • Dan Ebberts

    November 28, 2013 at 7:57 am

    if you want the color to fade based on the value of r (say as r goes from 90 to 95), you could do it by replacing the last line with something like this:

    linear(r,90,95,color1/255,color2/255)

    Dan

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