All Projects → ilariaventurini → colors-convert

ilariaventurini / colors-convert

Licence: MIT License
🦚 A simple colors library

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to colors-convert

color
A library of well-tested helper methods for working with colors.
Stars: ✭ 13 (-13.33%)
Mutual labels:  converts, hex, hsl, rgb, rgb-color, rgba, hsla, hex-color
ColorTranslator
A JavaScript library, written in TypeScript, to convert among different color models
Stars: ✭ 34 (+126.67%)
Mutual labels:  hsl, rgb, rgb-color, rgba, hsla, hsla-colors, rgba-color
ColorHelper
No description or website provided.
Stars: ✭ 34 (+126.67%)
Mutual labels:  hex, hsl, rgb, cmyk
vscode-color
Helper with GUI to generate color codes such as CSS color notations.
Stars: ✭ 88 (+486.67%)
Mutual labels:  hex, hsl, rgb, cmyk
go-rainbow
Golang Helper for beautiful CLI Applications
Stars: ✭ 86 (+473.33%)
Mutual labels:  hex, colors, rgb, rgba
Values.js
🍇 Get the tints and shades of a color
Stars: ✭ 97 (+546.67%)
Mutual labels:  hex, colors, hsl, rgb
Gradstop
JavaScript micro library to generate gradient color stops 🏳️‍🌈
Stars: ✭ 144 (+860%)
Mutual labels:  hex, colors, hsl, rgb
ColorMinePortable
ColorMinePortable
Stars: ✭ 37 (+146.67%)
Mutual labels:  hex, hsl, rgb, cmyk
tc-lib-color
PHP library to manipulate various color representations
Stars: ✭ 19 (+26.67%)
Mutual labels:  hsl, rgb, cmyk, rgba
colorsys.rs
Lib for modifying colors and converting to other spaces
Stars: ✭ 28 (+86.67%)
Mutual labels:  hex, hsl, rgb, cmyk
React Color Extractor
A React component which extracts colors from an image
Stars: ✭ 314 (+1993.33%)
Mutual labels:  hex, colors, hsl, rgb
ichiColor
Full features javascript color parser module, perfect work with vue.js; support RGB, HSL, HSV/HSB, HSL255, HSL240, HWB, XYZ, LAB, LUV, LHCab, xyY...
Stars: ✭ 23 (+53.33%)
Mutual labels:  hsl, rgba, colorspace
react-color
🎨 Is a tiny color picker widget component for React apps.
Stars: ✭ 50 (+233.33%)
Mutual labels:  hex, rgba, rgba-color
Tints And Shades
🌈 Display tints and shades of a given hex color in 10% increments.
Stars: ✭ 228 (+1420%)
Mutual labels:  hex, colors, rgb
Alfred-Colors-workflow
hex <=> rgb <=> hsl
Stars: ✭ 28 (+86.67%)
Mutual labels:  hex, hsl, rgb
khroma
A collection of functions for manipulating CSS colors, inspired by SASS.
Stars: ✭ 28 (+86.67%)
Mutual labels:  hex, hsl, rgb
Colorhighlight
🎨 Lightweight Color Highlight colorizer for Sublime Text
Stars: ✭ 76 (+406.67%)
Mutual labels:  hex, hsl, rgb
hex-rgba
Convert HEX to RGBA
Stars: ✭ 12 (-20%)
Mutual labels:  hex, colors, rgba
Culori
A comprehensive color library for JavaScript.
Stars: ✭ 271 (+1706.67%)
Mutual labels:  hex, hsl, rgb
andColorPicker
Color picker library for Android
Stars: ✭ 233 (+1453.33%)
Mutual labels:  hsl, rgb, cmyk

Colors convert

A simple colors library

Using colors-convert you can:

  • read colors in different formats
  • analyze and manipulate colors
  • convert colors into different formats
  • give a name to a color
  • mix colors
  • create random colors.

How to use

yarn add colors-convert

or

npm install --save colors-convert

API overview

Go here to take a look at the complete API.

Color formats

Different color formats are supported: hex, rgb, rgba, hsl, hsla and cmyk.

Hex

A valid hex color can be:

  • #rrggbb[aa](6/8-digit, long form)
  • #rgb[a] (3/4-digit, short form) with r, g, b, a in [0-9a-fA-F].

Rgb

A valid rgb color is an object like this {r, g, b} with r, b, g numeric values in [0, 255].

Rgba

A valid rgba color is an object like this {r, g, b, a} with r, g, b numeric values in [0, 255] and a in [0, 1].

Hsl

A valid hsl color is an object like this {h, s, l} with:

  • h (hue): [0-359]°
  • s (saturation): [0-100]%
  • l (lightness): [0-100]%.

Hsla

A valid hsl color is an object like this {h, s, l} with:

  • h (hue): [0-359]°
  • s (saturation): [0-100]%
  • l (lightness): [0-100]%
  • a (alpha): [0-1].

Cmyk

A valid cmyk color is an object like this {c, m, y, k} with c, m, y, k numeric values in [0, 100].


Conversion

You can convert a color in any format to any other supported format.

from \ to Hex Rgb Rgba Hsl Hsla Cmyk
Hex \ hexToRgb hexToRgba hexToHsl hexToHsla hexToCmyk
Rgb rgbToHex \ rgbToRgba rgbToHsl rgbToHsla rgbToCmyk
Rgba rgbaToHex rgbaToRgb \ rgbaToHsl rgbaToHsla rgbaToCmyk
Hsl hslToHex hslToRgb hslToRgba \ hslToHsla hslToCmyk
Hsla hslaToHex hslaToRgb hslaToRgba hslaToHsl \ hslaToCmyk
Cmyk cmykToHex cmykToRgb cmykToRgba cmykToHsl cmykToHsla \
Color colorToHex colorToRgb colorToRgba colorToHsl colorToHsla colorToCmyk

Specific functions by color format

Then there are more specific color format functions. You can also convert a Color to a redeable string format or a CSS string format. Go here to take a look at the complete API.

Other useful functions

  • name(color: Color): string: given a color (hex, rgb, rgba, hsl, hsla, cmyk), it returns the name of that color. It works using a list of 18315 unique color names.

  • mix(colors: Color[], weights?: number[]): rgb: mix two or more colors based on their weights.

  • randomHex(): HEX: return a random hex.

🎉 What's new in 1.3.0

  • [add] add the following functions: colorToHex, color2rgba, rgbaToHex, cmykToRgba, cmykToHsla, hexToHsla, rgbToHsla, rgbaToHsla, hslToRgba, colorToCmyk, colorToHsl, hslToHsla, colorToHsla, hslaStringToObject, hexToRgb, hexToRgba, shortToLongHex
  • [add] add hsla color format
  • [add] test coverage > 97%
  • [add] add api page
  • [add] add a new logo
  • [change] set as deprecated the following functions: color2string, color2cssString, hex2rgbOrRgba, hex2rgba, hex2hexWithAlpha, hex2cmyk, hex2hsl, rgb2hex, rgb2cmyk, rgb2hsl, rgb2rgba, color2rgb, rgbString2Object, rgba2rgb, rgbaString2Object, cmyk2hex, cmyk2rgb, cmyk2hsl, cmykString2Object, hsl2hex, hsl2rgb, hsl2cmyk, hslString2Object, getRandomColor,
  • [change] rgb2rgba has optional alpha parameter
  • [change] ColorName type: is no more a string but an object with name, hex and rgb
  • [fix] #00000 is not a valid hex color

Go here to see the CHANGELOG.

License

MIT © Ilaria Venturini

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].