Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@asamuzakjp/css-color
Advanced tools
Resolve and convert CSS colors.
npm i @asamuzakjp/css-color
import { convert, resolve } from '@asamuzakjp/css-color';
const resolvedValue =
resolve('color-mix(in oklab, rgb(255 0 0), color(srgb 0 0.5 0 / 0.5))');
// 'oklab(0.5914 0.103273 0.119688 / 0.75)'
const convertedValue = covert.colorToHex('lab(46.2775% -47.5621 48.5837)');
// '#008000'
resolves CSS color
color
string color value
opt
object? options (optional, default {}
)
opt.currentColor
string? color to use for currentcolor
keywordopt.format
string? output format, one of computedValue
(default), specifiedValue
, rgb
, hex
, hexAlpha
computedValue
is a computed value of the colorspecifiedValue
is a specified value of the colorhexAlpha
is a hex color notation with alpha channel, i.e. #rrggbbaa
opt.key
any? key e.g. CSS property background-color
Returns (string? | Array) returns one of rgba?()
, color(space r g b / a)
, color(space x y z / a)
, lab(l a b / A)
, lch(l c h / a)
, oklab(l a b / A)
, oklch(l c h / a)
, \#rrggbb(aa)?
, color-name?
, null
, and, if key
is specified, [key, rgba?()]
etc.
computedValue
, values are numbers, however rgb()
values are integersspecifiedValue
, returns empty string
for unknown and/or invalid colorrgb
, values are rounded to integers, and returns rgba(0, 0, 0, 0)
for unknown colorshex
, returns null
for transparent
, and also returns null
if any of r
, g
, b
, a
is not a numberhexAlpha
, returns #00000000
for transparent
, however returns null
if any of r
, g
, b
, a
is not a numberContains various color conversion functions.
convert number to hex string
value
number color valueReturns string hex string: 00..ff
convert color to hex
value
string color valueopt
object? options (optional, default {}
)
opt.alpha
boolean? return in #rrggbbaa notationReturns string #rrggbb|#rrggbbaa
convert color to hsl
value
string color valueReturns Array<number> [h, s, l, a]
convert color to hwb
value
string color valueReturns Array<number> [h, w, b, a]
convert color to lab
value
string color valueReturns Array<number> [l, a, b, aa]
convert color to lch
value
string color valueReturns Array<number> [l, c, h, aa]
convert color to oklab
value
string color valueReturns Array<number> [l, a, b, aa]
convert color to oklch
value
string color valueReturns Array<number> [l, c, h, aa]
convert color to rgb
value
string color valueReturns Array<number> [r, g, b, a]
convert color to xyz
value
string color valueopt
object? options (optional, default {}
)
opt.d50
boolean? xyz in d50 white pointReturns Array<number> [x, y, z, a]
convert color to xyz-d50
value
string color valueReturns Array<number> [x, y, z, a]
Copyright (c) 2024 asamuzaK (Kazz)
FAQs
CSS color - Resolve and convert CSS colors.
The npm package @asamuzakjp/css-color receives a total of 998,851 weekly downloads. As such, @asamuzakjp/css-color popularity was classified as popular.
We found that @asamuzakjp/css-color demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.