var potato=potato||{};potato.fx=potato.fx||{};
potato.fx.Tween=function(d,b){function c(){e=(new Date).getTime();a.config.onStart!=null&&a.config.onStart();__engine.add(a)}this.ratio=0;if(b==null)b={};this.config=b;var f=0,e=0,a=this,h=null;if(b.curve==null)b.curve=potato.fx.Ease.linear;this.start=function(g){clearTimeout(g);if(h)c();else h=setTimeout(c,g);return this};this.stop=function(){clearTimeout(delay);__engine.remove(a)};this.update=function(g){if(g==null)g=__engine.getTime();f=g-e;if(f>d)f=d;this.ratio=b.curve(f,0,1,d);b.onUpdate!=null&&
a.config.onUpdate!=null&&a.config.onUpdate(a);if(f==d){__engine.remove(a);a.config.onComplete!=null&&a.config.onComplete(a)}};return this};
var TweenEngine=function(){this.itens=[];this.updatesPerSecond=60;var d=null,b=TweenState.SLEEPING,c=this,f=new Date;this.add=function(e){c.itens.push(e);c.run()};this.remove=function(e){c.itens.splice(this.itens.indexOf(e),1);c.itens.length==0&&c.sleep()};this.update=function(){for(var e=(new Date).getTime(),a=0;a<c.itens.length;a++)c.itens[a].update(e)};this.run=function(){if(b!=TweenState.RUNNING){b=TweenState.RUNNING;clearInterval(d);d=setInterval(this.update,1E3/this.updatesPerSecond);this.update()}};
this.sleep=function(){if(b!=TweenState.SLEPPING){b=TweenState.SLEEPING;clearInterval(d)}};this.getTime=function(){return f.getTime()}},TweenState={};TweenState.SLEEPING="sleeping";TweenState.RUNNING="running";TweenState.COMPLETED="finished";var __engine=new TweenEngine;
