Forum Replies Created

Page 82 of 1081
  • Dan Ebberts

    July 22, 2022 at 11:18 am in reply to: Accelerate movement of layer based on audio

    Sure, you could include something like this in your expression:

    smoothAudio = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider").smooth(.25,10);
  • Dan Ebberts

    July 21, 2022 at 9:24 pm in reply to: Accelerate movement of layer based on audio
  • Dan Ebberts

    July 20, 2022 at 5:53 pm in reply to: Using loopIn and loopOut in the same expression

    I’m not sure if this is what you’re after, but your expression needs to define what happens between markers 2 and 3.

    n = 0;
    if (marker.numKeys > 0){
    n = marker.nearestKey(time).index;
    if (marker.key(n).time > time) n--;
    }
    if (n<=1){
    loopIn("pingpong");
    }else if (n>2){
    loopOut("pingpong");
    }else{
    value;
    }
  • I think you’d want to set it up like this:

    t1 = key(1).time;
    t2 = key(2).time;
    v1 = hexToRgb("0");
    v2 = hexToRgb("739c8a");
    linear(time,t1,t2,v1,v2)
  • Dan Ebberts

    July 19, 2022 at 2:00 pm in reply to: Moving the last keyframe in time using expressiosn

    You can’t really move keyframes with expressions, but you can simulate it with something like this (assumes there are only 2 keyframes):

    t1 = key(1).time;
    t2 = key(2).time;
    tNew = effect("Slider Control")("Slider");
    t = linear(time,t1,tNew,t1,t2);
    valueAtTime(t)
  • Dan Ebberts

    July 19, 2022 at 1:50 pm in reply to: Changing Font Weights with Sliders

    It worked fine for me once I cleaned up the way code gets trashed when you post it here without formatting it. This is what I used:

    weights = [
    'Light',
    'Regular',
    'Bold',
    'Ultra',
    'Black'
    ];
    family = thisProperty.style.font;
    family = family.split('-');
    select = Math.floor(clamp(effect("Select")("Slider"), 0, weights.length - 1));;
    createStyle().setFont(family[0] + '-' + weights[select]);
  • Dan Ebberts

    July 14, 2022 at 8:26 pm in reply to: Check to see if var is in array

    If you’re using the JavaScript expression engine, you can improve things a lot by using array.includes():

    par = parent.text.sourceText;
    src = par.charAt(par.length-1);
    lib = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
    libNum = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "/", ":", ";", "(", ")", "$", "&", "@", '"', '“', '”', ".", ",", "?", "!", "'", "’"];
    libSym = ["[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "_", "\\", "|", "~", "<", ">", "€", "£", "¥", "•"];
    if (src == " ") {
    1;
    }else if (lib.includes(src)){
    2;
    }else if (lib.includes(src.toLowerCase())){
    3;
    }else if (libNum.includes(src)){
    4;
    }else if (libSym.includes(src)){
    5;
    }else{ // just in case
    6;
    }
  • This should work:

    array = ["first","second","third","fourth"];
    myFont = ["ArialMT","Calibri","LucidaConsole","MyriadPro-Regular"];
    t = Math.floor(random(array.length));
    f = Math.floor(random(myFont.length));
    s = style;
    s.setFont(myFont[f]).setText(array[t]);
  • Dan Ebberts

    July 6, 2022 at 3:30 pm in reply to: blend random value every n frames and hold

    Try this:

    n = 5; //blend frames
    holdTime = .5; //time to hold each position (seconds)
    minVal = 100;
    maxVal = 1000;
    seed = Math.floor(time/holdTime);
    t = time%holdTime;
    seedRandom(seed,true);
    x2 =random(minVal,maxVal);
    seedRandom(seed-1,true);
    x1 =random(minVal,maxVal);
    x = linear(t,0,framesToTime(n),x1,x2);
    y = value[1];
    [x, y]
  • Dan Ebberts

    July 5, 2022 at 5:01 pm in reply to: Checkbox Control with more complex expression.

    Ah, OK. I think this should work:

    cb = effect("Checkbox Control")("Checkbox").value;
    if (cb){
    n = 0;
    if (numKeys > 0){
    n = nearestKey(time).index;
    if (key(n).time > time){
    n--;
    }
    }
    if (n == 0){
    t = 0;
    }else{
    t = time - key(n).time;
    }
    if (n > 0 && t < 1){
    v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
    amp = .02;
    freq = 3.0;
    decay = 5.0;
    value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
    }else{
    value;
    }
    }else{
    value;
    }
Page 82 of 1081

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