diff options
| author | Julie Lala <jules@okfoc.us> | 2014-04-15 20:15:31 -0400 |
|---|---|---|
| committer | Julie Lala <jules@okfoc.us> | 2014-04-15 20:15:31 -0400 |
| commit | 1e0cefea2daa2f757e9bd8c824c75b77c368ca07 (patch) | |
| tree | 265c3576590c267da3437d092569c2b442d2178f /assets/javascripts/util.js | |
| parent | 28da2a26238ff76f87f4e086a9832a5478c35b23 (diff) | |
| parent | 9c3c0151cb2b0a824f184501ea2672ef9e87a993 (diff) | |
merge
Diffstat (limited to 'assets/javascripts/util.js')
| -rw-r--r-- | assets/javascripts/util.js | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/assets/javascripts/util.js b/assets/javascripts/util.js index 81103aa..c56131d 100644 --- a/assets/javascripts/util.js +++ b/assets/javascripts/util.js @@ -12,6 +12,7 @@ var E = Math.E var PI = Math.PI var PHI = (1+Math.sqrt(5))/2 var TWO_PI = PI*2 +var HALF_PI = PI/2 var LN10 = Math.LN10 function clamp(n,a,b){ return n<a?a:n<b?n:b } function norm(n,a,b){ return (n-a) / (b-a) } @@ -112,6 +113,14 @@ function weave(a){ reverse(aa[1]).forEach(function(el){ b.push(el) }) return b } +function range(m,n,s){ + var a = [] + s = s || 1 + for (var i = m; i <= n; i += s) { + a.push(i) + } + return a +} var guid_syllables = "iz az ez or iv ex baz el lo lum ot un no".split(" ") var guid_n = 0 @@ -139,28 +148,3 @@ function smarten(a) { a = a.replace(/--/g, "\u2014"); // em-dashes return a }; - -(function() { - var lastTime = 0; - var vendors = ['ms', 'moz', 'webkit', 'o']; - for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; - window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] - || window[vendors[x]+'CancelRequestAnimationFrame']; - } - - if (!window.requestAnimationFrame) - window.requestAnimationFrame = function(callback, element) { - var currTime = new Date().getTime(); - var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(function() { callback(currTime + timeToCall); }, - timeToCall); - lastTime = currTime + timeToCall; - return id; - }; - - if (!window.cancelAnimationFrame) - window.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; -}()); |
