Skip to content

Releases: elchininet/ColorTranslator

v5.0.0

05 Jun 22:58

Choose a tag to compare

This release is a major update of the library and it brings new features and solve some minor bugs.

New features

Support from HWB colors

HWB colors are now supported in the library.

CSS string inputs

Example of CSS string inputs Description
hwb(0 0% 0%) Functional HWB notation
hwb(0 0% 0% / 0.5) Functional HWB notation with alpha
hwb(0deg 0% 0%) Functional HWB notation with hue in degrees
hwb(0grad 0% 0%) Functional HWB notation with hue in gradians
hwb(0rad 0% 0%) Functional HWB notation with hue in radians
hwb(0turn 0% 0%) Functional HWB notation with hue in turns

Object inputs

Example of object inputs Description
{H: 0, W: 0, B: 0} HWB notation
{H: 0, W: 0, B: 0, A: 0.5} HWB notation with alpha

Class public methods

Public methods Input Description
setWhiteness 0 ≤ input ≤ 100 Sets the color whiteness percentage
setBlackness 0 ≤ input ≤ 100 Sets the color blackness percentage

Class public readonly properties

Property Description
HWB Gets the css hwb representation of the color
HWBA Gets the css hwb representation of the color with alpha
HWBObject Gets the object HWB representation of the color
HWBAObject Gets the object HWB representation of the color with alpha
Whiteness Gets the color whiteness percentage
Blackness Gets the color blackness percentage

Color conversion static methods description

Static method Description
toHWB Converts to an hwb notation
toHWBObject Converts to an object in hwb notation
toHWBA Converts to an hwb notation with alpha
toHWBAObject Converts to an object in hwb notation with alpha
getBlendHWB Creates an array relative to the blend between two colors in hwb notation
getBlendHWBObject Creates an array of objects relative to the blend between two colors in hwb notation
getBlendHWBA Creates an array relative to the blend between two colors in hwb notation with alpha
getBlendHWBAObject Creates an array of objects relative to the blend between two colors in hwb notation with alpha
getMixHWB Gets the mix of the input colors in hwb notation
getMixHWBObject Gets the mix of the input colors in an object in hwb notation
getMixHWBA Gets the mix of the input colors in hwb notation with alpha
getMixHWBAObject Gets the mix of the input colors in an object in hwb notation with alpha

Support from LCH colors

LCH colors are now supported in the library.

Example of CSS string inputs Description
lch(54 107 41) Functional LCH notation
lch(54% 71% 41) Functional LCH notation with percentages
lch(54 107 41 / 0.5) Functional LCH notation with alpha
lch(54% 71% 41 / 0.5) Functional LCH notation with percentages and alpha
lch(54 107 41deg) Functional LCH notation with hue in degrees
lch(54 107 46grad) Functional LCH notation with hue in gradians
lch(54 107 1rad) Functional LCH notation with hue in radians
lch(54 107 0turn) Functional LCH notation with hue in turns

Object inputs

Example of object inputs Description
{L: 54, C: 107, H: 41} LCH notation
{L: 54, C: 107, H: 41, A: 0.5} LCH notation with alpha

Class public methods

Public methods Input Description
setLCHL 0 ≤ input ≤ 100 Sets the color lightness percentage
setLCHC 0 ≤ input ≤ 150 Sets the color chroma
setLCHH 0 ≤ input ≤ 360 Sets the lch color hue

Class public readonly properties

Property Description
LCH Gets the css lch representation of the color
LCHA Gets the css lch representation of the color with alpha
LCHObject Gets the object lch representation of the color
LCHAObject Gets the object lch representation of the color with alpha
LCHL Gets the lch color lightness
LCHC Gets the color chroma
LCHH Gets the lch color hue

Color conversion static methods description

Static method Description
toLCH Converts to a lch notation
toLCHObject Converts to an object in lch notation
toLCHA Converts to a lch notation with alpha
toLCHAObject Converts to an object in lch notation with alpha
getBlendLCH Creates an array relative to the blend between two colors in lch notation
getBlendLCHObject Creates an array of objects relative to the blend between two colors in lch notation
getBlendLCHA Creates an array relative to the blend between two colors in lch notation with alpha
getBlendLCHAObject Creates an array of objects relative to the blend between two colors in lch notation with alpha
getMixLCH Gets the mix of the input colors in lch notation
getMixLCHObject Gets the mix of the input colors in an object in lch notation
getMixLCHA Gets the mix of the input colors in lch notation with alpha
getMixLCHAObject Gets the mix of the input colors in an object in lch notation with alpha

Support from relative colors

Relative colors colors are now supported in the library as CSS input.

CSS string inputs

Example of CSS string inputs Description
rgb(from #F00 r g b) Functional RGB notation in relative color syntax
rgb(from hsl(0 100% 50%) calc(r + 5) g b / calc(alpha / 2)) Functional RGB notation in relative color syntax with alpha
hsl(from hsl(0 100 50) h s l) Functional HSL notation in relative color syntax
hsl(from hsl(0 100 50) calc(h + 5) s l / calc(alpha / 2)) Functional HSL notation in relative color syntax with alpha
hwb(from hwb(0 0% 0%) h w b) Functional HWB notation in relative color syntax
hwb(from hwb(0 0% 0%) calc(h + 2) w b / calc(alpha / 2)) Functional HWB notation in relative color syntax with alpha
lab(from #F00 l a b) Functional LAB notation in relative color syntax
lab(from #F00 calc(l + 5) a b / calc(alpha / 2)) Functional LAB notation in relative color syntax with alpha
lch(from lch(54 107 41) l c h) Functional LCH notation in relative color syntax
lch(from lch(54 107 41) calc(l + 2) c h / calc(alpha / 2)) Functional LCH notation in relative color syntax and alpha

Example:

const color = new ColorTranslator('#F0...
Read more

v4.1.0

27 Nov 21:19

Choose a tag to compare

🚀 Features

🛠 Fixes

v4.0.0

26 Nov 22:45

Choose a tag to compare

🚀 Features

🎲 Demo

🧩 Dependencies

v3.0.2

02 Aug 17:47

Choose a tag to compare

🛠 Fixes

🎲 Demo

⚙️ Configuration

v3.0.1

20 Jul 21:29

Choose a tag to compare

🛠 Fixes

🎲 Demo

🧩 Dependencies

v3.0.0

18 Jul 00:01

Choose a tag to compare

⚠️⚠️⚠️ BREAKING CHANGE!!! ⚠️⚠️⚠️
⚠️⚠️⚠️ BEFORE UPGRADE CONSULT THE README.md TO SEE THE LATEST CHANGES AND CHECK IF THEY CAN AFFECT YOU ⚠️⚠️⚠️

🚀 Features

🧩 Dependencies

⚙️ Configuration

v2.0.0

18 May 18:04

Choose a tag to compare

🚀 Features

  • Complete refactor of the library, add support to control the number of decimals

🛠 Fixes

🧩 Dependencies

⚙️ Configuration

📦 Other