-
sup all, new here, but i got something for ya :D
sup guys, so I have been working on this code for a bit, it still a work in progress, I would like to make a plug in for it, to create the objects in an interface : anyway here ya go:
let me know if you guys need help with how to make ur own event objects..
so the application for this, well its endless.. u don’t need to create keyframes.. all u need to know is when where and how 😀
ill add more tween formulas later if their is an intrest… and the ability to add ur own callback within each object.
I am using Object oriented programming in the example below: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(cell(t,b,c,d));}
};
Stage.prototype.getData = function (){
return database
};
return Stage
}())
function Events() {var d= [];
for(var i = 0; i < arguments.length ;i++){
d[i] = new Creator(arguments[i]);
d[i].timeEvent();
}
var current = d[0].getData();
for(var v = 0; v < current.length ; v++){
x = current[ToFrame()]
}
return x}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"} );