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 rgbToHSL
rgbToHSL(rgb: Array<number>): Array<number>

Converts RGB(A) color arrays to HSL(A) color arrays.

Examples

Conversion without alpha channel:

const rgb = [ 255 , 0 , 0 ] // Red

const hsl = rgbToHSL(rgb)

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

Conversion with alpha channel:

const rgba = [ 255 , 0 , 0 , 69 ] // Green

const hsl = rgbToHSL(rgba)

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

Parameters

[ 𝗥𝗲𝗱 0 - 255 , 𝗚𝗿𝗲𝗲𝗻 0 - 255 , 𝗕𝗹𝘂𝗲 0 - 255 , ( 𝗔𝗹𝗽𝗵𝗮 0 - 255 ) ]

Return Type

[ 𝗛𝘂𝗲 0 - 360 , 𝗦𝗮𝘁𝘂𝗿𝗮𝘁𝗶𝗼𝗻 0 - 100 , 𝗟𝗶𝗴𝗵𝘁𝗻𝗲𝘀𝘀 0 - 100 , ( 𝗔𝗹𝗽𝗵𝗮 0 - 255 ) ]

Add Package

deno add jsr:@omega/color

Import symbol

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

---- OR ----

Import directly with a jsr specifier

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

Add Package

npx jsr add @omega/color

Import symbol

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

Add Package

yarn dlx jsr add @omega/color

Import symbol

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

Add Package

pnpm dlx jsr add @omega/color

Import symbol

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

Add Package

bunx jsr add @omega/color

Import symbol

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