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

@tiger-ui/color-converter

v1.0.4

Published

Install the package in your project directory with: ### npm: ``` npm install @tiger-ui/color-converter ``` ### yarn: ``` yarn add @tiger-ui/color-converter ```

Downloads

56

Readme

Color Converter helps you convert your color codes to different color codes. For example, you can convert HEX code to RGB, RGBA code to HSLA, HEX code to HSL and many other color types.

Installation

Install the package in your project directory with:

npm:

npm install @tiger-ui/color-converter

yarn:

yarn add @tiger-ui/color-converter

Examples

HEX to RGB Codes

import ColorConverter from '@tiger-ui/color-converter';

const myHEXColor = '#ffffff';
const myRGBColorCodes = ColorConverter.hexToRgbCodes(myHEXColor);

console.log(myRGBColorCodes);

output:

{
    "r": 255,
    "g": 255,
    "b": 255
}

RGB to HSL Codes

import ColorConverter from '@tiger-ui/color-converter';

const red = 255;
const green = 255;
const blue = 255;
const myHSLColorCodes = ColorConverter.rgbToHslCodes(red, green, blue);

console.log(myHSLColorCodes);

output:

{
    "h": 0,
    "s": 0,
    "l": 100
}

RGBA to HSLA Codes

import ColorConverter from '@tiger-ui/color-converter';

const red = 255;
const green = 255;
const blue = 255;
const alpha = 0.5;
const myHSLAColorCodes = ColorConverter.rgbaToHslaCodes(red, green, blue, alpha);

console.log(myHSLAColorCodes);

output:

{
    "h": 0,
    "s": 0,
    "l": 100,
    "a": 0.5
}

HEX to RGBA Codes

import ColorConverter from '@tiger-ui/color-converter';

const myHEXColor = '#ffffff';
const alpha = 0.5;
const myRGBAColorCodes = ColorConverter.hexToRgbaCodes(myHEXColor, alpha);

console.log(myRGBAColorCodes);

output:

{
    "r": 255,
    "g": 255,
    "b": 255,
    "a": 0.5
}

HSL to RGB Codes

import ColorConverter from '@tiger-ui/color-converter';

const hue = 80;
const saturation = 60; // %60
const lightness = 40; // %40
const myRGBColorCodes = ColorConverter.hslToRgbCodes(hue, saturation, lightness);

console.log(myRGBColorCodes);

output:

{
    "r": 122,
    "g": 163,
    "b": 41
}

HSLA to RGBA Codes

import ColorConverter from '@tiger-ui/color-converter';

const hue = 80;
const saturation = 60; // %60
const lightness = 40; // %40
const alpha = 0.5;
const myRGBAColorCodes = ColorConverter.hslaToRgbaCodes(hue, saturation, lightness, alpha);

console.log(myRGBAColorCodes);

output:

{
    "r": 122,
    "g": 163,
    "b": 41,
    "a": 0.5
}

HEX to HSL Codes

import ColorConverter from '@tiger-ui/color-converter';

const myHEXColor = '#2c58d1';
const myHSLColorCodes = ColorConverter.hexToHslCodes(myHEXColor);

console.log(myHSLColorCodes);

output:

{
    "h": 224,
    "s": 65.2,
    "l": 49.6
}

RGB to HEX (String)

import ColorConverter from '@tiger-ui/color-converter';

const red = 255;
const green = 255;
const blue = 255;
const myHEXStringColor = ColorConverter.rgbToHex(red, green, blue);

console.log(myHEXStringColor);

output:

'#ffffff'

RGBA to HEXA (String)

import ColorConverter from '@tiger-ui/color-converter';

const red = 44;
const green = 88;
const blue = 209;
const alpha = 0.5;
const myHEXAStringColor = ColorConverter.rgbaToHexa(red, green, blue, alpha);

console.log(myHEXAStringColor);

output:

'#2c58d180'

HEX(A) to RGBA (String)

import ColorConverter from '@tiger-ui/color-converter';

const myHEXColor = '#1f4ecf';
const alpha = 0.5; // optional
const myRGBAStringColor = ColorConverter.hexToRgba(myHEXColor, alpha);

console.log(myRGBAStringColor);

output:

'rgba(31, 78, 207, 0.5)'

HEX to RGB (String)

import ColorConverter from '@tiger-ui/color-converter';

const myHEXColor = '#1f4ecf';
const myRGBStringColor = ColorConverter.hexToRgb(myHEXColor);

console.log(myRGBStringColor);

output:

'rgb(31, 78, 207)'

RGB to HSL (String)

import ColorConverter from '@tiger-ui/color-converter';

const red = 31;
const green = 78;
const blue = 207;
const myHSLStringColor = ColorConverter.rgbToHsl(red, green, blue);

console.log(myHSLStringColor);

output:

'hsl(224,73.9%,46.7%)'

HSL to RGB (String)

import ColorConverter from '@tiger-ui/color-converter';

const hue = 80;
const saturation = 60; // %60
const lightness = 40; // %40
const myRGBStringColor = ColorConverter.hslToRgb(hue, saturation, lightness);

console.log(myRGBStringColor);

output:

'rgb(122,163,41)'

HSLA to RGBA (String)

import ColorConverter from '@tiger-ui/color-converter';

const hue = 80;
const saturation = 60; // %60
const lightness = 40; // %40
const alpha = 0.5;
const myRGBAStringColor = ColorConverter.hslaToRgba(hue, saturation, lightness, alpha);

console.log(myRGBAStringColor);

output:

'rgba(122,163,41,0.5)'

HEX to HSL (String)

import ColorConverter from '@tiger-ui/color-converter';

const myHEXColor = '#1f4ecf';
const myHSLStringColor = ColorConverter.hexToHsl(myHEXColor);

console.log(myHSLStringColor);

output:

'hsl(224,73.9%,46.7%)'

RGB to RGB Codes

import ColorConverter from '@tiger-ui/color-converter';

const myRGBColor = 'rgb(122,163,41)';
const myRGBColorCodes = ColorConverter.rgbToRgbCodes(myRGBColor);

console.log(myRGBColorCodes);

output:

{
    "r": 122,
    "g": 163,
    "b": 41
}

RGBA to RGBA Codes

import ColorConverter from '@tiger-ui/color-converter';

const myRGBAColor = 'rgb(122,163,41,0.5)';
const myRGBAColorCodes = ColorConverter.rgbaToRgbaCodes(myRGBAColor);

console.log(myRGBAColorCodes);

output:

{
    "r": 122,
    "g": 163,
    "b": 41,
    "a": 0.5
}

Special Thanks

We would like to express our special thanks to the resources we have used in the development of this library, which have been of great help to us:

  • RGB TO HSL CODES:
    • https://www.30secondsofcode.org/js/s/rgb-to-hsl/
    • https://css-tricks.com/converting-color-spaces-in-javascript/#aa-rgb-to-hsl
  • RGBA TO HSLA CODES:
    • https://www.30secondsofcode.org/js/s/rgb-to-hsl/
    • https://css-tricks.com/converting-color-spaces-in-javascript/#aa-rgb-to-hsl
  • HEX TO RGB/RGBA CODES:
    • https://stackoverflow.com/a/28056903
  • HSL TO RGB CODES:
    • https://css-tricks.com/converting-color-spaces-in-javascript/#aa-hsl-to-rgb
  • HSLA TO RGBA CODES:
    • https://css-tricks.com/converting-color-spaces-in-javascript/#aa-hsla-to-rgba
  • RGB TO HEX:
    • https://css-tricks.com/converting-color-spaces-in-javascript/#aa-rgb-to-hex
  • RGBA TO HEXA:
    • https://css-tricks.com/converting-color-spaces-in-javascript/#aa-rgba-to-hex-rrggbbaa
  • HEX TO RGB/RGBA :
    • https://stackoverflow.com/a/28056903
  • HEX TO RGB:
    • https://stackoverflow.com/a/28056903
  • RGB TO RGB CODES:
    • https://stackoverflow.com/a/10971090
  • RGBA TO RGBA CODES:
    • https://stackoverflow.com/a/10971090