block by aubergene 7791133

Simple JavaScript Scale

I love D3’s Quantitative Scales and wanted a simple way to create and use scales in that style.

Example

var centigradeToFahrenheit = new Scale().domain(-40, 0).range(-40, 32);
var fahrenheitToCentigrade = new Scale().domain(-40, 32).range(-40, 0);

centigradeToFahrenheit(35); // 95 hot!
fahrenheitToCentigrade(14); // -10 cold!

sideburns.js