Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Help with Variable Color expression

  • Help with Variable Color expression

  • Anthony Kounouklos

    May 26, 2022 at 8:00 pm

    I’m working on a graphic where I have four colors that the client wants to use. Red, Orange, Yellow, and White. I have 20 lines with strokes and they are Color Filled. I have a Color Control layer set up with the four colors. I then linked them. Now the challenge is that the client wants the colors to slightly change from Red to Orange to Yellow and eventually to white. As each successive bar is animated on, I need the expression to look at the previous layer and ” say your red, this layer needs to be slightly less red but more Orange”. The first five will be iterations of Red. The Next 5 will start at Orange and slowly evolve into Yellow. The Next Five go from Yellow to White.

    I would like to avoid doing this manually. If someone could explain to me a method to set the script up, I would greatly appreciate it.

     

    Thanks.

  • Adam Greenberg

    May 26, 2022 at 9:04 pm

    i have a text layer that animates through 4 different colors but its more gradual, so you will need to edit it with some sort of index which Im not fully sure how to do. ill post it here in the next post hopefully it will get you closer to where you need to be

  • Adam Greenberg

    May 26, 2022 at 9:20 pm
  • Anthony Kounouklos

    May 26, 2022 at 11:15 pm

    Adam,

    Thank you for sending this. I’ll let you know how I make out with it.

  • Anthony Kounouklos

    May 27, 2022 at 7:33 pm

    Adam,

    I took a look at the project you sent. It’s cool, but not what I need. What I’m trying to figure out is a way to Change the Color of every line of a graphic to be a different color, but have it restricted to the 4 colors that the client requested. Red, Orange, Yellow and white. Now, if you can image there are 20 total lines that come on. 1st is Red, 2nd reddish Orange, 3rd more orangy red, 4th-> Organgy, 5th Orange, then 6th line Orange/Yellow-> as the lines keeping going the color of each successive line is more Yellow until the 10th one is full Yellow. This would continue until we get to White by the 20th line.

    I made a 4 color gradient and hand sampled every color for all 20 lines that animate on. I was hoping to automate this with a script because as we all know the client is going to want to use 4 different colors.

    Thanks

  • Adam Greenberg

    May 30, 2022 at 2:44 pm

    Oh i misunderstood, is there any animation in the color, if not i suspect this is super easy, can you post a jpeg of what you want it to look like, (or if its animated, ) a quicktime ?

  • Filip Vandueren

    May 30, 2022 at 4:01 pm

    You would either.use the linear() method on the intermediate lines to calculate intermediate colors.

    so line 1’s stroke color is something like;

    thisComp.layer("control").effect("color A")("Color")

    line 10’s stroke color is:

    thisComp.layer("control").effect("color B")("Color")

    the 9 lines in between have:

    percentage=50;
    linear(percentage,0,100,
    thisComp.layer("control").effect("color A")("Color"),
    thisComp.layer("control").effect("color B")("Color")
    );

    With percentages 10,20,30,40,…90

    OR,

    you make your artwork in grayscales from dark to light and use CC Toner to map those grayscales to up to 5 tones. For an even distribution of 4 colors I would use colors between 0 and 80% gray and disregard the 5th swatch of Toner Pentone mode

  • Dan Ebberts

    May 30, 2022 at 4:35 pm

    The trick is that the expression needs to determine which layer it’s currently working with. This example uses the layer index, but have to define the first and last index in the expression (you might also be able to calculate it from the layer name):

    colors = [[1,0,0,1],[1,.5,0,1],[1,1,0,1],[1,1,1,1]];

    firstIndex =1;

    lastIndex = 20;

    numColors = colors.length;

    idx = (index - firstIndex)/(lastIndex-firstIndex);

    colorIdx = idx*(numColors-1);

    if (colorIdx%1 != 0){

    color1 = colors[Math.floor(colorIdx)];

    color2 = colors[Math.floor(colorIdx) + 1];

    linear(colorIdx%1,0,1,color1,color2);

    }else{

    colors[colorIdx];

    }

Viewing 1 - 8 of 8 posts

Log in to reply.

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