Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions x and y expression

  • x and y expression

    Posted by Jack Parks on September 17, 2008 at 11:24 am

    Hi,

    I’ve been looking on the forum for an expression and the closest thing I could find are ones where the blur or opacity is affected by a layers z position.

    I would like a layers opacity to be (example)100% when at the centre of the comp, and falloff as the layer nears the edges (moves around x and y) (a slider would be handy so the opacity near the edge could be modified, 25% or 0% etc).

    A basic expression would be really helpful that could be modified and used for opacity or on a blur etc.
    I was trying to set it up based on a toWorld(?) as it would be great if it was flexible to use in different sized projects.
    (Also if z information is included that would be great too).

    Any suggestions would be appreciated.

    Thanks

    (Sorry if this has already been looked at in another post).

    Jack Parks replied 17 years, 10 months ago 2 Members · 4 Replies
  • 4 Replies
  • Mike Clasby

    September 18, 2008 at 1:25 am

    This seems to do what you want. Put a slider on a New Null (to adjust the distance that the layers opacity reacts too like you asked for). Put the expression on the layer’s opacity:

    d = thisComp.layer(“Null 1”).effect(“Slider Control”)(“Slider”);

    point1=this_layer.position;

    x = this_comp.width/2;
    y = this_comp.height/2;
    point2=[x,y];

    delta=sub(point1, point2);// Find the vector between them
    distance=length(delta);// Now find the length
    linear(distance, d, 0, 0, 100);

    It’s a hack from Dan’s stuff.

    If you want an ease on the interpolation change the last line to:

    easeIn(distance, d, 0, 0, 100);

    or

    easeOut(distance, d, 0, 0, 100);

  • Jack Parks

    September 18, 2008 at 2:06 pm

    Hi,
    Thanks for your help I really appreciate it.
    Sorry but I think I am getting something wrong though, the expression seems to have no effect.

    I set up a new comp for a test, with Null 1 and a slider, and a white solid with the expression on opacity.
    I keyframed the white solid to move from top left corner to bottom right corner.
    The solid doesn’t seem to change opacity, moving the slider results in 0% or 100%.
    [The effect I had hoped for was increasing opacity nearer the centre]

    Sorry I think I must have missed something even though it’s so simple.

    Any tips would be great.
    Thanks again.

  • Mike Clasby

    September 18, 2008 at 4:58 pm
    d = thisComp.layer("Null 1").effect("Slider Control")("Slider"); 
    
    point1=this_layer.position; 
    
    x = this_comp.width/2; 
    y = this_comp.height/2; 
    point2=[x,y]; 
    
    delta=sub(point1, point2);// Find the vector between them 
    distance=length(delta);// Now find the length 
    linear(distance, d, 0, 100, 0); 

    The correct code is above it works for me as avertised (as setup in my first post), but the original code I gave you did the opposite, it fades out as it approaches the center, here’s the correct last line:

    linear(distance, d, 0, 100, 0);

  • Jack Parks

    September 18, 2008 at 7:04 pm

    Hi,

    Thanks for your patience, you’re right it does work, I hadn’t got the slider at a high enough value. Sorry my bad.
    It’s great thanks for your help.

    Cheers

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