Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
color-convert
Advanced tools
Package description
The color-convert npm package is a library for converting colors between different color models such as RGB, HSL, HSV, HEX, and more. It provides functions for one-to-one, one-to-many, and many-to-one conversions.
RGB to HEX conversion
Converts an RGB color value to its HEX representation.
const convert = require('color-convert');
const hexColor = convert.rgb.hex(255, 255, 255);
HEX to HSL conversion
Converts a HEX color value to its HSL representation.
const convert = require('color-convert');
const hslColor = convert.hex.hsl('FFFFFF');
HSL to HSV conversion
Converts an HSL color value to its HSV representation.
const convert = require('color-convert');
const hsvColor = convert.hsl.hsv(360, 100, 100);
Keyword to RGB conversion
Converts a CSS keyword color value to its RGB representation.
const convert = require('color-convert');
const rgbColor = convert.keyword.rgb('blue');
ANSI 16 to HEX conversion
Converts an ANSI 16 color code to its HEX representation.
const convert = require('color-convert');
const hexColor = convert.ansi16.hex(90);
chroma-js is a powerful library for all kinds of color conversions and manipulations. It supports a wide range of color models, similar to color-convert, but also includes functions for color scale generation, interpolation, and more complex color operations.
tinycolor2 is a small, fast library for color manipulation and conversion in JavaScript. It provides many of the same conversion capabilities as color-convert but also includes additional features for checking color properties, such as brightness and readability.
color is a JavaScript library for immutable color conversion and manipulation with support for CSS color strings. It offers a chainable API and is similar to color-convert in terms of conversion features but also includes manipulation functions like lighten, darken, saturate, and desaturate.
Readme
Color-convert is a library of plain color conversion functions. It converts between rgb, hsl, hsv, and cmyk:
colorConvert.rgb2hsl([140, 200, 100])); // [96, 48, 59]
npm install color-convert
Download the latest color-convert.js. All the methods are on the colorConvert
object.
Color-convert converts all ways between rgb, hsl, hsv, cmyk, and CSS keyword. Also from rgb to xyz and lab (these two assume sRGB color profile):
var convert = require("color-convert");
convert.rgb2hsl([255, 255, 255]) // rgb -> hsl, hsv, cmyk, keyword, xyz, and lab
convert.hsl2rgb([360, 100, 100]) // hsl -> rgb, hsv, cmyk, and keyword
convert.hsv2rgb([360, 100, 100]) // hsv -> rgb, hsl, cmyk, and keyword
convert.cmyk2rgb([100, 100, 100, 100]) // cmyk -> rgb, hsl, hsv, and keyword
convert.keyword2rgb("blue") // keyword -> rgb, hsl, hsv, and cmyk
convert.xyz2rgb([100, 100, 100]) // xyz -> rgb
To get the unrounded conversion, append Raw
to the function name:
colorConvert.rgb2hslRaw([140, 200, 100]); // [95.99999999999999, 47.619047619047606, 58.82352941176471]
There's also a hash of the conversion functions keyed first by the "from" color space, then by the "to" color space:
convert["hsl"]["hsv"]([160, 0, 20]) == convert.hsl2hsv([160, 0, 20])
Please fork, add conversions, figure out color profile stuff for XYZ, LAB, etc. This is meant to be a basic library that can be used by other libraries to wrap color calculations in some cool way.
FAQs
Plain color conversion functions
The npm package color-convert receives a total of 217,543,310 weekly downloads. As such, color-convert popularity was classified as popular.
We found that color-convert 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.