Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Color Array on Fill effect assigned to Slider

  • Color Array on Fill effect assigned to Slider

    Posted by Terje Lundgren on October 22, 2015 at 1:04 pm

    How do I get this to work?

    if sliderValue is 0, color value in colors[0] is assigned to Fill -> Color.
    if sliderValue is 1, color value in colors[1] is assigned, etc…

    colors = [[0/255,0/255,0/255,255/255],[128255,128/255,129/255,255/255],[114/255,25/222,26/255,255/255],[12/255,62/255,0/255,255/255]]; //etc...
    sliderValue = Math.floor(comp("mainComp").layer("COLOR_ADJUSTMENT").effect("Slider Control")("Slider"))).value;
    value = colors[sliderValue];

    /Terje

    Chris Scalzo replied 10 years, 6 months ago 3 Members · 7 Replies
  • 7 Replies
  • Kalleheikki Kannisto

    October 22, 2015 at 1:23 pm

    I think you just need to take the “.value” out at the end of the second line.

  • Terje Lundgren

    October 22, 2015 at 1:56 pm

    Oh.. You are right. Thanks. There was a “)” too many in the code as well. Updated below in case someone wants to use it.

    However, this expression is very picky and breaks if the sliderValue goes out of range.

    Is there a way to prevent that?

    colors = [[0/255,0/255,0/255,255/255],[128255,128/255,129/255,255/255],[114/255,25/222,26/255,255/255],[12/255,62/255,0/255,255/255]]; //etc...
    sliderValue = Math.floor(comp("mainComp").layer("COLOR_ADJUSTMENT").effect("Slider Control")("Slider"));
    value = colors[sliderValue];

    /Terje

  • Terje Lundgren

    October 22, 2015 at 2:21 pm

    no luck in preventing the expression to break with the code below.

    value = colors[sliderValue];

    if (sliderValue > colors.length)
    value = [0/255,0/255,0/255,1]
    if (sliderValue < 0)
    value = [0/255,0/255,0/255,1]

    /Terje

  • Terje Lundgren

    October 22, 2015 at 2:28 pm

    Found Dan’s solution, which seems to work when applied to the slider!

    linear(value,1,100,1,100)

    /Terje

  • Chris Scalzo

    October 22, 2015 at 4:28 pm

    Whenever I make templates like this I tend to use the Color Control expression control instead. Then on top of Hue, saturation and brightness controls; end users can use the dropper to select colors.

  • Terje Lundgren

    October 22, 2015 at 7:49 pm

    Thanks for the input Chris. I agree the dropper is very convenient. Just a little bit more risky when you have to stick to a restricted palette.

    /Terje

  • Chris Scalzo

    October 22, 2015 at 8:23 pm

    That is exactly why I use the picker. We put guide layers with color palate for the appropriate show instead of a slider.

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