Forum Replies Created

  • sorry guys i posted the wrong one, here is the right one..

    var _Database=[]; // database for the value of x

    function easeInQuad(t,b,c,d){ return c*(t/=d)*t + b;} ;

    function easeInOutExpo (x, t, b, c, d) {

    if (t==0) return b;

    if (t==d) return b+c;

    if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;

    return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;};

    function easeInOutElastic(t, b, c, d) {

    var s=1.70158;var p=0;var a=c;

    if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);

    if (a < Math.abs(c)) { a=c; var s=p/4; }

    else var s = p/(2*Math.PI) * Math.asin (c/a);

    if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;

    return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;

    };

    function easeInBack(t, b, c, d, s) {

    if (s == undefined) s = 1.70158;

    return c*(t/=d)*t*((s+1)*t - s) + b;

    };

    var timeToFrame = 0;

    function ToFrame(){ timeToFrame= timeToFrames(time); var d = timeToFrame;if(d > _Database.length-1){ return d= _Database.length-1 } return d };

    var Creator = (function(){
    var _switch = true;
    var database = [];
    function Stage(event){

    if(!event){ return this}
    this.from = event.from;
    this.to = event.to - event.from ;
    this.duration = event.duration;
    this.type = event.type;
    }
    Stage.prototype.timeEvent = function (){
    function cell(t, b, c, d) {

    switch (now)

    {

    case "easeInQuad" : return easeInQuad(t,b,c,d) ;

    case "easeInBack" : return easeInBack(t,b,c,d) ;

    case "easeInOutElastic" :return easeInOutElastic(t,b,c,d);

    }

    }
    var frameRate = 1.0 / thisComp.frameDuration;
    var now = this.type;
    var c = this.to;
    var b = this.from;
    var d = this.duration * frameRate; ;
    for(var t = 0; t <d ; t++){
    database.push(cell(t,b,c,d));
    _Database.push(t);

    }
    };
    Stage.prototype.getData = function (){
    return database
    };
    return Stage
    }())
    function Events() {

    var d= [];
    for(var i = 0; i &lt; arguments.length ;i++){
    d[i] = new Creator(arguments[i]);
    d[i].timeEvent();
    }
    var current = d[0].getData();
    for(var v = 0; v &lt; current.length ; v++){
    x = current[ToFrame()]
    }
    return x}

    v = Events({to:2000, from:0, duration: 2, type: "easeInBack" },{to:400, from:2000, duration: 4, type: "easeInOutElastic"},{to:1200, from:400, duration: 2, type: "easeInBack"} );

  • ok so i updated the below code that that it doesnt do the math twice, as i had it doing so before, i did test this out on 20 shape layers at the same time, performance was fine.. but the more shape layers the more the pc has to cal..

    ok be singing off now :p

    var _Database=[]; // database for the value of x

    function easeInQuad(t,b,c,d){ return c*(t/=d)*t + b;} ;

    function easeInOutExpo (x, t, b, c, d) {

    if (t==0) return b;

    if (t==d) return b+c;

    if ((t/=d/2) &lt; 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;

    return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;};

    function easeInOutElastic(t, b, c, d) {

    var s=1.70158;var p=0;var a=c;

    if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);

    if (a &lt; Math.abs(c)) { a=c; var s=p/4; }

    else var s = p/(2*Math.PI) * Math.asin (c/a);

    if (t &lt; 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;

    return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;

    };

    function easeInBack(t, b, c, d, s) {

    if (s == undefined) s = 1.70158;

    return c*(t/=d)*t*((s+1)*t - s) + b;

    };

    var timeToFrame = 0;

    function ToFrame(){ timeToFrame= timeToFrames(time); var d = timeToFrame;if(d > _Database.length-1){ return d= _Database.length-1 } return d };

    var Creator = (function(){
    var _switch = true;
    var database = [];
    function Stage(event){

    if(!event){ return this}
    this.from = event.from;
    this.to = event.to - event.from ;
    this.duration = event.duration;
    this.type = event.type;
    }
    Stage.prototype.timeEvent = function (){
    function cell(t, b, c, d) {

    switch (now)

    {

    case "easeInQuad" : return easeInQuad(t,b,c,d) ;

    case "easeInBack" : return easeInBack(t,b,c,d) ;

    case "easeInOutElastic" :return easeInOutElastic(t,b,c,d);

    }

    }
    var frameRate = 1.0 / thisComp.frameDuration;
    var now = this.type;
    var c = this.to;
    var b = this.from;
    var d = this.duration * frameRate; ;
    for(var t = 0; t <d ; t++){
    database.push(cell(t,b,c,d));
    _Database.push(cell(t,b,c,d));

    }
    };
    Stage.prototype.getData = function (){
    return database
    };
    return Stage
    }())
    function Events() {

    var d= [];
    for(var i = 0; i &lt; arguments.length ;i++){
    d[i] = new Creator(arguments[i]);
    d[i].timeEvent();
    }
    var current = d[0].getData();
    for(var v = 0; v &lt; current.length ; v++){
    x = current[ToFrame()]
    }
    return x}

    v = Events({to:2000, from:0, duration: 2, type: "easeInBack" },{to:400, from:2000, duration: 4, type: "easeInOutElastic"},{to:1200, from:400, duration: 2, type: "easeInBack"} );

  • funny thing is that is how that code works, ill breake it down.. but u are right i have stuff int here that can be removed, tho i left it in for lazyness, and its only a concept at the moment..

    the creator ( a class object) takes 4 propeties, and contains them in an object, creates the data in a datase ( array), then Event fucntion goes over the database via timeToFrames method, and once it reaches the end thats it..

  • so what i am trying to create in affer effect is a page from robert penner programing in macromdia but in affter effects:

    https://robertpenner.com/easing/

  • thats correct, at the moment i only have 3 type of “ease” you can select from:

    “easeInQuad”

    “easeInBack”

    “easeInOutElastic”

    so test this copy the statment from the org post, and then modify this line:

    v = Events({to:360, from:0, duration: 2, type: “easeInBack” },{to:720, from:360, duration: 4, type: “easeInOutElastic”},{to:0, from:720, duration: 4, type: “easeInOutElastic”} );

    to be whatever u want, u can create as many or as lil objects withi event….

    this can be applied to anything, from effect to poistion..

  • just becuase there is alot of data their doesnt mean that its not efficient, rather the code is very simple…However i will try to overload my pc to see the results… ill get back to this post..

    however if u have an idea how i can create movment without key frames for automation let me know.

  • so one of the principle OOP is encapsulation, all u need to know is the Events takes the following:

    {to: (location of where to go) , from : ( location before), duration : (how log it will take to get there in sec), type: ( the “ease type you want to apply to each object)}

    so what makes this code interesting is one two things… u can have different type of “ease” for each object, and u can have an endless about of event objects within a position…

  • hey check out what I just posted here, it might help ya. as I think the code does what you want ( https://forums.creativecow.net/thread/227/32713 )

    Dan C

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