Skip to content
Manipulate, compare and convert colors
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.babelrc
.codeclimate.yml
.editorconfig
.eslintrc
.flowconfig
.gitignore
.travis.yml
LICENSE
README.md
jest.config.js
package-lock.json
package.json

README.md

Colorizr

NPM version build status Maintainability Test Coverage

JavaScript module to manipulate colors, get its properties and compare it with another color following the WCAG 2.0.

Setup

Install

npm install --save colorizr

And import it:

import Colorizr from 'Colorizr';

Usage

const colorizr = new Colorizr('#ff0044');

colorizr.hex // #ff0044
colorizr.hsl // { h: 344, s: 100, l: 50 };
colorizr.rgb // { r: 255, g: 0, b: 68 };

colorizr.saturate(20);
colorizr.lighten(10);

API

Set the instance color.
colorizr.setColor(color: string | Array | Object)

Getters

colorizr.hue // 0-360
colorizr.saturation // 0-100
colorizr.lightness // 0-100
colorizr.red // 0-255
colorizr.green // 0-255
colorizr.blue // 0-255
colorizr.luminance // 0-1
colorizr.chroma // 0-1

Manipulation

Increase lightness.
colorizr.lighten(percentage: number = 10)

Decrease lightness.
colorizr.darken(percentage: number = 10)

Increase saturation.
colorizr.saturate(percentage: number = 10)

Decrease saturation.
colorizr.saturate(percentage: number = 10)

References

calculating-color-contrast
Colour Contrast Check
Contrast Checker

You can’t perform that action at this time.