toColorPart

toColorPart() -> String

Produces a 2-digit hexadecimal representation of the number (which is therefore assumed to be in the [0..255] range). Useful for composing CSS color strings.

Examples


128.toColorPart()
// -> '70'

10.toColorPart()
// -> '0a'

'#' + [128, 10, 16].invoke('toColorPart').join('')
// -> '#800a10'