colorviews - Documentation¶
Colors¶
Classes to represent colors with and without alpha value.
Color represents color values without alpha and AlphaColor represents color values that have alpha.
-
class
colorviews.colors.
Color
(r: float, g: float, b: float)¶ Class representing colors without alpha value.
Information is stored using rgb values.
-
property
rgb
¶ RGB colorview as float values
-
property
hsl
¶ HSL colorview as float values
-
property
hsv
¶ HSV colorview as float values
-
property
rgb_
¶ RGB colorview as int values
-
property
hsl_
¶ HSL colorview as int values
-
property
hsv_
¶ HSV colorview as int values
-
classmethod
from_name
(name: str) → colorviews.colors.Color¶ Creates a Color object based on the given color name.
Only CSS3 extended color keyword names are recognized.
- Parameters
name – Name of color.
- Returns
Color object with value corresponding to the given color name.
-
classmethod
from_int
(value: int) → colorviews.colors.Color¶ Creates a Color object from the given integer color value.
- Parameters
value – Integer color value.
- Returns
Color object with given integer value.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_rgb
(r: float, g: float, b: float) → colorviews.colors.Color¶ Creates a Color object from the given RGB float values.
- Parameters
r – Red component of RGB value as a float in the range [0.0, 1.0]
g – Green component of RGB value as a float in the range [0.0, 1.0]
b – Blue component of RGB value as a float in the range [0.0, 1.0]
- Returns
Color object with given RGB values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_hsl
(h: float, s: float, l: float) → colorviews.colors.Color¶ Creates a Color object from the given HSL float values.
- Parameters
h – Hue component of HSL value as a float in the range [0.0, 1.0]
s – Saturation component of HSL value as a float in the range [0.0, 1.0]
l – Lightness component of HSL value as a float in the range [0.0, 1.0]
- Returns
Color object with given HSL values.
- Raises
ValueError – If any argument is outside valid range.
-
classmethod
from_hsv
(h: float, s: float, v: float) → colorviews.colors.Color¶ Creates a Color object from the given HSV float values.
- Parameters
h – Hue component of HSV value as a float in the range [0.0, 1.0]
s – Saturation component of HSV value as a float in the range [0.0, 1.0]
v – Value component of HSV value as a float in the range [0.0, 1.0]
- Returns
Color object with given HSV values.
- Raises
ValueError – If any argument is outside valid range.
-
classmethod
from_rgb_
(r: int, g: int, b: int) → colorviews.colors.Color¶ Creates a Color object from the given RGB unsigned int values.
- Parameters
r – Red component of RGB value as an int in the range [0, 255]
g – Green component of RGB value as an int in the range [0, 255]
b – Blue component of RGB value as an int in the range [0, 255]
- Returns
Color object with given RGB values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_hsl_
(h: int, s: int, l: int) → colorviews.colors.Color¶ Creates a Color object from the given HSL int values.
- Parameters
h – Hue component of HSL value as an int. Modulo 360 value is stored for values >= 360
s – Saturation component of HSL value as an int in the range [0, 100]
l – Lightness component of HSL value as an int in the range [0, 100]
- Returns
Color object with given HSL values.
- Raises
ValueError – If any argument is outside valid range.
-
classmethod
from_hsv_
(h: int, s: int, v: int) → colorviews.colors.Color¶ Creates a Color object from the given HSV int values.
- Parameters
h – Hue component of HSV value as an int. Modulo 360 value is stored for values >= 360
s – Saturation component of HSV value as an int in the range [0, 100]
v – Value component of HSV value as an int in the range [0, 100]
- Returns
Color object with given HSV values.
- Raises
ValueError – If any argument is outside valid range.
-
copy
() → colorviews.colors.Color¶ Creates a copy of the Color object.
- Returns
An identical copy of the Color object.
-
property
-
class
colorviews.colors.
AlphaColor
(r: float, g: float, b: float, a: float)¶ Class representing colors with alpha value.
Information is stored using rgba values.
-
property
rgba
¶ RGBA colorview as float values
-
property
hsla
¶ HSLA colorview as float values
-
property
hsva
¶ HSVA colorview as float values
-
property
rgba_
¶ RGBA colorview as int values
-
property
hsla_
¶ HSLA colorview as int values
-
property
hsva_
¶ HSVA colorview as int values
-
classmethod
from_name
(name: str, a: float = 0.0) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object based on the given color name.
Only CSS3 extended color keyword names are recognized.
- Parameters
name – Name of color.
a – Alpha value of color as a float in the range [0.0, 1.0]. Default value is 0.0
- Returns
AlphaColor object with value corresponding to the given color name and alpha value.
-
classmethod
from_int
(value: int) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object from the given integer color value.
- Parameters
value – Integer color value.
- Returns
AlphaColor object with given integer value.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_rgba
(r: float, g: float, b: float, a: float) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object from the given RGBA float values.
- Parameters
r – Red component of RGBA value as a float in the range [0.0, 1.0].
g – Green component of RGBA value as a float in the range [0.0, 1.0].
b – Blue component of RGBA value as a float in the range [0.0, 1.0].
a – Alpha component of RGBA value as a float in the range [0.0, 1.0].
- Returns
AlphaColor object with given RGBA values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_hsla
(h: float, s: float, l: float, a: float) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object from the given HSLA float values.
- Parameters
h – Hue component of HSLA value as a float in the range [0.0, 1.0]
s – Saturation component of HSLA value as a float in the range [0.0, 1.0].
l – Lightness component of HSLA value as a float in the range [0.0, 1.0].
a – Alpha component of HSLA value as a float in the range [0.0, 1.0].
- Returns
AlphaColor object with given HSLA values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_hsva
(h: float, s: float, v: float, a: float) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object from the given HSVA float values.
- Parameters
h – Hue component of HSVA value as a float in the range [0.0, 1.0]
s – Saturation component of HSVA value as a float in the range [0.0, 1.0].
v – Value component of HSVA value as a float in the range [0.0, 1.0].
a – Alpha component of HSVA value as a float in the range [0.0, 1.0].
- Returns
AlphaColor object with given HSVA values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_rgba_
(r: int, g: int, b: int, a: int) → colorviews.colors.AlphaColor¶ Creates a AlphaColor object from the given RGBA int values.
- Parameters
r – Red component of RGBA value as an int in the range [0, 255]
g – Green component of RGBA value as an int in the range [0, 255]
b – Blue component of RGBA value as an int in the range [0, 255]
a – Alpha component of RGBA value as an int in the range [0, 100]
- Returns
AlphaColor object with given RGBA values.
- Raises
ValueError – If any value is outside the valid range.
-
classmethod
from_hsla_
(h: int, s: int, l: int, a: int) → colorviews.colors.AlphaColor¶ Creates a AlphaColor object from the given HSLA int values.
- Parameters
h – Hue component of HSLA value as an int. Modulo 360 value is stored for values >= 360
s – Saturation component of HSLA value as an int in the range [0, 100]
l – Lightness component of HSLA value as an int in the range [0, 100]
a – Alpha component of HSVA value as a float in the range [0, 100].
- Returns
AlphaColor object with given HSLA values.
- Raises
ValueError – If any argument is outside valid range.
-
classmethod
from_hsva_
(h: float, s: float, v: float, a: float) → colorviews.colors.AlphaColor¶ Creates an AlphaColor object from the given HSVA int values.
- Parameters
h – Hue component of HSVA value as an int. Modulo 360 value is stored for values >= 360
s – Saturation component of HSVA value as an int in the range [0, 100]
v – Value component of HSVA value as an int in the range [0, 100]
a – Alpha component of HSVA value as a float in the range [0, 100].
- Returns
AlphaColor object with given HSVA values.
- Raises
ValueError – If any value is outside the valid range.
-
copy
() → colorviews.colors.AlphaColor¶ Creates a copy of the AlphaColor object.
- Returns
An identical copy of the AlphaColor object.
-
property
Views¶
For Color
:
For AlphaColor
:
ColorView classes for Color and AlphaColor objects
-
class
colorviews.views.
ColorViewRGB_
(color: colors.BaseColor)¶ Rounded int RGB view of Color objects.
-
property
vals
¶ Tuple of RGB values as ints.
-
replace
(r=None, g=None, b=None) → colors.Color¶ Create a new Color object by replacing the RGB values (as ints) of the Color object associated with the colorview.
- Parameters
r – Red component of RGB value as an int in the range [0, 255]
g – Green component of RGB value as an int in the range [0, 255]
b – Blue component of RGB value as an int in the range [0, 255]
- Returns
Color object with modified RGB values.
-
property
b
¶ Blue component as an int value
-
color
¶
-
property
g
¶ Green component as an int value
-
property
r
¶ Red component as an int value
-
property
-
class
colorviews.views.
ColorViewRGBA_
(color: colors.BaseColor)¶ Rounded int RGBA view of AlphaColor objects.
-
property
vals
¶ Tuple of RGBA values as ints.
-
replace
(r=None, g=None, b=None, a=None) → colors.AlphaColor¶ Create a new AlphaColor object by replacing the RGBA values (as ints) of the AlphaColor object associated with the colorview.
- Parameters
r – Red component of RGBA value as an int in the range [0, 255]
g – Green component of RGBA value as an int in the range [0, 255]
b – Blue component of RGBA value as an int in the range [0, 255]
a – Alpha component of RGBA value as an int in the range [0, 100]
- Returns
AlphaColor object with modified RGBA values.
-
property
a
¶ Alpha component as an int value
-
property
b
¶ Blue component as an int value
-
color
¶
-
property
g
¶ Green component as an int value
-
property
r
¶ Red component as an int value
-
property
-
class
colorviews.views.
ColorViewRGB
(color: colors.BaseColor)¶ RGB view of Color objects in float values
-
property
vals
¶ Tuple of RGB values as floats.
-
replace
(r=None, g=None, b=None) → colors.Color¶ Create a new Color object by replacing the RGB values of the Color object associated with the colorview.
- Parameters
r – Red component of RGB value as a float in the range [0, 0.1].
g – Green component of RGB value as a float in the range [0, 0.1].
b – Blue component of RGB value as a float in the range [0, 0.1].
- Returns
Color object with modified RGB values.
-
property
b
¶ Blue component as a float value
-
color
¶
-
property
g
¶ Green component as a float value
-
property
r
¶ Red component as a float value
-
property
-
class
colorviews.views.
ColorViewRGBA
(color: colors.BaseColor)¶ RGBA view of Color objects in float values
-
property
vals
¶ Tuple of RGBA values as floats.
-
replace
(r=None, g=None, b=None, a=None) → colors.AlphaColor¶ Create a new Color object by replacing the RGBA values of the Color object associated with the colorview.
- Parameters
r – Red component of RGBA value as a float in the range [0, 0.1].
g – Green component of RGBA value as a float in the range [0, 0.1].
b – Blue component of RGBA value as a float in the range [0, 0.1].
a – Alpha component of RGBA value as a float in the range [0, 0.1].
- Returns
Color object with modified RGBA values.
-
property
a
¶ Alpha component as a float value
-
property
b
¶ Blue component as a float value
-
color
¶
-
property
g
¶ Green component as a float value
-
property
r
¶ Red component as a float value
-
property
-
class
colorviews.views.
ColorViewHSL_
(color: colors.BaseColor)¶ Rounded int HSL view of Color objects.
-
property
vals
¶ Tuple of HSL values as ints.
-
replace
(h=None, s=None, l=None) → colors.Color¶ Create a new Color object by replacing the HSL values of the Color object associated with the colorview.
- Parameters
h – Hue component of HSL value as an int. Resultant value will be h modulo 360.
s – Saturation component of HSL value as an int in the range [0, 100].
l – Lightness component of HSL value as an int in the range [0, 100].
- Returns
Color object with modified HSL values.
-
color
¶
-
property
h
¶ Hue component as an int value
-
property
l
¶ Lightness component as an int value
-
property
s
¶ Saturation component as an int value
-
property
-
class
colorviews.views.
ColorViewHSLA_
(color: colors.BaseColor)¶ Rounded int HSLA view of AlphaColor objects.
-
property
vals
¶ Tuple of HSLA values as ints.
-
replace
(h=None, s=None, l=None, a=None) → colors.AlphaColor¶ Create a new AlphaColor object by replacing the HSLA values of the AlphaColor object associated with the colorview.
- Parameters
h – Hue component of HSLA value as a float. Resultant value will be h modulo 360
s – Saturation component of HSLA value as a float in the range [0, 100].
l – Lightness component of HSLA value as a float in the range [0, 100].
a – Alpha component of HSLA value as a float in the range [0, 100].
- Returns
AlphaColor object with modified HSLA values.
-
property
a
¶ Alpha component as an int value
-
color
¶
-
property
h
¶ Hue component as an int value
-
property
l
¶ Lightness component as an int value
-
property
s
¶ Saturation component as an int value
-
property
-
class
colorviews.views.
ColorViewHSL
(color: colors.BaseColor)¶ HSL view of Color objects in float values
-
property
vals
¶ Tuple of HSL values as floats.
-
replace
(h=None, s=None, l=None) → colors.Color¶ Create a new Color object by replacing the HSL values of the Color object associated with the colorview.
- Parameters
h – Hue component of HSL value as a float. Resultant value will be h modulo 1.0
s – Saturation component of HSL value as a float in the range [0, 0.1].
l – Lightness component of HSL value as a float in the range [0, 0.1].
- Returns
Color object with modified HSL values.
-
color
¶
-
property
h
¶ Hue component as a float value
-
property
l
¶ Lightness component as a float value
-
property
s
¶ Saturation component as a float value
-
property
-
class
colorviews.views.
ColorViewHSLA
(color: colors.BaseColor)¶ HSLA view of Color objects in float values
-
property
vals
¶ Tuple of HSLA values as floats.
-
replace
(h=None, s=None, l=None, a=None) → colors.AlphaColor¶ Create a new AlphaColor object by replacing the HSLA values of the AlphaColor object associated with the colorview.
- Parameters
h – Hue component of HSLA value as a float. Resultant value will be h modulo 1.0
s – Saturation component of HSLA value as a float in the range [0, 0.1].
l – Lightness component of HSLA value as a float in the range [0, 0.1].
a – Alpha component of HSLA value as a float in the range [0, 0.1].
- Returns
AlphaColor object with modified HSLA values.
-
property
a
¶ Alpha component as a float value
-
color
¶
-
property
h
¶ Hue component as a float value
-
property
l
¶ Lightness component as a float value
-
property
s
¶ Saturation component as a float value
-
property
-
class
colorviews.views.
ColorViewHSV_
(color: colors.BaseColor)¶ Rounded int HSV view of Color objects.
-
color
¶
-
property
h
¶ Hue component as an int value
-
property
s
¶ Saturation component as an int value
-
property
v
¶ Value component as an int value
-
property
vals
¶ Tuple of HSV values as ints.
-
replace
(h=None, s=None, v=None) → colors.Color¶ Create a new Color object by replacing the HSV values of the Color object associated with the colorview.
- Parameters
h – Hue component of HSV value as an int. Resultant value will be h modulo 360.
s – Saturation component of HSV value as an int in the range [0, 100].
v – Value component of HSV value as an int in the range [0, 100].
- Returns
Color object with modified HSV values.
-
-
class
colorviews.views.
ColorViewHSVA_
(color: colors.BaseColor)¶ Rounded integer HSVA view of AlphaColor objects.
-
property
a
¶ Alpha component as an int value
-
color
¶
-
property
h
¶ Hue component as an int value
-
property
s
¶ Saturation component as an int value
-
property
v
¶ Value component as an int value
-
property
vals
¶ Tuple of HSVA values as ints.
-
replace
(h=None, s=None, v=None, a=None) → colors.AlphaColor¶ Create a new AlphaColor object by replacing the HSVA values of the AlphaColor object associated with the colorview.
- Parameters
h – Hue component of HSVA value as an int. Resultant value will be h modulo 360.
s – Saturation component of HSVA value as an int in the range [0, 100].
v – Value component of HSVA value as an int in the range [0, 100].
a – Alpha component of HSVA value as an int in the range [0, 100].
- Returns
AlphaColor object with modified HSVA values.
-
property
-
class
colorviews.views.
ColorViewHSV
(color: colors.BaseColor)¶ HSV view of Color objects in float values
-
color
¶
-
property
h
¶ Hue component as a float value
-
property
s
¶ Saturation component as a float value
-
property
v
¶ Value component as a float value
-
property
vals
¶ Tuple of HSV values as floats.
-
replace
(h=None, s=None, v=None) → colors.Color¶ Create a new Color object by replacing the HSV values of the Color object associated with the colorview.
- Parameters
h – Hue component of HSV value as a float in the range [0, 0.1].
s – Saturation component of HSV value as a float in the range [0, 0.1].
v – Value component of HSV value as a float in the range [0, 0.1].
- Returns
Color object with modified HSV values.
-
-
class
colorviews.views.
ColorViewHSVA
(color: colors.BaseColor)¶ HSVA view of Color objects in float values
-
property
a
¶ Alpha component as a float value
-
color
¶
-
property
h
¶ Hue component as a float value
-
property
s
¶ Saturation component as a float value
-
property
v
¶ Value component as a float value
-
property
vals
¶ Tuple of HSVA values as floats.
-
replace
(h=None, s=None, v=None, a=None) → colors.AlphaColor¶ Create a new AlphaColor object by replacing the HSVA values of the AlphaColor object associated with the colorview.
- Parameters
h – Hue component of HSVA value as a float in the range [0, 0.1].
s – Saturation component of HSVA value as a float in the range [0, 0.1].
v – Value component of HSVA value as a float in the range [0, 0.1].
a – Alpha component of HSVA value as a float in the range [0, 0.1].
- Returns
AlphaColor object with modified HSVA values.
-
property