Node.js examples for Number:Random Number
Get random color
exports.randomColor = function() { var color = '#' + ('00000' + (Math.random() * (1 << 24) | 0).toString(16)).slice(-6); var c = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(color); var r = (parseInt(c[1], 16) - 32) > 0 ? (parseInt(c[1], 16) - 32) : 0; var g = (parseInt(c[2], 16) - 32) > 0 ? (parseInt(c[2], 16) - 32) : 0; var b = (parseInt(c[3], 16) - 32) > 0 ? (parseInt(c[3], 16) - 32) : 0; return {/*from w w w . ja va 2 s .c om*/ fill: color, border: '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1) }; };