# colorsys

> Bidirectional conversions between different colors format like RGB, HSL, HSV and HEX

Latest version **1.0.22** (published 2018-10-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install colorsys
pnpm add colorsys
yarn add colorsys
bun add colorsys
```

## 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.0.22 |
| Published | 2018-10-18 |
| First published | 2016-02-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 66.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | jsdario, netbeast.staff, pablo.pi |
| Keywords | color, colour, rgb, hex, hsv, hsl, converter |

## Links

- npm: https://www.npmjs.com/package/colorsys
- Homepage: https://github.com/netbeast/colorsys
- npm.io page: https://npm.io/package/colorsys

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 1.0.22 (latest) — 2018-10-18
- 1.0.21 — 2018-04-12
- 1.0.20 — 2018-01-02
- 1.0.19 — 2017-11-09
- 1.0.18 — 2017-11-09
- 1.0.17 — 2017-10-24
- 1.0.16 — 2017-10-23
- 1.0.15 — 2017-10-23
- 1.0.14 — 2017-10-23
- 1.0.13 — 2017-10-09
- 1.0.12 — 2017-10-09
- 1.0.11 — 2017-10-09
- 1.0.10 — 2017-03-16
- 1.0.9 — 2016-05-26
- 1.0.7 — 2016-02-17
- … 7 more at https://npm.io/package/colorsys/versions

## README

# colorsys
[![CircleCI](https://circleci.com/gh/netbeast/colorsys.svg?style=svg)](https://circleci.com/gh/netbeast/colorsys)
![npm version](https://badge.fury.io/js/colorsys.svg)

**Colorsys** is a simple javascript color conversion library that allows bidirectional color conversion.
**Lightweight**, **immutable**. With support for RGB, HEX, HSV, HSL and CMYK and CSS strings.

## install

**With npm**
```
npm install colorsys
```

**Load on browser or copy paste into your code**
```
<script src="https://unpkg.com/colorsys@1.0.11/colorsys.js"></script>
```


## example
```javascript
var colorsys = require('colorsys')
const hsl = colorsys.parseCss('hsl(0, 0%, 100%)') //  { h: 0, s: 0, l: 100 }
colorsys.hsl2Hex(hsl) // '#ffffff'
const hsv = colorsys.rgb_to_hsv({r: 255, g: 255, b: 255 })
colorsys.stringify(hsv) // 'hsv(0, 0%, 100%)'
// Parsing an hex string will result in a RGB object!
colorsys.parseCss('#ff00ff') // { r: 255, g: 0, b: 255 }
```

For more examples please visit the [tests](test/test.js)

## API
For any method the input arguments can be an object `(r: 50, g: 100, b: 0}` or a set of integers `50, 100, 0`. You have aliases in both snake_case (`hex_to_hsl`) or `rgb2Hex`, `hsv2Rgb` form.

* `colorsys.parseCss(color: string)` will parse a color string in an object with the same keys.
* `colorsys.stringify(color: Object)` will output a valid css string.
* `colorsys.rgb_to_hsl({ r: 255, g: 255, b: 255 }) => { h: 0 , s: 0 , l: 100 }`
* `colorsys.rgb_to_hsv({ r: 255, g: 255, b: 255 }) => { h: 0 , s: 0 , v: 100 }`

Try with any combination. Look at the [source](colorsys.js) to double check!
* `colorsys.hslToRgb`
* `colorsys.hsvToRgb`
* `colorsys.rgbToHex`
* `colorsys.hexToRgb`
* `colorsys.hsvToHex`
* `colorsys.hexToHsv`
* `colorsys.hslToHex`
* `colorsys.hexToHsl`
* `colorsys.rgb2cmyk`
* `colorsys.cmyk2rgb`

Other methods:
* Generate a random hex color: `colorsys.random()`
* Rotate a color hue: `colorsys.rotateHue(120, 120)` will output `240`.
You can also use HSL or HSV objects as `rotateHue(hsv, 120)` will output
an object containing `{h: 240}`.

There are some formats missing like `YIQ`, `HWB`, `ansii` and `ansi16`. Please help us to complete this library making a pull request. 

## Contact
* Mail us: staff [at] netbeast.co
* Report a bug or enter discussion at [issues](https://github.com/netbeast/colorsys/issues)
* [Twitter](https://twitter.com/YetiSmartHome)

This repo is shared with :heart: from Netbeast. This package powers [Yeti Smart Home](https://getyeti.co) and is used in production.

<a href="https://getyeti.co" target="_blank">
   <img alt="works with yeti" src="https://github.com/netbeast/react-native-big-slider/raw/master/works-with-yeti.png" width="100" />
</a>

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