Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Timeline segmentation

  • Timeline segmentation

    Posted by Rury Nelson on September 22, 2016 at 3:23 pm

    Hi guys,
    So I am looking at good techniques for segmenting the timeline. The intention comes from a current project where I have a Colorama (the artist is quite happy with the default 6-part hue cycle) colouring an object and cycling through time. Now, where this gets challenging is that the object fades up, cycles and fades down, with the fading up colour matching the first and the fading down colour matching the last colour in the cycle (effecting doubling that colour). Also the colour offsets by one each cycle.

    My approach was to cut the timeline up into “segs” as is throughout the code. If the time was inside certain segments, then certain functions would be called. The only problem I’ve had is that this feels a little clunky and the colour cycling doesn’t work properly. It gets to the right area and then kind of sawtooths between one colour and the next one in the sequence (weirdly offset correctly in each repetition of the cycle).

    Does anyone know of a more effective way to create “regions” within the timeline or, just as a side note, why my cycling doesn’t work properly?

    (This was attached to the “Input Phase” parameter of “Colorama”.

    If the attached code makes no sense, I can do an annotated version explaining my madness.

    Cheers,
    Rury

    compLen = thisComp.duration;
    numCols = 6;
    numHoldSegs = 2;
    numSubSegs = numCols + numHoldSegs;
    numReps = 6;
    currentRep = 0;
    currentSeg = 0;
    numSegs = numSubSegs * numReps;
    segLen = compLen/numSegs;
    t = time;
    segNum = 0;
    val = 0;
    maxVal = 360;
    defVal = 0;
    intSeg = 0;

    for(i = 0; i< numSegs; i++){
    minim = i * segLen;
    maxim = i * (segLen + 1);
    if(t >= minim && t << maxim){ segNum = i; } } for(j = 0; j

    Xavier Gomez replied 9 years, 8 months ago 2 Members · 6 Replies
  • 6 Replies
  • Xavier Gomez

    September 22, 2016 at 6:08 pm

    Thank you for sharing 😉

    Can you post a screenshot of how it should look like in the graph editor ?

  • Rury Nelson

    September 23, 2016 at 12:38 pm

    This is kinda what I am trying to achieve, the above is only a portion of what I am aiming for. But the principle remains the same throughout. Also After Effects automatically cycles round to 0 degrees itself, so there should be no need to do it manually.

  • Rury Nelson

    September 23, 2016 at 12:41 pm

    Also note the above is relatively freehand

  • Xavier Gomez

    September 23, 2016 at 1:39 pm

    Hi,
    you can try this, which seems to reproduce your graphics.
    But i’m surprised because your graphics has no color doubling as announced in the first post.

    t1 = 0;
    t2 = thisComp.duration;
    numCycles = 6;
    numStepsPerCycle = 8; // 6+2
    // ============================

    if (time<=t1 || t2<=time){0;}else{
    t = time-t1;
    fullDuration = t2-t1;

    stepDuration = fullDuration/(numCycles*numStepsPerCycle);
    cycleDuration = numStepsPerCycle*stepDuration;
    stepIndex = Math.floor(t/stepDuration);
    cycleIndex = Math.floor(stepIndex/numStepsPerCycle);
    stepIndexInCycle = stepIndex%numStepsPerCycle;

    phaseShiftPerCycle = 360/numCycles;
    shiftStart = cycleIndex*phaseShiftPerCycle;
    linear(t%cycleDuration, stepDuration, cycleDuration-stepDuration, shiftStart, shiftStart+360)%360;
    };

    Xavier

  • Rury Nelson

    September 23, 2016 at 1:56 pm

    Cheers man, works perfectly!

    The colour doubling I may have just explained badly, because you have it in perfectly. When working with maths like this is it generally worth sketching out how you want the motion graph to look or are there other methods that help?

  • Xavier Gomez

    September 23, 2016 at 2:08 pm

    Sketch is ideal.

    I realized some lines in the expression are superfluous and even not used. This one is better:

    t1 = 0;
    t2 = thisComp.duration;
    numCycles = 6;
    numStepsPerCycle = 8; // 6+2
    // ============================

    if (time<=t1 || t2<=time){0;}else{
    t = time-t1;
    fullDuration = t2-t1;

    stepDuration = fullDuration/(numCycles*numStepsPerCycle);
    cycleDuration = numStepsPerCycle*stepDuration;
    cycleIndex = Math.floor(t/cycleDuration);

    phaseShiftPerCycle = 360/numCycles;
    shiftStart = cycleIndex*phaseShiftPerCycle;
    linear(t%cycleDuration, stepDuration, cycleDuration-stepDuration, shiftStart, shiftStart+360)%360;
    };

    Xavier

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