Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random Lines Expression

  • Random Lines Expression

    Posted by David Rodriguez on October 9, 2007 at 4:11 am

    I am using Dan Ebbert’s random lines expression
    https://www.motionscript.com/expressions-lab-ae65/random-lines.html

    how can I change the expression for horizontal bars?
    I cant figure out what part of the expression changes [x,y]

    tMin = .5; //minimum segment duration
    tMax = 2; //maximum segment duration

    end = 0;
    j = 0;
    while (time >= end){
    j++;
    seedRandom(j,true);
    start = end;
    end += random(tMin,tMax);
    }
    endVal = random(thisComp.width);
    seedRandom(j – 1,true);
    x = random(); //this is a throw-away value
    startVal = random()*this_comp.width;
    x = ease(time,start,end,startVal,endVal);
    [x,value[1]]

    David Rodriguez replied 18 years, 10 months ago 2 Members · 4 Replies
  • 4 Replies
  • Mike Clasby

    October 9, 2007 at 6:15 am

    This seems to work on a horizontal line’s position:

    tMin = .5; //minimum segment duration
    tMax = 2; //maximum segment duration

    end = 0;
    j = 0;
    while (time >= end){
    j++;
    seedRandom(j,true);
    start = end;
    end += random(tMin,tMax);
    }
    endVal = random(thisComp.height);
    seedRandom(j – 1,true);
    y = random(); //this is a throw-away value
    startVal = random()*this_comp.width;
    y = ease(time,start,end,startVal,endVal);
    [value[0], y]

    I just replaced the x’s with y’s (lines 14, 16, and 17). Then in line 17 “value[0]” means use the x value, and their places are reversed since the left side is the x, and where the y is in line 17 is the y value (it was value[1] meaning use the y value).

    Also I changed the “width” in line 12 to “height”, so the lines stay within the screen:

    endVal = random(thisComp.width);

    to

    endVal = random(thisComp.height);

    So in case I was vague above,
    value[0] is the x value
    and value[1] is the y value
    and value[2] is the z value

  • David Rodriguez

    October 9, 2007 at 6:29 am

    Thank you so much. This is very close to what I need. For some reason the lines do not stay on screen they go way off the bottom but not the top.

    Thanks for you help
    David

  • Mike Clasby

    October 9, 2007 at 7:02 am

    Yikes, I forgot a width to height change on line 15, it should be this:

    startVal = random()*this_comp.height;

    And the whole expression, this:

    tMin = .5; //minimum segment duration
    tMax = 2; //maximum segment duration

    end = 0;
    j = 0;
    while (time >= end){
    j++;
    seedRandom(j,true);
    start = end;
    end += random(tMin,tMax);
    }
    endVal = random(thisComp.height);
    seedRandom(j – 1,true);
    y = random(); //this is a throw-away value
    startVal = random()*this_comp.height;
    y = ease(time,start,end,startVal,endVal);
    [value[0], y]

  • David Rodriguez

    October 9, 2007 at 7:26 am

    Thank you, it is perfect!

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