All Projects β†’ netbeast β†’ colorsys

netbeast / colorsys

Licence: MIT license
🎨 Minimalistic color converter for RGB, HSV, HSL, CMYK, HEX and CSS strings

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to colorsys

ColorHelper
No description or website provided.
Stars: ✭ 34 (-35.85%)
Mutual labels:  hex, color, rgb, hsv, cmyk
vscode-color
Helper with GUI to generate color codes such as CSS color notations.
Stars: ✭ 88 (+66.04%)
Mutual labels:  hex, rgb, hsv, cmyk
colorsys.rs
Lib for modifying colors and converting to other spaces
Stars: ✭ 28 (-47.17%)
Mutual labels:  hex, color, rgb, cmyk
color
A library of well-tested helper methods for working with colors.
Stars: ✭ 13 (-75.47%)
Mutual labels:  hex, color, random, rgb
utils.js
πŸ‘· πŸ”§ zero dependencies vanilla JavaScript utils.
Stars: ✭ 14 (-73.58%)
Mutual labels:  hex, color, random
ColorMinePortable
ColorMinePortable
Stars: ✭ 37 (-30.19%)
Mutual labels:  hex, rgb, cmyk
colors-convert
🦚 A simple colors library
Stars: ✭ 15 (-71.7%)
Mutual labels:  hex, rgb, cmyk
Culori
A comprehensive color library for JavaScript.
Stars: ✭ 271 (+411.32%)
Mutual labels:  hex, color, rgb
khroma
A collection of functions for manipulating CSS colors, inspired by SASS.
Stars: ✭ 28 (-47.17%)
Mutual labels:  hex, color, rgb
Xcodecolorsense
🎈 An Xcode plugin that makes working with color easier
Stars: ✭ 79 (+49.06%)
Mutual labels:  hex, color, rgb
Colorhighlight
🎨 Lightweight Color Highlight colorizer for Sublime Text
Stars: ✭ 76 (+43.4%)
Mutual labels:  hex, color, rgb
Values.js
πŸ‡ Get the tints and shades of a color
Stars: ✭ 97 (+83.02%)
Mutual labels:  hex, color, rgb
rgb-tui
Create and get colors code from the terminal using a nice interface.
Stars: ✭ 57 (+7.55%)
Mutual labels:  color, rgb, hsv
hex-to-css-filter
Easy way to generate colors from HEX to CSS Filters
Stars: ✭ 20 (-62.26%)
Mutual labels:  hex, color, rgb
Farge
🎈Tell the name of hex color
Stars: ✭ 23 (-56.6%)
Mutual labels:  hex, color, rgb
Colorpicker
A mininal but complete colorpicker desktop app
Stars: ✭ 766 (+1345.28%)
Mutual labels:  hex, color, rgb
Color
A little library to deal with color conversions
Stars: ✭ 166 (+213.21%)
Mutual labels:  hex, color, rgb
tc-lib-color
PHP library to manipulate various color representations
Stars: ✭ 19 (-64.15%)
Mutual labels:  color, rgb, cmyk
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 (-56.6%)
Mutual labels:  color, hsv
dehex
πŸŽ¨πŸ‘€ R package: learn to assess a colour hex code by eye
Stars: ✭ 29 (-45.28%)
Mutual labels:  hex, color

colorsys

CircleCI npm version

Colorsys is a simple javascript color conversion library that allows bidirectional color conversion. Lightweight, immutable. With support for RGB, HEX, HSV, HSL and CMYK and CSS strings.

install

With npm

npm install colorsys

Load on browser or copy paste into your code

<script src="https://unpkg.com/[email protected]/colorsys.js"></script>

example

var colorsys = require('colorsys')
const hsl = colorsys.parseCss('hsl(0, 0%, 100%)') //  { h: 0, s: 0, l: 100 }
colorsys.hsl2Hex(hsl) // '#ffffff'
const hsv = colorsys.rgb_to_hsv({r: 255, g: 255, b: 255 })
colorsys.stringify(hsv) // 'hsv(0, 0%, 100%)'
// Parsing an hex string will result in a RGB object!
colorsys.parseCss('#ff00ff') // { r: 255, g: 0, b: 255 }

For more examples please visit the tests

API

For any method the input arguments can be an object (r: 50, g: 100, b: 0} or a set of integers 50, 100, 0. You have aliases in both snake_case (hex_to_hsl) or rgb2Hex, hsv2Rgb form.

  • colorsys.parseCss(color: string) will parse a color string in an object with the same keys.
  • colorsys.stringify(color: Object) will output a valid css string.
  • colorsys.rgb_to_hsl({ r: 255, g: 255, b: 255 }) => { h: 0 , s: 0 , l: 100 }
  • colorsys.rgb_to_hsv({ r: 255, g: 255, b: 255 }) => { h: 0 , s: 0 , v: 100 }

Try with any combination. Look at the source to double check!

  • colorsys.hslToRgb
  • colorsys.hsvToRgb
  • colorsys.rgbToHex
  • colorsys.hexToRgb
  • colorsys.hsvToHex
  • colorsys.hexToHsv
  • colorsys.hslToHex
  • colorsys.hexToHsl
  • colorsys.rgb2cmyk
  • colorsys.cmyk2rgb

Other methods:

  • Generate a random hex color: colorsys.random()
  • Rotate a color hue: colorsys.rotateHue(120, 120) will output 240. You can also use HSL or HSV objects as rotateHue(hsv, 120) will output an object containing {h: 240}.

There are some formats missing like YIQ, HWB, ansii and ansi16. Please help us to complete this library making a pull request.

Contact

  • Mail us: staff [at] netbeast.co
  • Report a bug or enter discussion at issues
  • Twitter

This repo is shared with ❀️ from Netbeast. This package powers Yeti Smart Home and is used in production.

works with yeti
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].