Skip to content

Instantly share code, notes, and snippets.

@neocoder
Created September 23, 2011 08:36
Show Gist options
  • Save neocoder/1236966 to your computer and use it in GitHub Desktop.
Save neocoder/1236966 to your computer and use it in GitHub Desktop.
Logorithmic slider function
// Thanks to STH - http://stackoverflow.com/users/56338/sth
function logslider(value) {
// value will be between 0 and 100
var min = 0;
var max = 100;
// The result should be between 100 an 10000000
var minv = Math.log(100);
var maxv = Math.log(10000000);
// calculate adjustment factor
var scale = (maxv-minv) / (max-min);
return Math.exp(minv + scale*(value-min));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment