Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Controlling color and scale with a Null’s position?

  • Controlling color and scale with a Null’s position?

    Posted by Simon Terrey on September 21, 2015 at 3:55 pm

    Hi everyone!

    I’m making a timeline where when I move a Null, data panels attached to the timeline scale in size.
    I’ve managed to find a script to do this (which I assign to the scale parameter of the data panels):

    So when I move the Null (called Scale_Control) towards the panels the panels grow! Great. But what I want to do as well is change their color as they grow in size and go back to their original color when the Null has passed-on. I’ve looked everywhere and know I need to convert the colors to HLS with an array (I think) and use a similar approach to the scale expression above but I can’t get it to work.
    Hope you can help?

    mouse_layer = thisComp.layer("Scale_Control");//Mouse layer
    beginScale = 75;//Scale begins at this
    endScale = 100;//Scale ends at this
    beginDistance = 200;//Distance to begin magnifying in pixels
    endDistance = 0;//Distance to end magnifying in pixels
    //--Don't modify below here
    dis = length(this.position, mouse_layer.position);
    val = ease(dis, beginDistance, endDistance, endScale, beginScale);
    [val, val]

    Simon Terrey replied 10 years, 7 months ago 2 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    September 21, 2015 at 4:24 pm

    You didn’t mention exactly what you want the color to do.

    Dan

  • Simon Terrey

    September 21, 2015 at 4:26 pm

    Hi Dan,

    I just wanted it to change from grey to orange as it scales-up, then go back to grey when it scales back-down again.

  • Dan Ebberts

    September 21, 2015 at 4:37 pm

    If you applied a Fill effect you could use something like this on the Color parameter:


    mouse_layer = thisComp.layer("Scale_Control");//Mouse layer
    beginColor = [.5,.5,.5,1]; // grey
    endColor = [1,.5,0,1]; // orange
    beginDistance = 200;//Distance to begin magnifying in pixels
    endDistance = 0;//Distance to end magnifying in pixels
    //--Don't modify below here
    dis = length(this.position, mouse_layer.position);
    ease(dis, beginDistance, endDistance, endColor, beginColor);

    Dan

  • Simon Terrey

    September 21, 2015 at 4:45 pm

    Hi Dan,

    Many thanks for getting back to me with this!

    I’ve just tried it on the Fill layer (of my shape layer) and it returned with this:

    Error at line 0 in property ‘Color’ of layer 15 (‘DataPanel 11’) in comp ‘Timeline’.
    Object of type Layer found where a Number, Array, or Property is needed.

    This was the message that flagged-up when I tired other techniques earlier…

  • Dan Ebberts

    September 21, 2015 at 5:00 pm

    I hadn’t tried it on a shape layer (I was using a solid with the Fill effect), but it seems to work fine for me (with a shape layer, the anchor point will need to be at the center of the shape). The only way I can generate your error message is to leave out everything except the first line.

    Dan

  • Simon Terrey

    September 21, 2015 at 5:17 pm

    Hi Dan,

    I’ve just tried uploading a small comp aep file with my controller Null and a shape layer (and a new solid with fill) to show you what i’m doing.
    I tried your expression on a new Solid with a fill and it flagged the same error message!
    Are expressions different between CC versions by any chance?

    Simon

  • Simon Terrey

    September 21, 2015 at 5:24 pm

    Hold the fort!

    I’ve got it working. When I paste the expression in, it goes in on one line.
    As soon as I added returns at the end of each line to match-up with the original the error message went away and it’s all good!

    Dan the Man!

    Thank you very much.

    Simon

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