0.1.4 • Published 2 years ago

color-code-converter v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

MIT License

Installation

yarn

yarn add color-code-converter

npm

npm install color-code-converter

How to Use

import * as ccc from "color-code-converter";
// or
const ccc = require("color-code-converter");

// convert from decimal
const decr = ccc.dec2decr([13, 146, 213]); // [0.051, 0.573, 0.835]
const hex = ccc.dec2hex([13, 146, 213]); // ["0d", "92", "d5"]
const code = ccc.dec2code([13, 146, 213]); // "#0d92d5"
const codex = ccc.dec2codex([13, 146, 213]); // "0x0d92d5"

// convert from ratio of decimal
const dec = ccc.decr2dec([0.051, 0.573, 0.835]); // [13, 146, 213]
const hex = ccc.decr2hex([0.051, 0.573, 0.835]); // ["0d", "92", "d5"]
const code = ccc.decr2code([0.051, 0.573, 0.835]); // "#0d92d5"
const codex = ccc.decr2codex([0.051, 0.573, 0.835]); // "0x0d92d5"

// convert from hexadecimal
const dec = ccc.hex2dec(["0d", "92", "d5"]); // [0.051, 0.573, 0.835]
const decr = ccc.hex2decr(["0d", "92", "d5"]); // ["0d", "92", "d5"]
const code = ccc.hex2code(["0d", "92", "d5"]); // "#0d92d5"
const codex = ccc.hex2codex(["0d", "92", "d5"]); // "0x0d92d5"

// convert from color code starting "#" starting
const dec = ccc.code2dec("#0d92d5"); // [13, 146, 213]
const decr = ccc.code2decr("#0d92d5"); //  [0.051, 0.573, 0.835]
const hex = ccc.code2hex("#0d92d5"); // ["0d", "92", "d5"]
const codex = ccc.code2codex("#0d92d5"); // "0x0d92d5"

// convert from color code starting "0x" starting
const dec = ccc.codex2dec("0x0d92d5"); // [13, 146, 213]
const decr = ccc.codex2decr("0x0d92d5"); //  [0.051, 0.573, 0.835]
const hex = ccc.codex2hex("0x0d92d5"); // ["0d", "92", "d5"]
const code = ccc.codex2code("0x0d92d5"); // "#0d92d5"