Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression selector and wiggle workaround

  • Expression selector and wiggle workaround

    Posted by Mateo Mazzini on September 5, 2016 at 7:52 pm

    Hi, I am using a code shown in this thread(https://forums.adobe.com/thread/420410) in the following project (https://www.dropbox.com/s/srduk6ph128nrcy/first%20attempt.aep?dl=1 )
    this expression animates the text using an expression selector with a wiggle calculated for each character so they change randomly.
    I use a layer called “type here” where you can type a text that will appear in another layer, from the random characters wiggle.
    i’m pretty happy with this outcome, but I would really like it to be faster to calculate
    Does anybody has a workaround on this?
    also, I would like to know if there’s a way to recalculate the kerning after the expression is executed, because right now, it seems to keep the kerning of the character matrix that I’ve built to be able to execute this.
    thank you!
    Mateo.

    /*the center idea of this expression is to take the full ascii character range (0 - 65535),
    and use a wiggle to change between characters. the problem is that only few characters of that range
    are "visible", so I choose the range between the 33 and the 254. which you can check here: https://www.asciitable.com.
    that range it is used in percentage representation because the expression selector works that way. So in order to represent
    the character 33, and 254 of the ascii table i have to use these numbers:
    character 33=0.0503547722591
    middle character= 0.1686121919585
    character 254 =0.38757915617609
    which you will see all along this code.*/

    //define the variables to use and set the random rig
    seedRandom(textIndex*(thisComp.layer("CONTROLS").effect("Random")("Slider")),true)
    var IT = thisComp.layer("INPUT TEXT").text.sourceText;
    var OT = text.sourceText;
    var t=random(0,thisComp.layer("CONTROLS").effect("MaxrandomIN")("Slider"));
    var tOut=random(0,thisComp.layer("CONTROLS").effect("MaxrandomOUT")("Slider"));
    var tStart=thisComp.layer("CONTROLS").effect("Text Start Time")("Slider");
    var vIn=thisComp.layer("CONTROLS").effect("Velocity IN Text")("Slider");
    var of=thisComp.layer("CONTROLS").effect("Offset")("Slider");
    var asciiMod=linear(thisComp.layer("CONTROLS").effect("ASCII Modifier")("Slider"),0,100,0,0.1686121919585);
    var asciiOf=linear(thisComp.layer("CONTROLS").effect("ASCII Offset")("Slider"),0,100,0.0503547722591,0.38757915617609);
    var velMa=thisComp.layer("CONTROLS").effect("Velocity Matrix")("Slider");
    CarV = text.animator("Code").property.characterValue;

    //make a wiggle to pivot from the middle of the ascii table, driven by the ascii modifier control
    var wigg=wiggle(velMa,asciiMod)-100;

    //define data, which is a point in reference of the visible values of the ascii table.
    var data=asciiOf;

    //state the var data, which oscilates between the range of characters defined in wigg.
    /*note that, if ASCII Offset is set too high or too low, and ASCII Modifier are set too high,
    characters will tend to be ones which are not visible.*/
    data+wigg[0];

    //use time conditionals with t var to control the characters' random turning on and off.
    if(time<=t){0;};
    if(time>=tOut+thisComp.layer("CONTROLS").effect("Duration")("Slider")){0;};

    //use a set of conditionals to set the characters written in the TYPE HERE layer when "Text Start Time" indicates
    if(textIndex>of){
    if(time>=((textIndex+(vIn-1)-(of+4)+tStart)/vIn)&&textIndex<=(IT.length)){
    if(textIndex < OT.length) STCode = OT.charCodeAt(textIndex) else OTCode = 0;
    if(textIndex <= IT.length) ITCode = IT.charCodeAt(textIndex-1) else ITCode = 0;
    linear(ITCode, OTCode*2-CarV, CarV,-100,100)
    };
    };

    //now I'll paste the code from the source text in this layer

    //this code fills a Matrix of characters with value 0 in the ascii table, so it can be replace later with random characters.
    var T=String.fromCharCode(0);
    for(var i=0;i<thisComp.layer("CONTROLS").effect("Matrix Size")("Slider");i++){
    T+=String.fromCharCode(0);
    if(T.length % thisComp.layer("CONTROLS").effect("Matrix Width")("Slider") == 0)
    T+="\r"
    };
    T;

    //now I'll paste the code from the layer INPUT TEXT.sourceText

    /*this code puts spaces at the begining of the text typed by the user.
    the amount is controlled by the offset control.*/
    var t=thisComp.layer("TYPE HERE").text.sourceText;
    var t2="";
    var of=thisComp.layer("CONTROLS").effect("Offset")("Slider");
    for(i=0;i<of;i++){
    t2+=" ";
    };
    t2+=t;
    t2;

    Matz

    Mateo Mazzini replied 9 years, 8 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

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