MCPcopy Create free account
hub / github.com/breck7/scroll / bimap

Function bimap

external/.d3.js:14971–14976  ·  view source on GitHub ↗
(domain, range, interpolate)

Source from the content-addressed store, hash-verified

14969// normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
14970// interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b].
14971function bimap(domain, range, interpolate) {
14972 var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
14973 if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
14974 else d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
14975 return function(x) { return r0(d0(x)); };
14976}
14977
14978function polymap(domain, range, interpolate) {
14979 var j = Math.min(domain.length, range.length) - 1,

Callers

nothing calls this directly

Calls 2

normalizeFunction · 0.85
interpolateFunction · 0.85

Tested by

no test coverage detected