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

@cubehelix-studio/core

v0.0.1

Published

Grayscale-safe color palettes from cubehelix. Generation, sampling, and WCAG contrast utilities. Zero runtime dependencies.

Downloads

21

Readme

@cubehelix-studio/core

Cubehelix color palettes that survive grayscale, colorblindness, and print. Generation, sampling, and WCAG contrast utilities. Zero runtime dependencies.

Interactive playground: obang.pub/cubehelix-studio — adjust these parameters live in your browser.

Install

npm install @cubehelix-studio/core
# or
pnpm add @cubehelix-studio/core

Usage

import {
  cubehelix,
  sampleSequential,
  toHex,
  toCssRgb,
  DEFAULT_CUBEHELIX_PARAMS,
} from "@cubehelix-studio/core";

// Single point on the curve
const mid = cubehelix(0.5, DEFAULT_CUBEHELIX_PARAMS);

// 9 evenly-spaced samples (endpoints included)
const palette = sampleSequential(DEFAULT_CUBEHELIX_PARAMS, 9);

palette.map(toHex);
// → ["#000000", "#1c1338", ..., "#ffffff"]

API

cubehelix(t, params): RGB

Evaluates the cubehelix curve at fraction t in [0, 1].

interface CubehelixParams {
  start: number; // starting hue position; default 0.5
  rotations: number; // rotations through the color wheel; default -1.5
  saturation: number; // chromatic amplitude; default 1.0
  gamma: number; // gamma correction; default 1.0
}

interface RGB {
  r: number; // [0, 1]
  g: number; // [0, 1]
  b: number; // [0, 1]
}

sampleSequential(params, n): RGB[]

Returns n colors sampled at evenly-spaced positions i / (n - 1). Requires n >= 2.

toHex(rgb): string

Formats an RGB as #rrggbb (lowercase).

toCssRgb(rgb): string

Formats an RGB as rgb(R G B) using modern space-separated syntax.

DEFAULT_CUBEHELIX_PARAMS

The standard cubehelix parameters: { start: 0.5, rotations: -1.5, saturation: 1.0, gamma: 1.0 }.

Note: matplotlib's cubehelix_palette and Dave Green's original 2011 paper call this parameter hue. It controls chromatic amplitude — when zero, the output collapses to a pure greyscale ramp — so saturation is more accurate.

contrastRatio(a, b): number

WCAG 2.1 contrast ratio between two colors, in the range [1, 21].

pickTextColor(bg, candidates?): RGB

Returns whichever candidate has the highest contrast against bg. Defaults to [white, black]. Throws RangeError when given an empty candidate list.

import {
  pickTextColor,
  toCssRgb,
  cubehelix,
  DEFAULT_CUBEHELIX_PARAMS,
} from "@cubehelix-studio/core";

const swatch = cubehelix(0.3, DEFAULT_CUBEHELIX_PARAMS);
const text = pickTextColor(swatch);
element.style.backgroundColor = toCssRgb(swatch);
element.style.color = toCssRgb(text);

License

MIT