Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
colors-convert
Advanced tools
A simple colors library.
Using colors-convert
you can:
yarn add colors-convert
or
npm install --save colors-convert
Different color formats are supported: hex, rgb, rgba, cmyk and hsl.
A valid hex color can be:
#FFFFFF
#FFF
#FFFFFFFF
(white with opacity FF=1
).isHex(color): boolean
Returns true
if color
is a valid hex, false
otherwise.
A valid rgb color is an object like this {r, g, b}
with r, b, g
numeric values in range [0, 255]
.
isRgb(color): boolean
Returns true
if color
is a valid rgb, false
otherwise.
A valid rgba color is an object like this {r, g, b, a}
with r, g, b
numeric values in range [0, 255]
and a
in range [0, 1]
.
isRgba(color): boolean
Returns true
if color
is a valid rgba, false
otherwise.
A valid cmyk color is an object like this {c, m, y, k}
with c, m, y, k
numeric values in range [0, 100]
.
isCmyk(color): boolean
Returns true
if color
is a valid cmyk, false
otherwise.
A valid hsl color is an object like this {h, s, l}
where:
h
(hue): [0-359]°
s
(saturation): [0-100]%
l
(lightness): [0-100]%
.isHsl(color): boolean
Returns true
if color
is a valid hsl, false
otherwise.
hex2rgbOrRgba(hex): rgb | rgba
: Converts a hex to a rgb or rgba color (depends on hex format)
hex2rgba(hex, alpha = 1): rgba
: Converts a hex to a rgba object
hex2hexWithAlpha(hex, alpha): hex
: Converts a hex to another hex with the given alpha
hex2cmyk(hex): cmyk
: Converts a hex to a cmyk. If hex is in the long format (e.g. #000000FF) it removes the last two chars because cmyk doens't support opacity
hex2hsl(hex): hsl
: Converts a hex object to hsl
rgb2hex(rgb): hex
: Converts a rgb object to hex
rgb2cmyk(rgb): cmyk
: Converts a rgb to a cmyk
rgb2hsl(rgb): hsl
: Converts a rgb object to hsl
rgba2rgb(rgba): rgb
: Converts a rgba color to a rgb color removing the alpha value
rgb2rgba(rgb): rgba
: Converts a rgb color to a rgba color adding 1 as alpha
color2rgb(color): rgb
: Converts a generic color (hex, rgb, rgba, cmyk, hsl) to rgb
cmyk2rgb(cmyk): rgb
: Converts a cmyk color to a rgb
cmyk2hex(cmyk): hex
: Converts a cmyk color to a hex
cmyk2hsl(cmyk): hsl
: Converts a cmyk object to hsl
hsl2hex(hsl): hex
: Converts a hsl object to hex
hsl2rgb(hsl): rgb
: Converts a hsl object to rgb
hsl2cmyk(hsl): cmyk
: Converts a hsl object to cmyk
name(color): string
: Given a color (hex, rgb, rgba, cmyk or hsl), it returns the name of that color. It works using a list of 18315 unique color names.color2string(color): string
: Converts a color to a string format. For example:
#E6259F
230, 37, 159
230, 37, 159, 1
0%, 84%, 31%, 10%
322, 79%, 52%
color2cssString(color): string
: Converts a color to a string format usable in CSS. For example:
#E6259F
rgb(230, 37, 159)
rgba(230, 37, 159, 1)
cmyk(0%, 84%, 31%, 10%)
hsl(322, 79%, 52%)
mix(colors: Color[], weights?: number[]): rgb
: Mix two or more colors based on their weights.
FAQs
A simple color library
The npm package colors-convert receives a total of 1,267 weekly downloads. As such, colors-convert popularity was classified as popular.
We found that colors-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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.