color_identifier
v0.0.2
Published
This package is made to identify user inputed colors from a field. Figuring out if the color is RGB HEX6 HEX3, CMYK is hard work, some user use # some don't, some use , other ; there are users that like using percentage unites and expect use to figure it
Downloads
2
Readme
Color identifier
This package is made to identify user inputed colors from a field. Figuring out if the color is RGB HEX6 HEX3, CMYK is hard work, some user use # some don't, some use , other ; there are users that like using percentage unites and expect use to figure it out while they are typing. This package does all the busy work for you so you can use 1 single input field for all inputtable color variants.
If there is a way you found out user input colors please contribute to the test_data, it is greatly appreciated.
const colorIdentifier = require('color_identifier');
const hex = colorIdentifier('#4287f5');
const rgb = colorIdentifier('rgb(50,60,80)');
const rgbMostLikely = colorIdentifier(' 50 60 aaa 80 ');
const cmyk = colorIdentifier('cmyk(73%, 45%, 0%, 4%)');
const cmykMostLikely = colorIdentifier('73 45 0 4 ');
console.log(hex) // { type: 'hex', format: 6, sanitizedData: '4287f5' }
console.log(rgb) // { type: 'rgb', format: 'rgb', sanitizedData: [ '50', '60', '80' ] }
console.log(rgbMostLikely) // { type: 'rgb', format: 'rgb', sanitizedData: [ '50', '60', '80' ] }
console.log(cmyk) // { type: 'cmyk', format: 'cmyk', sanitizedData: [ '73', '45', '0', '4' ] }
console.log(cmykMostLikely) // { type: 'cmyk', format: 'cmyk', sanitizedData: [ '73', '45', '0', '4' ] }
What we support (now)
Look at the data test to get an idea of what works.
| input | support |
| --- | --- |
| cmyk | yes |
| grayscale | soon |
| hex3 | yes |
| hex6 | yes |
| hsl | soon |
| lab | soon |
| rgb | yes |