Skip to main content

@omega/color@1.2.11
Built and signed on GitHub Actions

Various color conversions.

This package works with Node.js, Deno, Bun, BrowsersIt is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
6 months ago (1.2.11)
function hexToHSL
hexToHSL(hex: string): Array<number>

Parses a hex RGB(A) color code into a HSL(A) array.

Examples

Parsing a long form RGBA hex code with alpha:

const hex = '#FF000069' // Red

const hsl = hexToHSL(hex)

console.debug(hsl) // [ 0 , 100 , 50 , 69 ]

Parsing a short form RGB hex code without #:

const hex = 'F00' // Red

const hsl = hexToHSL(hex)

console.debug(hsl) // [ 0 , 100 , 50 ]

Parameters

Hex RGB(A) color code string.

Return Type

[ 𝗛𝘂𝗲 0 - 360 , 𝗦𝗮𝘁𝘂𝗿𝗮𝘁𝗶𝗼𝗻 0 - 100 , 𝗟𝗶𝗴𝗵𝘁𝗻𝗲𝘀𝘀 0 - 100 ]

Add Package

deno add jsr:@omega/color

Import symbol

import { hexToHSL } from "@omega/color/HSL";

---- OR ----

Import directly with a jsr specifier

import { hexToHSL } from "jsr:@omega/color/HSL";

Add Package

npx jsr add @omega/color

Import symbol

import { hexToHSL } from "@omega/color/HSL";

Add Package

yarn dlx jsr add @omega/color

Import symbol

import { hexToHSL } from "@omega/color/HSL";

Add Package

pnpm dlx jsr add @omega/color

Import symbol

import { hexToHSL } from "@omega/color/HSL";

Add Package

bunx jsr add @omega/color

Import symbol

import { hexToHSL } from "@omega/color/HSL";