convert_color_codes
The convert_color_codes module deals with the conversion of color codes. Conversion from these codes HSV/HSB, RGB, CMYK, HSL from one to another.
Installation
You can install convert_color_codes from PyPI:
pip install convert_color_codes
It is supported on Python 2, 3 ...
How to use
from convert_color_codes import *
There are several functions like rgb2hex(red, green, blue)
, see the table:
Source with Arguments β Target and Return Value β |
rgb2...(red, green, blue) |
hex2...("#RRGGBB" or "#RGB") |
hsl2...(hue, saturation, lightness) |
hsv2...(hue, saturation, value) hsb2...(hue, saturation, brightness)
|
hsv2...(cyan, magenta, yellow, black) |
---|---|---|---|---|---|
rgb β (red, green, blue)
|
β | β | β | β | |
hex β "#RRGGBB"
|
β | β | β | β | |
hsl β (hue, saturation, lightness)
|
β | β | β | β | |
hsv or hsb β (hue, saturation, brightness)
|
β | β | β | β | |
cmyk β (cyan, magenta, yellow, black)
|
β | β | β | β |
The values have different ranges:
name | min | max | type |
---|---|---|---|
red | 0 | 255 | int |
green | 0 | 255 | int |
blue | 0 | 255 | int |
R | 0 | F | str |
G | 0 | F | str |
B | 0 | F | str |
hue | 0 | 360 | int or float |
saturation | 0 | 1 | float |
lightness | 0 | 1 | float |
value or brightness | 0 | 1 | float |
cyan | 0 | 1 | float |
magenta | 0 | 1 | float |
yellow | 0 | 1 | float |
black | 0 | 1 | float |