0.5.2 • Published 3 months ago

color-translate v0.5.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Color Translator

This package allows translating colors among all valid css formats

Installation

Using npm:

npm i color-translate

Usage

import ColorTranslator from "color-translate";

const color = new ColorTranslator("hsl(0 100% 50%)");
color.updateRgb({ r: 127.5, b: 255 });
color.updateRgb({ alpha: 0.4 });
color.updateOptions({ angleUnit: "grad" });

console.log(color.lch.l);
// 39.282796563892475

console.log(color.lch.toString());
// "lch(39.28 121.27 -57.78grad / 0.4)"

console.log(color.lch.toString({ legacy: true }));
// "lch(39.28, 121.27, -57.78grad, 0.4)"

Options:

OptionDescriptionDefault value
angleUnitAngle unit'none'
cacheInputPersist last inputfalse
legacyLegacy modetrue
limitToColorSpaceClamp colors to format spacetrue
maxDigitsRound color values to a max number of decimal places2
spacedSpace between string color valuesfalse

🌐 Links

NPM

Github Repository

0.5.2

3 months ago

0.5.0

4 months ago

0.5.1

4 months ago

0.4.1

4 months ago

0.4.0

4 months ago

0.4.2

4 months ago

0.3.0

7 months ago

0.1.2

7 months ago

0.2.0

7 months ago

0.3.2

7 months ago

0.3.1

7 months ago

0.1.3

7 months ago

0.3.4

6 months ago

0.3.3

7 months ago

1.0.0

5 years ago