Color
Color
- Initialize the color from hex value, rgb or cmyk tuple.
Or from string rgb(r,g,b) or cmyk(c,m,y,k) - Initialize output format as either cmyk, rgb, hex or uhex
- Otherwise raise an error
Python example
Color('#b20071')
Color((178,0,112))
Color((0, 0.7, 0.26, 0.3))
Color('rbg(178,0,112)')
Color(('cmyk(0, 0.7, 0.26, 0.3)')
Color('#b20071','rgb')
Color('#b20071','cmyk')
c = Color('#b20071')
print c.lighten(30)
>>> #fe16a9
print c.lighten(30).desaturate(40)
>>> #d0439c
print c
>>> #b20070
Color('#b20071')
Color((178,0,112))
Color((0, 0.7, 0.26, 0.3))
Color('rbg(178,0,112)')
Color(('cmyk(0, 0.7, 0.26, 0.3)')
Color('#b20071','rgb')
Color('#b20071','cmyk')
c = Color('#b20071')
print c.lighten(30)
>>> #fe16a9
print c.lighten(30).desaturate(40)
>>> #d0439c
print c
>>> #b20070
| Method | Attributes | Docstring or default value |
|---|---|---|
| CMYK | 'cmyk' | |
| RGB | 'rgb' | |
| RGBA | 'rgba' | |
| _b | ||
| _cmyk |
The c.cmyk returns the color as e.g. rgb(254, 63, 103)
|
|
| _g | ||
| _get | ||
| _getlist | ||
| _hex |
The c.hex returns the color as e.g. #fe3f67
|
|
| _negative |
The c.negativebw returns white Color if the color is dark, and black if color is light.
|
|
| _negativebw |
The c.negativebw returns white Color if the color is dark, and black if color is light.
|
|
| _r | ||
| _rgb | alpha |
The c.rgb returns the color as e.g. rgb(254, 63, 103).
Or add alpha as e.g. c.rgb(0.5) the color is returned as rgba(254, 63, 103, 0.5).
|
| _uhex |
The c.hex returns the color as e.g. 0xfe3f67
|
|
| change | hue lightness saturation |
The c.change() returns a new Color object, that is changed with lightness ranging [-100:100] (default is 0), saturation ranging [-100:100] (default is 0), hue ranging [0:254] (default is 0), |
| darken | v |
The c.darken() returns a new Color object, that is darkened with with v ranging [0:100].
|
| desaturate | v |
The c.desaturate() returns a new Color object, that is desaturated with with v ranging [0:100].
|
| lighten | v |
The c.lighten() returns a new Color object, that is lightened with with v ranging [0:100].
|
| mix | mix |
The c.mix() returns a new Color object with mixed RGB channels. mix |
| opposite |
The c.opposite() returns a new Color object with opposite r,g and b channels. E.g. if the red channel of the color is 203, it will be changed to 51 |
|
| oppositehue |
The c.oppositehue() returns a new Color object with the opposite color on the hue circle,
while the lightness and saturation is unchanged.
|
|
| saturate | v |
The c.saturate() returns a new Color object, that is saturated with with v ranging [0:100].
|
| setformat | format |
The c.setformat() change the output format - if format is either
cmyk,rgb or hex
|
| setrgb | blue green red |
The c.setrgb() set the red, green and blue channel of the color.
|
