# convert-web-colors

> Convert between web color formats: rgb(a), hsl(a) and hexadecimal (6 and 8 digit)

Latest version **1.1.2** (published 2017-10-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install convert-web-colors
pnpm add convert-web-colors
yarn add convert-web-colors
bun add convert-web-colors
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2017-10-24 |
| First published | 2017-08-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | josephkmh |

## Links

- npm: https://www.npmjs.com/package/convert-web-colors
- Repository: https://github.com/josephkmh/convert-web-colors
- Homepage: https://github.com/josephkmh/convert-web-colors#readme
- Issues: https://github.com/josephkmh/convert-web-colors/issues
- npm.io page: https://npm.io/package/convert-web-colors

## Recent versions

- 1.1.2 (latest) — 2017-10-24
- 1.1.1 — 2017-08-22
- 1.1.0 — 2017-08-22
- 1.0.8 — 2017-08-15
- 1.0.7 — 2017-08-15
- 1.0.6 — 2017-08-15
- 1.0.5 — 2017-08-15
- 1.0.4 — 2017-08-15
- 1.0.3 — 2017-08-15
- 1.0.2 — 2017-08-13
- 1.0.1 — 2017-08-13
- 1.0.0 — 2017-08-12

## README

See it in action: [colorconverter.io](https://colorconverter.io)

convert-web-colors is a web color conversion library for JavaScript and node. It supports conversion between rgb, hsl and hex strings, both with and without alpha channels (transparency).

# Install
`$ npm i -S convert-web-colors`

# Usage
Just provide a string or array in one of the supported formats:

```javascript
var converter = require('convert-web-colors');

var colors = converter.convert('rgb(120,113,54)'); // converter.convert([120,113,54]) would return the same result

var rgb  = colors.rgb;  // rgb(120, 113, 54)
var rgba = colors.rgba; // rgba(120, 113, 54, 1)

var hsl  = colors.hsl;  // hsl(53.6, 37.9%, 34.1%)
var hsla = colors.hsla; // hsla(54, 37.9%, 34.1%, 1)

var hex  = colors.hex;  // #787136
var hexa = colors.hexa; // #787136FF
```

## Arrays
By default, an object containing color values as strings will be returned. If you want to receive values as arrays instead, pass in an object as the second parameter with a property: <code>returnArrays: true;</code>

```javascript
var converter = require('convert-web-colors');

var colors = converter.convert('rgb(120,113,54)', { returnArrays: true });

var rgb  = colors.rgb;  // [120, 113, 54]
var rgba = colors.rgba; // [120, 113, 54, 1]

var hsl  = colors.hsl;  // [54, 37.9, 34.1]
var hsla = colors.hsla; // [53.6, 37.9, 34.1, 1]

var hexa = colors.hexa; // #787136FF
var hex  = colors.hex;  // #787136
```

---
_Source: https://npm.io/package/convert-web-colors · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
