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

palletize

v0.0.2

Published

Tools for collections of colors

Downloads

12

Readme

Palletize

Tools for collections of colors.

Insert a library of color swatches, then query individual or batches of swatches based on visual attributes. Consumes a hex string for each swatch, then calculates and attaches additional data points for rgba, hsla, and luminance.

Installation

Install the palletize package

npm i palletize

Usage

  1. Prepare your library of swatches. Each swatch must have a unique id string and hex string properties:
[
  {
    "id": "naturally-white",
    "hex": "#fffffd",
  },
  {
    "id": "egyptian-cotton",
    "hex": "#fdfdfb",
  },
  {
    "id": "cotton",
    "hex": "#fffef9",
  },
  ...
]
  1. Initialize a palette using the library:
const Palletize = require('palletize')
const Palette = Palletize(require('./natural-paint-co.json'))
  1. Query swatches using the fetcher methods (detailed below)
const color = Palette.id('cotton')
console.log(color)

API

id(id)

Query a single swatch by it's id

random(n = 1)

Query randomized swatches from the whole library

luminance(min, max, n = 1)

Query randomized swatches within a luminance range

hue(theta, range, n = 1)

Query randomized swatches within a range on the hue wheel
theta: Degrees around the hue wheel 0:red -> 120:green -> 240:blue
range: Degrees in either direction on the wheel to include in results

saturation(min, max, n = 1)

Query randomized swatches within a saturation range

lightness(min, max, n = 1)

Query randomized swatches within a lightness range

hsl(hue, saturation, lightness, n = 1)

Query randomized swatches that match the HSL ranges
hue: [theta, range]
saturation: [min, max]
lightness: [min, max]

Exclude

All randomized methods can provide an exclude array as the final argument; these items are excluded from the selection process:

const background = Palette.id('cotton')
const colors = Palette.random(10, [background]) // `Cotton` swatch excluded from selection pool

Examples

Palette.id('black-robin')

Palette.random(10)

Palette.luminance(0, 0.2, 10)

Palette.luminance(0.6, 1, 10)

Palette.hue(0, 15, 10)

Palette.hue(120, 30, 10)

Palette.hue(200, 30, 10)

Palette.saturation(0.5, 1, 10)

Palette.saturation(0, 0.1, 10)

Palette.lightness(0, 0.33, 10)

Palette.lightness(0.8, 1, 10)

Palette.hsl([0, 45], [0.5, 1], [0.7, 1], 10)

Palette.hsl([150, 35], [0, 0.33], [0, 0.5], 10)

Palette.hsl(undefined, [0.5, 1], [0.5, 1], 10)