@guyn/tools
TypeScript icon, indicating that this package has built-in type declarations

1.0.11 • Public • Published

Guyn Tools

Convert, find, check and manipulate colors.

Guyn Tools is a collection of Javascript functions to deal with colors.

Convert

rgbToHex

Convert rgb color to hex

rgbToHex({ r: 0, g: 0, b: 0 }); // #000000

hexToRgb

Convert hex color to rgb

hexToRgb('#000000'); // {r: 0, g: 0, b: 0})

rgbToHsl

Convert rgb color to hsl

rgbToHsl({ r: 0, g: 0, b: 0 }); // {h: 0, s: 0, l: 100}

hexToHsl

Convert hex color to hsl

hexToHsl('#000000'); // {h: 0, s: 0, l: 100}

Checking

isHex

Is this string a hex color?

isHex('#000000'); // true
isHex('#00000'); // false
isHex('#000'); // false
isHex('#ff00gg'); // false

isObjectString

Check if a string could be a valid object.

isObjectString('something'); // false
isObjectString('"{"test":"test"}"'); // true

Hex Strings

toHexChars

Convert a possible hex color code to a valid hex color code

toHexChars(' #00aa 00'); // #00aa00
toHexChars('#fff'); // #ffffff;
toHexChars('#fffaabbaa'); // #fffaab;

toHexCharsGroup

Convert an array of possible hex color codes to valid color codes.

toHexChars([' #00aa 00', '#fff']); // ['#00aa00', '#ffffff']

findHex

Find all Hex colors in a string

findHex('#000#aaa#abcdef'); // ['#000000','#aaaaaa', '#abcdef']

Readme

Keywords

Package Sidebar

Install

npm i @guyn/tools

Weekly Downloads

1

Version

1.0.11

License

MIT

Unpacked Size

159 kB

Total Files

100

Last publish

Collaborators

  • silvandiepen