Forum Replies Created

Page 88 of 1081
  • Dan Ebberts

    May 27, 2022 at 3:27 pm in reply to: Random character opacity on and off

    It depends on which expression you mean, but with the latest one, you could do something like this:

    revealTime = 3; // reveal over 3 seconds

    fadeTime = .5;

    seedRandom(textIndex,true);

    myReveal = random(revealTime);

    linear((time-inPoint), myReveal, myReveal+fadeTime, 100, 0)

    or maybe switch the last line to this:

    linear((time-inPoint), myReveal, myReveal+fadeTime, 0, 100)

    depending on whether you want the letters to fade in or out.

  • The trick is that it’s actually the jumbled order that gets stored at negative time and the opacity expression uses that to figure out when each of the jumbled words needs to turn on. If you look at the Source Text expression, you’ll see that both the negative and positive time portions use the same random sort algorithm.

  • Dan Ebberts

    May 25, 2022 at 8:17 pm in reply to: [HELP] Time Remap – Trying to create a Script

    Something like this maybe:

    var comp = app.project.activeItem;

    var layers = comp.selectedLayers;

    var timeRemapProp;

    if(layers.length == 0){

    alert("You must select a layer");

    } else {

    for(var i = 0; i < layers.length; i++){

    if (layers[i].canSetTimeRemapEnabled){

    layers[i].timeRemapEnabled = true;

    timeRemapProp = layers[i].property("ADBE Time Remapping");

    timeRemapProp.addKey(timeRemapProp.keyTime(timeRemapProp.numKeys)-comp.frameDuration);

    timeRemapProp.removeKey(timeRemapProp.numKeys);

    }

    }

    }

  • Dan Ebberts

    May 24, 2022 at 4:35 pm in reply to: Slider control keyframe value from JSON

    One thing you could do is put the keyframes directly on the shape size. Then you could do something like this (again, not tested):

    val = footage("value.json").dataValue([0])

    [ease(time, key(1).time, key(2).time, key(1).value[0], val),20]

  • Dan Ebberts

    May 24, 2022 at 3:26 pm in reply to: Slider control keyframe value from JSON

    It’s a little complicated because an expression can’t just replace the value at a keyframe, it needs to replace every value. The simplest change would be construct your own linear ramp, using the slider keyframes to provide the timing info and the first value and your data file to provide the second value. That could look like this (not tested, so there may be typos):

    val = footage("value.json").dataValue([0]);

    rect = thisComp.layer("Null 1").effect("Slider Control")("Slider");

    linear (time,rect.key(1).time, rect.key(2).time, rect.key(1).value, val);

    But it seems like you could clean this up and get rid of the slider altogether, but you’d have to get the timing info from somewhere else (or hard code it).

  • Dan Ebberts

    May 22, 2022 at 10:08 pm in reply to: Prevent subsequent random value

    See if this is close:

    f = timeToFrames(time);

    seedRandom(index,true);

    numShapes = 5;

    numVars = 4;

    varDur = 6;

    shapeDur = numVars*varDur;

    fCur = 0;

    segDur = 2;

    curShape = Math.floor(random(numShapes));

    for (fCur = 0; fCur <= f; fCur += segDur){

    curShape = (curShape + Math.floor(random(1,numShapes)))%numShapes;

    }

    seedRandom(fCur,true);

    curVar = Math.floor(random(numVars));

    framesToTime(curShape*shapeDur + curVar*varDur);

  • Dan Ebberts

    May 21, 2022 at 3:37 pm in reply to: Keyframes as a Var

    I’m not sure how you would do that, or how you would trigger it if you could do it.

    I have no idea if this is of any use to you, but you could define a set of “action” functions that would respond to specific triggers. For example, you could set up some opacity functions that could be triggered by layer markers. In this simple example, layer markers with the comment “fadeIn”, “fadeOut”, “flickerOn”, or “flickerOff” would trigger a specific function. Each comment can also include an option duration (in frames) parameter, so, for example, you could trigger a 25-frame fadeIn with this comment: “fadeIn 25”. If no duration parameter is included, a default of 10 frames is assumed. This opacity expression is a simplified version of such a marker-triggered system:

    function fadeIn(t,dur){

    return linear(t,0,dur,0,100);

    }

    function fadeOut(t,dur){

    return linear(t,0,dur,100,0);

    }

    function flickerOn(t,dur){

    return t < dur ? (random() < 0.5 ? 0 : 100) : 100;

    }

    function flickerOff(t,dur){

    return t < dur ? (random() < 0.5 ? 0 : 100) : 0;

    }

    defaultDur = 10; // default duration in frames

    val = value;

    m = marker;

    if (m.numKeys > 0){

    n = m.nearestKey(time).index;

    if (time < m.key(n).time) n--;

    if (n > 0){

    c = m.key(n).comment.split(" ");

    myDur = framesToTime(c.length > 1 ? parseInt(c[1]) : defaultDur);

    myT = time - m.key(n).time;

    switch(c[0]){

    case "fadeIn":

    val = fadeIn(myT,myDur);

    break;

    case "fadeOut":

    val = fadeOut(myT,myDur);

    break;

    case "flickerOn":

    val = flickerOn(myT,myDur);

    break;

    case "flickerOff":

    val = flickerOff(myT,myDur);

    break;

    default:

    break;

    }

    }

    }

    val

  • This should do it:

    function addExpressions(){

    var myOpacityExpr = 'ease(time,inPoint,inPoint+1,0,100)';

    var myAudioExpr = 'ease(time,inPoint,inPoint+1,[-192,-192],[0,0])';

    var myComp = app.project.activeItem;

    if ((myComp == null) || ! (myComp instanceof CompItem)){

    alert ("No comp active.");

    return;

    }

    var myLayers = myComp.selectedLayers;

    for (var i = 0; i < myLayers.length; i++){

    if (myLayers[i].hasVideo){

    myLayers[i].property("Opacity").expression = myOpacityExpr;

    }

    if (myLayers[i].hasAudio){

    myLayers[i].property("Audio Levels").expression = myAudioExpr

    }

    }

    }

    addExpressions();

  • Try this. Set your Source Text Expression to this:

    a = value.split(" ");

    seedRandom(index,true);

    if (time < 0){

    b = [];

    for (i = 0; i < a.length; i++) b.push(i);

    b.sort(() => random() - 0.5);

    }else{

    a.sort(() => random() - 0.5).join(" ");

    }

    Add an Opacity Animator, and set the Opacity value to 0. Add an Expression Selector, and delete the Range Selector. In the Expression Selector, set Based On to Words, and set the Amount expression to:

    delay = .25;

    fadeTime = .25;

    order = text.sourceText.valueAtTime(-1).split(",");

    myDelay = order[textIndex-1]*delay;

    linear(time,inPoint+myDelay,inPoint+myDelay+fadeTime,100,0)

    Tweak delay and fadeTime to get the animation you want.

  • This should get you started for #1:

    function renameComps(theFolderName, theSuffix){

    var theFolder = null;

    for (var i = 1; i <= app.project.numItems;i++){

    if ((app.project.item(i).name == theFolderName) && (app.project.item(i) instanceof FolderItem)){

    theFolder = app.project.item(i);

    break;

    }

    }

    if (theFolder == null){

    alert("Can't find folder '" + theFolderName + "'");

    retrun;

    }

    var myComps = [];

    for (var i = 1; i <= app.project.numItems; i++){

    if ((app.project.item(i).parentFolder.id == theFolder.id) && (app.project.item(i) instanceof CompItem)){

    myComps.push(app.project.item(i));

    }

    }

    for (var i = 0; i < myComps.length; i++){

    myComps[i].name = myComps[i].name + theSuffix;

    }

    }

    renameComps("myFolder", "_Old_Do_Not_Use");

    and this for #2:

    function addExpressions(){

    var myOpacityExpr = 'ease(time,inPoint,inPoint+1,0,100)';

    var myAudioExpr = 'ease(time,inPoint,inPoint+1,[-192,-192],[0,0])';

    var myComp = app.project.activeItem;

    if ((myComp == null) || ! (myComp instanceof CompItem)){

    alert ("No comp active.");

    return;

    }

    for (var i = 1; i <= myComp.numLayers; i++){

    if (myComp.layer(i).hasVideo){

    myComp.layer(i).property("Opacity").expression = myOpacityExpr;

    }

    if (myComp.layer(i).hasAudio){

    myComp.layer(i).property("Audio Levels").expression = myAudioExpr

    }

    }

    }

    addExpressions();

Page 88 of 1081

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