@f/to-rgba

1.0.1 • Public • Published

to-rgba

Build status Git tag NPM version Code style

Convert any color string to an RGBA array

Installation

$ npm install @f/to-rgba

Usage

var toRgba = require('@f/to-rgba')

toRgba('hsl(214, 1, 0.5)')       // -> [0, 110, 255, 1]
toRgba('hsv(74, 0.19, 0.41)')    // -> [100, 105, 85, 1]
toRgba('rgba(128, 20, 30, 50%)') // -> [128, 20, 30, .50]

Recognized color encodings

Percentages

Where appropriate, values may be expressed as a percentage. They will be translated to their corresponding decimal equivalent. I.e. 20% -> .20.

API

toRgba(str)

  • str - A CSS color string.

Returns: An array of [red, green, blue, alpha].

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @f/to-rgba

Weekly Downloads

3

Version

1.0.1

License

MIT

Last publish

Collaborators

  • f