Forum Replies Created

Page 4 of 6
  • Hi Aurora, you’re right – the first code needs tweaking. Check out this great reference that dives a bit deeper into getting actual text heights:

    https://motiondeveloper.com/blog/dealing-with-descenders

    Regarding split(‘\r’).length, split first breaks up the text into an array using the carriage return as a separator, then length returns the length of that array.

  • Had to clean it up a little, but here you go:

    https://drive.google.com/drive/folders/1vdlmhN9yyc2klLr5o90XxCFXVtJZ0IT5?usp=sharing

    And for a quick overview, here’s my source text:

    const y1 = effect("Vertical Copies")("Slider");

    const y2 = value.split('\r').length;


    if (y2 == 1) { //textmode detection

    txt = (value.repeat(1)+"\n").repeat(y1)+("|\n").repeat(y1); // textmode1: repeat 1 word vertically, then repeat stack with the "|" char for matte

    } else {

    txt = (value+"\n")+("|\n").repeat(y2); // textmode 2: option for multiple words, then repeat stack with the "|" char for matte

    }


    txt.replace(/\n$/, "") // remove last linebreak

    Thanks Filip 🙂

  • Hey again, Filip! I ran into this little issue with the code, and I was wondering if perhaps you’d be able to give me a hand on it.

    Literally all I’m trying to do is split the selection into 2 equal parts now, each doing the same, so the pseudo matte I’m working with follows the stacked text’s position.

    Quick explanation: My text consists of 2 “layers”. First, there are x lines of text, followed by the same amount of lines with the “|” character, which is then layered onto the text with a position animator, stretched out with a scale animator, and finally filled with a color to create the pseudo matte which you can see in my previous video.

    So far, I’ve managed to band-aid the code, so it only applies for the first half and remains static for the other, which looks like this:

    const flip = effect("Flip")("Checkbox");

    const stggr = effect("Stagger")("Slider");

    const tot = textTotal-1;

    const ind = textIndex-1;


    const range = textTotal/4;

    const offst = range - ind;

    const rO = offst/range;

    const mod = Math.cos(Math.PI*2-.25+rO*2) + 1;


    let sel1 = linear(textIndex, 1, textTotal/2, -100, 100); //0-50% selection

    sel = textIndex > textTotal/4 && flip == 1 ? sel1 : -sel1;

    //let sel2 = linear(textIndex, textTotal/2, textTotal, -100, 100);


    if(stggr <= 0) {

    easeL = sel * mod/2;

    v = ease(stggr, -100, 0, easeL, sel);

    } else if(stggr >= 0) {

    easeH = sel / mod/2;

    v = ease(stggr, 0, 100, sel, easeH);

    }


    const pos = effect("XYZ")("3D Point");

    const delaySldr = effect("Time Delay")("Slider");

    const delay = effect("Time Delay")("Slider").value * thisComp.frameDuration;


    let p = ind < range ?

    pos.valueAtTime(time + delay*ind)

    :

    pos.valueAtTime(time + delay*(Math.round((tot/2)-ind-1)));


    textIndex <= textTotal/2 ? p*v/10000 : 0

    …but obviously that’s just a substitute.

    I’ve tried overly complicated if else’s and a bunch of other stuff I can’t even remember anymore, but either the whole distribution was distorted or the timing of the delay didn’t match between the two halves… Maybe you know an elegant fix for this, or can explain to me how to split a slightly more complex text selection like this into multiple segments?

  • Hi, you could either take fontSize*.75 + leading, or the sourceRect height of your text layer divided by the number of lines. So:

    const { fontSize, leading } = thisComp.layer("Text").text.sourceText.style;

    const lineHeight = fontSize*.75 + leading;

    Or

    const numLines = thisComp.layer("Text").text.sourceText.split('\r').length;

    const lineHeight = thisComp.layer("Text").sourceRectAtTime().height/numLines;

  • Getting fantastic results, Filip. Thanks a bunch.

    One outstanding thing I noticed with your code is that the delay works either starting inwards, or outwards of the comp’s center depending on whether the delay time is negative or positive.

    I also remember that previously, when the first keyframe of an animation was the absolute position, I had to compensate for the delay by shifting the keyframes forward a bit, which isn’t necessary anymore. I couldn’t be happier!

  • Filip, thank you so much! This is spot on, I got exactly what I wanted out of it! 🙂

    One tiny thing I had to modify, though, was how the delay behaves. Initially, the delay started at the very top and progressed down each row, while I needed the top and bottom half to reflect each other.

    This tweak did it:

    const pos = effect("Position")("3D Point");

    const delaySldr = effect("Time Delay")("Slider");

    const delay = textIndex*thisComp.frameDuration*effect("Time Delay")("Slider");

    const p = textIndex < textTotal/2 ? pos.valueAtTime(time + delay) : pos.valueAtTime(time+(delaySldr/3)- delay);

    Assuming 9 rows of text, dividing delaySldr by 3 made the timing pixel perfect for the second half of the text. The only issue is that this currently doesn’t respond to changes in the amount of rows. (See attachment)
    Whenever I change that number, I need to recalculate what delaySldr is divided by. But I can’t for the life of me figure out how to determine that.

    As an example, for 7 rows, I eyeballed that 3.75 works, and for 5 rows it’s 5. Maybe there is an elegant solution to calculate this automatically…

    Do you have any ideas? I really appreciate your knowledge.

  • No worries Dan, thanks for your effort🙂

  • Hi Dan! Thanks for getting back. I am aware of this concept, but I’m guessing it’s not as simple in my case, as I want to preserve everything in my code, but only add a slight delay to each word when I animate the animator’s position. (Or if that doesn’t work, a slider)

    I hope the video I posted above shines a light on what I’m after.

    Here’s another example:
    https://youtu.be/ce3h46mp4Q4?t=89

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

  • For visual reference, here’s what I’m trying to add a slight word delay to:

  • Anyone?

Page 4 of 6

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