Skip to content

pantoken-root / design/swatches/src / hexToRgb

Funkcja: hexToRgb() ​

hexToRgb(hex): Rgb | undefined

Eksperymentalne

Parsuj #rgb/#rrggbb/#rrggbbaa na kanały 0–255 albo undefined, jeśli nie jest to kolor szesnastkowy.

Parametry ​

hex ​

string

Zwraca ​

Rgb | undefined

Przykład ​

ts
import { hexToRgb } from "@pantoken/swatches";

hexToRgb("#ff8800"); // { r: 255, g: 136, b: 0 }
hexToRgb("nope"); // undefined