English | 简体中文
Supports #RGB[A]
, RGB[A]
, HSL[A]
interconversion RGB[A]
and HSL[A]
support comma
, percent sign
, /
, space
and other separators, with a total of 50 formats conversions. The following conversions are supported:
npm i color-transfer
import { HEXToHSL, HEXToRGB, RGBToHEX, RGBToHSL, HSLToHEX, HSLToRGB } from 'color-transfer'
HEXToRGB('#f36') // => [255, 51, 102]
RGBToHSL('rgba(100% 0% 60% / 0.4)') // => [324, 100, 50, 0.4]
// ...
-
#rgb => rgb(r,g,b)
-
#rgba => rgb(r,g,b,a)
-
#rrggbb => rgb(r,g,b)
-
#rrggbbaa => rgba(r,g,b,a)
-
#rgb => hsl(h,s%,l%)
-
#rgba => hsl(h,s%,l%,a)
-
#rrggbb => hsl(h,s%,l%)
-
#rrggbbaa => hsl(h,s%,l%,a)
-
(r,g,b) => #rgb
-
(r,g,b,a) => #rrggbbaa
-
rgb(r,g,b) => #rgb
-
rgba(r,g,b,a) => #rgba
-
rgba(r g b) => #rgb
-
rgba(r g b / a) => #rgba
-
rgb(r%,g%,b%) => #rgb
-
rgba(r%,g%,b%,a) => #rgba
-
rgba(r%,g%,b%,%a) => #rgba
-
rgb(r% g% b%) => #rgb
-
rgba(r% g% b% / a%) => #rgba
-
(r,g,b) => hsl(h,s%,l%)
-
(r,g,b,a) => hsl(h,s%,l%,a)
-
rgb(r,g,b) => hsl(h,s%,l%)
-
rgba(r,g,b,a) => hsl(h,s%,l%,a)
-
rgba(r g b) => hsl(h,s%,l%)
-
rgba(r g b / a) => hsl(h,s%,l%,a)
-
rgb(r%,g%,b%) => hsl(h,s%,l%)
-
rgb(r%,g%,b%,%a) => hsl(h,s%,l%,a)
-
rgb(r% g% b%) => hsl(h,s%,l%)
-
rgba(r% g% b% / a%) => hsl(h,s%,l%,a)
-
rgb(r%,g%,b%,a) => hsl(h,s%,l%,a)
-
(h,s%,l%) => #rgb
-
(h,s%,l%,a) => #rgba
-
hsl(h,s%,l%) => #rgb
-
(h,s%,l%,a) => #rgba
-
hsl(h s% l%) => #rgb
-
hsl(hdeg,s%,l%) => #rgb
-
hsl(hrad,s%,l%) => #rgb
-
hsl(hturn,s%,l%) => #rgb
-
hsla(h s% l% / a) => #rgba
-
hsla(h s% l% / a%) => #rgba
-
(h,s,l) => rgb(r,g,b)
-
(h,s,l,a) => rgb(r,g,b,a)
-
hsl(h,s,l) => rgb(r,g,b)
-
(h,s,l,a) => rgb(r,g,b,a)
-
hsl(h s l) => rgb(r,g,b)
-
hsl(hdeg,s,l) => rgb(r,g,b)
-
hsl(hrad,s,l) => rgb(r,g,b)
-
hsl(hturn,s,l) => rgb(r,g,b)
-
hsla(h s l / a) => rgb(r,g,b,a)rgb(r,g,b,a)
-
hsla(h s l / a%) => rgb(r,g,b,a)
- 📦 bundle
npm i
npm run build
- unit test
npm run test
All 50 type conversions have passed unit tested, with 100% unit test code coverage
- support for format output