Socket
Socket
Sign inDemoInstall

@csstools/convert-colors

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @csstools/convert-colors

Convert colors between RGB, HEX, HSL, HWB, LAB, LCH, and more


Version published
Weekly downloads
1.8M
decreased by-4.1%
Maintainers
1
Install size
198 kB
Created
Weekly downloads
 

Package description

What is @csstools/convert-colors?

The @csstools/convert-colors npm package provides functionality for converting colors between different color models such as RGB, HSL, HWB, and more. It can be used to manipulate and convert color values in various formats, which is useful for web development and design tasks where precise color management is required.

What are @csstools/convert-colors's main functionalities?

RGB to HSL conversion

Converts an RGB color value to its equivalent HSL value.

const { rgb2hsl } = require('@csstools/convert-colors');
const hsl = rgb2hsl(255, 0, 0); // Convert red from RGB to HSL

HSL to RGB conversion

Converts an HSL color value to its equivalent RGB value.

const { hsl2rgb } = require('@csstools/convert-colors');
const rgb = hsl2rgb(0, 100, 50); // Convert red from HSL to RGB

RGB to HEX conversion

Converts an RGB color value to its equivalent HEX value.

const { rgb2hex } = require('@csstools/convert-colors');
const hex = rgb2hex(255, 0, 0); // Convert red from RGB to HEX

HEX to RGB conversion

Converts a HEX color value to its equivalent RGB value.

const { hex2rgb } = require('@csstools/convert-colors');
const rgb = hex2rgb('#ff0000'); // Convert red from HEX to RGB

HWB to RGB conversion

Converts an HWB color value to its equivalent RGB value.

const { hwb2rgb } = require('@csstools/convert-colors');
const rgb = hwb2rgb(0, 0, 0); // Convert black from HWB to RGB

Other packages similar to @csstools/convert-colors

Changelog

Source

2.0.0 (January 25, 2019)

  • Add hex, keyword, luminance, contrast, and CIEDE2000 conversions
  • Support Node 6+

Readme

Source

Convert Colors Convert Colors

NPM Version Linux Build Status Windows Build Status

Convert Colors converts colors between RGB, HEX, HSL, HWB, LAB, LCH, and more.

import convert from '@csstools/convert-colors';

convert.rgb2hsl(100, 100, 100); // [ 0, 0, 100 ]
convert.rgb2hwb(100, 100, 100); // [ 0, 100, 0 ]

convert.hsl2rgb(0, 0, 100); // [ 0, 100, 0 ]
convert.hsl2hwb(0, 0, 100); // [ 0, 100, 0 ]

convert.hwb2rgb(0, 100, 0); // [ 0, 0, 100 ]
convert.hwb2hsl(0, 100, 0); // [ 0, 0, 100 ]

convert.rgb2hue(0, 0, 100); // 240

convert.rgb2contrast([100, 100, 100], [0, 0, 0]); // 21
convert.rgb2ciede2000([100, 100, 100], [0, 0, 0]); // 100

Usage

Add Convert Colors to your build tool:

npm install @csstools/convert-colors --save-dev

Features

Conversions work by taking arguments that represents a color in one color space and returning an array of that same color in another color space.

Documentation

Keywords

FAQs

Last updated on 29 Jan 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc