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

huefy

v1.1.4

Published

Smooth color interpolation with customizable curves and support for multiple color formats like HEX, RGB, and RGBA.

Downloads

1,313

Readme

🌟 Huefy

Smooth color interpolation with customizable curves and support for mixing multiple color formats like HEX, RGB, RGBA, HSL, HSV, HWB, CMYK, and color keywords.

The purpose of this package is to take two colors, and find the color x percentage of the way inbetween them.

Key Features:

  • Smooth Interpolation: Seamlessly transition between colors using customizable curve functions.
  • Multiple Color Formats: Output colors in HEX, RGB, RGBA, HSL, HSV, HWB, CMYK, and color keyword (red, green, blue...) format.
  • Easy to Use: Simple API for both JavaScript and command-line usage.
  • Customizable: Choose different interpolation curves for your color transitions.

🚀 Installation

npm install huefy

🛠 Getting Started

To get started with Huefy, import the function and start creating beautiful color transitions:

import huefy from 'huefy';

const startColor = '#ff0000';
const endColor = '#0000ff';
const percentage = 0.5;

const resultColor = huefy(startColor, endColor, percentage, { as: 'rgb' });
console.log(resultColor); // Outputs: rgb(128, 0, 128)

📸 Example

How the interpolated colors look at various percentages between two colors: Color Transition Examples

🌟 Why Choose Huefy?

Huefy provides a simple yet powerful way to create smooth color interpolations with support for a wide range of color formats and customizable interpolation curves. This package could be used to create your own gradients, fade colors in and out, etc.

🌍 Supported Environments

  • Node.js 14+
  • ES Modules (import/export)
  • CommonJS (require)

🎨 Customization

You can customize your color transitions by choosing different curve functions to control the interpolation between colors. The default curve is linear, but you can define your own curve function for more advanced effects.

import huefy from 'huefy';

const customCurve = (value) => Math.pow(value, 2); // A simple quadratic curve

const resultColor = huefy('#ff0000', '#0000ff', 0.5, { curve: customCurve, as: 'hex' });
console.log(resultColor); // Outputs a color based on the custom curve

🔧 Command Line Usage

Huefy can also be used directly from the command line.

Basic Usage

huefy <color1> <color2> <percentage> [options]

Options

  • -f, --format [format]: Specify the output format (cmyk, rgb, rgba, hex, hsl, hsv)

Version

huefy --version

Example Commands

Transition from red to blue at 50% and output the result in RGB format:

huefy '#ff0000' '#0000ff' 0.5 -f rgb

Combining Options

You can combine different options to customize the output:

huefy '#ff0000' 'rgba(0, 129, 201, 0.25)' 0.25 -f rgba

🔧 Acknowledgments & Contributions

This package is built using great tools and libraries like color-string and color-convert. Contributions are welcome! Feel free to open issues or submit pull requests on GitHub.