Skip to main content
Home

Built and signed on GitHub Actions

Functional color conversion, shade/tint generation, and more in TypeScript.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
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
9 months ago (2.0.2)

A collection of functions to extract information from colors, generate shades and tints, convert to other color spaces, etc.

Note: All methods either accept RGB/RGBA colors as parameters or give RGB/RGBA colors as results. In order to work with other color spaces (eg. XYZ), convert them to RGB first.

Examples

Example 1

// Deno /x
import { rgbaFromHex, xyz, lab } from "https://deno.land/x/colors/mod.ts";

// Deno JSR
import { rgbaFromHex, xyz, lab } from "jsr:@retraigo/colors";

// Node JSR (after installation)
import { rgbaFromHex, xyz, lab } from "jsr:@retraigo/colors";

const color = rgbaFromHex("#fceff1");

// CIE XYZ color space
console.log(xyz(color));

// CIE LAB color space
console.log(lab(color));

// Conversion of color into all supported spaces
console.log(json(color));
Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@retraigo/colors

Import symbol

import * as colors from "@retraigo/colors";
or

Import directly with a jsr specifier

import * as colors from "jsr:@retraigo/colors";

Add Package

pnpm i jsr:@retraigo/colors
or (using pnpm 10.8 or older)
pnpm dlx jsr add @retraigo/colors

Import symbol

import * as colors from "@retraigo/colors";

Add Package

yarn add jsr:@retraigo/colors
or (using Yarn 4.8 or older)
yarn dlx jsr add @retraigo/colors

Import symbol

import * as colors from "@retraigo/colors";

Add Package

vlt install jsr:@retraigo/colors

Import symbol

import * as colors from "@retraigo/colors";

Add Package

npx jsr add @retraigo/colors

Import symbol

import * as colors from "@retraigo/colors";

Add Package

bunx jsr add @retraigo/colors

Import symbol

import * as colors from "@retraigo/colors";