This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateID() { | |
return ("000000" + (Math.random()*Math.pow(36,6) << 0).toString(36)).slice(-6)); | |
} | |
function generateIDFromStr() { | |
var seed = str.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0); | |
return ( "000000" + ( seed << 0 ).toString( 36 ) ).slice( -6 ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Number.prototype.clamp = function(min, max) { | |
return Math.min(Math.max(this, min), max); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//returns the interpolated value from a and b at the given weight (from 0 to 1) | |
var lerp = function(a, b, w) { | |
return (1 - w) * a + w * b; | |
} |
NewerOlder