npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@open-kappa/colors

v0.1.2

Published

Color library

Readme

@open-kappa/colors

A professional, high-precision color manipulation library for TypeScript and JavaScript. Designed for scientific accuracy, HDR workflows, and modern web standards.

Features

  • Type-Safe: Written purely in strict TypeScript.
  • Universal: Supports both ESM (EcmaScript Modules) and CommonJS. Works in Node.js and Browsers.
  • Professional Grade: Designed with many advanced use cases in mind.
    • Immutable Objects For predictable state management.
    • High Precision: Uses spectral calculations and high-bit depth logic where applicable. 1 * HDR Support: Handles out-of-bound values (values > 1.0 or < 0.0) natively without clamping.
  • Advanced Capabilities:
    • Tone Mapping: Includes industry standards like AgX, ACES (Rgb/Luminance), and Reinhard.
    • Gamut Mapping: Perceptual compression using Oklch/Oklab logic.
    • Chromatic Adaptation: Automatic White Point balancing (e.g., D50 D65) using Bradford matrices.
  • Utilities:
    • Accessibility: WCAG contrast ratios and APCA.
    • CVD: Color Vision Deficiency (Color Blindness) simulation and correction.
    • Extraction: K-Means and Median Cut algorithms for palette generation from images.
    • Generators: Palettes, scales, gradients, and statistical distributions.
  • Tree-Shakeable: Import only what you need.

Installation

npm install @open-kappa/colors
// Or
bun install @open-kappa/colors

Quick Start

Basic Conversion

Simple conversion between spaces. By default, high-precision mathematical conversions are used.

import {
    Hex,
    Oklch
} from "@open-kappa/colors"

// Parse a color
const red = Hex.fromRgbHexString("#FF0000")

// Convert to modern perceptual space
const oklch = red.to(Oklch)
console.log(oklch.components) // [0.627, 0.257, 29.23, 1]

Advanced HDR Pipeline

Handle complex scenarios like converting an HDR Rec.2020 color to a standard sRGB monitor, applying Tone Mapping and Gamut Mapping automatically.

import {
    Base,
    Rec2020,
    Rgb
} from "@open-kappa/colors"

// An extremely bright HDR red (unsupported by standard monitors)
const superBright = Rec2020.fromComponents([2.0, 0, 0, 1])

// "The Ultimate Conversion": White Balance -> Tone Map -> Gamut Map
const displayReady = Base.convert(superBright, Rgb, {
    "gamutMapping": true,
    // Use modern AgX filmic tone mapping
    "toneMapping": {"fn": "agX", "look": "punchy"},
    "whiteBalance": "bradford"
})

Supported Spaces

Currently supports 28 color spaces, including legacy, print, and modern HDR standards:

  • Standard RGB: RGB (sRGB), Linear RGB, P3 (Display P3), Adobe RGB, ProPhoto RGB (ROMM RGB), Rec.2020, Rec.709
  • CIE Standards: XYZ (D65), XYZ D50, xyY, Lab (CIELAB), Luv, Lch (CIELCH), Lch(uv)
  • Perceptual & HDR: Oklab, Oklch, ICtCp (ITU-R BT.2100), JzAzBz (IzAzBz), JzCzHz
  • LMS: LMS (Oklab/V3), Lms2006, LmsCat02, LmsHpe
  • Digital Video/Legacy: YCbCr, YUV, ACEScg
  • Cylindrical/Web: HSL, HSV (HSB), HWB
  • Print: CMYK

Architecture

To ensure maintainability and tree-shakability, the library uses a Star Topology. Every color space maps directly to/from XYZ (D65). This allows conversion between any two spaces in exactly two steps, avoiding the complexity of direct converters.

flowchart LR
    XYZ <--> AcesCg
    XYZ <--> aRgb[Adobe RGB]
    XYZ <--> CMYK
    XYZ <--> LinearRGB
    XYZ <--> HSL
    XYZ <--> ICtCp
    XYZ <--> JzAzBz
    XYZ <--> JzCzHz
    XYZ <--> Lab
    XYZ <--> Lch
    XYZ <--> LchUv
    XYZ <--> LMS
    XYZ <--> Luv
    XYZ <--> Lms2006
    XYZ <--> LmsCat02
    XYZ <--> LmsHpe
    XYZ <--> OKLAB
    XYZ <--> OKLCH
    XYZ <--> ProPhoto
    XYZ <--> Rec.2020
    XYZ <--> Rec.709
    XYZ <--> RGB
    XYZ <--> HSV
    XYZ <--> HWB
    XYZ <--> P3
    XYZ <--> xyY
    XYZ <--> XYZ-D50
    XYZ <--> YCbCr
    XYZ <--> YUV

License

@open-kappa/colors is released under the liberal MIT License. Please refer to the LICENSE.txt project file for further details.

Links