Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions pickwhip colour values to other values?

  • pickwhip colour values to other values?

    Posted by Emma Nichols on May 26, 2011 at 11:27 pm

    Hi, This may seem basic but I am really struggling to understand this…trying my best as a beginner.

    colour has RGBA values and I know that this is 0 1 2 3 dimensions

    but how would I pickwhip other values to the individual rgba values or the average of them?

    I currently have a layer with a colour fill

    I am trying to use the rgba values of the colour fill to control other values

    scale and position (x y Z)

    thanks

    Darby Edelen replied 14 years, 11 months ago 3 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    May 27, 2011 at 12:03 am

    It depends on exactly what you want the relationship between the color and the transform to be, but here’s a simple example where the red level controls the x scale and the blue level controls the y scale (maximum scale value = 100):

    c = effect(“Fill”)(“Color”);
    [c[0],c[2]]*100

    Dan

  • Darby Edelen

    May 27, 2011 at 7:58 pm

    [Emma Nichols] “colour has RGBA values and I know that this is 0 1 2 3 dimensions

    but how would I pickwhip other values to the individual rgba values or the average of them?”

    A color is an array, or vector, in After Effects. So you can access each of its parts individually. For example:


    color = effect("Fill")("Color");
    average = (color[0] + color[1] + color[2] + color[3]) / 4;

    Element 0 is Red, element 1 is Green, 2 is Blue and 3 is Alpha. If you didn’t want to include the alpha in the average you would use:


    color = effect("Fill")("Color");
    average = (color[0] + color[1] + color[2]) / 3;

    The values that are returned from the array are going to be float values where black is equal to 0 and white is equal to 1. This means you will likely need to remap the values to fit your needs. If you want black to translate to an upper left coordinate in the composition and yellow to translate to lower right (red increases along x and green increases along y), then you could do something like this:


    color = effect("Fill")("Color");
    x = linear(color[0], 0, 1, 0, thisComp.width);
    y = linear(color[1], 0, 1, 0, thisComp.height);
    [x,y]

    The ‘x’ variable checks the Red channel. If there is no red (0) then it returns 0, if there is full red (1) then it returns thisComp.width. The ‘y’ variable does the same but for the Green channel.

    Darby Edelen

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