summaryrefslogtreecommitdiff
path: root/assets/javascripts/math
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/math')
-rw-r--r--assets/javascripts/math/util.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/assets/javascripts/math/util.js b/assets/javascripts/math/util.js
index 609bdd6..396d8cd 100644
--- a/assets/javascripts/math/util.js
+++ b/assets/javascripts/math/util.js
@@ -67,6 +67,7 @@ function dist(x0,y0,x1,y1){ return sqrt(pow(x1-x0,2)+pow(y1-y0,2)) }
function angle(x0,y0,x1,y1){ return atan2(y1-y0,x1-x0) }
function avg(m,n,a){ return (m*(a-1)+n)/a }
function noop(){}
+function toArray(a){ return Array.prototype.slice.call(a) }
function pixel(x,y){ return 4*(mod(y,actual_h)*actual_w+mod(x,actual_w)) }
function rgbpixel(d,x,y){
@@ -254,3 +255,42 @@ function selectElementContents(el) {
}
}
+
+// 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 );
+}
+Model=function a(b,c,d,e){function f(){var a=this,f={};a.on=function(a,b){(f[a]||
+(f[a]=[])).push(b)},a.trigger=function(a,b){for(var c=f[a],d=0;c&&d<c.length;)c
+[d++](b)},a.off=function(a,b){for(d=f[a]||[];b&&(c=d.indexOf(b))>-1;)d.splice(c
+,1);f[a]=b?d:[]};for(c in b)d=b[c],a[c]=typeof d=="function"?function(){return(
+d=this.apply(a,arguments))===e?a:d}.bind(d):d;a.init&&a.init.apply(a,arguments)
+}return f.extend=function(f){d={};for(c in b)d[c]=b[c];for(c in f)d[c]=f[c],b[c
+]!==e&&(d["__"+c]=b[c]);return a(d)},f},typeof module=="object"&&(module.exports
+=Model); // c-{{{-<
+
+