From 282657a4beb7c78c4420c6b8268d8d929fe6a670 Mon Sep 17 00:00:00 2001 From: timb Date: Tue, 14 Jan 2014 23:33:59 -0800 Subject: reorder smoothstep args, add julestep fn back --- instructions.html | 2 +- js/util.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/instructions.html b/instructions.html index fb522c0..dff99d8 100644 --- a/instructions.html +++ b/instructions.html @@ -30,7 +30,7 @@ E, PI, PHI clamp(n,min,max) mix(n,a,b) (lerp) step(a,b) -smoothstep(n,a,b) +smoothstep(min,max,n) avg(m,n,a) cosp, sinp (mapped to [0,1]) pixel(x,y) == 4*(y*w+h) diff --git a/js/util.js b/js/util.js index 46943f9..7bb1c78 100644 --- a/js/util.js +++ b/js/util.js @@ -61,9 +61,13 @@ function step(a, b){ // ^^ bool -> int } +function julestep (a,b,n) { + return clamp((n - a) / (b - a), 0.0, 1.0); +} + // hermite curve apparently -function smoothstep(n,a,b){ - var t = clamp((n - a) / (b - a), 0.0, 1.0); +function smoothstep(min,max,n){ + var t = clamp((n - min) / (max - min), 0.0, 1.0); return t * t * (3.0 - 2.0 * t) } -- cgit v1.2.3-70-g09d2