Colors
hexToRGB

It converts hexadecimal color values into RGB color values.

⚠️

It does not work with shorthand form & alpha param.

Syntax

import { hexToRGB } from '@opentf/std';
 
hexToRGB(hex: string): number[];

Examples

hexToRGB("#000000"); //=> [0, 0, 0]
 
hexToRGB("#FFFFFF"); //=> [255, 255, 255]
 
hexToRGB("#ffffff"); //=> [255, 255, 255]
 
hexToRGB("#FF0000"); //=> [255, 0, 0]
 
hexToRGB("#00FF00"); //=> [0, 255, 0]
 
hexToRGB("#0000FF"); //=> [0, 0, 255]
 
hexToRGB("#AAAAAA"); //=> [170, 170, 170]
 
hexToRGB("#DDDDDD"); //=> [221, 221, 221]
 
hexToRGB("#ff851b"); //=> [255, 133, 27]

Try