# color-magic

> A CSS color convertion and manipulation library

Latest version **3.1.1** (published 2017-02-10) · MIT license · 0 weekly downloads

## Install

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

## 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 | 3.1.1 |
| Published | 2017-02-10 |
| First published | 2017-02-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Thomas Alrek |
| Maintainers | apility |

## Links

- npm: https://www.npmjs.com/package/color-magic
- npm.io page: https://npm.io/package/color-magic

## Recent versions

- 3.1.1 (latest) — 2017-02-10
- 3.1.0 — 2017-02-10
- 3.0.0 — 2017-02-07

## README

# Color-Magic

A library for doing CSS color manipulation and conversion

[Live demo](https://rawgit.com/apility/color-magic/master/example.html)

## Construction

```javascript
let ColorMagic = require('ColorMagic');

// Can be constructed from all valid CSS color formats
let red = new ColorMagic('#f00');
let green = new ColorMagic('rgba(0,255,0,1)');
let blue = new ColorMagic('blue');

// Can also construct from these formats
let grey = new ColorMagic(128);
let magenta = new ColorMagic(255, 255, 0);
let cyan = new ColorMagic(0, 255, 255, 0.5);
let orange = new ColorMagic([255,165,0,1]);
```

## Complementary colors and contrasting colors

```javascript
// Find the font color that contrasts the best with out background color
let background = new ColorMagic('black');
let fontColor = new ColorMagic().contrast(background);

// Get the inverse color of a given color
let yellow = new ColorMagic('blue').invert();
```

## Mixing colors

```javascript
// Add colors
let red = new Color('red');
let green = new Color('green');
let blue = new Color('blue');

let white = new Color().add(red).add(green).add(blue);

// Subtract colors
let black = new Color(white).subtract(white);
```

## Building

To build, you need to have webpack installed. (`npm install -g webpack`)

Simply run `webpack` from this directory, and `color-magic.js` and `color-magic.js.map` will be built in the `dist` folder.

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