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, parse, convert CSS color.
npm i @asamuzakjp/css-color
import { convert, parse, resolve } from '@asamuzakjp/css-color';
const rgb = resolve('color-mix(in srgb, red, blue)');
// 'rgb(128, 0, 128)'
const xyz = parse('lab(46.2775% -47.5621 48.5837)');
const hex = convert.xyzToHex(xyz);
// '#008000'
Resolve CSS color.
color
string color value
opt
object? options
Returns (string? | Array) rgba?()
, [r, g, b, a]
, #rrggbb(aa)?
, null
, or if key
is specified, [key, rgba?()|[r, g, b, a]|#rrggbb(aa)?|null]
rgb
:
r
, g
, b
values are rounded.array
:
[undefined, undefined, undefined, undefined]
.hex
:
transparent
returns null
.null
for unknown / unsupported color name.currentcolor
resolves as #000000
if opt.currentColor
is not specified.hexAlpha
:
transparent
resolves as #00000000
.currentcolor
resolves as #00000000
if opt.currentColor
is not specified.null
for unknown / unsupported color name.Parse CSS color.
color
string color value
color-mix()
and <system-color>s are not supported. It throws.opt
object? options
opt.d50
boolean? get xyz values in d50 white pointReturns Array<number> [x, y, z, a]
x|y|z|a: 0..1
Contains conversion functions as properties.
Convert xyz to hex color notation.
Returns string #rrggbbaa
Convert xyz to hsl color array.
Returns Array<number> [h, s, l, a]
h: 0..360 s|l: 0..100 a: 0..1
Convert xyz to hwb color array.
Returns Array<number> [h, w, b, a]
h: 0..360 w|b: 0..100 a: 0..1
Convert xyz to oklab color array.
Returns Array<number> [l, a, b, A]
l|A: 0..1 a|b: -0.4..0.4
Convert xyz to oklch color array.
Returns Array<number> [l, c, h, a]
l|a: 0..1 c: 0..0.4 h: 0..360
Convert xyz to rgb color array.
Returns Array<number> [r, g, b, a]
r|g|b: 0..255 a: 0..1
Convert xyz to xyz-d50 color array.
Returns Array<number> xyz - [x, y, z, a]
x|y|z|a: 0..1
Convert xyz-d50 to lab color array.
Returns Array<number> [l, a, b, A]
l: 0..100 a|b: -125..125 A: 0..1
Convert xyz-d50 to lch color array.
Returns Array<number> [l, c, h, a]
l: 0..100 c: 0..150 h: 0..360 a: 0..1
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.