color-parse
Color string parser
Last updated 5 years ago by dfcreative .
MIT · Repository · Bugs · Original npm
$ cnpm install color-parse 
SYNC missed versions from official npm registry.

color-parse build size stable

Fast and compact color string parser.

$ npm install color-parse

var parse = require('color-parse')

parse('hsla(12 10% 50% / .3)')
// { space: 'hsl', values: [12, 10, 50], alpha: 0.3 }

Parsed strings

  • [x] Color keywords: red, green etc., see color-name
  • [x] #RGB[A]
  • [x] #RRGGBB[AA]
  • [x] rgb[a](R, G, B[, A])
  • [x] rgb[a](R G B[ / A])
  • [x] hsl[a](H, S, L[, A]), inc. named hues
  • [x] hsl[a](H S L [ / A])
  • [x] hwb(H, W, B)
  • [x] cmyk(C, M, Y, K)
  • [x] xyz(X, Y, Z)
  • [x] lab(L, A, B)
  • [x] lch(L, C, H)
  • [x] luv(L, U, V)
  • [x] R:10 G:20 B:30
  • [x] (R10 / G20 / B30)
  • [x] C100/M80/Y0/K35

Parsed not strings

  • [x] [10, 20, 20] as RGB color space
  • [x] {r: 10, g: 20, b: 30}
  • [x] {red: 10, green: 20, blue: 30}
  • [x] {h: 10, s: 20, l: 30}
  • [x] 0x00ff00, 0x0000ff numbers

Not parsed strings

  • [x] 'yellowblue' returns null

Related

  • color-space — collection of color space conversions.
  • color-rgba — convert any color string to rgba array.
  • color-alpha — change alpha component of any color.

Analogs

  • parse-color — parser by @substack. Performs calculations to every possible space, which bloats size.
  • color-parser — parser by @tjholowaychuk. Supports limited set of spaces.
  • color-string — parsing/serializing module by Heather Arthur. Has extensive API for parsing and serializing from any to any space.

NPM

Current Tags

  • 1.4.2                                ...           latest (5 years ago)

2 Versions

  • 1.4.2                                ...           5 years ago
  • 1.3.8                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org