1.0.11 • Published 4 years ago

@guyn/tools v1.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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']
1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago