mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 17:35:16 +00:00
11 lines
450 B
JavaScript
11 lines
450 B
JavaScript
|
function shortenRgb(red, green, blue) {
|
||
|
var normalizedRed = Math.max(0, Math.min(parseInt(red), 255));
|
||
|
var normalizedGreen = Math.max(0, Math.min(parseInt(green), 255));
|
||
|
var normalizedBlue = Math.max(0, Math.min(parseInt(blue), 255));
|
||
|
|
||
|
// Credit: Asen http://jsbin.com/UPUmaGOc/2/edit?js,console
|
||
|
return '#' + ('00000' + (normalizedRed << 16 | normalizedGreen << 8 | normalizedBlue).toString(16)).slice(-6);
|
||
|
}
|
||
|
|
||
|
module.exports = shortenRgb;
|