Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random Position Based on Scale

  • Random Position Based on Scale

    Posted by Eddie Torre on March 31, 2012 at 6:33 pm

    Hello,

    I have a comp that is 1920×1080. It has several layers, with a random scale value on each layer (e.g. Layer 1 scale is 125%, Layer 2 scale is 112%……). The range of the scaling is 100% to 150%

    I was hoping to generate a random position for each layer based on its scale value. The positional randomness of the scaled layer would be restricted by its borders and/or corners so that it filled the 1920 x 1080 comp window at all times (not revealing the layer beneath it).

    I think I have a few lines, but haven’t been able to solve it. Here is what I have so far.

    I figured the limits could be something like this…

    Width

    minVal =((transform.scale/100*thisComp.width)-thisComp.width/2)-thisComp.width/2;
    maxVal =((transform.scale/100*thisComp.width)-thisComp.width/2)+thisComp.width/2;

    Height

    minVal =((transform.scale/100*thisComp.height)-thisComp.height/2)-thisComp.height/2;
    maxVal =((transform.scale/100*thisComp.height)-thisComp.height/2)+thisComp.height/2;

    and the randomness could be something like this…

    seedRandom(index,true);
    s = random(minVal,maxVal);
    [s,s]

    but I haven’t been able to figure out a way to get it all to work together in one expression. Any help would be great. Thanks in advance.

    Eddie Torre replied 14 years, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    March 31, 2012 at 7:38 pm

    This should work:

    minX = width*transform.scale[0]/200;
    maxX = thisComp.width – minX;
    minY = height*transform.scale[1]/200;
    maxY = thisComp.height – minY;
    seedRandom(index,true);
    random([minX,minY],[maxX,maxY]);

    Dan

  • Eddie Torre

    March 31, 2012 at 8:16 pm

    Works perfectly!

    I know it gets said a lot around here, but thank you very much Dan, not only for help with this but for making this forum a joy to visit.

    effect.awesome

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