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

color-harmony

v0.3.0

Published

Create color scales by rotating hue

Downloads

5,997

Readme

color-harmony

NPM version Build Status Code Climate Coverage Status Dependency Status devDependency Status

NPM

Description

A javascript library that creates color scales/harmonies by rotating the hue of the given color.

There are also helper methods to create shades (mixing w/ black), tints (mixing w/ white), and tones (mixing w/ middle gray).

Getting Started

Install the module with: npm install color-harmony

var Harmonizer = require('color-harmony').Harmonizer;
var harmonizer = new Harmonizer();
harmonizer.harmonizeAll('#c820f1'); // returns a map of scales
harmonizer.harmonize('#000', 'complementary'); // returns ['#000000', '#ffffff']

Documentation

This library uses the onecolor parser, so colorString can in many different formats (i.e. #ff00cc, rgb(13,42,255), etc).

harmonizer.add(harmonyName, degreeArray)

Add a new named harmony. If the harmony name already exists, it will be overwritten. If degreeArray is not an array of numbers, then the harmony will not be added.

harmonizer.harmonizeAll(colorString)

Return a map of all the harmonies for the given color string.

harmonizer.harmonize(colorString, harmony)

Return an array of hex codes based on the given color string and harmony.

The harmony argument can be a 'named harmony', or it can be a custom harmony by passing in an array of numbers (degrees 0-360).

harmonizer.shades(colorString, size)

Return an array of hex codes container the shades of a given color (i.e. mix it with black - #000000).

If size is not a valid number, then the array will default to a size of 10.

harmonizer.tints(colorString, size)

Return an array of hex codes container the tints of a given color (i.e. mix it with white - #FFFFFF).

If size is not a valid number, then the array will default to a size of 10.

harmonizer.tones(colorString, size)

Return an array of hex codes container the tones of a given color (i.e. mix it with middle gray - #777777).

If size is not a valid number, then the array will default to a size of 10.

Available Harmony Names (and their associated degrees of hue rotation)

  • complementary: [0,180]
  • splitComplementary: [0,150,320]
  • splitComplementaryCW: [0,150,300]
  • splitComplementaryCCW: [0,60,210]
  • triadic: [0,120,240]
  • clash: [0,90,270]
  • tetradic: [0,90,180,270]
  • fourToneCW: [0,60,180,240]
  • fourToneCCW: [0,120,180,300]
  • fiveToneA: [0,115,155,205,245]
  • fiveToneB: [0,40,90,130,245]
  • fiveToneC: [0,50,90,205,320]
  • fiveToneD: [0,40,155,270,310]
  • fiveToneE: [0,115,230,270,320]
  • sixToneCW: [0,30,120,150,240,270]
  • sixToneCCW: [0,90,120,210,240,330]
  • neutral: [0,15,30,45,60,75]
  • analogous: [0,30,60,90,120,150]

NOTE: This list was compiled based on the data in color-js

Examples

Get all the stored harmonies

harmonizer.harmonizeAll('#c820f1'); // returns a map of scales

Get a named harmony

harmonizer.harmonize('#000', 'complementary'); // returns ['#000000', '#ffffff']

Get a custom harmony

harmonizer.harmonize('#000', [0, 10, 20, 30, 40]); // returns an array of colors

Add a custom harmony that can later be referenced by name

harmonizer.add('foo', [0, 25, 45]);
harmonizer.harmonize('#00cc00', 'foo'); // returns your custom data

Return the shades of a given color (mix it with black - #000000)

harmonizer.shades('#925719'); // returns 10 by default
harmonizer.shades('#925719', 14); // you can return a custom amount (an array of 14)

Return the tints of a given color (mix it with white - #FFFFFF)

harmonizer.tints('#925719'); // returns 10 by default
harmonizer.tints('#925719', 14); // you can return a custom amount (an array of 14)

Return the tones of a given color (mix it with middle gray - #777777)

harmonizer.tones('#925719'); // returns 10 by default
harmonizer.tones('#925719', 14); // you can return a custom amount (an array of 14)

Release History

v0.2.0 - Released June 22, 2014

  • fixing a bug with the saturation value that was being used

v0.1.0 - Released June 21, 2014

  • initial release

License

Copyright (c) 2014 skratchdot
Licensed under the MIT license.