Skip to main content
Module

x/colors/mod.ts

Color conversion and stuff in TypeScript
Go to Latest
import * as colors from "https://deno.land/x/colors@v2.0.0-rc.2/mod.ts";

Variables

6 / 29

4 / 29

Standard illuminant D65

Functions

Get average of colors. Can be used for grayscale.

Calculate chroma

Convert RGB(A) to CMYK

Get contrast ratio

Find the nearest neighbour of a color in a palette It would be more accurate to use consider luminance along with Euclidean distance but I chose to stay with distance for performance.

Convert RGB(A) to HCG

Convert RGB(A) to Hex

Convert RGB(A) to Hue, Saturation, Lightness

Convert RGB(A) to Hue, Saturation, Value

Calculate hue using chroma

Inverse lab function

Invert HSV

Invert a color linearly

Bright colors darken, dark colors brighten.

CIE Lab color space

t = C / Cn ratio

Get lightness of color.

Get linear rgb values

Calculate luminance

Get maximum of r, g, b

Calculate mean distance between two colors

Get minimum of r, g, b

Mix with a different color. Copyright (c) 2006-2009 Hampton Catlin, Natalie Weizenbaum, and Chris Eppstein http://sass-lang.com

Get perceived lightness

Convert Hexadecimal string to RGBA

Convert CMYK to RGB

Convert HSL color to RGB

Convert HSV color to RGB

Convert CIE Lab to Linear RGB color space

Convert CIE XYZ to Linear RGB color space

Get saturation

Get a shade of the color

Stringify the RGBA color

Get a tint of the color

CIE 1931 XYZ

Convert CIE Lab* to CIE XYZ

Type Aliases

1-Channel Color (Grayscale)

3-Channel Color

4-Channel Color