mpp-server-dev2/src/ColorEncoder.js

16 lines
382 B
JavaScript
Raw Normal View History

2020-04-07 09:55:16 +02:00
function hashCode(str) { // java String#hashCode
var hash = 0;
for (var i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
return hash;
}
function intToRGB(i){
var c = (i & 0x00FFFFFF)
.toString(16)
.toUpperCase();
return "00000".substring(0, 6 - c.length) + c;
}
module.exports = {hashCode, intToRGB};