Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@csstools/convert-colors
Advanced tools
Convert colors between RGB, HEX, HSL, HWB, LAB, LCH, and more
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, 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
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.
FAQs
Convert colors between RGB, HEX, HSL, HWB, LAB, LCH, and more
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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.