# color-fns

> Modern JavaScript color utility library.

Latest version **0.1.1** (published 2019-05-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install color-fns
pnpm add color-fns
yarn add color-fns
bun add color-fns
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2019-05-23 |
| First published | 2018-01-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 98.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 81 |
| Maintainers | abdelrahman3d, logaretm |
| Keywords | color, utility, functions |

## Links

- npm: https://www.npmjs.com/package/color-fns
- Repository: https://github.com/baianat/color-fns
- npm.io page: https://npm.io/package/color-fns

## 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

- 0.1.1 (latest) — 2019-05-23
- 0.1.0 — 2019-05-23
- 0.0.10 — 2019-01-23
- 0.0.9 — 2019-01-13
- 0.0.8 — 2019-01-13
- 0.0.7 — 2018-07-13
- 0.0.6 — 2018-05-28
- 0.0.5 — 2018-05-28
- 0.0.4 — 2018-04-19
- 0.0.3 — 2018-04-12
- 0.0.2 — 2018-03-27
- 0.0.1 — 2018-03-13
- 0.0.0 — 2018-01-08

## README

<p align="center">
  <img width="400" src="https://github.com/baianat/color-fns/blob/master/logo.svg">
</p>

<p align="center">

[![Build Status](https://travis-ci.org/baianat/color-fns.svg?branch=master)](https://travis-ci.org/baianat/color-fns)
[![codecov](https://codecov.io/gh/baianat/color-fns/branch/master/graph/badge.svg)](https://codecov.io/gh/baianat/color-fns)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a4d7bc3726514688b7186cce0852ebc4)](https://www.codacy.com/app/logaretm1/color-fns?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=baianat/color-fns&amp;utm_campaign=Badge_Grade)

</p>
<br>

Modern and Modular JavaScript color utility library. [inspired by date-fns](https://date-fns.org/).

## Features

- Written in TypeScript. 😎
- Lightweight. 💸
- Modular and Tree-shakable.🌳
- Multi-Color Model Support. 🎨
- CSS compatible output. 💨

## Installation

```bash
# yarn
yarn add color-fns

# npm
npm i color-fns
```

OR

```html
<script src="https://unpkg.com/color-fns"></script>
```

### Usage

```js
// ES2015 (ES6)
import { toRgb } from 'color-fns';

console.log(toRgb('#fff'));


// CommonJS
const { toRgb } = require('color-fns');
console.log(toRgb('#fff'));

// UMD (Script Tag)
console.log(ColorFns.toRgb('#fff'));
```

### Available Functions

#### Parsing

- parseCmyk
- parseHex
- parseHsl
- parseHsv
- parseRgb

#### Conversion

- cmykToRgb
- hexToRgb
- hslToRgb
- hsvToRgb
- rgbToCmyk
- rgbToHex
- rgbToHsl
- rgbToHsv
- toCmyk
- toHex
- toHsl
- toHsv
- toRgb

#### Operations

- mix

#### Format and Display

- expandHexShorthand
- formatCmyk
- formatHex
- formatHsl
- formatHsv
- formatRgb

#### Validation

- isValidCmyk
- isValidHex
- isValidHsl
- isValidHsv
- isValidRgb

#### Querying

- whichModel
- constrastInfo
- isDark

#### Calculations

- relativeLuminance

### Contribution

Contributions are welcomed, however make sure you read the [contribution guide](.github/CONTRIBUTING.md) and the [code of conduct](.github/CONDUCT.md) before making any pull requests.

### License

MIT

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