Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@csstools/convert-colors
Advanced tools
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.
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
A popular color conversion library that provides conversions between various color models. It has a similar range of functionalities as @csstools/convert-colors but with a different API and additional conversions like CMYK and ANSI.
A more comprehensive color manipulation library that not only allows color conversions but also provides features for color scale generation, color blending, and manipulation of color properties. It is more feature-rich compared to @csstools/convert-colors.
A small, fast library for color parsing and manipulation. It provides color conversion as well as utility functions for readability, darkness, and other color-related calculations. It is a good alternative with a simple API.
Convert Colors converts colors between RGB, HSL, HWB, Lab, LCH, HSV, and XYZ.
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
Add Convert Colors to your build tool:
npm install @csstools/convert-colors --save-dev
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.
1.4.0 (January 27, 2018)
FAQs
Convert colors between RGB, HEX, HSL, HWB, LAB, LCH, and more
The npm package @csstools/convert-colors receives a total of 1,295,429 weekly downloads. As such, @csstools/convert-colors popularity was classified as popular.
We found that @csstools/convert-colors demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.