summaryrefslogtreecommitdiff
path: root/js/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/util.js')
-rw-r--r--js/util.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/js/util.js b/js/util.js
index 5466c07..0dffc74 100644
--- a/js/util.js
+++ b/js/util.js
@@ -3,7 +3,28 @@ if (window.$) {
$.fn.float = function(){ return parseFloat($(this).val()) }
}
+var E = Math.E
+var PI = Math.PI
function clamp(n,a,b){ return n<a?a:n<b?n:b }
+function lerp(n,a,b){ return (b-a)*n+a }
+function mix(n,a,b){ return a*(1-n)+b*n }
+function ceil(n){ return Math.ceil(n) }
+function floor(n){ return Math.floor(n) }
+function round(n){ return Math.round(n) }
+function sin(n){ return Math.sin(n) }
+function cos(n){ return Math.cos(n) }
+function tan(n){ return Math.tan(n) }
+function atan(n){ return Math.atan(n) }
+function rand(n){ return (Math.random()*n) }
+function randint(n){ return rand(n)|0 }
+function choice(a){ return a[randint(a.length)] }
+function deg(n){ return n*180/PI }
+function rad(n){ return n*PI/180 }
+function smoothstep(n,a,b){
+ var t = clamp((n - a) / (b - a), 0.0, 1.0);
+ return t * t * (3.0 - 2.0 * t)
+}
+
function loadImage(imageURL, callback) {
var imageURL = proxify( imageURL );