summaryrefslogtreecommitdiff
path: root/assets/javascripts/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/util.js')
-rw-r--r--assets/javascripts/util.js34
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);
- };
-}());