Forum Replies Created

Page 22 of 277
  • Filip Vandueren

    December 9, 2022 at 8:58 am in reply to: Rotating the Shortest Way Possible

    I couldn’t really deduce what you were doing with the weight variables.

    Here’s an example that bases itself off of the rotation keyframes already present and always takes the shortest route (always <=180°)

    nk = nearestKey(time);
    prevKey = key ( nk.time >time ? nk.index-1||1 : nk.index );
    nextKey = key( Math.min(numKeys, prevKey.index + 1) );
    delta = (nextKey.value - prevKey.value)%360;
    shortRoute = Math.abs(delta)>180 ? (Math.abs(delta)-360)*Math.sign(delta) : delta;
    // longRoute = Math.abs(delta)<180 ? (Math.abs(delta)-360)*Math.sign(delta) : delta;
    linear(time, prevKey.time, nextKey.time, prevKey.value, prevKey.value + shortRoute);
  • Filip Vandueren

    December 8, 2022 at 9:21 pm in reply to: Rotating the Shortest Way Possible

    The easiest fix is to use Orientation on a 3D layer.

  • Filip Vandueren

    December 1, 2022 at 8:23 am in reply to: after effects jsx reset position
  • Filip Vandueren

    December 1, 2022 at 8:06 am in reply to: toFixed() for all iterations after “.join()

    Unless you are using a fixed-width font, it is almost impossible to do that kind of layout using an expression on sourceText alone.

    I prefer doing it with text animator like this:

    • add a position text-animator.
    • set the position-value to: 10,000 , 10,000
    • remove the default range and add an expression selector
    • change its “based on” property to: “Lines”
    • this is the expression for that selector:
    i = textIndex-1;
    st = text.sourceText.style;
    ld = st.autoLeading ? st.fontSize*1.2 : st.leading; rowH = 128;
    columnW = 360; itemsPerRow = 8;
    x = (i%itemsPerRow) * columnW;
    y = Math.floor(i/itemsPerRow) * rowH; y-= ld*i; // offset the already present Y-difference caused by newlines
    [x, y]/100;

    This will fill up the “grid” rows first, then columns.

    If you want it to fill up by columns first, then change the middle part to:

    itemsPerColumn = 8;
    x = Math.floor(i/itemsPerColumn) * columnW;
    y = (i%itemsPerColumn) * rowH;

    Some extra remarks:

    It will look best with the paragraph Right Aligned I suppose.

    Make sure that in the Paragraph palette “Add space before” and “…after” and all the other margin parameters are set to 0px. (they don’t get count in the leading and will push each next cell a bit more down and off the grid)

    Some Fonts lay out their digits so that they line up nicer in spreadsheets (as if they are fixed-width) but to get that feature, the kerning of your text-layer needs to be set to “Metrics”.
    Not all fonts have this (for example Museo, Montserrat or more Display/whimsical stuff like Comic sans or Herculanum don’t) but most professional typefaces that are used for layout do.

    You can of course hook up some of the parameters to sliders.

  • Filip Vandueren

    November 30, 2022 at 12:16 pm in reply to: after effects jsx reset position

    You can add an animation preset to Kbar I believe ?

    Then set the value of position to 0,0 manually, select the property and create an animation preset of this. So, no scripting is needed.

    A scripting solution would use:

    yourLayer.transform.position.setValue([0,0]);

    but you’d first need to establish what “yourLayer” is.

  • Hi Robert and Dan,

    after a bit of experimenting with Dan’s code, I think this one works for any angle (although still only for square compositions) and any width (up to the width of the comp of course):

    halfwidth = value[0]/2;
    compdiagonal = Math.sqrt((thisComp.width/2)**2 + (thisComp.height/2)**2);
    criticalAngle = 45 - radiansToDegrees(Math.asin(value[0]/2/compdiagonal));
    r=((Math.abs(rotation)+45)%90)-45;
    if (Math.abs(r) < criticalAngle) {
    a = degreesToRadians(r);
    offset = halfwidth*Math.tan(a);
    len = (thisComp.height/2)/Math.cos(a) + (a < 0 ? -offset : offset);
    [value[0],len*2];
    } else {
    a=degreesToRadians(Math.abs(Math.abs(rotation%90)-45));
    len = 2 * compdiagonal * Math.cos(a);
    [value[0],len];
    }
  • Filip Vandueren

    November 28, 2022 at 10:34 am in reply to: Setting Camera Film Size Via Script

    Hi SJ,

    I believe this is the Math:

    Zoom (pixels) = thisComp.width (pixels) * Focal Length (mm) / Film Size (mm);

    (for “Measure Film size” horizontally, otherwise use comp height or calculate comp diagonal)

    The horizontal FOV is then:

    FOV = radiansToDegrees(2*Math.atan( thisComp.width / 2 / Zoom));

  • Filip Vandueren

    November 27, 2022 at 11:28 am in reply to: Setting Camera Film Size Via Script

    Film size isn’t used for anything, other than calculating what the zoom-value should be if you want to enter the lens in mms too.

    AFAIK, as soon as you are out of the camera options window, none of those matter anymore, as everything is calculated in pixels.

    Why do you need to set it ? (because you are correct, it isn’t an available property via expressions and scripting)

  • Filip Vandueren

    November 25, 2022 at 2:19 pm in reply to: How to change random colors gradually?

    Try this Gerben:

    colors = new Array();
    numColors = thisComp.layer("Ctrl").effect("numColors")("Slider");
    for(i = 1; i <= numColors; i++){
    newColor = thisComp.layer("Ctrl").effect("Color Control " + i)("Color");
    colors.push(newColor);
    }
    slider = thisComp.layer("Ctrl").effect("Freq")("Slider").value;
    counter = Math.floor(time/slider);
    seedRandom(counter, true);
    fromColor = colors[Math.floor(random(colors.length))];
    seedRandom(counter+1, true);
    toColor = colors[Math.floor(random(colors.length))];
    ease((time/slider)%1,0,1,fromColor, toColor);

    Note that Frequency is actually duration per flash, not flashes per seconds.


    If you want to hold the colors for a little while before it interpolates, you could do this as the last line:

    ease((time/slider)%1, 0, 1/3, fromColor, toColor);

    which will ease for 1/3 of the time and hold 2/3 of the time.

  • Hi Christiaan,

    Javascript in external files get processed a bit different, and need more methods to be tied explicitly to their ancestor (usually thisProperty and thisLayer)

    In this case you would need:

    thisLayer.seedRandom()

    read more about it here:

    https://helpx.adobe.com/au/after-effects/using/legacy-and-extend-script-engine.html#syntax-requirements-expression-libraries

    and here:

    https://motiondeveloper.com/blog/write-expressions-external-files

Page 22 of 277

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