JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 999630
  • Score
    100M100P100Q184403F
  • License MIT

Color string parser

Package Exports

  • color-parse

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (color-parse) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

color-parse Build Status

Fast and tiny 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

  • red, green etc., see color-name
  • rgb(10, 20, 30), rgba(10, 20, 30, .3)
  • hsl(), hsla() inc. named hues
  • hwb()
  • cmyk()
  • xyz()
  • lab()
  • lch()
  • luv()
  • #RGB
  • #RGBA
  • #RRGGBB
  • #RRGGBBAA
  • R:10 G:20 B:30
  • (R10 / G20 / B30)
  • C100/M80/Y0/K35

Parsed not strings

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

Not parsed strings

  • 'yellowblue' returns null
  • 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 James Halliday. Initially inspired by that awesome parser. It performs calculations to every possible space which results in bloated size of lib.
  • color-parser — parser by TJ. Supports limited set of spaces.
  • color-string — color parsing/serializing module by Heather Arthur. Has extensive API for parsing and serializing from any to any space.

NPM