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 🙏

© 2024 – Pkg Stats / Ryan Hefner

hueman

v2.1.3

Published

Color space based on human perception

Downloads

20

Readme

Features

  • Brightness / Saturation calibration across hues
  • Find intermediate hues (good for programmatic gradients)
  • Works on both server and client
  • Pairs well with themepark

Usage

Installation

Via NPM:

npm install hueman

NodeJS

// CJS syntax
var { hueman, mix, correction } = require('hueman');

// ES6 Syntax
import { hueman, mix, correction } from 'hueman';

Script tag (via unpkg):

<!-- Available as global variable hueman -->
<script src="https://unpkg.com/hueman"></script>
<!-- Later -->
<script>
  console.log(hueman(120,1.0,0.5)); // "hsl(120,97%,37.5%)"
  console.log(hueman.mix(120,160,0.75)); // "150"
  console.log(hueman.correction(120)); // "[0.97, 0.75]"
</script>

Browser: Module (via snowpack):

import { hueman, mix, correction } from 'https://cdn.skypack.dev/hueman';

API

hueman(h,s,l,a)

  • h: [0,360] (values will automatically wrap if outside of this range)
  • s: [0.0,1.0] (defaults to 1.0)
  • l: [0.0,1.0] (defaults to 0.5)
  • a: [0.0,1.0] (defaults to 1.0)
  import { hueman } from 'hueman';
  hueman(210, 1.0, 0.5) // -> "hsl(210,100%,50%)"
  hueman(110, 1.0, 0.5, 0.5) // -> "hsla(110,97%,37.5%,0.5)"
  hueman(50, 1.0, 0.5) // -> "hsl(50,100%,37.5%)"

mix(hue1,hue2,ratio)

Returns the mixed hue between hue1 and hue2 at a desired ratio, where ratio = 0 results in hue1, and ratio = 1 results in hue2. Will correctly wrap across 0/360 (both 0 and 360 are red in HSL)

  import { mix } from 'hueman';
  mix(100, 200, 0.5) // -> 150
  mix(340, 100, 0.1) // -> 352
  mix(0, 200, 0.75) // -> 240 (closer distance between 200 and 360 than 0 and 200)

correction(hue)

Returns [chroma, lightness] correction coefficient compared to base hue (210). Useful for calculating opacity for transparent overlays and other indirect hue-influenced calculations.

  import { correction } from 'hueman';
  // correction(h,s,l) => [chroma, lightness]
  correction(0) // [0.9, 1] (reduce chroma, don't alter lightness)
  correction(120) // [0.97, 0.75] (slightly reduce chroma, reduce lightness)
  correction(240) // [0.97, 1.27]
  correction(240,0.2,0.2) // [ 0.9976, 1.0216 ] (reduced effect since hue is less vibrant)

Development

Roadmap

  • Color generator webapp
  • Examples + Explanations in readme
  • Reduced import size (encode hue biases more efficiently)
  • Add luminance / chroma testing for formula refinements

Acknowledgements

License

MIT © Marshall Brandt