2.1.13 • Published 3 years ago

simple-color-converter v2.1.13

Weekly downloads
614
License
MIT
Repository
github
Last release
3 years ago

build passing License maintained Vulnerabilities Node Version NPM size NPM size Release Commit Issues Total downloads

Simple color converter for (almost) Any Color

DEMO

It covers most colors formats from Pantone, Ral, Hex 3/4/6/8, HTML, sRgb, CMYK, etc for converting from -> and -< to. It's designed with simplicity in mind. you can pass data and specify the format or just let is guess what color you are trying to pass as string.

simple color convertor logo

Install

$ npm install simple-color-converter

Usage

const simpleColorConverter = require('simple-color-converter');

var color = new simpleColorConverter({
    ral: { ral: 3009 }, 
    to: 'cmyk'
})

console.log(color) // { c: 0, m: 53, y: 60, k: 60 } 

Supported colors

Expected input value list [here].

Expected output value list [here].

color systemobjectarraystring
cmyk{c: 39, m: 0, y: 39, k: 7}39, 0, 39.7'cmyk 39 0 39 7'
grayscale'78'
hex3'#9E9'
hex4'#9E9F'
hex6'#90EE90'
hex8'#90EE90FF'
html'Light Green'
hsl{ h: 120, s: 73.4, l: 74.9 }120, 73.4, 74.9'hsl 120 73.4 74.9'
hsv{ h: 120, s: 39.4, l: 93.3 }120, 39.4, 93.3'hsl 120 39.4 93.3'
lab{l: 86.5, a: -46.3, b: 36.9}86.5, -46.3, 36.9'lab 86.5 -46.3 36.9'
pantone{name: '358C'}'pantone 358C'
ral{ ral : 6019 }'ral 6019'
rgb{ r: 144, g: 238, b: 144 }144, 238, 144'rgb 144 238 144'
rgba{ r: 144, g: 238, b: 144, a: 1 }144, 238, 144, 1'rgba 144 238 144 1'
rgb decimal'rgb decimal 6812065'
w{ r: 144, g: 238, b: 144, a: 1 }144, 238, 144, 1'w 544'
xyz{ x: 44, y: 69, z: 45 }44, 69, 45'xyz 44 69 45'
yuv{ y: 180, u: 113.2, v: 73.5 } 180, 113.2, 73.5 'yuv 180 113.2 73.5'

From

Any of the colors mentioned above. You can specify the color and it will be faster of just use the built in color detector.

// faster
var fasterColor = new simpleColorConverter({
    rgb: {r: 10, g: 200, b: 50}, 
    to: 'cmyk'
})

// slower but more convenient

var slowerColor = new simpleColorConverter({
    color: 'rgb 10 200 50', 
    to: 'cmyk'
})
Extra From colorsnote
colorAutoidentify color
hexAutoidentify hex color
androidhex8

Flags

flags are the arguments used for special modifiers. The most useful one is rendering grayscale color, but there is a debugger and a hexref flag created if you need to convert a color but also output a close hex similar color(in case of online color convertors).

const simpleColorConverter = require('simple-color-converter');

var color = simpleColorConverter({
    hex3: '#228', 
    to: 'cmyk', 
    grayscale: true 
})

console.log(color) // { c: 0, m: 0, y: 0, k: 87 }
flagoutputdata typedefaultnote
grayscalegrayscale value in the from formatbooleanfalse
hexrefReference value in hex formatbooleanfalseFor Hex it equels Hex6
debugthis prevents the object cleanupbooleanfalse

Future

I am working on version 3 or this package and the new version will be a modern setter and getter based color convertor. A much modern way of approaching this problem.

Contribute

If there are any features you would like to support, or want to add it directly please send us a pull request. I`m more then happy.

If you have any suggestions or you spotted an aberrant behavior or bugs, don't hesitate to send me an email.

License

Copyright © 2019, Radu Dragan. Licensed under the MIT License.

Thank you

I`m Radu, Thank you for using my color convertor, I hope it is useful for you. I genuinely excited to build this kind of solutions.

2.1.13

3 years ago

2.1.12

3 years ago

2.1.11

3 years ago

2.1.10

3 years ago

2.1.9

4 years ago

2.1.8

4 years ago

2.1.7

4 years ago

2.1.6

4 years ago

2.1.5

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.3

4 years ago

2.0.4

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago