Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Link Ramp color to Ramp Position

  • Link Ramp color to Ramp Position

    Posted by Achille Abboud on November 30, 2010 at 10:18 am

    I am “deleting” some text from a boat and I want to use the Ramp to be my background.

    The Boat is in moving, so the colors are changing with it. My idea is to mask the text and Add a Solid BG with a ramp fx. I want to link the Boats color to the Position of the Ram Position. My problem is, I don´t yet figure it out, how to tell the “position” what color it is touching. I want to use the information of that Point the my “position” is on and reflect it to the color. In this case I will only have to change (track) the movement of the Ramp position and I might have the perfect Retouch!

    Darby Edelen replied 15 years, 8 months ago 3 Members · 4 Replies
  • 4 Replies
  • Kevin Camp

    November 30, 2010 at 4:39 pm

    you can use sampleImage() to sample a color of a layer.

    something like this may work in the ramp color property (start point):
    target=thisComp.layer("boat"); // the layer you want to sample the color from
    p=toComp(effect("Ramp")("Start of Ramp")); // sets the sample point as the start ramp point
    r=[.5,.5]; // radius of the sample point
    target.sampleImage(p,r)

    to set the end point color, you would apply the same expression to that property and change the ‘p’ variable to the ‘End of Ramp’ property.

    if you needed more color variation, you could try the 4-color gradient effect and apply the same expression to all 4 color properties.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Achille Abboud

    December 1, 2010 at 6:20 pm

    Thank you Kevin. It is working perfectly.

    Now I would like to ask you how to delay the changes, because now that it is working, I would prefer to change the color every -lets say- 10 frames.

    If I would change the Radius Value, would it give the average of the color that is in the Pixel amout?

    so if I wrote r=[10,10];, would it be the Average of a 10 SqueerPixel Value?!

    Thanx again,

    Achille

    Greetings from Berlin,
    Achille

  • Kevin Camp

    December 1, 2010 at 8:44 pm

    [Achille Abboud] “if I wrote r=[10,10];, would it be the Average of a 10 SqueerPixel Value?!”

    yep… that can help to average out the color change.

    [Achille Abboud] “I would prefer to change the color every -lets say- 10 frames.”

    i can’t test this right now (too much rendering going on), but i think you might be able to use posterizeTime() to get something like that…

    try adding this as the first line of the expression:

    posterizeTime(3) // the value in () is in frames per second

    if that doesn’t work there is a time component that can be specified in sampleImage() and we could probably figure out a way to manipulate that.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Darby Edelen

    December 3, 2010 at 7:23 pm

    [Kevin Camp] “if that doesn’t work there is a time component that can be specified in sampleImage() and we could probably figure out a way to manipulate that.”

    This seems to work:

    n = timeToFrames(time) / 10;
    t = framesToTime(Math.floor(n) * 10);
    target.sampleImage(p,r,true,t);

    If you don’t want any jumping in the color you could apply just the first two lines of this expression to a Slider Effect (under Effect > Expression Controls), then link that into the sampleImage() expression with a smooth() method attached.

    Applied to “Slider Control”:

    n = timeToFrames(time) / 10;
    t = framesToTime(Math.floor(n) * 10);

    Then this becomes the last bit of code for the ramp color:

    t = effect("Slider Control")("Slider").smooth(framesToTime(3), 9);
    target.sampleImage(p,r,true,t);

    The above will smooth the transition in color every 10th frame over 3 frames.

    Darby Edelen

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