Forum Replies Created

Page 7 of 1081
  • Dan Ebberts

    March 20, 2025 at 6:32 pm in reply to: Trigger comps on timeline in a random sequence

    Something like this time remapping expression maybe:

    dur = 5; // play each clip 5 seconds
    seed = 1103; // change this to get different result
    m = marker;
    val = time;
    if (m.numKeys > 0){
    period = Math.floor(time/dur);
    t = time%dur;
    seedRandom(seed+period,true);
    n = Math.floor(random(m.numKeys)) + 1;
    val = m.key(n).time + t;
    }
    val
  • Dan Ebberts

    March 19, 2025 at 7:07 pm in reply to: RANDOMLY DISTRIBUTE INSIDE CIRCLE

    I think the whole problem gets simpler if you switch from rectangular coordinates to polar coordinates (radius and angle). Then a circular random distribution centered around the comp center becomes something like this:

    c = [thisComp.width,thisComp.height]/2; // center
    rMax = 500; // max radius
    seedRandom(index,true);
    a = random(Math.PI*2);
    r = random(rMax);
    x = r*Math.cos(a);
    y = r*Math.sin(a);
    c + [x,y]

    It gets more complicated if you have a rectangular exclusion zone in the center of the field, but by using a little trig, you can avoid the while loop that can hang AE:

    c = [thisComp.width,thisComp.height]/2; // center
    w = 400; // width of rectangular exclusion area
    h = 300; // height of rectangular exclusion area
    rMax = 500; // max radius (must be big enough to enclose the rectangle)
    seedRandom(index,true);
    a = random(Math.PI/2);
    aMid = Math.atan2(h/2,w/2);
    if (a < aMid){
    rMin = (w/2)/Math.cos(a);
    }else{
    rMin = (h/2)/Math.cos(Math.PI/2 - a);
    }
    r = random(rMin,rMax);
    x = r*Math.cos(a);
    y = r*Math.sin(a);
    n = Math.floor(random(4));
    if (n == 1){
    x = -x;
    }else if (n == 2){
    x = -x;
    y = -y;
    }else if (n == 3){
    y = -y;
    }
    c + [x,y]
  • Dan Ebberts

    March 18, 2025 at 7:17 pm in reply to: Activate/DeActivate A parent using a checkbox

    This may not be what you’re after, as it requires the checkbox to be keyframed to on when you want the child’s x position to follow changes in the parent’s x position:

    p = thisComp.layer("parent").transform.xPosition;
    cb = effect("Checkbox Control")("Checkbox");
    accum = value-value;
    if (cb.numKeys > 0){
    n = 0;
    n = cb.nearestKey(time).index;
    if (cb.key(n).time > time) n--;
    if (n > 1){
    if (cb.key(n).value) accum += p - p.valueAtTime(cb.key(n).time);
    for (i = n-1; i > 0; i--){
    if (cb.key(i).value) accum += p.valueAtTime(cb.key(i+1).time) - p.valueAtTime(cb.key(i).time);
    }
    if (cb.key(1).value) accum += p.valueAtTime(cb.key(1).time) - p.valueAtTime(0);
    }
    }else{
    if (cb.value) accum = p - p.valueAtTime(0);
    }
    value + accum
  • Dan Ebberts

    March 17, 2025 at 8:52 pm in reply to: counter expression

    This should work, but there might be a more efficient way to do it, depending on what’s driving your value (for this example, I’m assuming the value is contained in a slider):

    s = effect("Slider Control")("Slider");
    f = timeToFrames(time);
    above = s.valueAtTime(0) >= 1;
    n = above ? 1 : 0;
    for (i = 1; i <= f; i++){
    if (above){
    if (s.valueAtTime(framesToTime(i)) < 1){
    above = false;
    }
    }else{
    if (s.valueAtTime(framesToTime(i)) >= 1){
    n++;
    above = true;
    }
    }
    }
    n
  • That’s considerably more complicated and will bog down in a longer comp because of the additional processing that needs to happen at each successive frame. Try this:

    numFrames = 5; // change colors every 5 frames
    c1 = effect("Color Control 1")("Color");
    c2 = effect("Color Control 2")("Color");
    c3 = effect("Color Control 3")("Color");
    c4 = effect("Color Control 4")("Color");
    c5 = effect("Color Control 5")("Color");
    colors = [c1,c2,c3,c4,c5];
    f = timeToFrames(time);
    curPeriod = Math.floor(f/numFrames);
    colorIdx = [];
    seedRandom(0,true);
    for (i = 0; i < value.length; i++){
    colorIdx.push(Math.floor(random(colors.length)));
    }
    i = 1;
    while (i <= curPeriod){
    seedRandom(i,true);
    for (j = 0; j < value.length; j++){
    temp = colorIdx[j] + Math.floor(random(colors.length-1)) + 1;
    colorIdx[j] = temp%colors.length;
    }
    i++;
    }
    myExpr = "style";
    for (i = 0; i < value.length; i++){
    myExpr += ".setFillColor(colors[colorIdx[" + i + "]]," + i + ",1)";
    }
    eval(myExpr)
  • Do you mean so that each letter has a color different than the one next to it, or so that a letter doesn’t get the same color for two consecutive periods?

  • Something like this should work. You might have to fiddle with it a bit:

    s = effect("Slider Control")("Slider");
    fadeDuration = .333;
    t = s.key(textIndex+1).time;
    ease(time,t,t+fadeDuration,100,0);
  • It works for me if I change your fadeDuration from 10 to .333.

  • This Source Text expression appears to work:

    numFrames = 5; // change colors every 5 frames
    c1 = effect("Color Control 1")("Color");
    c2 = effect("Color Control 2")("Color");
    c3 = effect("Color Control 3")("Color");
    c4 = effect("Color Control 4")("Color");
    c5 = effect("Color Control 5")("Color");
    colors = [c1,c2,c3,c4,c5];
    f = timeToFrames(time);
    seed = Math.floor(f/numFrames);
    seedRandom(seed,true);
    myExpr = "style";
    for (i = 0; i < value.length; i++){
    myExpr += ".setFillColor(colors[Math.floor(random(colors.length))]," + i + ",1)";
    }
    eval(myExpr)
  • You could add a Position Animator and set its Position value to 0,30. Add an Expression Selector, delete the Range Selector, and use this expression for the Expression Selector’s Amount property:

    s = effect("Slider Control")("Slider").value;
    ease(s,textIndex,textIndex+1,100,0)

    It uses the same slider as your Source Text expression.

Page 7 of 1081

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