summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authortimb <opuscule@gmail.com>2014-01-13 22:11:45 -0800
committertimb <opuscule@gmail.com>2014-01-13 22:11:45 -0800
commit5242f387995b6251ff1bf7902b3ac6428f381fb0 (patch)
tree15011b43f8e770096a98ee1cba30f993ff9049e2 /js
parent9401ffc256bc39dc085ebea21de4942083219b88 (diff)
make step work like in glsl... step(a,b) returns 0 if b < a, 1 otherwise
Diffstat (limited to 'js')
-rw-r--r--js/util.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/js/util.js b/js/util.js
index b728377..46943f9 100644
--- a/js/util.js
+++ b/js/util.js
@@ -56,9 +56,11 @@ 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 step (n,a,b) {
- return clamp((n - a) / (b - a), 0.0, 1.0);
+function step(a, b){
+ return (b >= a) + 0
+ // ^^ bool -> int
}
+
// hermite curve apparently
function smoothstep(n,a,b){
var t = clamp((n - a) / (b - a), 0.0, 1.0);