From 04537ed34d443d0610b77420d1dbef64bc05fbfa Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 22 Nov 2014 23:19:12 -0500 Subject: fix atan2 --- js/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/util.js b/js/util.js index 7bb1c78..1a1a0fe 100644 --- a/js/util.js +++ b/js/util.js @@ -30,7 +30,7 @@ function tan(n){ return Math.tan(n) } function acos(n){ return Math.cos(n) } function asin(n){ return Math.sin(n) } function atan(n){ return Math.atan(n) } -function atan2(n){ return Math.atan2(n) } +function atan2(a,b){ return Math.atan2(a,b) } function sec(n){ return 1/cos(n) } function csc(n){ return 1/sin(n) } function cot(n){ return 1/tan(n) } -- cgit v1.2.3-70-g09d2 From bf3ba2a13ed3e97f1caabfcd04762a6a8ed5db8c Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 16 Dec 2014 04:13:12 -0500 Subject: easing functions --- js/util.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'js') diff --git a/js/util.js b/js/util.js index 911e44b..f76fc8e 100644 --- a/js/util.js +++ b/js/util.js @@ -114,3 +114,32 @@ function weave(a){ reverse(aa[1]).forEach(function(el){ b.push(el) }) return b } + +// easing functions +function circular (t) { return Math.sqrt( 1 - ( --t * t ) ) } +function quadratic (t) { return t * ( 2 - t ) } +function back (t) { + var b = 4; + return ( t = t - 1 ) * t * ( ( b + 1 ) * t + b ) + 1; +} +function bounce (t) { + if (t >= 1) return 1; + if ( ( t /= 1 ) < ( 1 / 2.75 ) ) { + return 7.5625 * t * t; + } else if ( t < ( 2 / 2.75 ) ) { + return 7.5625 * ( t -= ( 1.5 / 2.75 ) ) * t + 0.75; + } else if ( t < ( 2.5 / 2.75 ) ) { + return 7.5625 * ( t -= ( 2.25 / 2.75 ) ) * t + 0.9375; + } else { + return 7.5625 * ( t -= ( 2.625 / 2.75 ) ) * t + 0.984375; + } +} +function elastic (t) { + var f = 0.22, + e = 0.4; + + if ( t === 0 ) { return 0; } + if ( t == 1 ) { return 1; } + + return ( e * Math.pow( 2, - 10 * t ) * Math.sin( ( t - f / 4 ) * ( 2 * Math.PI ) / f ) + 1 ); +} -- cgit v1.2.3-70-g09d2