UNPKG

e-lado

Version:

[![CircleCI](https://circleci.com/gh/sharetribe/sharetribe/tree/master.svg?style=svg)](https://circleci.com/gh/sharetribe/sharetribe/tree/master) [![Dependency Status](https://gemnasium.com/sharetribe/sharetribe.png)](https://gemnasium.com/sharetribe/shar

11 lines (8 loc) 450 B
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;