Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | /*!
* Copyright (c) Microsoft. All rights reserved.
* Licensed under the MIT license. See LICENSE file in the project.
*/
interface RGB {
r: number
g: number
b: number
}
/**
* Creates RGB color object from HEX color string
* @param color - HEX color string
* @returns rgb color object \{r:number, g: number, b:number\}
*/
export function parseRgbFromCssColor(colorInput: string): RGB {
const color = colorInput.replace('#', '') // strip of leading # if necessary
const colorNumber = parseInt(color, 16)
return {
r: colorNumber >> 16,
g: (colorNumber >> 8) & 255,
b: colorNumber & 255,
}
}
|