colors-formater
A library to provide simple manipulation between colors formats in javascript
Instalation
Latest Version
// NPM
npm install --save colors-formater
// Yarn
yarn add colors-formater
A Specific Version
// NPM
npm install --save colors-formater#v.0.8
// Yarn
yarn add colors-formater#v.0.8
Examples
Import
const Colors = require("colors-formater");
import Colors from "colors-formater";
Initialization
const color = Colors("123");
const color = Colors("#123");
const color = Colors("#ABCDEF");
const color = Colors({ r: 255, g: 23, b: 87 });
const color = Colors("rgb(23, 45, 67)");
const color = Colors("rgba(23, 45, 67, 0.4)");
const color = Colors({ h: 255, s: "23%", l: "50%" });
const color = Colors("hsl(255, 23%, 50%)");
Convertions
const color = Colors("#abc");
color.toHex();
color.toRGB();
color.toRGBString();
color.toHSL();
color.toHSLString();
Verifications
const color = Colors("#abc");
color.isValid();
color.isHex();
color.isHSL();
color.isRGB();
color.isLight();
color.isDark();
Calculations
These functions changes internal initial color. Always
prefer using it with the constructor Colors([color])
const color = Colors("#abc");
Colors("#A34").darken(0.2).toHex();
Colors("#A34").lighten(0.35).toRGB();
Colors("#A34").invert().toHSL();
Alpha
These functions adds alpha to color
const color = Colors("#abc");
Colors("#A34").toHexa(0.2);
Colors("#A34").toRGBA(0.2);
Colors("#A34").toRGBAString(0.2);