Forum Replies Created

Page 1026 of 1081
  • Dan Ebberts

    April 26, 2006 at 8:00 pm in reply to: Expression for 24 p Jittery Title Roll

    Just Alt+click the Position stopwatch and enter (or paste) the text of your expression.

    Dan

  • Dan Ebberts

    April 26, 2006 at 5:28 pm in reply to: Mutually Excusive Positioning with Expressions

    Got a little careless with my math. Question 1 should be:

    1) Why will this method fail if your comp is longer than 5 minutes and 24 seconds?

    Dan

  • Dan Ebberts

    April 26, 2006 at 5:28 pm in reply to: Mutually Excusive Positioning with Expressions

    Got a little careless with my math. Question 1 should be:

    1) Why will this method fail if your comp is longer than 5 minutes and 24 seconds?

    Dan

  • Dan Ebberts

    April 26, 2006 at 5:11 pm in reply to: Mutually Excusive Positioning with Expressions

    OK then. Let’s make it a little training exercise. First the code.

    Instead of a text layer, you would create a null, name it “master”, add a slider to it, and add this expression to the slider:

    setSize = 25;

    t = Math.round(time);
    setNo = Math.floor(t/setSize);
    setIdx = t%setSize;

    seed = Math.floor(setNo);
    seedRandom(seed,true);
    posArray = [];
    for (var i = 0; i < 25; i++){ posArray[i] = i; } for (var i = 0; i <25; i++){ idx = Math.floor(random(i)); temp = posArray[idx]; posArray[idx] = posArray[i]; posArray[i] = temp; } posArray[setIdx] As before, this layer needs to be at the bottom of your layer stack. Then add this position expression to your grid layers: holdTime = .75 setSize = 25; setNumber = Math.floor(time/holdTime); myTime = setNumber*setSize + index - 1; posX= [130, 284, 438, 591, 745]; posY = [132, 294, 455, 617, 778]; myIdx = thisComp.layer("master").effect("Slider Control")("Slider").valueAtTime(myTime); myXIdx = Math.floor(myIdx/5); myYIdx = myIdx%5; [posX[myXIdx],posY[myYIdx]] If you can figure out how it works, I'd have to say that you've learned quite a bit about expressions. Bonus points if you can answer these questions: 1. Why will this method fail if your comp is longer than 7 minutes and 12 seconds? 2. If your comp is longer than that, what could you do to make this method work? 🙂 Dan

  • Dan Ebberts

    April 26, 2006 at 5:11 pm in reply to: Mutually Excusive Positioning with Expressions

    OK then. Let’s make it a little training exercise. First the code.

    Instead of a text layer, you would create a null, name it “master”, add a slider to it, and add this expression to the slider:

    setSize = 25;

    t = Math.round(time);
    setNo = Math.floor(t/setSize);
    setIdx = t%setSize;

    seed = Math.floor(setNo);
    seedRandom(seed,true);
    posArray = [];
    for (var i = 0; i < 25; i++){ posArray[i] = i; } for (var i = 0; i <25; i++){ idx = Math.floor(random(i)); temp = posArray[idx]; posArray[idx] = posArray[i]; posArray[i] = temp; } posArray[setIdx] As before, this layer needs to be at the bottom of your layer stack. Then add this position expression to your grid layers: holdTime = .75 setSize = 25; setNumber = Math.floor(time/holdTime); myTime = setNumber*setSize + index - 1; posX= [130, 284, 438, 591, 745]; posY = [132, 294, 455, 617, 778]; myIdx = thisComp.layer("master").effect("Slider Control")("Slider").valueAtTime(myTime); myXIdx = Math.floor(myIdx/5); myYIdx = myIdx%5; [posX[myXIdx],posY[myYIdx]] If you can figure out how it works, I'd have to say that you've learned quite a bit about expressions. Bonus points if you can answer these questions: 1. Why will this method fail if your comp is longer than 7 minutes and 12 seconds? 2. If your comp is longer than that, what could you do to make this method work? 🙂 Dan

  • Dan Ebberts

    April 26, 2006 at 3:56 pm in reply to: Mutually Excusive Positioning with Expressions

    Sorry, I should have posted a warning that it could be damaging to your eyeballs and brain. 🙂

    Actually, if you think that one is tough, there’s an even more mind-numbing (but better, I think) solution involving time multiplexing. Not for the faint of heart though.

    Dan

  • Dan Ebberts

    April 26, 2006 at 3:56 pm in reply to: Mutually Excusive Positioning with Expressions

    Sorry, I should have posted a warning that it could be damaging to your eyeballs and brain. 🙂

    Actually, if you think that one is tough, there’s an even more mind-numbing (but better, I think) solution involving time multiplexing. Not for the faint of heart though.

    Dan

  • Dan Ebberts

    April 25, 2006 at 8:42 pm in reply to: Mutually Excusive Positioning with Expressions

    OK – you’ve stumbled on to one of the more obscure limitations of expressions. As far as I know, there’s no way to generate the same random sequence in different layers. This becomes an issue in applications like yours that need the random action of different layers to be coordinated. So, the work-around is to do all the random calculations in one layer, which will serve the results to the others. Here’s one way:

    First, create a text layer (name it “master”) and apply this expression for the source text:

    holdTime = .75;
    seed = Math.floor(time/holdTime);
    seedRandom(seed,true);
    posArray = [];
    for (var i = 0; i < 25; i++){ posArray[i] = i; } for (var i = 0; i <25; i++){ idx = Math.floor(random(i)); temp = posArray[idx]; posArray[idx] = posArray[i]; posArray[i] = temp; } outStr = ""; for (var i = 0; i < 25; i++){ outStr += posArray[i]; if(i != 24) outStr += ","; } outStr You'll notice that you get a comma-separated random sequence of the numbers from 0 to 24 that changes every 3/4 seconds (holdTime). You can turn off visibility for this layer. You need to keep this layer below (in the layer stack) the layers that you will be randomly positioning. Those layers need to be layers 1 through 25 in the layer stack. Apply this expression to each of those layer's position property: posX= [130, 284, 438, 591, 745]; posY = [132, 294, 455, 617, 778]; arrayText = thisComp.layer("master").text.sourceText; myArray = arrayText.split(","); myIdx = parseInt(myArray[index-1]); myXIdx = Math.floor(myIdx/5); myYIdx = myIdx%5; [posX[myXIdx],posY[myYIdx]] This expression reads the random number from the text layer that is appropriate for its layer index and converts that to indexes into the posX and posY tables. This renders fairly slowly, because there is a lot of calculating going on. Have fun! Dan

  • Dan Ebberts

    April 25, 2006 at 8:42 pm in reply to: Mutually Excusive Positioning with Expressions

    OK – you’ve stumbled on to one of the more obscure limitations of expressions. As far as I know, there’s no way to generate the same random sequence in different layers. This becomes an issue in applications like yours that need the random action of different layers to be coordinated. So, the work-around is to do all the random calculations in one layer, which will serve the results to the others. Here’s one way:

    First, create a text layer (name it “master”) and apply this expression for the source text:

    holdTime = .75;
    seed = Math.floor(time/holdTime);
    seedRandom(seed,true);
    posArray = [];
    for (var i = 0; i < 25; i++){ posArray[i] = i; } for (var i = 0; i <25; i++){ idx = Math.floor(random(i)); temp = posArray[idx]; posArray[idx] = posArray[i]; posArray[i] = temp; } outStr = ""; for (var i = 0; i < 25; i++){ outStr += posArray[i]; if(i != 24) outStr += ","; } outStr You'll notice that you get a comma-separated random sequence of the numbers from 0 to 24 that changes every 3/4 seconds (holdTime). You can turn off visibility for this layer. You need to keep this layer below (in the layer stack) the layers that you will be randomly positioning. Those layers need to be layers 1 through 25 in the layer stack. Apply this expression to each of those layer's position property: posX= [130, 284, 438, 591, 745]; posY = [132, 294, 455, 617, 778]; arrayText = thisComp.layer("master").text.sourceText; myArray = arrayText.split(","); myIdx = parseInt(myArray[index-1]); myXIdx = Math.floor(myIdx/5); myYIdx = myIdx%5; [posX[myXIdx],posY[myYIdx]] This expression reads the random number from the text layer that is appropriate for its layer index and converts that to indexes into the posX and posY tables. This renders fairly slowly, because there is a lot of calculating going on. Have fun! Dan

  • Dan Ebberts

    April 25, 2006 at 5:29 pm in reply to: Mutually Excusive Positioning with Expressions

    It might look something like this:

    for (var i = 1; i <= thisComp.numLayers; i++){ match = false; //assume no layer's position matches if (i == index) continue; //skip self if (position == thisComp.layer(i).position){ match = true; // oops - found a layer with same position break; } } if (match) { // your "else" stuff goes here } I haven't tested it so there may be errors, but it should be close. It assumes that you want to check every other layer in the comp. If you have cameras, lights, or other layers you want to exclude - you'll have to modify the code. Dan

Page 1026 of 1081

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